/* FANCYBOX */
$(document).ready(function() {
$("a[rel=apdev_repertoire_fiche_image]").fancybox({
'overlayOpacity'	: 0.6,
'overlayColor'		: '#000',
'autoScale' : true,
'padding' : 0,
onComplete : function() {
$.fancybox.resize();
},
onStart : function() {
$("#fancybox-wrap").addClass("fancybox-repertoire");
$("#fancybox-wrap").addClass("fancybox-repertoire52");
}
});
});

/* SLIDESHOW */
$(document).ready(function() {
	rotatePics(1);	
}
)

function rotatePics(currentPhoto) {
	var numberOfPhotos = $('#slideshow_entete img').length;
	currentPhoto = currentPhoto % numberOfPhotos;	


$('#slideshow_entete img').eq(currentPhoto).fadeOut(function() {
	// réorganise les Z
	$('#slideshow_entete img').each(function(i) {
		$(this).css(
			'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
			);
	});
	
	$(this).show();
	setTimeout(function() {rotatePics(++currentPhoto);},5000);
});
}

/* BANNIÈRES PARTENAIRES */


$(document).ready(function() {
	rotateBannierePart(1);	
}
)

function rotateBannierePart(currentBannierePart) {
	var numberBannierePart = $('#droite div.banniere1').length;
	currentBannierePart = currentBannierePart % numberBannierePart;	


$('#droite div.banniere1').eq(currentBannierePart).fadeOut(function() {
	// réorganise les Z
	$('#droite div.banniere1').each(function(i) {
		$(this).css(
			'zIndex', ((numberBannierePart - i) + currentBannierePart) % numberBannierePart
			);
	});
	
	$(this).show();
	setTimeout(function() {rotateBannierePart(++currentBannierePart);},3000);
});
}

/* BANNIÈRES LOTOQC*/


$(document).ready(function() {
	rotateBanniereLotoQC(1);	
}
)

function rotateBanniereLotoQC(currentBanniereLotoQC) {
	var numberBanniereLotoQC = $('#droite div.banniere2').length;
	currentBanniereLotoQC = currentBanniereLotoQC % numberBanniereLotoQC;	


$('#droite div.banniere2').eq(currentBanniereLotoQC).fadeOut(function() {
	// réorganise les Z
	$('#droite div.banniere2').each(function(i) {
		$(this).css(
			'zIndex', ((numberBanniereLotoQC - i) + currentBanniereLotoQC) % numberBanniereLotoQC
			);
	});
	
	$(this).show();
	setTimeout(function() {rotateBanniereLotoQC(++currentBanniereLotoQC);},12000);
});
}

/* PROG LISTE TMB */




$(document).ready(function() {
	
	var classes = ['rouge', 'jaune', 'bleu', 'blanc', 'noir'];
	$('.prog_liste_tmb > li.prog_tmb > div').each(function(i) {
        $(this).addClass(
            classes[Math.floor(Math.random()*classes.length)]);
    });
	
	/*$("ul.prog_liste_tmb > li.prog_tmb").addClass(Math.floor(Math.random()*6));*/

	$("ul.prog_liste_tmb > li.prog_tmb").hover(function() {
		$(this)
			.find("div")
			.stop(true, true)
			.fadeIn("fast");
	}, function() {
		$(this)
			.find("div")
			.stop(true, true)
			.fadeOut("fast");
	});			
});
