var photoDiv;
var photoImg;
var currentImage=0;

function setPhotoTarget(divName) {
	try {
		photoDiv = document.getElementById(divName);
		photoImg = photoDiv.getElementsByTagName("img");
	} catch(e) {
		photoDiv = null;
		photoImg = null;
	}
}

function switchPhoto(imgElement) {

	setPhotoOverView(imgElement.src);

}

function setPhotoOverView(src) {

	if(!photoDiv !== null) {

		photoImg[0].src = src;

	}
}


function showImage(navigateTo)
{
	if(max == currentImage) {
	    currentImage = -1;
	}



    if(navigateTo == 'back')
	{
	    if(currentImage == 0) {
	       currentImage = max;
	    }

	    currentImage = currentImage - 1;

	}
	else
	{
		currentImage = currentImage + 1;
	}

	var imageObj = document.getElementById("photoLarge");
	imageObj.src=ImageArray[currentImage].src;

}
