/* 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');
}

$(document).ready(function(){
	if($.browser.msie && $.browser.version <= 7){
		$('#box-categories .box-categorie *').css('cursor','pointer');
		$('#box-categories .box-categorie').click(function(){
			window.location.href = $(this).attr('href'); 
		});
	} 
	
	$('#box-categories .box-categorie').hover(
		function(){
			var slide = $('.box-categorie-desc',this);
			slide.show();
		},
		function(){
			var slide = $('.box-categorie-desc',this);
			slide.hide();
		}
	);
	
	buttons = new Array();
	$("#box-visionneuse-medias .pub-nav-wrapper button").each(function(i){
		buttons.push('#'+$(this).attr('id'));
	});
	
	buttonsNav = $("#box-visionneuse-medias .pub-nav-wrapper button");
	
	// Si l'encart publicitaire a plusieurs bannières alors on initialise le carousel
	if($("#box-visionneuse-medias .rs-banners ul li").length > 1) {
		$("#box-visionneuse-medias .rs-banners").jCarouselLite({
			auto: 8000,
	   		speed: 500,
			visible: 1,
			circular:true,
			btnGo:buttons,
			btnPrev:"#pub-nav-1-prev",
			btnNext:"#pub-nav-1-next",
			afterEnd: function(a) {
	
				$('#box-visionneuse-medias .pub-nav-wrapper button').removeClass('selected');
	        	$('#box-visionneuse-medias .pub-nav-wrapper #'+$(buttonsNav.get(parseInt(a.attr('id').substring(7))-1)).attr('id')).addClass('selected');
				//alert(a.attr('id'));
	    	}
		});
	}
	if($("#box-news-wrapper ul li").length > 1) {
		$("#box-news-wrapper").jCarouselLite({
			speed: 500,
			visible: 1,
			circular:true,
			btnPrev: "#box-news-prev",
			btnNext: "#box-news-next"
		});
	}
});
