/*

			Développé par LUNIWARE - http://luniware.com
			¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


             (__)    /¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\ 
             (oo)   (  dernière modification le 20 juin 2007  )
   /-------\/  --'\__________________________________________/ 
  / |     ||
 *  ||----||      	johan@trilogik.net  |  http://trilogik.net
    ^^    ^^
 
 
		Modification de Diaporama 6.04.03 - http://so.fun.free.fr
		
*/

	if (occDiapo == null)
	{
		var occDiapo = new Array();
	}

	function Diaporama(id_diaporama, frequenceH, vitesseH,	delai)
	{
		this.id_diaporama = id_diaporama;
		this.diapo = new Array();
		this.description = new Array();
		this.calque1 = "";
		this.calque2 = "";
		this.calque1link = "";
		this.calque2link = "";
		this.calqueDesc = "";
		this.frequenceH = frequenceH;
		this.vitesseH = vitesseH;
		this.delai = delai;
		this.indexDiapo = 2;
	}

	function ajoutePhoto(url_photo)
	{
		nb_diapo = this.diapo.length;
		this.diapo[nb_diapo] = new Image();
		this.diapo[nb_diapo].src = url_photo;
	}

	function ajouteDescription(desc)
	{
		nb_description = this.description.length;
		this.description[nb_description] = desc;
	}

	function nextDiap()
	{
		this.vitesse = this.vitesseH;
		this.frequence = this.frequenceH;

		if (this.calque1.style.opacity > 0)
		{
			// FF
			// ce paramètre sert de base commune pour les deux navigateurs pour tester l'état du calque
			opacite = parseFloat(this.calque1.style.opacity) - parseFloat(this.vitesse / 100);
			if (opacite < 0)
			{
				opacite=0;
			}
			this.calque1.style.opacity = opacite

			// IE
			if (this.calque1.style.filter)
			{
				texte = this.calque1.style.filter;
				opacite = texte.replace(/alpha\(opacity=([0-9]*)\)/, '$1');
				opacite = parseFloat(opacite) - this.vitesse;
				if (opacite < 0)
				{
					opacite=0;
				}
				this.calque1.style.filter = 'alpha(opacity=' + opacite + ')';
			}

			setTimeout("occDiapo[" + this.id_diaporama + "].nextDiap()", this.frequence);
		}
		else
		{	// inversion des calques
			this.calque1.style.zIndex = 0;
			this.calque2.style.zIndex = 1;
			
			this.calque1.style.opacity = 1;
			if (this.calque1.style.filter)
			{
				this.calque1.style.filter = 'alpha(opacity=100)';
			}

			// Mise en place d'une nouvelle image dans le calque qui se trouve en arrière
			this.calque1.style.backgroundImage = "url('" + this.diapo[this.indexDiapo].src + "')";	
		/*	this.calque1link.href = this.diapo[this.indexDiapo].src + '_big';*/
			this.indexDiapo++;
			if (this.indexDiapo >= this.diapo.length) this.indexDiapo = 0;
		
			//	Changement du sous titre
/*			if(this.indexDiapo == 0){
				this.calqueDesc.innerHTML = this.description[this.diapo.length-2];
			}else{
				if(this.indexDiapo == 1){
					this.calqueDesc.innerHTML = this.description[this.diapo.length-1];
				}else{
					this.calqueDesc.innerHTML = this.description[this.indexDiapo-2];
				}
			}*/
		
			//inversion des références des calques car seul calque1 rétrécit
			calqueTemp = this.calque2;
			this.calque2 = this.calque1;
			this.calque1 = calqueTemp;
	/*		calqueTempLink = this.calque2link;
			this.calque2link = this.calque1link;
			this.calque1link = calqueTempLink;			
*/
			setTimeout("occDiapo[" + this.id_diaporama + "].nextDiap()", this.delai);
		}
	}

	function placeDiaporama()
	{		
		//	Définir ici l'apparence de la div si besoin.
	document.write('<div id="diapo">');
		document.write('<div id="div_diapo2_' + this.id_diaporama + '" style="position:absolute;width:540px; height:228px; background-image:url(\'' + this.diapo[1].src + '\'); opacity:1; filter: alpha(opacity=100)"></div>');
		
		document.write('<div id="div_diapo1_' + this.id_diaporama + '" style="position:absolute;width:540px; height:228px;background-image:url(\'' + this.diapo[0].src + '\'); opacity:1; filter: alpha(opacity=100)"></div>');
		document.write('</div>');
		
		this.calque1 = document.getElementById('div_diapo1_' + this.id_diaporama);
		this.calque2 = document.getElementById('div_diapo2_' + this.id_diaporama);
		/*this.calque1link = document.getElementById('piclink1_' + this.id_diaporama);
		this.calque2link = document.getElementById('piclink2_' + this.id_diaporama);		
		this.calqueDesc = document.getElementById('titre_diapo_descr');*/
		this.calque1.style.zIndex = 1;
		this.calque2.style.zIndex = 0;
		
		/*this.calqueDesc.innerHTML = this.description[0];*/
		setTimeout("occDiapo[" + this.id_diaporama + "].nextDiap()", this.delai);
	}


	// liaison des fonctions à l'objet
	Diaporama.prototype.ajoutePhoto = ajoutePhoto;
	Diaporama.prototype.ajouteDescription = ajouteDescription;
	Diaporama.prototype.nextDiap = nextDiap;
	Diaporama.prototype.placeDiaporama = placeDiaporama;