function displayPhoto(photoNum)
{
	var allPhotos = document.photos.photoArray.value;
	var allPhotosArray = allPhotos.split(';');
	
	if (photoNum > allPhotosArray.length)
		photoNum = 1;
	else if (photoNum < 1)
		photoNum = allPhotosArray.length;
	
	document.getElementById('productImageCounter').innerHTML = photoNum;
	document.photos.currentPhotoNum.value = photoNum;
	
	if (Right(allPhotosArray[photoNum - 1], 4) != ".swf")
	{
		document.getElementById('productImage').src = "images/" + allPhotosArray[photoNum - 1];
		document.getElementById('productImageDiv').style.display = "block";
		document.getElementById('productVideoDiv').style.display = "none";
	}
	else
	{
		var FO_obj = { movie:"images/" + allPhotosArray[photoNum - 1], width:"320", height:"240", majorversion:"6", build:"0", play:"true", quality:"high", scale:"showall" };
		UFO.create(FO_obj, "productVideoDiv");
		document.getElementById('productImageDiv').style.display = "none";
		document.getElementById('productVideoDiv').style.display = "block";
	}
	
	
}

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 Right(str, n)
{
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
	{
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}
