var aPhoto = [];
var n = 0;

function previous()
{
	n--;
	
	if (n < 0)
		n = aPhoto.length-1;
		
	showPhoto();
}

function next()
{
	n++;
	
	if (n >= aPhoto.length)
		n = 0;
		
	showPhoto();
}

function setCurrentPhoto(i)
{
	n = i;
}

function showPhoto()
{
	try
	{
		$("#photo-count").html("Photo " + (n+1) + " of " + aPhoto.length );
	
		$("#photo-tbl"			).css('margin-left', Math.floor((640 - aPhoto[n].width)/2).toString() + 'px');
		$("#gallery-photo"		).html( '<img src="' + aPhoto[n].src + '" width="' + aPhoto[n].width + '" height="' + aPhoto[n].height + '" />' );
		$("#photo-caption"		).html( aPhoto[n].caption );
		$("#photo-description"	).html( aPhoto[n].description );
	}
	catch (ex) { alert(ex); }
}
