ES.affiche = {
	total:0,
	link:'',
	links:[],
	images:[],
	times:[],
	current:null,
	interval:null,
	preload:new Array,
	open:null,
	kill:null,
	init:function(){
		ES.affiche.total=ES.affiche.images.length;
		if(document.images){for(var i=1;i<ES.affiche.total;i++){ES.affiche.preload[i]=new Image;ES.affiche.preload[i].src=ES.affiche.images[i];}}
		ES.affiche.number("affiche-button");
	},
	change:function(n){
		n=parseInt(n,10);
		if(ES.affiche.images[n]=="undefined" || ES.affiche.links[n]=="undefined" || ES.affiche.times[n]=="undefined"){return false;}
		document.getElementById("affiche").style.backgroundImage="url("+ES.affiche.images[n]+")";
		ES.affiche.link=ES.affiche.links[n];
		clearInterval(ES.affiche.interval);
		
		for(var i=1;i<ES.affiche.total;i++){document.getElementById("button"+i).style.color="#ffffff";}
		document.getElementById("button"+n).style.color = "#909090";
		
		if(b != "IE" || v != "6.0" || o != "WIN"){
			for(var i=1;i<ES.affiche.total;i++){document.getElementById("button"+i).style.backgroundImage="url('images/affiche/button.png')";}
			document.getElementById("button"+n).style.backgroundImage="url('images/affiche/button-hover.png')";
			
			document.getElementById("barre").style.backgroundPosition="100%";
			$('#barre').stop().animate({backgroundPosition:"0%"},{duration:ES.affiche.times[n]*1000,complete:function(){$(this).css({backgroundPosition: "100%"});}});
		}else{
			for(var i=1;i<ES.affiche.total;i++){document.getElementById("button"+i).style.backgroundImage="url('images/affiche/button.gif')";}
			document.getElementById("button"+n).style.backgroundImage="url('images/affiche/button-hover.gif')";
		}
		if(!ES.affiche.current || ES.affiche.current==null) ES.affiche.current=1;
		if ((n+1)<ES.affiche.total)	ES.affiche.current=n+1;
		else	ES.affiche.current=1;
		
		ES.affiche.interval=setInterval("ES.affiche.change("+ES.affiche.current+")",ES.affiche.times[n]*1000);
	},
	number:function(o){
		var number="";
		for(var i=1;i<ES.affiche.total;i++){number+="<a href=\"javascript:;\" id=\"button"+i+"\" onclick=\"ES.affiche.change("+i+");ES.affiche.kill_link();\">"+i+"</a> ";}
		document.getElementById(o).innerHTML=number;
	},
	open_link:function(){ES.affiche.open=setTimeout("window.location=ES.affiche.link;",100);},
	kill_link:function(){ES.affiche.kill=setTimeout("clearTimeout(ES.affiche.open);",50);}
};
