

$(window).load(function(){




var nb_img = $("#bandeau img").length;
var indice = nb_img-1;
var anim;


ind = 0
//$("#bandeau img").each(function(){
	//if($(this).height() > 400) {

	//$(this).load(function(){
		//ind++;
		//$("#conferences h1").prepend(ind);
		//$("#bande_trsp").html('<p><span><span>Chargement... '+ind+'/'+nb_img+'<span></span></p>');
	//});
	//}
//});



	/*animation*/


//$("#conferences h1").html(indice);
//anim = 0;


// une pile d'images qu'on fait fondre, puis revenir qd c'est fini
function animer(){



//$("#conferences h1").html(indice);

	if(indice == 0) {
		nb_img = $("#bandeau img").length;	
		indice = nb_img-1;
		
		//$("#bande_trsp").css({left: '-1100px'});
		//$("#fond_bande_trsp").css({opacity: 0});
		
		/*$("#bandeau a").each(function(){
			//$(this).css({left: '27px'}).animate({opacity: 1},1500);
			srcc = this.src;
			$("#conferences h1").append(srcc);			
		});*/
		$("#bandeau a").css({left: '27px'}).animate({opacity: 1},1500);
		bande();

	}
	else {
		$("#bandeau a").eq(indice).animate({opacity: 0},1500, function(){			
			$(this).css({left: '-1200px'});//dégager pour pouvoir cliquer sur le lien de dessous
			bande();
		});
		
		indice --;
	}
		$("#bande_trsp").css({left: '-1100px'});
		$("#fond_bande_trsp").css({opacity: 0});
	
		//control
		
		

		
	
			
			//le bandeau txt
			/*if(indice == $("#bandeau img").length) {
				indiceimdudessous = 0;
				} else {
					indiceimdudessous = indice-1;
				}*/
				
							//indiceimdudessous = indice;
			
//////
			//});
			
			
		
	
	
			

anim = 	setTimeout(function(){
			animer();
	},5000);
}

function check(){
		if(ind == nb_img){
			$("#bandeau img").css({display: 'block'});
			$("#bande_trsp").html('<p>'+im.attr('title')+'<span> - '+im.attr('alt')+'</span></p>');
			anim =	setTimeout(function(){
				animer();		
			},5000);
	} else {
		setTimeout(function(){
			check()
		},1000);
	}
}

function bande(){

	im = $("#bandeau a img").eq(indice);
	$("#bande_trsp").html('<p>'+im.attr('title')+'<span> - '+im.attr('alt')+'</span></p>');
	$("#fond_bande_trsp").stop().animate({opacity: .3},800,function(){
		$("#bande_trsp").stop().animate({left: '38px'},1300);
	});
}

//init
arrette();
im = $("#bandeau a img").eq(indice);
$("#fond_bande_trsp").css({display: 'block'}).css({opacity: 0});



$("#bande_trsp").html('<p>'+im.attr('title')+'<span> - '+im.attr('alt')+'</span></p>');
anim = setTimeout(function(){
		animer();		
	},5000);
	
		
//check()	;
	

	
function va(){
	$("#menu").bind('mouseover',function(){
		animer();
		arrette();
		$(this).unbind('mouseover');
	});

}
function arrette(){
	$("#bandeau").bind('mouseover',function(){
			clearTimeout(anim);
			$(this).unbind('mouseover');
			va();
		});
}	
		
		
		
		

	//$("#bandeau a").eq(indice).css({display: 'block'});
});
