var coef = 0.05 ; 	 // avancement de l'opacité
var temps = 50 ; 	 // temps entre chaque changement d'opacité
var temps_pause = 2000 ; // temps d'attente entre 2 changements d'images

var tabImg = new Array();
tabImg[0]=new Image();	tabImg[0].src = "../images/accueil/img1.jpg";
tabImg[1]=new Image();	tabImg[1].src = "../images/accueil/img2bis.jpg";
tabImg[2]=new Image();	tabImg[2].src = "../images/accueil/img3.jpg";
tabImg[3]=new Image();	tabImg[3].src = "../images/accueil/img7.jpg";
tabImg[4]=new Image();	tabImg[4].src = "../images/accueil/img4.jpg";
tabImg[5]=new Image();	tabImg[5].src = "../images/accueil/img5.jpg";
tabImg[6]=new Image();	tabImg[6].src = "../images/accueil/img6.jpg";
tabImg[7]=new Image();	tabImg[7].src = "../images/accueil/img8.jpg";

// pas touche
var indice = 2; 	// les 2 premiere image sont deja charger dans le HTML, on commence a la 3eme
var isIE = navigator.userAgent.toLowerCase().indexOf('msie')!=-1 ;
var img1 = null;
var img2 = null;
var sens = 1;

function init() { img1 = document.getElementById("defilement1") ;	img2 = document.getElementById("defilement2") ;	change_opacity();}
function change_opacity()
{
	var opacity1 = 0 ;	var opacity2 = 0 ;
	if (isIE)  // for IE
	{	opacity1 = parseFloat(img1.filters.alpha.opacity);	opacity2 = parseFloat(img2.filters.alpha.opacity);	}
	else       // for mozilla
	{	opacity1 = parseFloat(img1.style.MozOpacity);		opacity2 = parseFloat(img2.style.MozOpacity);		}
	if (sens)
	{	if (isIE)  // for IE
		{	img1.filters.alpha.opacity = opacity1 + coef * 100;		img2.filters.alpha.opacity = opacity2 - coef * 100;	}
		else 	  // for Mozilla
		{	img1.style.MozOpacity = opacity1 + coef;			img2.style.MozOpacity = opacity2 - coef;		}	
	}
	else
	{
		if (isIE)  // for IE
		{	img1.filters.alpha.opacity = opacity1 - coef * 100;	img2.filters.alpha.opacity = opacity2 + coef * 100;	}
		else 	  // for Mozilla
		{	img1.style.MozOpacity = opacity1 - coef;		img2.style.MozOpacity = opacity2 + coef;		}
	}
	if (isIE)  // for IE
	{	opacity1 = parseFloat(img1.filters.alpha.opacity);		opacity2 = parseFloat(img2.filters.alpha.opacity);	}
	else       // for mozilla
	{	opacity1 = parseFloat(img1.style.MozOpacity);			opacity2 = parseFloat(img2.style.MozOpacity);	}
	// on fait varié le sens d'opacité
	if (opacity2  <= 0)
	{	img2.src=tabImg[indice++].src;
		sens = 0;
		if (indice == (tabImg.length)) indice=0;
		window.setTimeout("change_opacity()",temps_pause) ;
		return 0;
	}
	else if (opacity1 <= 0)
	{	img1.src=tabImg[indice++].src;
		sens = 1;
		if (indice == (tabImg.length)) indice=0;
		window.setTimeout("change_opacity()",temps_pause) ;
		return 0;
	}
	window.setTimeout("change_opacity()",temps) ;
}

