/* 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-2 button").each(function(i){
		buttons.push("#pub-nav-but-2-"+(i+1));								 
	});
	
	$("#publicites-2").jCarouselLite({
		auto: 8000,
   		speed: 500,
		visible: 1,
		circular:true,
		btnGo:buttons,
		afterEnd: function(a) {

			$('#pub-nav-wrapper-2 button').removeClass('selected');
        	$('#pub-nav-wrapper-2 #pub-nav-but-2-'+a.attr('id').substring(6)).addClass('selected');
			//alert(a.attr('id'));
    	}
	});
	
	$('#home-header-img').hover(function() {
		var fade = $('#pub-nav-wrapper-2',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-2',this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(500, 0, resetPubNav);
		} else {
			fade.fadeOut(500, resetPubNav);
		}
	});

});
