var currentPhoto = 0;

function nextPhoto(descriptionBox, currentPhotoBox) {
	if (typeof(photos) != "undefined") {
		currentPhoto++;
		if (currentPhoto >= photos.length) {
			currentPhoto = 0;
		}
		showPhoto(descriptionBox, currentPhotoBox);
	}
}

function prevPhoto(descriptionBox, currentPhotoBox) {
	if (typeof(photos) != "undefined") {
		currentPhoto--;
		if (currentPhoto < 0) {
			currentPhoto = photos.length-1;
		}
		showPhoto(descriptionBox, currentPhotoBox);
	}
}

function showPhoto(descriptionBox, currentPhotoBox) {
	if (document.images["PhotoGallery"] != null) {
		document.images["PhotoGallery"].src = photos[currentPhoto].src;
		document.images["PhotoGallery"].alt = photos[currentPhoto].description;
		document.getElementById(descriptionBox).value = photos[currentPhoto].description;
		document.getElementById(currentPhotoBox).value = "Photo " + (currentPhoto+1) + " of " + photos.length;
	}
}