  /*
	-----------------------------------------------
	Script : Rotation d'image
	Version 1.0
	-----------------------------------------------
	Site : http://www.dreaminvasion.com
	Par : Gerald LONLAS
	Email : webmaster@dreaminvasion.com
	-----------------------------------------------
*/

// variables
var imgList = new Array();
var zInterval = null;
var indice=0;

// Change Opacité de l'image
function setOpacity(objet)
{
	if(objet.xOpacity>.99)
	{
		objet.xOpacity = .99;
		return;
	}

	objet.style.opacity = objet.xOpacity;
	objet.style.MozOpacity = objet.xOpacity;
	objet.style.filter = 'alpha(opacity=' + (objet.xOpacity*100) + ')';
}

// Fonction de changement des images (rotation)
function rotation()
{
	cOpacity = imgList[indice].xOpacity;
	nIndex = imgList[indice + 1]? indice + 1 : 0;
	nOpacity = imgList[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgList[nIndex].style.display = 'block';
	imgList[indice].xOpacity = cOpacity;
	imgList[nIndex].xOpacity = nOpacity;

	setOpacity(imgList[indice]);
	setOpacity(imgList[nIndex]);

	if(cOpacity<=0)
	{
		imgList[indice].style.display = 'none';
		indice = nIndex;
		setTimeout(rotation, 4000);
	}
	else
	{
		setTimeout(rotation, 50);
	}
}

// Initialisation du rotation
function rotationInit(elementId)
{
	if(document.getElementById || document.createElement)
	{
		imgList = document.getElementById( elementId ).getElementsByTagName('img');
		
		for(i=1;i<imgList.length;i++) 
		{ imgList[i].xOpacity = 0; }
		
		imgList[0].style.display = 'block';
		imgList[0].xOpacity = .99;

		setTimeout(rotation, 4000);
	};
}