imgCounter = 0;
captCounter = 0;

// set up gallery images
image0 = new Image();
image1 = new Image();
image2 = new Image();
image3 = new Image();
image4 = new Image();
image5 = new Image();
image6 = new Image();
image7 = new Image();
image8 = new Image();
image9 = new Image();

image0.src = "commercial/000.jpg";
image1.src = "commercial/001.jpg";
image2.src = "commercial/002.jpg";
image3.src = "commercial/003.jpg";
image4.src = "commercial/004.jpg";
image5.src = "commercial/005.jpg";
image6.src = "commercial/006.jpg";
image7.src = "commercial/007.jpg";
image8.src = "commercial/008.jpg";
image9.src = "commercial/009.jpg";

imgArray = new Array();
imgArray[0] = image0;
imgArray[1] = image1;
imgArray[2] = image2;
imgArray[3] = image3;
imgArray[4] = image4;
imgArray[5] = image5;
imgArray[6] = image6;
imgArray[7] = image7;
imgArray[8] = image8;
imgArray[9] = image9;

// set up 'previous' thumbnails
prev_img0 = new Image();
prev_img1 = new Image();
prev_img2 = new Image();
prev_img3 = new Image();
prev_img4 = new Image();
prev_img5 = new Image();
prev_img6 = new Image();
prev_img7 = new Image();
prev_img8 = new Image();
prev_img9 = new Image();

prev_img0.src = "commercial_thumb/thumb_prev.jpg";
prev_img1.src = "commercial_thumb/000.jpg";
prev_img2.src = "commercial_thumb/001.jpg";
prev_img3.src = "commercial_thumb/002.jpg";
prev_img4.src = "commercial_thumb/003.jpg";
prev_img5.src = "commercial_thumb/004.jpg";
prev_img6.src = "commercial_thumb/005.jpg";
prev_img7.src = "commercial_thumb/006.jpg";
prev_img8.src = "commercial_thumb/007.jpg";
prev_img9.src = "commercial_thumb/008.jpg";


prevArray = new Array();
prevArray[0] = prev_img0;
prevArray[1] = prev_img1;
prevArray[2] = prev_img2;
prevArray[3] = prev_img3;
prevArray[4] = prev_img4;
prevArray[5] = prev_img5;
prevArray[6] = prev_img6;
prevArray[7] = prev_img7;
prevArray[8] = prev_img8;
prevArray[9] = prev_img9;

// set up 'next' thumbnails
next_img0 = new Image();
next_img1 = new Image();
next_img2 = new Image();
next_img3 = new Image();
next_img4 = new Image();
next_img5 = new Image();
next_img6 = new Image();
next_img7 = new Image();
next_img8 = new Image();
next_img9 = new Image();

next_img0.src = "commercial_thumb/001.jpg";
next_img1.src = "commercial_thumb/002.jpg";
next_img2.src = "commercial_thumb/003.jpg";
next_img3.src = "commercial_thumb/004.jpg";
next_img4.src = "commercial_thumb/005.jpg";
next_img5.src = "commercial_thumb/006.jpg";
next_img6.src = "commercial_thumb/007.jpg";
next_img7.src = "commercial_thumb/008.jpg";
next_img8.src = "commercial_thumb/009.jpg";
next_img9.src = "commercial_thumb/thumb_next.jpg";

nextArray = new Array();
nextArray[0] = next_img0;
nextArray[1] = next_img1;
nextArray[2] = next_img2;
nextArray[3] = next_img3;
nextArray[4] = next_img4;
nextArray[5] = next_img5;
nextArray[6] = next_img6;
nextArray[7] = next_img7;
nextArray[8] = next_img8;
nextArray[9] = next_img9;

captArray = new Array('capt0','capt1','capt2','capt3','capt4','capt5','capt6','capt7','capt8');

function setClass(objectID,newClass) {
	var dom = findDOM(objectID,0);
	dom.className = newClass;
	}
	
function nextImg() {
	theObject = captArray[captCounter];
	setClass(theObject,'hidden');
	setClass('prev','shown');
	
 	if (imgCounter < (imgArray.length - 1)) {
	imgCounter++;
	captCounter++;
	}
	else {
	}
	
	document.photo.src=imgArray[imgCounter].src;
	document.thumb_prev.src=prevArray[imgCounter].src;
	document.thumb_next.src=nextArray[imgCounter].src;
	theObject = captArray[captCounter];
	setClass(theObject,'shown');
	
	if (imgCounter == (imgArray.length - 1)) {
		setClass('next','hidden');
		setClass('prev','shown');
	}
	}
	
function prevImg() {
	theObject = captArray[captCounter];
	setClass(theObject,'hidden');
	setClass('next','shown');
 	if (imgCounter > 0) {
	imgCounter--;
	captCounter--;
	}
	else {
	}
	document.photo.src=imgArray[imgCounter].src;
	document.thumb_prev.src=prevArray[imgCounter].src;
	document.thumb_next.src=nextArray[imgCounter].src;
	theObject = captArray[captCounter];
	setClass(theObject,'shown');
	if (imgCounter == 0) {
		setClass('prev','hidden');
		setClass('next','shown');
	}
	}
