
//build image array and pre-cache them:
var images;
var count = 1; //start on first image, this one loads from the HTML markup

if(document.images) {
	images = new Array(photoDetails.length);
	for(var i=0; i<photoDetails.length; i++) {
		images[i] = new Image(307,224);
		images[i].src = photoDetails[i][0];
	}
}

function nextPhoto() {
	if(count == photoDetails.length) { count = 0; }
	document.getElementById("photo").src = photoDetails[count][0];
	document.getElementById("photo").alt = photoDetails[count][1];

	document.getElementById("phototitle").innerHTML = photoDetails[count][1];
	
	count++;
}

window.onload = function() {
	if(document.getElementById('next')) {
		document.getElementById('next').onclick = function() {
			nextPhoto();
		}
	}
}