$(document).ready(function(){

$("body").prepend('<div id="preload" style="position: absolute; top: -2000px"></div>');//

manif_en_cours = parseInt($("#affiche img").attr('name')); //indice manif au chargement
next = manif_en_cours+1;
prev = (manifs.length)-1;

if(next == manifs.length) {next = 0}
if(prev == manifs.length) {prev = 0}

	function change(){
	
		manif_en_cours ++;
		next ++;
		prev ++;

		 if(manif_en_cours == manifs.length) {manif_en_cours = 0}
		 if(next == manifs.length) {next = 0}
		 if(prev == manifs.length) {prev = 0}
				
		$("#affiche").css({backgroundImage: 'url('+$("#affiche img").attr('src')+')'});
		
		$("#affiche img").fadeOut(500, function(){
			$(this).attr('src','img/affiches/g/'+manifs[manif_en_cours]+'.jpg').fadeIn(1200,function(){
				$("#affiche").css({backgroundImage: 'url(img/layout/loading.gif)'});
				$("#preload").html('<img src="img/affiches/g/'+manifs[next]+'.jpg"');
				
		$("#avant img").attr('src','img/affiches/v/'+manifs[prev]+'.jpg');
		$("#apres img").attr('src','img/affiches/v/'+manifs[next]+'.jpg');
						
		$("#affiche a").attr('href', manifs[manif_en_cours]+'.php');		
				
				
				
			});
			
		});

	setTimeout(function(){change();},6000);
					
}

	setTimeout(function(){change();},6000);
});

