var countShowcases = 7;
var currentShowcase = 1;
var delaySeconds = 9;
var timeoutID = 0;

function nextShowcase(clicked) {
	if(clicked!=1){
		// if this is not the result of a user click, set timeout for the next automatic slide
		clearTimeout(timeoutID);
		timeoutID = setTimeout('nextShowcase()', (delaySeconds*1000));
	}
	if(currentShowcase==countShowcases) {
		// ** jump to the first showcase without animating:
		sp1.enableAnimation=false;
		sp1.showFirstPanel();
		currentShowcase=1;
		// turn animation back on:
		sp1.enableAnimation=true;
		sp1.showNextPanel();
		currentShowcase=2;
	} else {
		sp1.showNextPanel();
		currentShowcase++;
	}
}

function prevShowcase(clicked) {
	// prevShowcase only happens as a result of a user click
	if(currentShowcase==1) {
		// ** jump to the last showcase without animating:
		sp1.enableAnimation=false;
		sp1.showLastPanel();
		currentShowcase=countShowcases;
		// turn animation back on:
		sp1.enableAnimation=true;
		sp1.showPreviousPanel();
		currentShowcase=countShowcases-1;
	} else {
		sp1.showPreviousPanel();
		currentShowcase--;
	}
}

function startShowcase() {
	timeoutID = setTimeout('nextShowcase()', (delaySeconds*1000));
}

function suspendShowcase() {
// suspends rotating while mouse is over showcase i.e. customer is interacting with it
	clearTimeout(timeoutID);
}

addLoadEvent(startShowcase);
