// JavaScript Document

var SpotLight = {
	init:function(){
		this.stopEvent=false;
		this.pauseTime=6000; //set time off in between two slides : 6000 
		this.globalSelectedVariable=1;
		this.preCounter=$$('#spotlights li').length;
		this.counter=$$('#spotlights li').length;
		this.numberOfSpotlightsToDisplay=2;
		this.paginationCursor=0;
		this.numberOfPages=0;
		this.defaultFlag=true;
		this.current=1;
		this.next=1;
		this.timeOut = {};
		this.spotlightsPointer=1;
		$$("#spotlights li").invoke('addClassName','display_none');
		var paginationUl = new Element('ul',{'id':"pagination_e115"});
		var increaser= 0;
		for(var i=0;i<this.preCounter;i++){
			increaser= i+1;
			$$("#spotlights li")[i].addClassName('counter_'+increaser);
			var pagination_hidden = new Element('li',{'id':"hidden_pagination_e115_"+increaser, 'class':"hidden_nav"});
			if(i==0){pagination_hidden.addClassName('selected_nav')}
			var anchor_hidden = new Element('a',{'class':"pagination hidden_pagination_a115_"+increaser,'href':"javascript:void(0);"});
			anchor_hidden.observe('click', this.selectThis.bindAsEventListener(this))
			paginationUl.insert({'bottom':pagination_hidden});
			pagination_hidden.insert({'bottom':anchor_hidden});
			anchor_hidden.innerHTML=increaser;
		}
		$("spotlights").insert({'bottom':paginationUl});
		this.showSpotLight();
		this.interval = setInterval(SpotLight.selectNext, this.pauseTime);
	},
	selectThis:function(event){
		this.current=event.element().innerHTML;
		this.showSpotLight();
	},
	
	selectNext:function(){
		var numberOfListedItems = parseInt(SpotLight.preCounter);
		var curentCurent = parseInt(SpotLight.current);
		if (curentCurent >= numberOfListedItems) {SpotLight.current=1; }
		else {SpotLight.current = parseInt(SpotLight.current)+1}
		SpotLight.showSpotLight();
	},
	
	showSpotLight:function(){
		//alert(this.current)
		//alert('showSpotLight: ' + SpotLight.current)
		if ($("spotlights")){
			$$("#pagination_e115 li").invoke('removeClassName','selected_nav');
			if($("hidden_pagination_e115_"+this.current)){$("hidden_pagination_e115_"+this.current).addClassName('selected_nav');}
			$$("#spotlights li").invoke('removeClassName','display_block');
			if($$("#spotlights li.counter_"+this.current)){$$("#spotlights li.counter_"+this.current).each(function(element){element.addClassName('display_block')});}
		}		
	}
	
	
}


