// variables for all showcaseshows 
var xsShowcases = new Array(new Array(),new Array(),new Array());	// *** multi-dimensional array to store image src, alt, and captions
var xsShowcaseIndex;			// *** tracks current showcase index number 
var xsShowcaseHasCap;			// *** true to display Captions *** PASS values in page-embedded script

var xsShowcaseURL = new Array();		// *** showcaseshow images 
var xsShowcaseCAP = new Array();		// *** showcaseshow captions
var xsShowcaseALT = new Array();		// *** showcaseshow alt text
var xsShowcaseStart;			// *** starting showcase index number, -1 for random start *** PASS values in page-embedded script
var xsInterval = 4000;

// initializes user-navigable showcase 
function xsStartshowcaseshow(bCap, iStart, bAuto)								
{	
	xsShowcaseHasCap = bCap;
	if (iStart > -1) 
		xsShowcaseIndex = iStart;
	else
		xsShowcaseIndex = xsGetRandomIndex(xsShowcases.length);
	if (document.images.xsShowcaseImage) {
		document.xsShowcaseImage.src = xsShowcases[xsShowcaseIndex][0];
		document.xsShowcaseImage.alt = xsShowcases[xsShowcaseIndex][1];
		xsSwapLink();
		if(xsShowcaseHasCap) xsDisplayCaption();
		xsLoadAllShowcases();
	}
	if (bAuto)
		self.setInterval("xsNextShowcase()", xsInterval);
	return false;
}

// swaps the href of the showcase link
function xsSwapLink()
{	
	var link;
	if (document.all)
		link = document.all.xsShowcaseLink;
	else if (document.getElementById)
		link = document.getElementById("xsShowcaseLink");
	if (link != undefined)
		link.href = xsShowcases[xsShowcaseIndex][3];
}

// loads all showcases in the array
function xsLoadAllShowcases()
{	
	for (i=0;i<xsShowcases.length;i++) {
		eval("img" + i + " = new Image()");
		eval("img" + i + ".src = '" + xsShowcases[i][0] + "'");
	}
	return false;
}

// displays captions for any showcaseshow *** DO NOT EDIT 
function xsDisplayCaption()
{
	var cap = "&nbsp;";
	if(typeof(xsShowcases[xsShowcaseIndex][2]) != "undefined") cap = xsShowcases[xsShowcaseIndex][2];
	if(document.all)
		document.all.xsShowcaseCaption.innerHTML = cap;
	else if(document.getElementById)
		document.getElementById("xsShowcaseCaption").innerHTML = cap;
	return false;
}

// moves to next index in user-navigable showcaseshow 
function xsNextShowcase()									
{
	xsShowcaseIndex = (xsShowcaseIndex < (xsShowcases.length-1))? ++xsShowcaseIndex : xsShowcaseIndex = 0;
	document.xsShowcaseImage.src = xsShowcases[xsShowcaseIndex][0];
	document.xsShowcaseImage.alt = xsShowcases[xsShowcaseIndex][1];
	xsSwapLink();
	if(xsShowcaseHasCap) xsDisplayCaption();
	return false;
}

// moves to previous index in user-navigable showcaseshow 
function xsBackShowcase(arrayname)								
{
	xsShowcaseIndex = (xsShowcaseIndex >= 1)? --xsShowcaseIndex : xsShowcases.length-1
	document.xsShowcaseImage.src = xsShowcases[xsShowcaseIndex][0];
	document.xsShowcaseImage.alt = xsShowcases[xsShowcaseIndex][1];
	xsSwapLink();
	if(xsShowcaseHasCap) xsDisplayCaption();
	return false;
}

// gets a random number 
function xsGetRandomIndex(iMax) {
	var randomNum = Math.random();
	randomNum = randomNum * iMax;
	randomNum = parseInt(randomNum);
	if(isNaN(randomNum)) randomNum = 0; // for Netscape
	return randomNum;
}

// functions for webpage showcaseshow (fade transitioning, automated, user-navigable)
var xsWebInterval = 4000;
var xsTimeout, xsShowcaseIndex;
var filterobj, filtersupp, blenddelay;

function xsStartWebShowcases() {
	filterobj= document.getElementById("xsWebShowcases");
	filtersupp = filterobj.filters;
	blenddelay=(filtersupp)? filterobj.filters[0].duration*1000 : 0;
	xsShowcaseIndex = 0;
	window.setTimeout('xsNextWebShowcase(true)', xsWebInterval+blenddelay);
}
function xsShowWebShowcase(filter) {
	if (filtersupp && filter)
		filterobj.filters[0].apply();
	for(i=0;i<xsWebShowcases.length;i++) {
		document.getElementById(xsWebShowcases[i]).style.display = (i==xsShowcaseIndex)?"block":"none";
	}
	if (filtersupp && filter)
		filterobj.filters[0].play();
	xsTimeout = window.setTimeout('xsNextWebShowcase(true)', xsWebInterval+blenddelay);
}
function xsBackWebShowcase(filter) {
	clearTimeout(xsTimeout);
	xsShowcaseIndex = (xsShowcaseIndex >= 1)? --xsShowcaseIndex : xsWebShowcases.length-1;
	xsShowWebShowcase(filter);
}
function xsNextWebShowcase(filter) {
	clearTimeout(xsTimeout);
	xsShowcaseIndex = (xsShowcaseIndex < (xsWebShowcases.length-1))? ++xsShowcaseIndex : 0;
	xsShowWebShowcase(filter);
}
