var thumbIndex = 0;
var thumbsPerPage = 5;
var linklineArray = new Array(10);
var numLinks = 1;
var linkLine;
var thumbCounter;

function initLinks() {
	linklineArray[0] = "Home";
	numLinks = 0;
}

function pushLink( linkName ) {
	numLinks++;
	linklineArray[numLinks] = linkName;
}


function setLinks() {
	var i;
	var j;
	linkLine = "<BR>";
	for (i=0; i<numLinks;i++) {
		linkLine +="&nbsp;/&nbsp;<a href=\"";
		for (j=0; j<(numLinks-i); j++) {
			linkLine +="../";
		}
		linkLine += "index.html\" target=\"_top\" ";
		linkLine += "class=\"linkline\" >&nbsp;" + linklineArray[i] + "</a>";
	}
	linkLine += "&nbsp;/&nbsp;<FONT color=\"red\">" + linklineArray[i] + "</FONT>";
}


function setThumbCounter( availableThumbs ) {
	var i;
	var sURL;
	var page;
	var p = location.search;
	thumbIndex = 0;
	if ( (p != null) && (p.length > 0)) {
		//?i=7
		thumbIndex = Number(p.substr(3));
	}
	var lastIndex = thumbsPerPage + thumbIndex;
	if (lastIndex > availableThumbs)
		lastIndex = availableThumbs;
	thumbCounter = "<SPAN class= \"info\">&nbsp;&nbsp;&nbsp;";
	if (thumbIndex > 0) {
		i = thumbIndex - thumbsPerPage;
		if (i<0)
			i = 0;
		sURL = location.pathname + "?i=" + i;
		thumbCounter += "<a href=\"" + sURL + "\" class=\"info\"><img src=\"/prior.gif\" alt=\"\" border=0 height=25 width=100 class=\"info\"></a>&nbsp;&nbsp;";
	}
	thumbCounter += "Images&nbsp;" + (thumbIndex+1) + " to " + lastIndex + " of " + availableThumbs;
	if (lastIndex < availableThumbs) {
		i = thumbIndex + thumbsPerPage;
		sURL = location.pathname + "?i=" + i;
		thumbCounter += "&nbsp;&nbsp;<a href=\"" + sURL + "\" class=\"info\"><img src=\"/next.gif\" alt=\"\" border=0 height=25 width=100 class=\"info\"></a>";
	}
	thumbCounter += "&nbsp;&bull;&nbsp;page:";
	for (page=0, i=0; i<availableThumbs; i+=thumbsPerPage, page++) {
		sURL = location.pathname + "?i=" + i;

		if ( (thumbIndex >= page*thumbsPerPage) && (thumbIndex < (page+1)*thumbsPerPage) ) {
			thumbCounter += "&nbsp;<FONT color=\"red\">" + (page+1) + "</FONT>";
		}
		else {
			thumbCounter += "&nbsp;<a href=\"" + sURL + "\" class=\"info\">" + (page+1) + "</a>";
		}

	}

	thumbCounter += "&nbsp;</SPAN><BR><BR>";
}

function formatImageTable() {
	var availableThumbs = image.length;
	var i = thumbIndex;
	var lastIndex = thumbsPerPage + i;
	if (lastIndex > availableThumbs)
		lastIndex = availableThumbs;
	document.writeln("<TABLE class=\"linktable\" border=4 cellspacing=4 cellpadding=4>" );
	for (; i<lastIndex; i++) {
		var onClick = " onclick=\"win(\'" + imagePath + image[i] + ".jpg\', \'" + imageTitle[i] + "\', " + jpgWidth[i] + ", " + jpgHeight[i] + ");";

		document.writeln("<TR>");
		document.write("<TH class=\"linktable\"><A HREF=\"/njs.html\" class=\"linktable\"" + onClick + "return false;\">");
		document.write("<img src=\"" + imagePath + image[i] + ".gif\" width=" + gifWidth[i] + " height=" + gifHeight[i] + " border=0 alt=\"\">");
		document.writeln("</A></TH>");
		document.write("<TD class=\"linktable\"><A HREF=\"/njs.html\"" + onClick + "return false;\">");
		document.write(imageTitle[i]);
		document.writeln("</A>");
		document.write(" ");
		document.writeln(imageDescription[i]);
		document.writeln("</TD>");
		document.writeln("</TR>");
	}
	document.writeln("</TABLE>");
}

function formatZoomTable() {
	var availableThumbs = image.length;
	var i = thumbIndex;
	var lastIndex = thumbsPerPage + i;
	if (lastIndex > availableThumbs)
		lastIndex = availableThumbs;
	document.writeln("<TABLE class=\"linktable\" border=4 cellspacing=4 cellpadding=4>");
	for (; i<lastIndex; i++) {
		var onClick = " onclick=\"zoom(\'" + imagePath + image[i] + "\', \'" + imageTitle[i] + "\');";
					
		document.writeln("<TR>");
		document.write("<TH class=\"zoomtable\"><A HREF=\"/njs.html\" class=\"linktable\"" + onClick + "return false;\">");
		document.write("<img src=\"" + imagePath + image[i] + "/TileGroup0/0-0-0.jpg\" border=0 alt=\"\">");
		document.writeln("</A></TH>");
		document.write("<TD class=\"linktable\"><A HREF=\"/njs.html\" class=\"linktable\"" + onClick + "return false;\">");
		document.write(imageTitle[i]);
		document.writeln("</A>");
		document.write(" ");
		document.writeln(imageDescription[i]);
		document.writeln("</TD>");
		document.writeln("</TR>");
	}
	document.writeln("</TABLE>");
}

function showHeader() {
}

function searchAdvice() {
	document.writeln("<P><b>To Search:</b><br>");
	document.writeln("If you are looking for something specific, I recommend that you use the Find ");
	document.writeln("feature of your browser.  Press Control (Ctrl) F or Command F on a Mac and enter one of your search terms.</P>");
}
