
// Generic Stuff for all slideshows
var Current = -1;
var navBar;
var headTag;
var preLoaded = 0;
var picWin;

preload = new Array();
Captions = new Array();
showImages = new Array();

// Set default window width and height here
var defaultWidth = 680;
var defaultHeight = 535;

// Choose background color, font color, font specs
var bgColor = "#ffffff";
var fontColor = "#000000";
var fontFace = "";
var fontSize = "";

var bodyTag = "<body bgcolor=" + bgColor + " text=" + fontColor + ">\n";

// HTML for the navigation bar at the bottom
var backBut = "<a href=javascript:window.opener.goBack()>" +
				"<img src=products/panfora/images/bt_back_ro.gif border=0 alt='Previous'></a>\n";
var closeBut = "<a href=javascript:window.close()>" +
				"<img src=products/panfora/images/bt_close_ro.gif border=0 alt='Close'></a>\n";
var nextBut = "<a href=javascript:window.opener.goNext()>" +
				"<img src=products/panfora/images/bt_next_ro.gif border=0 alt='Next'></a>\n";
var refreshBut = "<a href=javascript:window.opener.goRefresh()>" +
				"<img src=products/panfora/images/bt_refresh_ro.gif border=0 alt='Refresh'></a>\n";

// Table definitions			
var tableStart = "<table border=0 cellpadding=0 cellspacing=0>\n" +
				"<tr><td width=33% align=right valign=top>";
var tableMid1 = "</td><td width=33% align=center valign=top nowrap>";
var tableMid2 = "</td><td width=33% align=left valign=top>";
var tableEnd = "</td></tr></table>\n";

// ----------------- End of configurable stuff --------------------------- //

/* function makeShortCaps() {
	for (var i=0; i < Captions.length; i++) {
		var ind = Captions[i].indexOf("\<br\>");
		if (ind == -1) {
			ind = Captions[i].length;
		}
		shortCap[i] = Captions[i].substring(0, ind);
	}
} */

// Preload images
function doPreload() {
	for (var i=1; i < showImages.length; i++) {
		preload[i] = new Image();
		preload[i].src = showImages[i];
	}
}

// The function to draw the window
function Show(Ind, wid, hei) {
	// Preload images
	if (Ind == 0 && preLoaded == 0) {
		doPreload();
		preLoaded = 1;
	}
	// Make sure image loaded
	if (! preload[Ind].complete) {
		preload[Ind].src = showImages[Ind];
	}

	var w = defaultWidth;
	var h = defaultHeight;
	
	if (wid) {
		w = wid;
	} else {
		w = defaultWidth;
	}
	if (hei) {
		h = hei;
	} else {
		h = defaultHeight;
	}
	
	Current = Ind;
	
	
	navBar = tableStart;
	if (Current > 0) {
		navBar += backBut;
	}
	navBar += tableMid1 + closeBut + "<br>" + refreshBut + tableMid2;
	if (Current < Captions.length - 1) {
		navBar += nextBut;
	}
	navBar += tableEnd;

	var options = "location=0,toolbar=0,menubar=0,resizable=1,scrollbars=1,width=" + w + ",height=" + h;
	picWin = window.open("", "picWin", options);
	
	picWin.focus();

	timerID = setTimeout("drawWin()", 500);
}

function drawWin() {
	Ind = Current;
	picWin.document.writeln(headTag);
	picWin.document.writeln(bodyTag);
	if (fontFace != "") {
		picWin.document.writeln("<font face=" + fontFace + ">");
	}
	if (fontSize != "") {
		picWin.document.writeln("<font size=" + fontSize +">");
	}
	picWin.document.write("<table><tr><td colspan=2>");
	if (Current == Captions.length - 1) {
		picWin.document.write("<a href='javascript:window.opener.goDemo();window.close()'>");
	} else {
		picWin.document.write("<a href=javascript:window.opener.goNext()>");
	}
	picWin.document.writeln("<img src=" + showImages[Ind] + " border=0></a></td></tr>");
	picWin.document.writeln("<tr><td valign=top align=left width=55></td>");
	picWin.document.writeln("<td align=left width=545></td></tr><tr><td colspan=2><hr></td></tr></table>");
	picWin.document.writeln("<table border=0><tr><td width=355 valign=top align=left class=footer><img src=images/dot_clear.gif><br>&copy; 2002 wiTHinc Corporation. All rights reserved.</td>");
	picWin.document.writeln("<td valign=top align=right width=245 class=footer>");
	picWin.document.writeln(navBar + "</td></tr></table>\n</body></html>");
	picWin.document.close();
}

// Function to show the next image.
function goNext() {
	if (Current < Captions.length - 1) {
		Show(Current + 1);
	}
}

// Function to show the previous image
function goBack() {
	if (Current > 0) {
		Show(Current - 1);
	}
}

// Function to refresh current page
function goRefresh() {
	Show(Current);
}

// Function to go to demo
function goDemo() {
	document.location = "products/panfora/demo.html";
}

// Update the status bar
function Preview(Ind) {
	window.status = Captions[Ind];
}

function donothing() {
}
