/**
 * JavaScript - affichage diapos - 10 08 2010
 * 
 * @package chez eugene
 * @author Elie Perrichon
 * @copyright Elie Perrichon/Artists-planet © 2010 - All right reserved
 */
var aImgUrl = new Array();
var aImgPos = new Array();
var aDiaGo = new Array();
var aEimg0 = new Array();
var aEimg1 = new Array();
var sImgPath = 'images/';
var iDelais = 4000;
var aTmpAff = new Array();
var iTradia = 3;
function diapo(sId, iNb, iDir) {
	if (typeof (aDiaGo[iNb]) == 'undefined') {
		aDiaGo[iNb] = 1;
		if (document.getElementById) {
			aEimg0[iNb] = document.getElementById('img' + sId);
			aEimg1[iNb] = document.getElementById('imgca' + sId);
		}
		if (typeof (aImgPos[iNb]) == 'undefined') {
			aImgPos[iNb] = 1;
			aEimg0[iNb].style.opacity = 1;
			aEimg1[iNb].style.opacity = 0;
			if (document.body.filters != undefined) {
				aEimg0[iNb].style.filter = 'alpha(opacity:100)';
				aEimg1[iNb].style.filter = 'alpha(opacity:0)';
			}
			aEimg1[iNb].style.visibility = 'visible';
		}
		aEimg1[iNb].onLoad = setTimeout('lance(' + iNb + ',' + iTradia + ')',
				iDelais);
	}
};
function lance(iNb, iDir) {
	opacite(aEimg1[iNb], iDir, false);
	aTmpAff[iNb] = setTimeout('affiche(' + iNb + ',' + iDir + ')', Math
			.round((100 / Math.abs(iDir)) * 45));
};
function affiche(iNb, iDir) {
	eIcharge = (iDir > 0) ? aEimg0[iNb] : aEimg1[iNb];
	iDir -= iDir * 2;
	iImgSuiv = aImgPos[iNb] + 1;
	aImgPos[iNb] = (iImgSuiv >= 0) ? ((iImgSuiv <= aImgUrl[iNb].length - 1) ? iImgSuiv
			: 0)
			: aImgUrl[iNb].length - 1;
	eIcharge.src = sImgPath + aImgUrl[iNb][aImgPos[iNb]];
	eIcharge.onLoad = setTimeout('lance(' + iNb + ',' + iDir + ')', iDelais);
};
function opacite(eOpac, iDir, bCl) {
	iFin = (iDir > 0) ? 100 : 0;
	iOp = parseInt(eOpac.style.opacity * 100);
	if (document.body.filters != undefined) {
		eOpac.style.filter.search(/\d{1,3}/);
		iOp = parseInt(RegExp.lastMatch);
	}
	iOp = (iOp + iDir > 100 || iOp + iDir < 0) ? iFin : iOp + iDir;
	if (iOp != iFin) {
		eOpac.style.opacity = iOp / 100;
		if (document.body.filters != undefined)
			eOpac.style.filter = 'alpha(opacity:' + (iOp) + ')';
		eOagain = eOpac;
		tOpaci = setTimeout('opacite(eOagain,' + iDir + ',' + bCl + ')', 40);
	} else {
		clearTimeout(tOpaci);
		eOpac.style.opacity = iFin / 100;
		if (document.body.filters != undefined)
			eOpac.style.filter = 'alpha(opacity:' + iFin + ')';
		if(iFin == 0 && bCl == true)
			eOpac.style.visibility = 'hidden';
	}
};
function transition(eMoins, ePlus) {
	iCa = parseFloat(eMoins.style.opacity);
	iMo = parseFloat(ePlus.style.opacity);
	if (document.body.filters != undefined) {
		eMoins.style.filter.search(/\d{1,3}/);
		iCa = parseInt(RegExp.lastMatch) / 100;
		ePlus.style.filter.search(/\d{1,3}/);
		iMo = parseInt(RegExp.lastMatch) / 100;
	}
	if (iCa != 0 && iMo != 1) {
		eMoins.style.opacity = iCa - 0.1;
		ePlus.style.opacity = iMo + 0.1;
		if (document.body.filters != undefined) {
			eMoins.style.filter = 'alpha(opacity:' + ((iCa - 0.1) * 100) + ')';
			ePlus.style.filter = 'alpha(opacity:' + ((iMo + 0.1) * 100) + ')';
		}
		eEff = eMoins;
		eAff = ePlus;
		tTrans = setTimeout('transition(eEff,eAff)', 40);
	} else {
		clearTimeout(tTrans);
		eMoins.style.opacity = 0;
		ePlus.style.opacity = 1;
		if (document.body.filters != undefined) {
			eMoins.style.filter = 'alpha(opacity:0)';
			ePlus.style.filter = 'alpha(opacity:100)';
		}
	}
};
var bCis = false;
function menu(iCarte) {
	if (document.getElementById) {
		eBtj = document.getElementById('bjour');
		eBts = document.getElementById('bsoir');
		ePj = document.getElementById('pjour');
		ePs = document.getElementById('psoir');
		eMenuj = document.getElementById('cjour');
		eMenus = document.getElementById('csoir');
		eDej = document.getElementById('pdj');
		eMentel = document.getElementById('menutel');
	}
	if ((bCis == false || ePs.className == 'bjon') && parseInt(iCarte) == 0) {
		eMenus.style.opacity = 1;
		eMenuj.style.opacity = 0;
		eDej.style.opacity = 0;
		eDej.style.visibility = 'visible';
		if (document.body.filters != undefined) {
			eMenus.style.filter = 'alpha(opacity:100)';
			eMenuj.style.filter = 'alpha(opacity:0)';
			eDej.style.filter = 'alpha(opacity:0)';
		}
		if (bCis == false) {
			eMenuj.style.visibility = 'visible';
			bCis = true;
		}
		ePj.className = 'bjon';
		ePs.className = 'bjoff';
		opacite(eDej, 10, false);
		transition(eMenus, eMenuj);
	} else if (ePs.className == 'bjoff' && parseInt(iCarte) == 1) {
		ePj.className = 'bjoff';
		ePs.className = 'bjon';
		opacite(eDej, -10, true);
		transition(eMenuj, eMenus);
	}
};
