//sistemul de rularea a bannerelor pe prima pagina

	var currentPromo = 0;
	var delay = 5000;
	var delayOnClick = 6000;
	var canBeSwitched = true;
	var openedTab = 'banner_0';
	var timeoutId = 0;	 

	
	
	function redirect2Promo(){
		document.location ="redirect-to-promotion-"+currentPromo;
	}
	
	function activateBanner(elm){		
		
		document.getElementById('banner_img_' + currentPromo).className = "inactivePromo";
		document.getElementById('banner_img_' + elm).className = "activePromo";
		
		document.getElementById('btn_menu_' + currentPromo).className="banner_tab";
		document.getElementById('btn_menu_' + elm).className="banner_tab_selected";
		
		
		document.getElementById('separator_left_' + currentPromo).className = "banner_tab_left_off";
		document.getElementById('separator_right_' + currentPromo).className = "banner_tab_right_off";

		document.getElementById('separator_left_' + elm).className = "banner_tab_left_on";
		document.getElementById('separator_right_' + elm).className = "banner_tab_right_on";
		
		currentPromo = elm;
	}
	
	function clearPostedTimeout(){
		clearTimeout(timeoutId);		
		timeoutId = setTimeout('moveToNext()', delay);	
	}
	
	function moveToNext(){		
		var next = currentPromo+1;
		if(next==noBanners){
			next = 0;
		}		
		activateBanner(next);		
		clearPostedTimeout();
	}
	
	function bannerClick(id){
		if( id != currentPromo){
			clearTimeout(timeoutId);
			activateBanner(id);
			currentPromo = id;
			timeoutId = setTimeout('moveToNext()', delayOnClick);
		}
		else{
			clearPostedTimeout();
		}
	}
	
	function play(){
		timeoutId = setTimeout('moveToNext()', delayOnClick);
		document.getElementById('img_play').style.display = "none";
		document.getElementById('img_pause').style.display = "";
	}
	
	function pause(){
		clearTimeout(timeoutId);	
		document.getElementById('img_play').style.display = "";
		document.getElementById('img_pause').style.display = "none";
	}
	
	function goToPrevious(){
		clearTimeout(timeoutId);
		var el = currentPromo-1;
		if (el < 0){
			el = noBanners - 1;
		}
		activateBanner(el);
		play();
	}
	
	function goToNext(){
		clearTimeout(timeoutId);
		var el = currentPromo+1;
		if (el >= noBanners){
			el = 0 ;
		}
		activateBanner(el);
		play();
	}