/* Fait tourner les publicites */
var publicites = 0;
var publicitesNav = 0;
var publicitesTimer = 0;
var publicitesDelay = 5000;

function resetPubNav(){
	$(this).css('opacity','1');
	$(this).css('display','none');
}

$(window).load(function(){
	buttons = new Array();
	$("#pub-nav-wrapper-1 button").each(function(i){
		buttons.push("#pub-nav-but-1-"+(i+1));								 
	});
	
	// Si l'encart publicitaire a plusieurs bannières alors on initialise le carousel
	if($("#publicites-1 ul li").length > 1) {
		$("#publicites-1").jCarouselLite({
			auto: 8000,
	   		speed: 500,
			visible: 1,
			circular:true,
			btnGo:buttons,
			afterEnd: function(a) {
	
				$('#pub-nav-wrapper-1 button').removeClass('selected');
	        	$('#pub-nav-wrapper-1 #pub-nav-but-1-'+a.attr('id').substring(6)).addClass('selected');
				//alert(a.attr('id'));
	    	}
		});
	}
	// A voir
	$('#box-tete-affiche').hover(function() {
		var fade = $('#pub-nav-wrapper-1',this);
 		
		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(500, 1);
		} else {
			fade.fadeIn(500);
		}
		
	}, function () {
		var fade = $('#pub-nav-wrapper-1',this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(500, 0, resetPubNav);
		} else {
			fade.fadeOut(500, resetPubNav);
		}
	});

});
