var sImagePrefix = "Image";
var nMax = captions.length;
var nCurrent = 1;
var sSearch = location.search;
if (sSearch.length != 0)
{
	nCurrent = sSearch.substring(sSearch.lastIndexOf("=")+1);	
	if (nCurrent.length == 0)		
	nCurrent = 1;
}

var sImage = "";
if (nCurrent < 10)
	sImage = sImagePrefix + "00" + nCurrent + ".jpg";
else if (nCurrent < 100)
	sImage = sImagePrefix + "0" + nCurrent + ".jpg";
else sImage = sImagePrefix + nCurrent + ".jpg";
var sCaption = "";
if (nCurrent-1 < captions.length && nCurrent > 0)
	sCaption = captions[nCurrent - 1];
	
function doPrevious()
{
	if (nCurrent == 1)
	{
		alert("This is the first picture!");
		return;
	}
	nCurrent--;
	doDisplay();
}

function doNext()
{
	if (nCurrent == nMax)
	{
		alert("This is the last picture!");
		return;
	}
	nCurrent++;
	doDisplay();
}

function doDisplay(){
	var sNew = location.pathname + "?which=" + nCurrent;
	location.href = sNew;
}

function outputCurrent()
{
	document.write('<P ALIGN=center>');
	document.write('<FONT COLOR=#cc6600 class=basic>');
	document.write('<b>');
	document.write(title);
	document.write('</b></FONT>');
	document.write('<P ALIGN=center>');

	if (nCurrent > 1)
	{
		document.write('<A href="javascript:doPrevious();" ><img src=/images/backbutton.gif alt="Previous" border=0></A>');
	}
	if (nCurrent < nMax)
	{	
		document.write('<A href="javascript:doNext();" ><img src=/images/nextbutton.gif alt="Next" border=0></A>');
	}
	document.write('<A href="/photos/index.html" ><img src=/images/indexbutton.gif alt="Index" border=0></A><p>');

	document.write('<table width=100% cellpadding=0 cellspacing=0 border=0>');
	document.write('<tr><td align=center valign=top>');
	document.write('<font class=basic><b>');
		    
	document.write("<IMG SRC=" + sImage + "><BR>");
	document.write(sCaption);
	document.write('</b></font>');
	document.write('</td>');
	document.write('<td width=120 valign=top>');
	document.write('<table cellpadding=0 cellspacing=0 width=120>');
	document.write('<tr><td bgcolor=#cc6600 colspan=2>');
	document.write('<img src=/images/photogallery.gif>');
	document.write('</td></tr>');
	
	for (var i=1; i<=nMax; i++)
	{
		document.write("<tr bgcolor=#eeeecc><td valign=top><img src=/images/go.gif width=16 height=16 align=absmiddle></td>");
		document.write("<td valign=top><font face=Arial,Helvetica size=-1 color=#ffffff class=basic><A HREF=index.php?which=" + i + ">" + captions[i-1] + "</A></font></td></tr>");	
	}


	document.write('</table>');
	document.write('</td>');
	document.write('</tr></table>');
}

