// imageSwapper.js
// copyright 2005 Matt Klausmeier (www.MattKlausmeier.com)
// I, Matt Klausmeier, give You, whoever is reading this file, the right to do anything You want with this code.
function imageSwapper(photoArray, divName, tableHeight, tableWidth, align, msDelay, totalPics) {
	document.photoArray = photoArray;
	document.align = align
	document.totalPics = totalPics;
	document.picTracker = 2;
	document.swapperDelay = msDelay;
	document.tableHeight = tableHeight;
	document.tableWidth = tableWidth;
	document.divName = divName;
		
	window.setInterval("animate()", document.swapperDelay);
}

function imageSwapperManual(photoArray, divName, tableHeight, tableWidth, align, msDelay, totalPics) {
	document.photoArray = photoArray;
	document.align = align
	document.totalPics = totalPics;
	document.picTracker = 0;
	document.swapperDelay = msDelay;
	document.tableHeight = tableHeight;
	document.tableWidth = tableWidth;
	document.divName = divName;
}

function animate(){
	matt = document.getElementById("picture");
	matt.innerHTML = "<table width='" + document.tableWidth + "' height='" + document.tableHeight + "' border='0' align='" + document.align + "' cellpadding='0' cellspacing='0'><tr><td><img src='" + document.photoArray[document.picTracker] + "' align='" + document.align + "'></td></tr><tr><td><div align='center'><strong>" + document.photoArray[document.picTracker + 1] + "</strong><br><br></div></td></tr></table>";
	document.picTracker = document.picTracker + 2;
	if ((document.picTracker/2) == document.totalPics) { document.picTracker = 0; }

}

function animateForward(){
	document.picTracker = document.picTracker + 4;
	if ((document.picTracker/4) == document.totalPics) { document.picTracker = 0; }
	matt = document.getElementById("picture");
	matt.innerHTML = "<table width='" + document.tableWidth + "' height='" + document.tableHeight + 
						"' border='0' align='" + document.align + "' cellpadding='0' cellspacing='0'><tr><td colspan='2'><img src='" + 
						document.photoArray[document.picTracker] + "' align='" + document.align + "' width='" + document.photoArray[document.picTracker + 2] + 
						"' height='" + document.photoArray[document.picTracker + 3] + "'></td></tr><tr><td colspan='2'><div align='center'><strong>" + 
						document.photoArray[document.picTracker + 1] + "</strong><br><br></div></td></tr><tr><td height='30' align='left'>" +
						"<a href='javascript:;' onClick='animateBackward()'>&lt;&lt; Previous Pic</a></td><td height='30' align='right'>" +
						"<a href='javascript:;' onClick='animateForward()'>NextPic &gt;&gt;</a></td></tr></table>";

}

function animateBackward(){
	document.picTracker = document.picTracker - 4;
	if (document.picTracker < 0) { document.picTracker = ((document.totalPics - 1) * 4); }
	matt = document.getElementById("picture");
	matt.innerHTML = "<table width='" + document.tableWidth + "' height='" + document.tableHeight + 
						"' border='0' align='" + document.align + "' cellpadding='0' cellspacing='0'><tr><td colspan='2'><img src='" + 
						document.photoArray[document.picTracker] + "' align='" + document.align + "' width='" + document.photoArray[document.picTracker + 2] + 
						"' height='" + document.photoArray[document.picTracker + 3] + "'></td></tr><tr><td colspan='2'><div align='center'><strong>" + 
						document.photoArray[document.picTracker + 1] + "</strong><br><br></div></td></tr><tr><td height='30' align='left'>" +
						"<a href='javascript:;' onClick='animateBackward()'>&lt;&lt; Previous Pic</a></td><td height='30' align='right'>" +
						"<a href='javascript:;' onClick='animateForward()'>NextPic &gt;&gt;</a></td></tr></table>";

}