//in HTML document:  var allPhotos = 'photo01.gif|PHOTORUN|This is somebody running|photo02.gif|Kirby Lee|This is somebody in the HJ';
var allPhotosArray;

function displayPhoto(photoNum)
{
	var arrayIndex;
	
	if (photoNum > allPhotosArray.length / 3)
		photoNum = 1;
	else if (photoNum < 1)
		photoNum = allPhotosArray.length / 3;
	
	arrayIndex = (photoNum - 1) * 3;
	
	document.getElementById("photo").src = allPhotosArray[arrayIndex];
	document.getElementById("credit").childNodes[0].nodeValue = allPhotosArray[arrayIndex + 1];
	document.getElementById("caption").childNodes[0].nodeValue = allPhotosArray[arrayIndex + 2];
}

function InitPhotos()
{
	if (allPhotos != '')
	{
		allPhotosArray = allPhotos.split("|");
		displayPhoto(1);
		BuildPhotoNav();
	}
	else
	{
		document.getElementById("photo").style.display = "none";
		document.getElementById("photoCredit").style.display = "none";
		document.getElementById("photoNav").childNodes[0].nodeValue = "No photos available";
	}
}

function BuildPhotoNav()
{
	var ne;
	var arrayIndex;
	
	for (var i = 1; i <= allPhotosArray.length / 3; i++)
	{
		arrayIndex = (i - 1) * 3;
		ne = document.createElement("img");
		ne.setAttribute("src", "tn/" + allPhotosArray[arrayIndex]);
		ne.setAttribute("alt", allPhotosArray[arrayIndex + 2]);
		ne.onclick = new Function("displayPhoto(" + i + ")");
		document.getElementById("photoNav").appendChild(ne);
	}
}
