var cpt = 0;
var cpt2 = 100;


function changeOpac(opacite, id) 
{ 
  var object = document.getElementById(id).style; 
  object.opacity = (opacite / 100);  
  //object.KhtmlOpacity = (opacite / 100); 
  object.filter = "alpha(opacity=" + opacite + ")";
}  

function opacPlus(opacFin, id) 
{ 
  if (cpt <= opacFin)
  { 
    changeOpac(cpt,id); 
    setTimeout("opacPlus('" + opacFin + "','" + id + "')",50); 
    cpt += 2; 
  }
  else
  {
    cpt = 0 ;
  }
	if (cpt >= opacFin/2)
	{
		document.getElementById("legende_img").innerHTML = tab_legende[index];
	}
} 

/*function opacMoins(opacFin, id) 
{ 
  if (cpt2 >= opacFin)
  { 
    changeOpac(cpt2,id); 
    setTimeout("opacMoins('" + opacFin + "','" + id + "')",50); 
    cpt2 -= 2; 
  }
  else
  {
    cpt2 = 100 ;
  } 
}*/

var tableau = new Array("image1","image2","image3","image4") ;         
var index = 0 ;
var nb = tableau.length - 1 ;
var actif ;
var z = 1 ;


function afficher(i) {
  document.getElementById(tableau[i]).style.zIndex = z ;
  opacPlus(100,tableau[i]) ;
  z += 1 ;
}

function suivante() {
  index += 1 ;
  if(index > nb) index = 0 ;
  afficher(index) ;
}

function auto() 
{
  document.getElementById("legende_img").innerHTML = tab_legende[index];
	actif = window.setInterval("suivante()",5000) ;
}