var thisPic = 0; //the counter for the image array var lastPic = 7; //the last cell in our array = (number of pictures - 1) cnnPix = new Array(lastPic); cnnPix[0]="/images/company/vcenter1.jpg"; cnnPix[1]="/images/company/vcenter2.jpg"; cnnPix[2]="/images/company/vcenter3.jpg"; cnnPix[3]="/images/company/vcenter4.jpg"; cnnPix[4]="/images/company/vcenter5.jpg"; cnnPix[5]="/images/company/vcenter6.jpg"; cnnPix[6]="/images/company/vcenter7.jpg"; cnnPix[7]="/images/company/vcenter8.jpg"; function processPrevious() { if (document.images) { if (thisPic==0) //if at the very beginning of array { thisPic=lastPic; //goto the last cell in the array } else { thisPic--; //else simply decrement the counter } document.myPicture.src=cnnPix[thisPic]; } } function processNext() { if (document.images) { if (thisPic==lastPic) //if at the very end of the array { thisPic=0; //goto the first cell of the array } else { thisPic++; //else simply increment the counter } document.myPicture.src=cnnPix[thisPic]; } }