// appetizer.js

var tizerCount = tizerList.length; // # of different pictures
var tizerTimeout = 5000; // how long shall one picture be displayed before it gets swapped?

var currentTizerPix = 0;

var pix2swap; // the picture which will be replaced
var appetizerLoaded = false;

var clearAppetizerID; // to clear the tizerTimeout when swapping the pictures



function initAppetizer () {
	preloadAppetizerImages (tizerCount);	
	clearAppetizerID = setTimeout ("swapTizer () ",tizerTimeout);
}


function preloadAppetizerImages (maxCount) {
	if (document.images) {
	 	for (i = 0; i<maxCount; i++) {
 			tmp = tizerList[i][0];
 			tizerList[i][0] = new Image ();
 			tizerList[i][0].src = pixPath + tmp;
 		}
	}
	pix2swap = document.act;
	appetizerLoaded = true;
}


function swapTizer () {
	if (appetizerLoaded) {
		currentTizerPix++;
		if (currentTizerPix==tizerCount) {currentTizerPix=0;}
		pix2swap.src = tizerList[currentTizerPix][0].src;
		clearAppetizerID = setTimeout ("swapTizer () ",tizerTimeout);
	}
}


function setAppetizerURL () {
	if (appetizerLoaded) {
		clearTimeout (clearAppetizerID);
		self.location = tizerList[currentTizerPix][2]+"?thru=appetizer";
	}
}


function showAppetizerStatus () {
	if (appetizerLoaded) {
		clearTimeout (clearAppetizerID);
		self.status = tizerList[currentTizerPix][1];
	}
}


function hideAppetizerStatus () {
	if (appetizerLoaded) {
		self.status = "";
		// swapTizer ();
		clearAppetizerID = setTimeout ("swapTizer () ",400);
	}
}	
