/* Dernière modif : 02/02/2012 */
//var isIE = navigator.userAgent.toLowerCase().indexOf('msie')!=-1;
var M2coef = 0.05 ; // avancement de l'opacité;
var M2temps = 50 ; // temps entre chaque changement d'opacité;
var M2temps_pause = 3500 ; // temps d'attente entre 2 changements d'images
var M2nombre_image = 56 ; // nombre d'images a faire bouger
var M2prefix_image = 'images/fondu2/photo'; // chemin + prefix du nom des images
var M2suffix_image = '.jpg' ; // suffix + '.extension' du nom des images

// pas touche
var M2indice = 2; // les 2 premiere image sont deja charger dans le HTML, on commence a la 3eme
//var isIE = navigator.userAgent.toLowerCase().indexOf('msie')!=-1 ;

var isIE = (navigator.userAgent.toLowerCase().indexOf('msie')!=-1) || (navigator.userAgent.toLowerCase().indexOf('chrome/')!=-1 )  ;

var isMozilla5 = navigator.userAgent.toLowerCase().indexOf('mozilla/5')!=-1 ;  // modif pour Mozilla 5.0
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome/')!=-1 ; // modif pour chrome
var M2img1 = null;
var M2img2 = null ;
var M2sens = 1;
var M2tabImg; // tab contenant les images

