﻿var activePhotoIndex = 0;
var photoUris = new Array();

function PreviousImage()
{
	if (activePhotoIndex > 0) activePhotoIndex = activePhotoIndex - 1;
	else activePhotoIndex = photoUris.length - 1;
	
	UpdateImageView();
}

function NextImage()
{
	if (activePhotoIndex < photoUris.length - 1) activePhotoIndex = activePhotoIndex + 1;
	else activePhotoIndex = 0;
	
	UpdateImageView();
}

function ShowImage(index)
{
	activePhotoIndex = index;
	UpdateImageView();
}

function UpdateImageView()
{
	HideInfo();
	
	//Fix for http://www.quirksmode.org/bugreports/archives/2005/03/Safari_Image_src_swap_resize_bug.html
	if (navigator.userAgent.indexOf('Safari')!=-1)
	{ document.getElementById("LargeImage").src = "../../SafariFix.gif"; }
	
	document.getElementById("LargeImage").src = photoUris[activePhotoIndex];
	
	var thumbsStrip = document.getElementById("Thumbs");
	var thumbs = thumbsStrip.getElementsByTagName('a');
	for (var i = 0; i < thumbs.length; i++)
	{
		Element.removeClassName(thumbs[i], "Active");
		if (i == activePhotoIndex) Element.addClassName(thumbs[i], "Active");
	}
}

function ShowInfo()
{
	document.getElementById("LargeImagePanel").style.display = "none";
	document.getElementById("InfoPanel").style.display = "block";
	
	var infoPanelInner = document.getElementById("InfoPanelInner");
	infoPanelInner.style.marginTop = (455 - infoPanelInner.offsetHeight) / 2 + 'px';
}

function HideInfo()
{
	document.getElementById("InfoPanel").style.display = "none";
	document.getElementById("LargeImagePanel").style.display = "block";
}