/***********************************************************************************************\
*	SlideShow.js:  Created on 2/16/2005 														*
\***********************************************************************************************/
currentFeatureNum	= 1;				//start on feature one
changeDelay			= 8000;				//time between slides (milliseconds)
numberOfCycles		= 10;				
IndividualControls	= 0;				// 0 = Turn on numbers, 1 = Turn off numbers
maxFeature			= 3;
minFeature			= 1;

feature1times		= numberOfCycles;

activeColor			= "#F1B012";		//"#CCCCCC";
activeLinkStyle		= "none";
inactiveColor		= "#FFFFFF";
inactiveLinkStyle	= "underline";

	var browserVersion;
	var bd = new BrowserDetector()
	var slideControlDivs = new Array();		//Create the array of controls for the Divs
	var slideControlLinks = new Array();	//Create the array of controls for the Links
	var slides = new Array();				//Create the array of slides

setBrowserVersion();

//Create all of the page elements for the controls.
function InitializeSlideShow(SlideCount, individualControls, slideDelay)
{
	maxFeature			= SlideCount;
	IndividualControls	= individualControls
	changeDelay			= slideDelay * 1000;	//time between slides (seconds)
	
	for (i = 1; i <= SlideCount; i++)
	{
		if (IndividualControls == 0)
		{
			slideControlDivs[i]		= setupPageElement("SlideControl" + i + "Div");
			slideControlLinks[i]	= setupPageElement("SlideControl" + i + "Link");
		}
		slides[i] 				= setupPageElement("slide" + i);
	}
}

//Display the next/previous feature...
function CycleFeature(direction) // either +1 (forward) or -1 (reverse)
{
	deactivateAllFeatures();
	if (direction == "-1")
	{
		targetFeatureNumber = currentFeatureNum - 1;
		if ( targetFeatureNumber < minFeature ) targetFeatureNumber = maxFeature;
	}
	else
	{
		targetFeatureNumber = currentFeatureNum + 1;
		if ( targetFeatureNumber > maxFeature ) targetFeatureNumber = minFeature;
	}
	
	activateFeature(targetFeatureNumber);
	
	if ( currentFeatureNum == 1 )
	//          feature1times--;
	if (feature1times < 1 ) {
	     clearTimeout(slideTimer);
	}
}

//Display the specified feature...
function gotoFeature(featurenum) 
{
	deactivateAllFeatures();
	activateFeature(featurenum);
}

//Change the bgcolor to White and underline the numbers...
function deactivateAllFeatures()
{    
	for (i = minFeature; i <= maxFeature; i++)
	{
		hideFeature(slides[i]);
		if (IndividualControls == 0)
		{
			changecolor(slideControlDivs[i],inactiveColor);
			divunderline(slideControlLinks[i],inactiveLinkStyle);
		}
	}
}

//Change the bgcolor to White and underline the numbers...
function activateFeature(featurenum)
{
	showFeature(slides[featurenum]);

	if (IndividualControls == 0)
	{
		changecolor(slideControlDivs[featurenum],activeColor);
		divunderline(slideControlLinks[featurenum],activeLinkStyle);
	}

	
	//reset the slideshow timers and set the current feature number...
	currentFeatureNum = featurenum;
	clearTimeout(slideTimer);
	slideTimer = setInterval("CycleFeature('+1')", changeDelay);
	
	//if there is only one slide, stop the show so the screen doesn't flash...
	if (maxFeature == 1)
	{
		stopSlideShow();
	}
}

//Change the underline status on a control...
function divunderline(div, style) {if ( !bd.ns4 ) div.textDecoration = style;}

//Stop the slide show until another button is clicked
function stopSlideShow()	{clearTimeout(slideTimer);}

slideTimer = setInterval("CycleFeature('+1')", changeDelay);

//Create an object for the Controls, Features and ControlNumbers.
function setupPageElement(element)
{
	if (bd.ns4)
		{return eval("document."+element);}
	else
		{return document.getElementById(element).style;}
}

//Change the font color for a given control...
function changecolor(control,color) {if (!bd.ns4) control.background=color;}

//Show a given feature...
function showFeature(feature) 
{
	if (bd.ns4)
	{
		feature.visibility="show";
	}
	else
	{
		feature.display="block";
	}
}

//Hide a given feature...
function hideFeature(feature) 
{
	if (bd.ns4)
	{
		feature.visibility="hide";
	}
	else
	{
		feature.display="none";
	}
}

//Browser detection functions
//************************************************************************
//Determine if the browser is IE or Netscape Compatible...old school.
function setBrowserVersion()
{
   if (document.all) {
      browserVersion = "IE";
   } else {
      browserVersion = "Netscape";
   }
}

//Detect the browser and the platform.
function BrowserDetector() 
{
	var agent = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
	this.ns2 = (this.ns && (this.major == 2));
	this.ns3 = (this.ns && (this.major == 3));
	this.ns4 = (this.ns && (this.major == 4));
	this.ns5 = (this.ns && (this.major > 4));
	this.ns6	= (this.ns && (this.major == 6));
	this.ns7	= (this.ns && (agent.indexOf("netscape/7") !=-1));
	this.ns71	= (this.ns && (agent.indexOf('netscape/7.1')!=-1));
	this.ns72	= (this.ns && (agent.indexOf('netscape/7.2')!=-1));
	this.firefox	= (this.ns && (agent.indexOf('firefox')!=-1));
	this.ie = (agent.indexOf("msie") != -1);
	this.ie3 = (this.ie && (this.major == 2));
	this.ie4 = (this.ie && (this.major >= 4));
	this.ie55	= (this.ie && (this.major == 4) && (agent.indexOf("msie 5.5") != -1));
	this.ie6	= (this.ie && (agent.indexOf("msie 6.0")!=-1));
	this.cs6	= (agent.indexOf("2000 6")!=-1); // CompuServe 6.0
	this.cs7	= (agent.indexOf("cs 2000 7")!=-1); // CompuServe 7.0
	this.op3 = (agent.indexOf("opera") != -1);
	this.mac = (agent.indexOf("mac") != -1);
	this.client = ( (navigator.userAgent.indexOf('AOL')!=-1) || (navigator.userAgent.indexOf('CS 2000')!=-1) )? 1 : 0;
}