function test()
{
alert ('test : '+navigator.userAgent);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function nouvelle_citation()
{
var ladate=new Date()
var s=ladate.getSeconds();
	//test();
	//alert (s);
	nbcit = 47;	// nombre de citations
	numalea=Math.random();
	//alert(numalea);
	ss = numalea * nbcit;
	sec = 1 + Math.floor(ss);
	//alert (sec);
	if (sec<10) {sec = "0" + sec}	;
	//citation ='cit' + sec;
	for (i=1; i<=nbcit; i++) {
		sc=i;
		if (sc<10) {sc = "0" + sc}	;
		c='cit' + sc;
		if (sec == sc){
			montre(c);
		} else {
			cache(c);
		}
	}
	
}
function montre(citation)
{
	if (isIE)
	{
		document.getElementById(citation).style.display = "block";
	}
	else
	{
		document.getElementById(citation).style.display = "table-row";
	}	
}
function cache(citation)
{
	if (isIE)
	{
		document.getElementById(citation).style.display = "none";
	}
	else
	{
		document.getElementById(citation).style.display = "none";
	}	
}

function montre_ssmenu(menu)
{
	nbssmenu=15;
/*	if (dermenu == menu) 
	{
		cache(dermenu);
		dermenu="";
	}
	else
	{*/
		for (i=1; i<=nbssmenu; i++) {
			ssmenu=i;
			if (ssmenu<10) {ssmenu = "0" + i}	;
			idssmenu='ssmenu' + ssmenu;
			//alert(idssmenu);
			cache(idssmenu);
		}
		montre (menu);
		//dermenu = menu;
	//}
}

function InitPage(menu)	// initialise une page avec la langue en cours
{
//{alert (menu);
//M3init();
nouvelle_citation(); //*****************************************************
if (menu>" ")
{
	montre_ssmenu(menu);
}
M2init();
}
function InitPageC(menu)	// initialise une page avec la langue en cours
{
nouvelle_citation(); //*****************************************************
//alert (menu);
//M3init;
if (menu>" ")
{
//alert ('1');
	montre_ssmenu(menu);
}

new zi (	{	'image':document.getElementById("alpha"),
				'loupe':200,
				'zoom':4,
				'iddiv':'tmpdiv',
				'idimage':'tmpimage'
			}	
		);

}
/*						+-----------------------------------------------------+
							¦identifiant¦	explications				¦ par défaut	¦
		+--------------+-----------+--------------------------+--------------¦
		¦ new zi (	{ 	'image' 		: image à gérer 				¦					¦
		¦					'zoom'  		: valeur du zoom initial 	¦ 3				¦
		¦					'loupe' 		: taille de la loupe			¦ 80				¦
		¦					'iddiv' 		: id du div interne			¦ 					¦
		¦					'idimage' 	: id image pour le zoom		¦ 					¦
		¦			) 	); +-----------------------------------------------------+
		+--------------+
							~\\|//
							 (@ ~)
		+--------oOOO----(_)----OOOo--------+
		¦ M'écrire : http://bul.o-n.fr/?bul ¦  /¯/ / / / 
		¦ Mon Site : http://bul.fr.nf       ¦ /¯/ / / / 
		¦       .oooO           Oooo.       ¦ ¯¯  ¯¯  ¯¯
		+-------(   )-----------(   )-------+
					\ (             ) /
					 \_)           (_/		  */

//------------------------------------------
function zi( prm )	//-- Zoom sur Images --
//------------------------------------------
{	this.init=prm['image'];
	this.zoom=prm['zoom']||3;
	this.carre=prm['loupe']||80;
	this.div=document.createElement("div");
		if ( prm['iddiv'] ) this.div.id=prm['iddiv'];
		this.div.style.position="absolute";
		this.div.style.overflow="hidden";
		this.div.style.top=this.init.offsetTop+"px";
		this.div.style.left=this.init.offsetLeft+"px";
		this.div.style.display="none";
		this.div.style.height=(this.carre*2)+"px";
		this.div.style.width=(this.carre*3)+"px";
		//---------------------------------------------------------
		this.div.oncontextmenu=function(event)	//-- menu contextuel --
		//---------------------------------------------------------
		{	var menu=document.createElement("div");
				var b1=document.createElement("button");
					b1.innerHTML="&nbsp;+&nbsp;";
					//----------------------------------------------------------------
					b1.onclick=function(event)	//-- augmenter la taille de la loupe --
					//----------------------------------------------------------------
					{	if ( 	( fnct.carre*2 )<fnct.init.offsetHeight &&
								( fnct.carre*2 )<fnct.init.offsetWidth )
						{	fnct.carre+=5;
							fnct.div.style.height=(fnct.carre*2)+"px";
							fnct.div.style.width=(fnct.carre*2)+"px";
						}
					}
					menu.appendChild(b1);
				b1=document.createElement("button");
					b1.innerHTML="&nbsp;-&nbsp;";
					//--------------------------------------------------------------
					b1.onclick=function(event)	//-- réduire la taille de la loupe --
					//--------------------------------------------------------------
					{	if ( 	((fnct.carre*2)-5)>this.parentNode.offsetWidth &&
								((fnct.carre*2)-5)>this.parentNode.offsetHeight )
						{	fnct.carre-=5;
							fnct.div.style.height=(fnct.carre*2)+"px";
							fnct.div.style.width=(fnct.carre*2)+"px";
						}
					}
					menu.appendChild(b1);
				l1=document.createElement("pre");
					l1.style.display="inline";
					l1.innerHTML="&#9;";
					menu.appendChild(l1);
				var l1=document.createElement("span");
					l1.innerHTML="Loupe&nbsp;";
					menu.appendChild(l1);
				l1=document.createElement("br");
					menu.appendChild(l1);
				b1=document.createElement("button");
					b1.innerHTML="&nbsp;+&nbsp;";
					//--------------------------------------------------
					b1.onclick=function(event)	//-- augmenter le zoom --
					//--------------------------------------------------
					{	//	if mais quoi ?
						{	fnct.zoom+=1;
							fnct.image.height=(fnct.zoom*fnct.init.offsetHeight);
							fnct.image.width=(fnct.zoom*fnct.init.offsetWidth);
						}
					}
					menu.appendChild(b1);
				b1=document.createElement("button");
					b1.innerHTML="&nbsp;-&nbsp;";
					//----------------------------------------------
					b1.onclick=function()	//-- diminuer le zoom --
					//----------------------------------------------
					{	if ( fnct.zoom>1 )
						{	fnct.zoom-=1;
							fnct.image.height=(fnct.zoom*fnct.init.offsetHeight);
							fnct.image.width=(fnct.zoom*fnct.init.offsetWidth);
						}
					}
					menu.appendChild(b1);
				l1=document.createElement("pre");
					l1.style.display="inline";
					l1.innerHTML="&#9;";
					menu.appendChild(l1);
				l1=document.createElement("span");
					l1.innerHTML="Zoom&nbsp;";
					menu.appendChild(l1);
				l1=document.createElement("br");
					menu.appendChild(l1);
				l1=document.createElement("pre");
					l1.style.display="inline";
					l1.innerHTML="&#9;";
					menu.appendChild(l1);
				b1=document.createElement("button");
					b1.innerHTML="Quitter";
					//-------------------------------------------------------
					b1.onclick=function()	//-- fermer le menu contextuel --
					//-------------------------------------------------------
					{	this.parentNode.parentNode.removeChild(this.parentNode);	}
					menu.appendChild(b1);
			menu.style.position="absolute";
			menu.style.top=this.offsetTop+"px";
			menu.style.left=this.offsetLeft+"px";
			menu.style.backgroundColor="#FFFFFF"
			menu.style.border="1px solid #FF0000";
			document.body.appendChild(menu);
			return false;
		}
		//--------------------------------------------------------------
		this.div.onmousemove=function(event)	//-- déplacement de la loupe --
		//--------------------------------------------------------------
		{	fnct.deplace(event)	};
		this.image=document.createElement("img");
			if ( prm['idimage'] )this.image.id=prm['idimage'];
			this.image.style.position="absolute";
			/*@cc_on	this.image.style.cursor="url(Img/loupe.ico)";	@*/
			this.image.src=this.init.src;
			this.image.height=(this.zoom*this.init.offsetHeight);
			this.image.width=(this.zoom*this.init.offsetWidth);
			this.div.appendChild(this.image);
	document.body.appendChild(this.div);
	var fnct=this;
	//---------------------------------------------------------------
	this.init.onmouseover=function(event)	//-- survol d'une image --
	//---------------------------------------------------------------
	{	fnct.div.style.display="inline";
		fnct.deplace(event);
	};
	//-----------------------------------------------
	this.deplace=function(event)	//-- déplacement --
	//-----------------------------------------------
	{	var x,y;
		if ( window.event )
				{	x=window.event.x+document.body.scrollLeft;
					y=window.event.y+document.body.scrollTop;
				}
		else	{	x=event.pageX;
					y=event.pageY
				}
		if (	(x+fnct.carre)<fnct.init.offsetLeft ||
				(x-fnct.carre)>(fnct.init.offsetLeft+fnct.init.offsetWidth) ||
				(y+fnct.carre)<fnct.init.offsetTop ||
				(y-fnct.carre)>(fnct.init.offsetTop+fnct.init.offsetHeight)	 )
				{	fnct.div.style.display="none";	}
		else	{	fnct.image.style.top=((-y+fnct.init.offsetTop)*fnct.zoom)+"px";
					fnct.image.style.left=((-x+fnct.init.offsetLeft)*fnct.zoom)+"px";
					fnct.div.style.top=(y-fnct.carre)+"px";
					fnct.div.style.left=(x-fnct.carre)+"px";
				}
	};
}

function M2prechargerImg(){
	M2tabImg = new Array(M2nombre_image);
	for (i=0; i<=M2nombre_image -1; i++){
	M2tabImg[i]=new Image();
	M2tabImg[i].src = M2prefix_image+(i+1)+M2suffix_image;
	}
}

function M2init()
{
	M2indice = Math.floor(Math.random()*M2nombre_image) +1;
	//alert(M2indice);
	//alert(navigator.userAgent);
	//if (isie) {alert ('IE')}
	//if (isMozilla5) {alert ('Mozilla 5')}
	
	M2img1 = document.getElementById("M2defilement1") ;
	M2img2 = document.getElementById("M2defilement2") ;
	M2prechargerImg();
	M2change_opacity();
}

function M2change_opacity()
{
	//alert('entrée M2change');
    var M2opacity1 = 0 ;
    var M2opacity2 = 0 ;
    if (isIE) // for IE
    { 
	//alert ('IE');
	M2opacity1 = parseFloat(M2img1.filters.alpha.opacity);
    M2opacity2 = parseFloat(M2img2.filters.alpha.opacity);
    }
     else // for mozilla
		{ if (isMozilla5) //  ===========================  Mozilla 5
			{
			//alert ('Mozilla 5');
			M2opacity1 = parseFloat(M2img1.style.opacity);
			M2opacity2 = parseFloat(M2img2.style.opacity);
			}
		else // for mozilla 4 et -
			{ 
			//alert ('Mozilla 4');
			M2opacity1 = parseFloat(M2img1.style.MozOpacity);
			M2opacity2 = parseFloat(M2img2.style.MozOpacity);
			}
		}
    if (M2sens)
    { if (isIE) // for IE
    { 	M2img1.filters.alpha.opacity = M2opacity1 + M2coef *100;
		M2img2.filters.alpha.opacity = M2opacity2 - M2coef *100;
    }
    else // for Mozilla
		{ if (isMozilla5) //  ===========================  Mozilla 5
			{ M2img1.style.opacity = M2opacity1 + M2coef;
			  M2img2.style.opacity = M2opacity2 - M2coef;
			}
	    else // for Mozilla 4 et -
			{ M2img1.style.MozOpacity = M2opacity1 + M2coef;
			  M2img2.style.MozOpacity = M2opacity2 - M2coef;
			}
		}
    }
    else
    {
    if (isIE) // for IE
    { 	M2img1.filters.alpha.opacity = M2opacity1 - M2coef* 100;
		M2img2.filters.alpha.opacity = M2opacity2 + M2coef *100;
    }
    else // for Mozilla
		{ if (isMozilla5) //  ===========================  Mozilla 5
			{ M2img1.style.opacity = M2opacity1 - M2coef;
			  M2img2.style.opacity = M2opacity2 + M2coef;
			}
		else // for Mozilla 4 et -
			{ M2img1.style.MozOpacity = M2opacity1 - M2coef;
			  M2img2.style.MozOpacity = M2opacity2 + M2coef;
			}
		}
	}
    
    if (isIE) // for IE
    { 	M2opacity1 = parseFloat(M2img1.filters.alpha.opacity);
		M2opacity2 = parseFloat(M2img2.filters.alpha.opacity);
    }
     else // for mozilla
		{ if (isMozilla5) //  ===========================  Mozilla 5
			{ 	M2opacity1 = parseFloat(M2img1.style.opacity);
				M2opacity2 = parseFloat(M2img2.style.opacity);
			}
		else // for mozilla
			{ 	M2opacity1 = parseFloat(img1.style.MozOpacity);
				M2opacity2 = parseFloat(img2.style.MozOpacity);
			}
		}
    // on fait varié le sens d'opacité du bazar
    if (M2opacity2 <= 0)
    { 	M2img2.src=M2tabImg[M2indice++].src;
		M2sens = 0;
		if (M2indice == (M2tabImg.length)) M2indice=0;
		window.setTimeout("M2change_opacity()",M2temps_pause) ; // attente
		return 0;
    }
    else if (M2opacity1 <= 0)
    { 	M2img1.src=M2tabImg[M2indice++].src;
		M2sens = 1;
		if (M2indice == (M2tabImg.length)) M2indice=0;
		window.setTimeout("M2change_opacity()",M2temps_pause) ; // attente
		return 0;
    }
    window.setTimeout("M2change_opacity()",M2temps) ; // recursion toutes les x millisec
}

