//////////////////////////////////////////////////////////////
// Image Functions
function displayLayer(layerName) {
	$(layerName).style.display="block";
}

function hideLayer(layerName) {
	$(layerName).style.display="none";
}

// set array index
var imgArrIndex = 0;

/////////////////////////////////////////////////////
// function to display next image
/////////////////////////////////////////////////////
function switchImage(dirToGo)
{

	// increment index
	if (dirToGo=="next")
	{
			imgArrIndex += 1;
	}else{
		if (imgArrIndex > 0)
			imgArrIndex -= 1;
	}
	
	if (imgArrIndex == photoArray.length)
		imgArrIndex = 0;

	// turn on/off next/previous buttons
	if (imgArrIndex == photoArray.length-1)
		document.imgNext.src = imgNxtSrc_off;
	else
		document.imgNext.src = imgNxtSrc;

	if (imgArrIndex == 0)
		document.imgPrevious.src = imgPreSrc_off;
	else
		document.imgPrevious.src = imgPreSrc;

	// display new image
	if (photoPathPrefix!='')
		document.theImage.src = photoPathPrefix + photoArray[imgArrIndex];
	else
		document.theImage.src = photoArray[imgArrIndex];

	setNumberingImgs();
	setTextDivs();
}


function setNumberingImgs()
{
	// display new image
	if (numberPathPrefix!='')
		document.firstNumber.src = numberPathPrefix + numberArray[imgArrIndex];
	else
		document.firstNumber.src = numberArray[imgArrIndex];
}

function setTextDivs()
{
	// set captions
	if ($('captionDiv0'))
	{
		for(x=0; x < photoArray.length; x++)
		{
			if (x==imgArrIndex)
				displayLayer('captionDiv'+x);
			else
				hideLayer('captionDiv'+x);
		}
	}

	// set header	
	if ($('headerDiv0'))
	{
		for(x=0; x < photoArray.length; x++)
		{
			if (x==imgArrIndex)
				displayLayer('headerDiv'+x);
			else
				hideLayer('headerDiv'+x);
		}
	}
}



