/* Global variables */

var curHomeSlide = 1;  // sets selected panel from Home Page slideshow
var curProductPanel = 1;  // sets selected panel from Product Highlights box
var intCount = 1; // counter for timed slideshow


setHomeSlideEvents = function()
{
	$$("body").onload = Effect.Appear("homeSlide" + curHomeSlide);
	$("slideAdvance").onclick = function() {advanceHomeSlide();};
}

/* timer loops through the home slides once then stops and displays button to manually click through slides */

new PeriodicalExecuter(function(pe)
{
	if (intCount > 3)
	{
		pe.stop();
		Effect.Appear("slideAdvance");
	
	} else {
		
		advanceHomeSlide();
		intCount++;
	}
}
, 5);


/* advance to the next slide */

advanceHomeSlide = function()
{
	if (curHomeSlide == 3)
	{
		nextHomeSlide = 1;
	
	} else {
		
		nextHomeSlide = curHomeSlide + 1;
	}
	
	$("homeSlide" + curHomeSlide).style.display = "none";
	
	Effect.Appear("homeSlide" + nextHomeSlide, {queue: 'end'});
	
	curHomeSlide = nextHomeSlide;
}


/* set events for products box on home page */

setProductBoxEvents = function()
{
	$("productOpt1").onclick = function() {changeProductPanel(1);};
	$("productOpt2").onclick = function() {changeProductPanel(2);};
	$("productOpt3").onclick = function() {changeProductPanel(3);};
}

/* display selected product, hide others */

changeProductPanel = function(selPanel)
{		
	$("productOpt" + curProductPanel).className = "col";	
	$("productOpt" + selPanel).className = "col sel";
	
	// change body content
	$("productBody" + curProductPanel).className = "hidden";
	$("productBody" + selPanel).className = "visible";
	
	curProductPanel = selPanel;
}