/*
This file contains the function needed to activate the Ticker on the homepage of B2C
/!\ ONLOAD Function at the bottom /!\
*/
/********* CONFIG TICKER *********/
	var oTicker;
	var confTicker_bTicker = true;
	var confTicker_iSpeed = 3000; //every 1 second
	var confTicker_currentActive = 1;
/*********************************/

/********* Ticker Variables *********/
var divContent_1 = 'ctl00_rptHomeContent_ctl00_divContentHome';
var divContent_2 = 'ctl00_rptHomeContent_ctl01_divContentHome';
var divContent_3 = 'ctl00_rptHomeContent_ctl02_divContentHome';
/*********************************/

function tickerChangePic() {
/*
	This function changes the actual pictures on the page. 
	It will call the [tickerExecuteShow] function to do the actual switching.
*/
	try {
		switch(confTicker_currentActive) {
		case 1:
		  tickerExecuteShow(2, divContent_2);
		  tickerSetCurrentActive(2);
		  break;    
		case 2:
		  tickerExecuteShow(3, divContent_3);
		  tickerSetCurrentActive(3)
		  break;
		default:
		  tickerExecuteShow(1, divContent_1);
		  tickerSetCurrentActive(1)
		}		
		tickerSetItOff(); //again
	}
	catch(e){}
}

function tickerSetCurrentActive(iTickerActiveItem) {
/*
	Simple function that sets the config parameter so that we know which image is active at any given time.
*/	
	try {
		confTicker_currentActive = iTickerActiveItem;
	}
	catch(e){}
}

function tickerExecuteShow(iTickerShowItem, oTickerDivContent) {
/*
	Function that does the actual switch of an image. Derived from the functionality that was already present in the mouseover's
*/	
	try {
		HideAllDiv();
		ShowColor('ctl00_rptHomeLeft_ctl0' + iTickerShowItem.toString() + '_lnkSummary');
		ShowDiv(oTickerDivContent);
	}
	catch(e){}
}

function tickerMouseOver() {
/*
	Function that stops the Ticker
*/	
	try {
		confTicker_bTicker=false;
		clearTimeout(oTicker);
	}
	catch(e){}
}

function tickerMouseOut() {
/*
	Function that restarts the Ticker on a mouseOut
*/
	try {
		confTicker_bTicker=true;
		tickerSetItOff();
	}
	catch(e){}
}

function tickerSetItOff() {
/*
	The function that actually starts the Ticker
*/
	try{
		if (confTicker_bTicker){
			oTicker = window.setTimeout(tickerChangePic, confTicker_iSpeed);
		}
	}
	catch(e){}
}

function ShowDiv(object){
	var div = document.getElementById(object);           
	if (div.style.display == "none")
	{
		div.style.display = "inline";
		//div.style.visibility = "visible";
	}
}  
 
function HideDiv(object){
	var div = document.getElementById(object);           
	if (div.style.display == "inline")
	{
		div.style.display = "none";
		//div.style.visibility = "hidden";
	}
}

function HideColor(object){
	var lnk = document.getElementById(object); 
	lnk.className = "";
} 

function ShowColor(object){
	var lnk = document.getElementById(object); 
	lnk.className = "selected";                          
} 

function HideAllDiv(){
	HideDiv(divContent_1);
	HideColor('ctl00_rptHomeLeft_ctl01_lnkSummary');
	HideDiv(divContent_2);
	HideColor('ctl00_rptHomeLeft_ctl02_lnkSummary');
	HideDiv(divContent_3);
	HideColor('ctl00_rptHomeLeft_ctl03_lnkSummary');
}
/*
/!\ Hook new ONLOAD Function to activate the Ticker /!\
*/
var oPreviousOnload = window.onload;
window.onload = function(){
	if ("function" == typeof oPreviousOnload) {
		//previous routine(s)
		oPreviousOnload();
		//new routine
		tickerSetItOff();
	}
}
