/**
 * @author mhannig
 */

 var globCurrentElement;
 var globNextElementTimer;
 var globNoAutoswitching;

 function ceRecommendHighlight( element )
 {
 	element.className = "active";
	
	
	for( i = 0; i < 5; i++ )
	{
		other = document.getElementById("ce-recommend-img-" + (i+1) );	
		if( other != element )
		{
			other.className = "";
		}
	}
	
		
 }
 
 function ceRecommendShow( what )
 {
 	element = document.getElementById("ce-recommend-" + (what + 1) );
	element.style.display = "block";
	
	for( i = 0; i < 5; i++ )	
	{
		other = document.getElementById("ce-recommend-" + (i+1) );	
		if( other != element )
		{
			other.style.display = "none";
		}		
	}

 }

 function noautoswitching( state )
 {
	globNoAutoswitching = state;
 }


 
function ceRecommendReset( element )
{
	
}

function showNextElement()
{
 if( globNoAutoswitching == 0 )
 {
   element = document.getElementById("ce-recommend-img-" + (globCurrentElement + 1) );
   if( element )
   {
	   ceRecommendHighlight( element ); 
 
	   ceRecommendShow( globCurrentElement );

}

 }

 globCurrentElement++; globCurrentElement = globCurrentElement % 5;
 globNextElementTimer = window.setTimeout( showNextElement, 5000 );
}

/* init function 
 *  - set timer and stuff.. 
 */

function ceRecommendInit()
{
	// add auto change timer:
	globNextElementTimer = window.setTimeout( showNextElement, 3000 );
    globCurrentElement = 0;

    globNoAutoswitching = 0;
}

registerInit( ceRecommendInit() );



