// variables
	var imgList = new Array();
	var indice = new Array();
	var config = new Array();
	
	// Change Opacité de l'image
	function setOpacity(objet)
	{
		if(objet.xOpacity > 1) {
			objet.xOpacity = 1;
			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(index)
	{						
		cOpacity = imgList[index][indice[index]].xOpacity;
		nIndex = imgList[index][(indice[index] + 1)] ? (indice[index] + 1) : 0;
		nOpacity = imgList[index][nIndex].xOpacity;
		cOpacity -= .05;
		nOpacity += .05;
		imgList[index][nIndex].style.display = 'block';
		imgList[index][indice[index]].xOpacity = cOpacity;
		imgList[index][nIndex].xOpacity = nOpacity;
		setOpacity(imgList[index][indice[index]]);
		setOpacity(imgList[index][nIndex]);
		if (cOpacity <= 0){
			imgList[index][indice[index]].style.display = 'none';
			indice[index] = nIndex;
			setTimeout(function(){ rotation(index); }, config[index][0]);
		} else {
			setTimeout(function(){ rotation(index); }, (config[index][1] / 200));
		}
	}
	// Initialisation du rotation
	function rotationInit(elementId)
	{
		var changeDelay = arguments[1] ? arguments[1] : 6000;
		var opacityDelay = arguments[2] ? arguments[2] : 10000;
		var firstChangeDelay = arguments[3] ? arguments[3] : 3000;
		var typeElement = arguments[4] ? arguments[4] : 'DIV';
		
		if (document.getElementById || document.createElement){
		
			var tmp_elmt = document.getElementById( elementId ).childNodes;
			var tmp_imgList = new Array();
			for (var i=0; i<tmp_elmt.length; i++){
			   if (tmp_elmt[i].nodeType == 1 && tmp_elmt[i].nodeName.toUpperCase() == typeElement.toUpperCase()){
				   tmp_imgList.push(tmp_elmt[i]);
			   }
			}
					
			for(i=1; i<tmp_imgList.length; i++){
				tmp_imgList[i].style.display = 'none'; 
				tmp_imgList[i].xOpacity = 0; 
			}
			
			tmp_imgList[0].style.display = 'block';
			tmp_imgList[0].xOpacity = 1;
			imgList.push(tmp_imgList);
			indice.push(0);
			config.push(new Array(changeDelay, opacityDelay));
			var tmp_index = imgList.length -1;
			setTimeout(function(){ rotation(tmp_index); }, firstChangeDelay);
		}
	}
	
function prepareRotation (id, elementAConserver){
   var obj = document.getElementById(id);
   if (obj){
       var divTmp = document.createElement('div');
       var elmts = obj.getElementsByTagName(elementAConserver);
       var nb_elmts = elmts.length;
       for (var i=0; i<nb_elmts; i++){
           divTmp.appendChild(elmts[0]);
       }
       obj.innerHTML = divTmp.innerHTML;
   }
}