function displayPhoto(photoNum)
{
	//var allPhotos = 'photo01.gif|PHOTORUN|This is somebody running|photo02.gif|Kirby Lee|This is somebody in the HJ';
	
	var arrayIndex;
	
	if (allPhotos != '')
	{
		var allPhotosArray = allPhotos.split('|');
		
		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').innerHTML = allPhotosArray[arrayIndex + 1];
		document.getElementById('caption').innerHTML = allPhotosArray[arrayIndex + 2];
		
		document.getElementById('counter').innerHTML = photoNum;
		document.getElementById('total').innerHTML = allPhotosArray.length/3;
		
		document.photos.currentPhotoNum.value = photoNum;
		
		// pre-load next one
		photoNum = photoNum + 1;
		if (photoNum > allPhotosArray.length/3)
			photoNum = 1;
		else if (photoNum < 1)
			photoNum = allPhotosArray.length/3;
		
		arrayIndex = (photoNum - 1) * 3;
		
		document.getElementById('preloadNextImage').style.backgroundImage = 'url(\'' + allPhotosArray[arrayIndex] + '\')';
	}
	else
	{
		document.getElementById('photo').style.display = 'none';
		document.getElementById('photoCredit').style.display = 'none';
		document.getElementById('caption').innerHTML = 'No photos available';
		document.getElementById('counter').innerHTML = 0;
		document.getElementById('total').innerHTML = 0;
	}
}

function NextPhoto()
{
	var thisPhotoNum = parseInt(document.photos.currentPhotoNum.value) + 1;
	displayPhoto(thisPhotoNum);
}

function PreviousPhoto()
{
	var thisPhotoNum = parseInt(document.photos.currentPhotoNum.value) - 1;
	displayPhoto(thisPhotoNum);
}

function popoff(myURL, myHeight, myWidth)
{
	window.open(myURL, '', 'width=' + myWidth + ',height=' + myHeight + ', toolbar=no,scrollbars=no, resizable=no');
}
