/* pour la page : page_index */
function traiter_erreur(message, adresse, ligne)
{
	alert("Erreur javascript détectée à la ligne " + ligne + "\n" + adresse + "\n" + message);
	return true;
}

window.onerror = traiter_erreur;
function classe_souris()
{
	this.x=0;
	this.y=0;
	this.liste_fonctions = new Array();
	this.ajoute_fonction = ajoute_fonction_souris;
	this.move=getMousePos;
	document.onmousemove=this.move;
	document.onmousewheel=this.move;
	window.onscroll=this.move;
	document.body.onscroll=this.move;
}

function getMousePos(e)
{
	if (document.all)
	{
		souris.x=event.x+document.body.scrollLeft;
		souris.y=event.y+document.body.scrollTop;
	}
	else
	{
		souris.x=e.pageX;
		souris.y=e.pageY;
	}
	for(var n=0;n<souris.liste_fonctions.length;n++)
	{
		souris.liste_fonctions[n]();
	}
}

function ajoute_fonction_souris(fonction, objet)
{
	souris.liste_fonctions.push(fonction);
}

var souris = new classe_souris();
function affiche(id, style)
{
	if(style==undefined) style="block";
	var element=document.getElementById(id);
	if(element!=null) element.style.display=style;
}

function cache(id)
{
	affiche(id, "none");
}
// fonction retournant l'objet XMLHttpRequest adéquat en fonction du navigateur
function getXMLHttpRequest()
{
	var req = false;
	try
	{
		req=new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			req=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				req = false;
			}
		}
	}
	return req;
}
// fonction qui lit le contenu d'un fichier distant et le renvoi
function getFileContent(url)
{
   var Xhr=GetXmlHttpRequest();
   Xhr.open("HEAD", url, false);
   Xhr.send(null);
   return Xhr.responseText;
}
// fonction qui remplit l'element identifié par l'id avec le contenu html HTML
function setInnerHTML(id, HTML)
{
	var divContent=document.getElementById(id);
	divContent.innerHTML=HTML; 
	var AllScripts=divContent.getElementsByTagName("script");
	for (var i=0; i<AllScripts.length; i++)
	{
		var s=AllScripts[i];
		if (s.src && s.src!="")
		{
			setTimeout("eval(getFileContent(" + s.src + "))", 0);
		}
		else
		{
			eval(s.innerHTML);
		}
	}
}
// Fonction qui récupère le contenu html HTML actuel de l'element identifié par l'id
function getInnerHTML(id)
{
	return(document.getElementById(id).innerHTML); 
}
// Fonction qui ajoute le contenu html HTML à l'element identifié par l'id
function addInnerHTML(id, HTML)
{
	setInnerHTML(id, getInnerHTML(id) + HTML);
}
// fonction qui remplit l'element identifié par l'id avec le contenu de la page html à l'adresse lien
function ajax_read(id, lien, message, image, post_vars, ne_pas_effacer, ne_pas_attendre)
{
	if(ne_pas_attendre == undefined) ne_pas_attendre=true;
	if(message == undefined) message = "Chargement en cours";
	if(image == undefined) image = '<img src="http://www.lovamine.fr/images/chargement.gif" width="32" height="32" alt="' + message + '" title="' + message + '"> ';
	if(ne_pas_effacer == undefined) setInnerHTML(id, image + message);
	var xhr = getXMLHttpRequest();
	if(post_vars == undefined)
	{
		xhr.open("GET", lien + "&force_type_page=ajax", ne_pas_attendre);
	}
	else
	{
		xhr.open("POST", lien + "&force_type_page=ajax", ne_pas_attendre);
	}
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			setInnerHTML(id, xhr.responseText);
		}
	}
	if(post_vars == undefined)
	{
		xhr.send(null);
	}
	else
	{
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var data = "";
		var n;
		for(n=0;n<post_vars.length;n++)
		{
			if(n>0) data = data + "&";
			data = data + post_vars[n]["nom"] + "=" + post_vars[n]["valeur"];
		}
		xhr.send(data);
	}
	if(ne_pas_attendre==false)
	{
		setInnerHTML(id, xhr.responseText);
	}
}

function ajoute_variable_post(post, nom, valeur)
{
	var n=post.length;
	post[n] = new Array();
	post[n]["nom"] = nom;
	post[n]["valeur"] = valeur;
}
function arrondi(valeur, precision)
{
	var m=Math.pow(10, precision);
	m=Math.round(valeur*m)/m;
	if(Math.round(m)-m==0) 
	{
		var texte=m + '.0000000000';
	}
	else
	{
		var texte=m + '00000000';
	}
	return texte.substring(0, texte.indexOf('.') + 1 + precision);
}
var dtable = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','.','_');

function inchar(d)
{
	r = -1;
	for (var i = 0; i < dtable.length; i++)
	{
		if (d == dtable[i])
		{
			r = i;
			break;
		}
	}	
	return r;
}
    
function Trouve(n)
{
	while (n > 256) { n -= 256; }
	return n
}

function base64_encode(n)
{
	var o1 = o2 = o3 =o4 = 0;
	var text = "";
	j = 0;
	for (var i = 0; i < n.length; i += 3)
	{
		t = Math.min(3, n.length - i);
		if (t == 1)
		{
			x = n.charCodeAt(i);
			text += dtable[(x >> 2)];
			text += dtable[((x & 0X00000003) << 4)];
			text += '-';
			text += '-';
		} else if (t == 2) {
			x = n.charCodeAt(i);
			y = n.charCodeAt(i+1);
			text += dtable[(x >> 2)];
			text += dtable[((x & 0X00000003) << 4) | (y >> 4)];
			text += dtable[((y & 0X0000000f) << 2)];
			text += '-';
		} else {
			x = n.charCodeAt(i);
			y = n.charCodeAt(i+1);
			z = n.charCodeAt(i+2);
			text += dtable[x >> 2];
			text += dtable[((x & 0x00000003) << 4) | (y >> 4)];
			text += dtable[((y & 0X0000000f) << 2) | (z >> 6)];
			text += dtable[z & 0X0000003f];
		}
	}
	return text;
}

function base64_decode(n) 
{
	var p;
	var o1 = o2 = o3 = 0;
	var text = "";
	if ((n.length % 4) != 0) { return null; }
	j = 0;
	for (var i = 0; i < n.length; i += 4) 
	{
		x1 = inchar(n.charAt(i));
		x2 = inchar(n.charAt(i+1));
		x3 = inchar(n.charAt(i+2));
		x4 = inchar(n.charAt(i+3));
		ol = 4;
		if (x4 == -1) { ol--; x4 = 0;}
		if (x3 == -1) { ol--; x3 = 0;}
		if (ol == 4) 
		{
			o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=Trouve(o1) : p=o1) ; text += String.fromCharCode(p);
			o2 = ((x2 << 4) | (x3 >> 2)); ((o2 > 256) ? p=Trouve(o2) : p=o2) ; text += String.fromCharCode(p);
			o3 = ((x3 << 6) | x4); ((o3 > 256) ? p=Trouve(o3) : p=o3) ; text += String.fromCharCode(p);
		} else if (ol == 3) {
			o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=Trouve(o1) : p=o1) ; text += String.fromCharCode(p);
			o2 = ((x2 << 4) | (x3 >> 2)); ((o2 > 256) ? p=Trouve(o2) : p=o2) ; text += String.fromCharCode(p);
		} else if (ol == 2) {
			o1 = ((x1 << 2) | (x2 >> 4)); ((o1 > 256) ? p=Trouve(o1) : p=o1) ; text += String.fromCharCode(p);
		}
	}
	return text;
} 
function bookmark_site(titre, url)
{
	if (document.all)
		window.external.AddFavorite(url, titre);
	else if (window.sidebar)
	{
		alert("Décochez la case 'Charger ce marque-page dans un panneau latéral.' sur la fenetre suivante.");
		window.sidebar.addPanel(titre, url, "")
	}
	else
		alert("Votre navigateur internet ne supporte pas cette fonction.");
}
function infobulle()
{
	this.affiche=affiche_infobulle;
	this.deplace=deplace_infobulle;
	this.cache=cache_infobulle;
	document.write("<div id='infobulle' class='texte'></div>");
	this.est_affiche=false;
	this.autorise_deplace=true;
	souris.ajoute_fonction(deplace_infobulle);
}

function affiche_infobulle(texte, titre, autorise)
{
	if(autorise==undefined) autorise = true;
	this.autorise_deplace=autorise;
	if(!this.est_affiche)
	{
		if (titre==undefined)
		{	
			setInnerHTML("infobulle", texte);
		}
		else
		{
			setInnerHTML("infobulle", "<table cellpadding='0' cellspacing='0'><tr><td class='titre'>" + titre + "</td></tr><tr><td class='texte'>" + texte + "</td></tr></table>");
		}
		affiche("infobulle");
		definit_z_index("infobulle", 1000);
		this.est_affiche=true;
		this.deplace(true);
	}
}

function deplace_infobulle(force)
{	
	if (force == undefined) force=false;
	if ((bulle_information.est_affiche) && ((bulle_information.autorise_deplace)||(force)))
	if (document.getElementById)
	{
		var X=souris.x;
		if (X<0) X=0;
		var Y=souris.y + 20;
		var Dimension_Bulle = dimension_element("infobulle");
		var depasse_droite = false;
		var depasse_bas = false;
		var position_zone_vue = position_element("zone_vue");
		var dimension_zone_vue = dimension_element("zone_vue");
		if((X + Dimension_Bulle.largeur) > (position_zone_vue.x + dimension_zone_vue.largeur)) depasse_droite = true;
		if((Y + Dimension_Bulle.hauteur) > (position_zone_vue.y + dimension_zone_vue.hauteur)) depasse_bas = true;
		if (depasse_droite) X -= Dimension_Bulle.largeur;
		if (depasse_bas) Y -= (Dimension_Bulle.hauteur + 25);
		if(!bulle_information.autorise_deplace)
		{
			X = souris.x - 10;
			Y = souris.y - 10;
		}
		var div=document.getElementById("infobulle");
		div.style.top  = Y + "px";
		div.style.left = X + "px";
	}
}

function cache_infobulle()
{
	cache("infobulle");
	this.est_affiche=false;
}

var bulle_information=new infobulle();
function creerCalendrier()
{
	this.date=new Date();
	this.mois=Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
	this.champ=null;
	this.timer=null;
	this.formatDate=formatDateCalendrier;
	this.getDate=getDateCalendrier;
	this.affiche=afficheCalendrier;
	this.cache=cacheCalendrier;
	this.getContenu=getContenuCalendrier;
	this.selectDate=selectDateCalendrier;
	this.initTimer=initTimerCalendrier;
	this.stopTimer=stopTimerCalendrier;
	document.write("<div id='divCalendrier' style='display:none;' onmouseover='calendrier.stopTimer();' onmousout='calendrier.initTimer();'></div>");
}

function formatDateCalendrier(dt)
{
	var Y=dt.getFullYear();
	var D=dt.getDate();
	if (D<10) { D="0"+D; }
	var M=dt.getMonth()+1;
	if (M<10) { M="0"+M; }
	return D+"/"+M+"/"+Y;
}

function getDateCalendrier(txtDt)
{
	var dt=new Date();
	var regControleDate=new RegExp("^[0-9]{2}(/){1}[0-9]{2}(/){1}[0-9]{4}$", "g");
	if (txtDt.match(regControleDate))
	{
		dt.setDate(txtDt.substring(0, 2));
		dt.setMonth(txtDt.substring(3, 5)-1);
		dt.setFullYear(txtDt.substring(6, 10));
	}
	return dt;
}

function afficheCalendrier(id, x, y)
{
	var champ=document.getElementById(id);
	if(champ!=null)
	{
		this.stopTimer();
		this.date=this.getDate(champ.value);
		this.champ=champ;
		var div=document.getElementById("divCalendrier");
		var PE=position_element(id);
		var nav = new navigateur();
		if(nav.safari())
		{
			if(document.all)
			{
				left = document.documentElement.scrollLeft;
				top = document.documentElement.scrollTop;
			}
			else
			{
				left = window.pageXOffset;
				top = window.pageYOffset;
			}
			PE.x = PE.x + left;
			PE.y = PE.y + top;
		}
		if(x == undefined)
		{
			div.style.left=PE.x+"px";
		}
		else
		{
			div.style.left=x+"px";
		}
		if(y == undefined)
		{
			div.style.top=(PE.y+20) + "px";
		}
		else
		{
			div.style.top=y+"px";
		}
		this.getContenu();
		affiche("divCalendrier");
		this.initTimer();
	}
}

function getContenuCalendrier()
{
	var mois=this.mois[this.date.getMonth()];
	var annee=this.date.getFullYear();
	var txtContenu  = "<table cellspacing='1'>";
	// Première Ligne
	txtContenu += "<tr>";
	txtContenu += "<td class='titre_bouton' onclick='calendrier.date.setMonth(" + (this.date.getMonth()-12) + ");calendrier.getContenu()' title='Année Précédente'><<</td>";
	txtContenu += "<td class='titre_bouton' onclick='calendrier.date.setMonth(" + (this.date.getMonth()-1) + ");calendrier.getContenu()' title='Mois Précédent'>&nbsp;<&nbsp;</td>";
	txtContenu += "<td colspan='5' class='titre'>" + mois + " " + annee + "</td>";
	txtContenu += "<td class='titre_bouton' onclick='calendrier.date.setMonth(" + (this.date.getMonth()+1) + ");calendrier.getContenu()' title='Mois Suivant'>&nbsp;>&nbsp;</td>";
	txtContenu += "<td class='titre_bouton' onclick='calendrier.date.setMonth(" + (this.date.getMonth()+12) + ");calendrier.getContenu()' title='Année Suivante'>>></td>";
	txtContenu += "</tr>";
	// Seconde Ligne
	txtContenu += "<tr>";
	txtContenu += "<td class='jour'>&nbsp;</td>";
	txtContenu += "<td class='jour' title='Lundi'>L</td>";
	txtContenu += "<td class='jour' title='Mardi'>M</td>";
	txtContenu += "<td class='jour' title='Mercredi'>M</td>";
	txtContenu += "<td class='jour' title='Jeudi'>J</td>";
	txtContenu += "<td class='jour' title='Vendredi'>V</td>";
	txtContenu += "<td class='jour' title='Samedi'>S</td>";
	txtContenu += "<td class='jour' title='Dimanche'>D</td>";
	txtContenu += "<td class='jour'>&nbsp;</td>";
	txtContenu += "</tr>";
	txtContenu += "<tr><td>&nbsp;</td>";
	// Recherche de la date
	var dtAujourdhui=new Date();
	var dtJour1=new Date();
	dtJour1.setDate(1);
	dtJour1.setMonth(this.date.getMonth());
	dtJour1.setFullYear(this.date.getFullYear());
	var nbJourDecalage=dtJour1.getDay();
	if (nbJourDecalage==0) // Dimanche
	{
		nbJourDecalage=7;
	}
	// Boucle sur les cases du Calendrier
	var nbCase=0;
	var dtBoucle=dtJour1;
	dtBoucle.setDate(1-nbJourDecalage);
	for (var i=0; i<42; i++)
	{
		dtBoucle.setDate(dtBoucle.getDate()+1);
		var txtDt=this.formatDate(dtBoucle);
		var classe="moisActif";
		if (dtBoucle.getMonth()!=this.date.getMonth())
		{
			classe="moisInactif";
		}
		if (txtDt==this.champ.value)
		{
			classe="jourSelection";
		}
		if ((this.champ.value=="")&&(txtDt==this.formatDate(dtAujourdhui)))
		{
			classe="jourSelection";
		}
		txtContenu += "<td class='" + classe + "' onclick='calendrier.selectDate(\"" + txtDt + "\");' title='" + txtDt + "'>" + dtBoucle.getDate() + "</td>";
		nbCase++;
		if (nbCase==7)
		{
			if(i==41)
			{
				txtContenu += "<td class='fermer' onclick='calendrier.cache();' title='Fermer le Calendrier'>x</td></tr>";
			}
			else
			{
				txtContenu += "<td>&nbsp;</td></tr>";
			}
			if(i<41)
			{
				txtContenu += "<tr><td>&nbsp;</td>";
			}
			nbCase=0;
		}
	}
	txtContenu += "</table>";
	setInnerHTML("divCalendrier", txtContenu);
}

function selectDateCalendrier(txtDate)
{
	this.champ.value=txtDate;
	this.cache();
}

function initTimerCalendrier()
{
	if (this.timer==null)
	{
		this.timer=setTimeout("cacheCalendrier();", 2000);
	}
}

function stopTimerCalendrier()
{
	if (this.timer!=null)
	{
		clearTimeout(this.timer);
		this.timer=null;
	}
}

function cacheCalendrier()
{
	cache("divCalendrier");
	calendrier.stopTimer();
}

var calendrier=new creerCalendrier();
function change_classe(id, classe)
{
	var a = id.split(',');
	for(var i=0;i<a.length;i++)
	{
		var objet = document.getElementById(a[i]);
		if(objet != null) objet.className = classe;
	}
}
function change_couleur_fond(id, couleur)
{
	if(couleur==undefined) couleur = 'ffffff';
	var a = id.split(',');
	for(var i=0;i<a.length;i++)
	{
		var objet = document.getElementById(a[i]);
		if(objet != null) objet.style.backgroundColor = "#" + couleur;
	}
}
function charge_page(url)
{
	window.location = "http://www.lovamine.fr/" + url;
}
function creerChoixCouleur()
{
	this.total=1657;
	this.aR=new Array(this.total);
	this.aG=new Array(this.total);
	this.aB=new Array(this.total);
	for (var i=0;i<256;i++)
	{
		this.aR[i+510]=this.aR[i+765]=this.aG[i+1020]=this.aG[i+5*255]=this.aB[i]=this.aB[i+255]=0;
		this.aR[510-i]=this.aR[i+1020]=this.aG[i]=this.aG[1020-i]=this.aB[i+510]=this.aB[1530-i]=i;
		this.aR[i]=this.aR[1530-i]=this.aG[i+255]=this.aG[i+510]=this.aB[i+765]=this.aB[i+1020]=255;
		if(i<255)
		{
			this.aR[i/2+1530]=127;
			this.aG[i/2+1530]=127;
			this.aB[i/2+1530]=127;
		}
	}
	var hexbase=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
	var i=0;
	this.jl=new Array();
	for(x=0;x<16;x++) for(y=0;y<16;y++) this.jl[i++]=hexbase[x]+hexbase[y];		
	this.champ=null;
	this.timer=null;
	this.affiche=afficheChoixCouleur;
	this.cache=cacheChoixCouleur;
	this.getContenu=getContenuChoixCouleur;
	this.selectCouleur=selectCouleur;
	this.initTimer=initTimerChoixCouleur;
	this.stopTimer=stopTimerChoixCouleur;
	document.write("<div id='divChoixCouleur' style='display:none;' onmouseover='choix_couleur.stopTimer();' onmousout='choix_couleur.initTimer();'></div>");
	this.getContenu();
}

function afficheChoixCouleur(id, x, y)
{
	var champ=document.getElementById(id);
	if(champ!=null)
	{
		this.stopTimer();
		this.couleur=champ.value;
		this.champ=champ;
		var div=document.getElementById("divChoixCouleur");
		var PE=position_element(id);
		if(x == undefined)
		{
			div.style.left=PE.x+"px";
		}
		else
		{
			div.style.left=x+"px";
		}
		if(y == undefined)
		{
			div.style.top=(PE.y+20) + "px";
		}
		else
		{
			div.style.top=y+"px";
		}
		affiche("divChoixCouleur");
		this.initTimer();
	}
}

function getContenuChoixCouleur()
{
	var X=0;
	var Y=0;
	var R=0;
	var G=0;
	var B=0;
	var txtContenu  = "<table cellspacing='0'>";
	// Boucle sur les cases du ChoixCouleur
	var H=W=63;
	for (Y=0;Y<=H;Y++)
	{
		txtContenu += "<tr height='2'>";
		j=Math.round(Y*(510/(H+1))-255)
		for (X=0;X<=W;X++)
		{
			i=Math.round(X*(this.total/W))
			R=this.aR[i]-j; if(R<0)R=0; if(R>255||isNaN(R)) R=255;
			G=this.aG[i]-j; if(G<0)G=0; if(G>255||isNaN(G)) G=255;
			B=this.aB[i]-j; if(B<0)B=0; if(B>255||isNaN(B)) B=255;
			txtContenu += "<td class='normal' width='2' bgcolor='#" + this.jl[R] + this.jl[G] + this.jl[B] + "' onclick='choix_couleur.selectCouleur(\"" + this.jl[R] + this.jl[G] + this.jl[B] + "\");' title='#" + this.jl[R] + this.jl[G] + this.jl[B] + "'></td>";
		}
		txtContenu += "</tr>";
	}
	txtContenu += "<tr>";
	for (X=0;X<=W;X++)
	{
		txtContenu += "<td></td>";
	}
	txtContenu += "<td class='fermer' onclick='choix_couleur.cache();' title='Fermer le Choix de Couleur'>x</td></tr>";
	txtContenu += "</tr>";
	txtContenu += "</table>";
	setInnerHTML("divChoixCouleur", txtContenu);
}

function selectCouleur(couleur)
{
	this.champ.value=couleur;
	this.champ.style.backgroundColor ="#" + couleur;
	this.cache();
}

function initTimerChoixCouleur()
{
	if (this.timer==null)
	{
		this.timer=setTimeout("cacheChoixCouleur();", 2000);
	}
}

function stopTimerChoixCouleur()
{
	if (this.timer!=null)
	{
		clearTimeout(this.timer);
		this.timer=null;
	}
}

function cacheChoixCouleur()
{
	cache("divChoixCouleur");
	choix_couleur.stopTimer();
}

var choix_couleur=new creerChoixCouleur();
// 100 = opaque
// 0   = transparent
function definit_opacite(elementId, opacite)
{
	if(opacite<0) opacite=0;
	if(opacite>100) opacite=100;
	var element = document.getElementById(elementId);
	if(element!=null)
	{
		element.style.opacity = opacite / 100;
		/** Test pour notre cher IE */
		if (document.body.filters != undefined)
		{
			element.style.filter = 'alpha(opacity:' + opacite + ')';
		}
	}
}
// 0   = opaque
// 100 = transparent
function definit_transparence(elementId, transparence)
{
	definit_opacite(elementId, 100 - transparence);
}
function definit_z_index(id, z_index)
{
	var o=document.getElementById(id);
	if(o != null) o.style.zIndex = z_index;
}
function dimension_element(id)
{
	var x;
	var y;
	var objet = document.getElementById(id);
	if(objet!=null)
	{
		x=objet.clientWidth;
		y=objet.clientHeight;
	}
	return {largeur:x,hauteur:y};
}
function dimension_fenetre()
{
	var x;
	var y;
	if(navigator.appName.substring(0,3) == "Net")
	{
		x=window.innerWidth;
		y=window.innerHeight;
	}
	else
	{
		var div=document.createElement('div');
		div.style.position="absolute";
		div.style.top="0px";
		div.style.left="0px";
		div.style.width="100%";
		div.style.height="100%";
		div.innerHTML="&nbsp;";
		document.body.appendChild(div);
		x=div.clientWidth;
		y=div.clientHeight;
		document.body.removeChild(div);		
	}
	return {largeur:x,hauteur:y};
}
function donne_le_focus(id)
{
	var element = document.getElementById(id);
	if (element.style.display!="none") element.focus();
}
/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
*    The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/
function dump(arr, level)
{
	var dumped_text = "";
	if(!level) level = 0;
	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";
	if(typeof(arr) == 'object')
	{ //Array/Hashes/Objects
		for(var item in arr)
		{
			var value = arr[item];
			if(typeof(value) == 'object')
			{ //If it is an array,
				dumped_text += level_padding + "'" + item + "' ...\n";
				dumped_text += dump(value, level+1);
			}
			else
			{
				dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
			}
		}
	}
	else
	{ //Stings/Chars/Numbers etc.
		dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
} 
function envoie_formulaire(id)
{
	var form = document.getElementById(id);
	form.submit();
}
function cree_lien(page, action)
{
	var lien = page + ".htm?";
	if(action != undefined) lien = lien + "action=" + action;
	return lien;
}

function ajoute_variable_lien(lien, id, nom)
{
	var variable = document.getElementById(id);
	if(nom == undefined) nom = id;
	if(variable != null) lien = lien + "&" + nom + "=" + variable.value;
	return lien;
}
/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = [];
	$c(children).each(function(child){
		if (Element.hasClassName(child, className)) elements.push(child);
	});  
	return elements;
}

//useful array functions
Array.prototype.iterate = function(func){
	for(var i=0;i<this.length;i++) func(this[i], i);
}
if (!Array.prototype.each) Array.prototype.each = Array.prototype.iterate;

function $c(array){
	var nArray = [];
	for (var i=0;i<array.length;i++) nArray.push(array[i]);
	return nArray;
}
/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
Sunday, March 05, 2006
v 1.2.3
*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 13);
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.iniWidth = this.el.offsetWidth;
		this.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {	
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
		this.setOpacity(this.now);
	},
	
	setOpacity: function(opacity) {
		if (opacity == 0 && this.el.style.visibility != "hidden") this.el.style.visibility = "hidden";
		else if (this.el.style.visibility != "visible") this.el.style.visibility = "visible";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.el.style.opacity = opacity;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}
// -----------------------------------------------------------------------------------
//
//	Litebox v1.0
//	A combined effort between detrate and gannon
//	07/03/06
//
//	Source edited from Lightbox v2.02
//	by Lokesh Dhakar - http://www.huddletogether.com
//
//	For more information on this script, visit:
//	http://doknowevil.net/litebox
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//	
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.org), Thomas Fuchs(mir.aculo.us), and others.
//
// -----------------------------------------------------------------------------------

//
//	Configuration
//
var fileLoadingImage = "images/chargement.gif";		
var fileBottomNavCloseImage = "images/fermer.gif";
var resizeSpeed = 6;	// controls the speed of the image resizing (1=slowest and 10=fastest)
var borderSize = 10;	//if you adjust the padding in the CSS, you will need to update this variable

// -----------------------------------------------------------------------------------

//
//	Global Variables
//
var imageArray = new Array;
var activeImage;

if(resizeSpeed > 10){ resizeSpeed = 10;}
if(resizeSpeed < 1){ resizeSpeed = 1;}
resizeDuration = (11 - resizeSpeed) * 100;

// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	hide: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = 'none';
		}
	},
	show: function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = '';
		}
	},
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
		element.style.width = w +"px";
	},
	getHeight: function(element) {
		element = $(element);
		return element.offsetHeight;
	},
	setHeight: function(element,h) {
   		element = $(element);
		element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
		element.style.top = t +"px";
	},
	setSrc: function(element,src) {
		element = $(element);
		element.src = src; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//
Array.prototype.removeDuplicates = function () {
	for(i = 1; i < this.length; i++){
		if(this[i][0] == this[i-1][0]){
			this.splice(i,1);
		}
	}
}

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------
//
//	Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var Lightbox = Class.create();

Lightbox.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 
	// 'lightbox' references and applies onclick events to appropriate links. The 2nd section of
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {
		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				anchor.onclick = function () {myLightbox.start(this); return false;}
			}
		}

		var objBody = document.getElementsByTagName("body").item(0);
		
		var objOverlay = document.createElement("div");
		objOverlay.setAttribute('id','overlay');
		objOverlay.onclick = function() { myLightbox.end(); return false; }
		objBody.appendChild(objOverlay);
		
		var objLightbox = document.createElement("div");
		objLightbox.setAttribute('id','lightbox');
		objLightbox.style.display = 'none';
		objBody.appendChild(objLightbox);
	
		var objOuterImageContainer = document.createElement("div");
		objOuterImageContainer.setAttribute('id','outerImageContainer');
		objLightbox.appendChild(objOuterImageContainer);

		var objImageContainer = document.createElement("div");
		objImageContainer.setAttribute('id','imageContainer');
		objOuterImageContainer.appendChild(objImageContainer);
	
		var objLightboxImage = document.createElement("img");
		objLightboxImage.setAttribute('id','lightboxImage');
		objImageContainer.appendChild(objLightboxImage);
	
		var objHoverNav = document.createElement("div");
		objHoverNav.setAttribute('id','hoverNav');
		objImageContainer.appendChild(objHoverNav);
	
		var objPrevLink = document.createElement("a");
		objPrevLink.setAttribute('id','prevLink');
		objPrevLink.setAttribute('href','#');
		objHoverNav.appendChild(objPrevLink);
		
		var objNextLink = document.createElement("a");
		objNextLink.setAttribute('id','nextLink');
		objNextLink.setAttribute('href','#');
		objHoverNav.appendChild(objNextLink);
	
		var objLoading = document.createElement("div");
		objLoading.setAttribute('id','loading');
		objImageContainer.appendChild(objLoading);
	
		var objLoadingLink = document.createElement("a");
		objLoadingLink.setAttribute('id','loadingLink');
		objLoadingLink.setAttribute('href','#');
		objLoadingLink.onclick = function() { myLightbox.end(); return false; }
		objLoading.appendChild(objLoadingLink);
	
		var objLoadingImage = document.createElement("img");
		objLoadingImage.setAttribute('src', fileLoadingImage);
		objLoadingLink.appendChild(objLoadingImage);

		var objImageDataContainer = document.createElement("div");
		objImageDataContainer.setAttribute('id','imageDataContainer');
		objImageDataContainer.className = 'clearfix';
		objLightbox.appendChild(objImageDataContainer);

		var objImageData = document.createElement("div");
		objImageData.setAttribute('id','imageData');
		objImageDataContainer.appendChild(objImageData);
	
		var objImageDetails = document.createElement("div");
		objImageDetails.setAttribute('id','imageDetails');
		objImageData.appendChild(objImageDetails);
	
		var objCaption = document.createElement("span");
		objCaption.setAttribute('id','caption');
		objImageDetails.appendChild(objCaption);
	
		var objNumberDisplay = document.createElement("span");
		objNumberDisplay.setAttribute('id','numberDisplay');
		objImageDetails.appendChild(objNumberDisplay);
		
		var objBottomNav = document.createElement("div");
		objBottomNav.setAttribute('id','bottomNav');
		objImageData.appendChild(objBottomNav);
	
		var objBottomNavCloseLink = document.createElement("a");
		objBottomNavCloseLink.setAttribute('id','bottomNavClose');
		objBottomNavCloseLink.setAttribute('href','#');
		objBottomNavCloseLink.onclick = function() { myLightbox.end(); return false; }
		objBottomNav.appendChild(objBottomNavCloseLink);
	
		var objBottomNavCloseImage = document.createElement("img");
		objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
		objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
		
		overlayEffect = new fx.Opacity(objOverlay, { duration: 300 });	
		overlayEffect.hide();
		
		imageEffect = new fx.Opacity(objLightboxImage, { duration: 350, onComplete: function() { imageDetailsEffect.custom(0,1); }});
		imageEffect.hide();
		
		imageDetailsEffect = new fx.Opacity('imageDataContainer', { duration: 400, onComplete: function() { navEffect.custom(0,1); }}); 
		imageDetailsEffect.hide();
		
		navEffect = new fx.Opacity('hoverNav', { duration: 100 });
		navEffect.hide();
	},
	
	//
	//	start()
	//	Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
	//
	start: function(imageLink) {	

		hideSelectBoxes();

		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setHeight('overlay', arrayPageSize[1]);
		overlayEffect.custom(0,0.8);
		
		imageArray = [];
		imageNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName('a');

		// if image is NOT part of a set..
		if((imageLink.getAttribute('rel') == 'lightbox')){
			// add single image to imageArray
			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
		} else {
		// if image is part of a set..

			// loop through anchors, find other images in set, and add them to imageArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
					imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
				}
			}
			imageArray.removeDuplicates();
			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
		}

		// calculate top offset for the lightbox and display 
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

		Element.setTop('lightbox', lightboxTop);
		Element.show('lightbox');
		this.changeImage(imageNum);
	},

	//
	//	changeImage()
	//	Hide most elements and preload image in preparation for resizing image container.
	//
	changeImage: function(imageNum) {
		
		activeImage = imageNum;	// update global var

		// hide elements during transition
		Element.show('loading');
		imageDetailsEffect.hide();
		imageEffect.hide();
		navEffect.hide();
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('numberDisplay');
		
		imgPreloader = new Image();
		// once image is preloaded, resize image container
		imgPreloader.onload=function(){
			Element.setSrc('lightboxImage', imageArray[activeImage][0]);
			myLightbox.resizeImageContainer(imgPreloader.width, imgPreloader.height);
		}
		imgPreloader.src = imageArray[activeImage][0];
	},

	//
	//	resizeImageContainer()
	//
	resizeImageContainer: function( imgWidth, imgHeight) {

		// get current height and width
		this.wCur = Element.getWidth('outerImageContainer');
		this.hCur = Element.getHeight('outerImageContainer');

		// calculate size difference between new and old image, and resize if necessary
		wDiff = (this.wCur - borderSize * 2) - imgWidth;
		hDiff = (this.hCur - borderSize * 2) - imgHeight;
		
		// Resize the outerImageContainer very sexy like
		reHeight = new fx.Height('outerImageContainer', { duration: resizeDuration });
		reHeight.custom(Element.getHeight('outerImageContainer'),imgHeight+(borderSize*2)); 
		reWidth = new fx.Width('outerImageContainer', { duration: resizeDuration, onComplete: function() { imageEffect.custom(0,1); }});
		reWidth.custom(Element.getWidth('outerImageContainer'),imgWidth+(borderSize*2));

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent image flicker.
		if((hDiff == 0) && (wDiff == 0)){
			if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);} 
		}

		Element.setHeight('prevLink', imgHeight);
		Element.setHeight('nextLink', imgHeight);
		Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));
		Element.setWidth( 'hoverNav', imgWidth + (borderSize * 2));
		
		this.showImage();
	},
	
	//
	//	showImage()
	//	Display image and begin preloading neighbors.
	//
	showImage: function(){
		Element.hide('loading');
		myLightbox.updateDetails(); 
		this.preloadNeighborImages();
	},

	//
	//	updateDetails()
	//	Display caption, image number, and bottom nav.
	//
	updateDetails: function() {

		Element.show('caption');
		Element.setInnerHTML( 'caption', imageArray[activeImage][1]);
		
		// if image is part of set display 'Image x of x' 
		if(imageArray.length > 1){
			Element.show('numberDisplay');
			Element.setInnerHTML( 'numberDisplay', "Image " + eval(activeImage + 1) + " / " + imageArray.length);
		}

		myLightbox.updateNav();
	},
	//
	//	updateNav()
	//	Display appropriate previous and next hover navigation.
	//
	updateNav: function() {

		// if not first image in set, display prev image button
		if(activeImage != 0){
			Element.show('prevLink');
			document.getElementById('prevLink').onclick = function() {
				myLightbox.changeImage(activeImage - 1); return false;
			}
		}

		// if not last image in set, display next image button
		if(activeImage != (imageArray.length - 1)){
			Element.show('nextLink');
			document.getElementById('nextLink').onclick = function() {
				myLightbox.changeImage(activeImage + 1); return false;
			}
		}
		
		this.enableKeyboardNav();
	},

	//
	//	enableKeyboardNav()
	//
	enableKeyboardNav: function() {
		document.onkeydown = this.keyboardAction; 
	},

	//
	//	disableKeyboardNav()
	//
	disableKeyboardNav: function() {
		document.onkeydown = '';
	},

	//
	//	keyboardAction()
	//
	keyboardAction: function(e) {
		if (e == null) { // ie
			keycode = event.keyCode;
		} else { // mozilla
			keycode = e.which;
		}

		key = String.fromCharCode(keycode).toLowerCase();
		
		if((key == 'x') || (key == 'o') || (key == 'c')){	// close lightbox
			myLightbox.end();
		} else if(key == 'p'){	// display previous image
			if(activeImage != 0){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage - 1);
			}
		} else if(key == 'n'){	// display next image
			if(activeImage != (imageArray.length - 1)){
				myLightbox.disableKeyboardNav();
				myLightbox.changeImage(activeImage + 1);
			}
		}
	},

	//
	//	preloadNeighborImages()
	//	Preload previous and next images.
	//
	preloadNeighborImages: function(){

		if((imageArray.length - 1) > activeImage){
			preloadNextImage = new Image();
			preloadNextImage.src = imageArray[activeImage + 1][0];
		}
		if(activeImage > 0){
			preloadPrevImage = new Image();
			preloadPrevImage.src = imageArray[activeImage - 1][0];
		}
	
	},

	//
	//	end()
	//
	end: function() {
		this.disableKeyboardNav();
		Element.hide('lightbox');
		imageEffect.toggle();
		overlayEffect.custom(0.8,0);
		showSelectBoxes();
	}
}

// -----------------------------------------------------------------------------------

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

// -----------------------------------------------------------------------------------

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// -----------------------------------------------------------------------------------

//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
	if (e == null) { // ie
		keycode = event.keyCode;
	} else { // mozilla
		keycode = e.which;
	}
	key = String.fromCharCode(keycode).toLowerCase();
	
	if(key == 'x'){
	}
}

// -----------------------------------------------------------------------------------

//
// listenKey()
//
function listenKey () {	document.onkeypress = getKey; }

// ---------------------------------------------------

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

// ---------------------------------------------------

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

// ---------------------------------------------------

//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}
// ---------------------------------------------------

function initLightbox() { myLightbox = new Lightbox(); }
function navigateur_est_ie()
{
	if(navigator.userAgent.search("MSIE") != -1) return true;
	return false;
}

function navigateur_est_firefox()
{
	if(navigator.userAgent.search("Firefox") != -1) return true;
	return false
}

function navigateur_est_safari()
{
	if(navigator.userAgent.search("Safari") != -1) return true;
	return false;
}

function navigateur_est_opera()
{
	if(navigator.userAgent.search("Opera") != -1) return true;
	return false;
}

function navigateur_est_google_chrome()
{
	if(navigator.userAgent.search("Chrome") != -1) return true;
	return false;
}

function navigateur()
{
	this.ie = navigateur_est_ie;
	this.firefox = navigateur_est_firefox;
	this.safari = navigateur_est_safari;
	this.opera = navigateur_est_opera;
	this.chrome = navigateur_est_google_chrome;
}
// Script for NiftyPlayer 1.7, by tvst from varal.org
// Released under the MIT License: http://www.opensource.org/licenses/mit-license.php

var FlashHelper =
{
	movieIsLoaded : function (theMovie)
	{
		if (typeof(theMovie) != "undefined") return theMovie.PercentLoaded() == 100;
		else return
		false;
  },

	getMovie : function (movieName)
	{
  	if (navigator.appName.indexOf ("Microsoft") !=-1) return window[movieName];
	  else return document[movieName];
	}
};

function niftyplayer(name)
{
	this.obj = FlashHelper.getMovie(name);

	if (!FlashHelper.movieIsLoaded(this.obj)) return;

	this.play = function () {
		this.obj.TCallLabel('/','play');
	};

	this.stop = function () {
		this.obj.TCallLabel('/','stop');
	};

	this.pause = function () {
		this.obj.TCallLabel('/','pause');
	};

	this.playToggle = function () {
		this.obj.TCallLabel('/','playToggle');
	};

	this.reset = function () {
		this.obj.TCallLabel('/','reset');
	};

	this.load = function (url) {
		this.obj.SetVariable('currentSong', url);
		this.obj.TCallLabel('/','load');
	};

	this.loadAndPlay = function (url) {
		this.load(url);
		this.play();
	};

	this.getState = function () {
		var ps = this.obj.GetVariable('playingState');
		var ls = this.obj.GetVariable('loadingState');

		// returns
		//   'empty' if no file is loaded
		//   'loading' if file is loading
		//   'playing' if user has pressed play AND file has loaded
		//   'stopped' if not empty and file is stopped
		//   'paused' if file is paused
		//   'finished' if file has finished playing
		//   'error' if an error occurred
		if (ps == 'playing')
			if (ls == 'loaded') return ps;
			else return ls;

		if (ps == 'stopped')
			if (ls == 'empty') return ls;
			if (ls == 'error') return ls;
			else return ps;

		return ps;

	};

	this.getPlayingState = function () {
		// returns 'playing', 'paused', 'stopped' or 'finished'
		return this.obj.GetVariable('playingState');
	};

	this.getLoadingState = function () {
		// returns 'empty', 'loading', 'loaded' or 'error'
		return this.obj.GetVariable('loadingState');
	};

	this.registerEvent = function (eventName, action) {
		// eventName is a string with one of the following values: onPlay, onStop, onPause, onError, onSongOver, onBufferingComplete, onBufferingStarted
		// action is a string with the javascript code to run.
		//
		// example: niftyplayer('niftyPlayer1').registerEvent('onPlay', 'alert("playing!")');

		this.obj.SetVariable(eventName, action);
	};

	return this;
}

function position_element(id)
{
	var x=0, y=0;
	var objet = document.getElementById(id);
	while (objet!=null)
	{
		x+=objet.offsetLeft-objet.scrollLeft;
		y+=objet.offsetTop-objet.scrollTop;
		objet=objet.offsetParent;
	}	
	return {x:x,y:y};
}
function print_r(obj, nom)
{
	if(nom==undefined) nom='print_r';
	win_print_r = window.open('about:blank', nom);
	win_print_r.document.write('<html><head><title>' + nom + '</title></head><body>');
	r_print_r(obj, win_print_r);
	win_print_r.document.write('</body></html>');
}

function r_print_r(theObj, win_print_r)
{
	for(var p in theObj)
	{
		if(theObj[p].constructor == Array || theObj[p].constructor == Object)
		{
			win_print_r.document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
			win_print_r.document.write("<ul>");
			r_print_r(theObj[p], win_print_r);
			win_print_r.document.write("</ul>");
		}
		else
		{
			win_print_r.document.write("<li>["+p+"] => "+theObj[p]+"</li>");
		}
	}
}
function remonte_scroll(id)
{
	var div=document.getElementById(id);
	id.scrollTop = 0;
}
function selection_radio(id)
{
	var element = document.getElementById(id);
	if (element.style.display!="none") element.click();
}
function setCookie(name, value, expires, path, domain, secure)
{
	document.cookie=name+"="+escape(value)+((expires==undefined) ? "" : ("; expires="+expires.toGMTString()))+((path==undefined) ? "" : ("; path="+path))+((domain==undefined) ? ""  : ("; domain="+domain))+((secure==true) ? "; secrure" : "");
}
function setvalue(id, value)
{
	var element = document.getElementById(id);
	if(element!=null) element.value=value
}
/*
  SortTable
  version 2
  7th April 2007
  Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
  
  Instructions:
  Download this file
  Add <script src="sorttable.js"></script> to your HTML
  Add class="sortable" to any table you'd like to make sortable
  Click on the headers to sort
  
  Thanks to many, many people for contributions and suggestions.
  Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
  This basically means: do what you want with it.
*/

 
var stIsIE = /*@cc_on!@*/false;

sorttable = {
  init: function() {
    // quit if this function has already been called
    if (arguments.callee.done) return;
    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;
    // kill the timer
    if (_timer) clearInterval(_timer);
    
    if (!document.createElement || !document.getElementsByTagName) return;
    
    sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
    
    forEach(document.getElementsByTagName('table'), function(table) {
      if (table.className.search(/\bsortable\b/) != -1) {
        sorttable.makeSortable(table);
      }
    });
    
  },
  
  makeSortable: function(table) {
    if (table.getElementsByTagName('thead').length == 0) {
      // table doesn't have a tHead. Since it should have, create one and
      // put the first table row in it.
      the = document.createElement('thead');
      the.appendChild(table.rows[0]);
      table.insertBefore(the,table.firstChild);
    }
    // Safari doesn't support table.tHead, sigh
    if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
    
    if (table.tHead.rows.length != 1) return; // can't cope with two header rows
    
    // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
    // "total" rows, for example). This is B&R, since what you're supposed
    // to do is put them in a tfoot. So, if there are sortbottom rows,
    // for backwards compatibility, move them to tfoot (creating it if needed).
    sortbottomrows = [];
    for (var i=0; i<table.rows.length; i++) {
      if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
        sortbottomrows[sortbottomrows.length] = table.rows[i];
      }
    }
    if (sortbottomrows) {
      if (table.tFoot == null) {
        // table doesn't have a tfoot. Create one.
        tfo = document.createElement('tfoot');
        table.appendChild(tfo);
      }
      for (var i=0; i<sortbottomrows.length; i++) {
        tfo.appendChild(sortbottomrows[i]);
      }
      delete sortbottomrows;
    }
    
    // work through each column and calculate its type
    headrow = table.tHead.rows[0].cells;
    for (var i=0; i<headrow.length; i++) {
      // manually override the type with a sorttable_type attribute
      if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
        mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
        if (mtch) { override = mtch[1]; }
	      if (mtch && typeof sorttable["sort_"+override] == 'function') {
	        headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
	      } else {
	        headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
	      }
	      // make it clickable to sort
	      headrow[i].sorttable_columnindex = i;
	      headrow[i].sorttable_tbody = table.tBodies[0];
	      dean_addEvent(headrow[i],"click", function(e) {

          if (this.className.search(/\bsorttable_sorted\b/) != -1) {
            // if we're already sorted by this column, just 
            // reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted',
                                                    'sorttable_sorted_reverse');
            this.removeChild(document.getElementById('sorttable_sortfwdind'));
            sortrevind = document.createElement('span');
            sortrevind.id = "sorttable_sortrevind";
            sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
            this.appendChild(sortrevind);
            return;
          }
          if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
            // if we're already sorted by this column in reverse, just 
            // re-reverse the table, which is quicker
            sorttable.reverse(this.sorttable_tbody);
            this.className = this.className.replace('sorttable_sorted_reverse',
                                                    'sorttable_sorted');
            this.removeChild(document.getElementById('sorttable_sortrevind'));
            sortfwdind = document.createElement('span');
            sortfwdind.id = "sorttable_sortfwdind";
            sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
            this.appendChild(sortfwdind);
            return;
          }
          
          // remove sorttable_sorted classes
          theadrow = this.parentNode;
          forEach(theadrow.childNodes, function(cell) {
            if (cell.nodeType == 1) { // an element
              cell.className = cell.className.replace('sorttable_sorted_reverse','');
              cell.className = cell.className.replace('sorttable_sorted','');
            }
          });
          sortfwdind = document.getElementById('sorttable_sortfwdind');
          if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
          sortrevind = document.getElementById('sorttable_sortrevind');
          if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
          
          this.className += ' sorttable_sorted';
          sortfwdind = document.createElement('span');
          sortfwdind.id = "sorttable_sortfwdind";
          sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
          this.appendChild(sortfwdind);

	        // build an array to sort. This is a Schwartzian transform thing,
	        // i.e., we "decorate" each row with the actual sort key,
	        // sort based on the sort keys, and then put the rows back in order
	        // which is a lot faster because you only do getInnerText once per row
	        row_array = [];
	        col = this.sorttable_columnindex;
	        rows = this.sorttable_tbody.rows;
	        for (var j=0; j<rows.length; j++) {
	          row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
	        }
	        /* If you want a stable sort, uncomment the following line */
	        //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
	        /* and comment out this one */
	        row_array.sort(this.sorttable_sortfunction);
	        
	        tb = this.sorttable_tbody;
	        for (var j=0; j<row_array.length; j++) {
	          tb.appendChild(row_array[j][1]);
	        }
	        
	        delete row_array;
	      });
	    }
    }
  },
  
  guessType: function(table, column) {
    // guess the type of a column based on its first non-blank row
    sortfn = sorttable.sort_alpha;
    for (var i=0; i<table.tBodies[0].rows.length; i++) {
      text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
      if (text != '') {
        if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
          return sorttable.sort_numeric;
        }
        // check for a date: dd/mm/yyyy or dd/mm/yy 
        // can have / or . or - as separator
        // can be mm/dd as well
        possdate = text.match(sorttable.DATE_RE)
        if (possdate) {
          // looks like a date
          first = parseInt(possdate[1]);
          second = parseInt(possdate[2]);
          if (first > 12) {
            // definitely dd/mm
            return sorttable.sort_ddmm;
          } else if (second > 12) {
            return sorttable.sort_mmdd;
          } else {
            // looks like a date, but we can't tell which, so assume
            // that it's dd/mm (English imperialism!) and keep looking
            sortfn = sorttable.sort_ddmm;
          }
        }
      }
    }
    return sortfn;
  },
  
  getInnerText: function(node) {
    // gets the text we want to use for sorting for a cell.
    // strips leading and trailing whitespace.
    // this is *not* a generic getInnerText function; it's special to sorttable.
    // for example, you can override the cell text with a customkey attribute.
    // it also gets .value for <input> fields.
    
    hasInputs = (typeof node.getElementsByTagName == 'function') &&
                 node.getElementsByTagName('input').length;
    
    if (node.getAttribute("sorttable_customkey") != null) {
      return node.getAttribute("sorttable_customkey");
    }
    else if (typeof node.textContent != 'undefined' && !hasInputs) {
      return node.textContent.replace(/^\s+|\s+$/g, '');
    }
    else if (typeof node.innerText != 'undefined' && !hasInputs) {
      return node.innerText.replace(/^\s+|\s+$/g, '');
    }
    else if (typeof node.text != 'undefined' && !hasInputs) {
      return node.text.replace(/^\s+|\s+$/g, '');
    }
    else {
      switch (node.nodeType) {
        case 3:
          if (node.nodeName.toLowerCase() == 'input') {
            return node.value.replace(/^\s+|\s+$/g, '');
          }
        case 4:
          return node.nodeValue.replace(/^\s+|\s+$/g, '');
          break;
        case 1:
        case 11:
          var innerText = '';
          for (var i = 0; i < node.childNodes.length; i++) {
            innerText += sorttable.getInnerText(node.childNodes[i]);
          }
          return innerText.replace(/^\s+|\s+$/g, '');
          break;
        default:
          return '';
      }
    }
  },
  
  reverse: function(tbody) {
    // reverse the rows in a tbody
    newrows = [];
    for (var i=0; i<tbody.rows.length; i++) {
      newrows[newrows.length] = tbody.rows[i];
    }
    for (var i=newrows.length-1; i>=0; i--) {
       tbody.appendChild(newrows[i]);
    }
    delete newrows;
  },
  
  /* sort functions
     each sort function takes two parameters, a and b
     you are comparing a[0] and b[0] */
  sort_numeric: function(a,b) {
    aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
    if (isNaN(aa)) aa = 0;
    bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); 
    if (isNaN(bb)) bb = 0;
    return aa-bb;
  },
  sort_alpha: function(a,b) {
    if (a[0]==b[0]) return 0;
    if (a[0]<b[0]) return -1;
    return 1;
  },
  sort_ddmm: function(a,b) {
    mtch = a[0].match(sorttable.DATE_RE);
    y = mtch[3]; m = mtch[2]; d = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
    dt1 = y+m+d;
    mtch = b[0].match(sorttable.DATE_RE);
    y = mtch[3]; m = mtch[2]; d = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
    dt2 = y+m+d;
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
  },
  sort_mmdd: function(a,b) {
    mtch = a[0].match(sorttable.DATE_RE);
    y = mtch[3]; d = mtch[2]; m = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
    dt1 = y+m+d;
    mtch = b[0].match(sorttable.DATE_RE);
    y = mtch[3]; d = mtch[2]; m = mtch[1];
    if (m.length == 1) m = '0'+m;
    if (d.length == 1) d = '0'+d;
    dt2 = y+m+d;
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
  },
  
  shaker_sort: function(list, comp_func) {
    // A stable sort function to allow multi-level sorting of data
    // see: http://en.wikipedia.org/wiki/Cocktail_sort
    // thanks to Joseph Nahmias
    var b = 0;
    var t = list.length - 1;
    var swap = true;

    while(swap) {
        swap = false;
        for(var i = b; i < t; ++i) {
            if ( comp_func(list[i], list[i+1]) > 0 ) {
                var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
                swap = true;
            }
        } // for
        t--;

        if (!swap) break;

        for(var i = t; i > b; --i) {
            if ( comp_func(list[i], list[i-1]) < 0 ) {
                var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
                swap = true;
            }
        } // for
        b++;

    } // while(swap)
  }  
}

/* ******************************************************************
   Supporting functions: bundled here to avoid depending on a library
   ****************************************************************** */

// Dean Edwards/Matthias Miller/John Resig

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", sorttable.init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            sorttable.init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            sorttable.init(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = sorttable.init;

// written by Dean Edwards, 2005
// with input from Tino Zijdel, Matthias Miller, Diego Perini

// http://dean.edwards.name/weblog/2005/10/add-event/

function dean_addEvent(element, type, handler) {
	if (element.addEventListener) {
		element.addEventListener(type, handler, false);
	} else {
		// assign each event handler a unique ID
		if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
		// create a hash table of event types for the element
		if (!element.events) element.events = {};
		// create a hash table of event handlers for each element/event pair
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};
			// store the existing event handler (if there is one)
			if (element["on" + type]) {
				handlers[0] = element["on" + type];
			}
		}
		// store the event handler in the hash table
		handlers[handler.$$guid] = handler;
		// assign a global event handler to do all the work
		element["on" + type] = handleEvent;
	}
};
// a counter used to create unique IDs
dean_addEvent.guid = 1;

function removeEvent(element, type, handler) {
	if (element.removeEventListener) {
		element.removeEventListener(type, handler, false);
	} else {
		// delete the event handler from the hash table
		if (element.events && element.events[type]) {
			delete element.events[type][handler.$$guid];
		}
	}
};

function handleEvent(event) {
	var returnValue = true;
	// grab the event object (IE uses a global event object)
	event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
	// get a reference to the hash table of event handlers
	var handlers = this.events[event.type];
	// execute each event handler
	for (var i in handlers) {
		this.$$handleEvent = handlers[i];
		if (this.$$handleEvent(event) === false) {
			returnValue = false;
		}
	}
	return returnValue;
};

function fixEvent(event) {
	// add W3C standard event methods
	event.preventDefault = fixEvent.preventDefault;
	event.stopPropagation = fixEvent.stopPropagation;
	return event;
};
fixEvent.preventDefault = function() {
	this.returnValue = false;
};
fixEvent.stopPropagation = function() {
  this.cancelBubble = true;
}

// Dean's forEach: http://dean.edwards.name/base/forEach.js
/*
	forEach, version 1.0
	Copyright 2006, Dean Edwards
	License: http://www.opensource.org/licenses/mit-license.php
*/

// array-like enumeration
if (!Array.forEach) { // mozilla already supports this
	Array.forEach = function(array, block, context) {
		for (var i = 0; i < array.length; i++) {
			block.call(context, array[i], i, array);
		}
	};
}

// generic enumeration
Function.prototype.forEach = function(object, block, context) {
	for (var key in object) {
		if (typeof this.prototype[key] == "undefined") {
			block.call(context, object[key], key, object);
		}
	}
};

// character enumeration
String.forEach = function(string, block, context) {
	Array.forEach(string.split(""), function(chr, index) {
		block.call(context, chr, index, string);
	});
};

// globally resolve forEach enumeration
var forEach = function(object, block, context) {
	if (object) {
		var resolve = Object; // default
		if (object instanceof Function) {
			// functions have a "length" property
			resolve = Function;
		} else if (object.forEach instanceof Function) {
			// the object implements a custom forEach method so use that
			object.forEach(block, context);
			return;
		} else if (typeof object == "string") {
			// the object is a string
			resolve = String;
		} else if (typeof object.length == "number") {
			// the object is array-like
			resolve = Array;
		}
		resolve.forEach(object, block, context);
	}
};
function strip_tags(oldString)
{
	var newString = "";
	var inTag = false;
	for(var i = 0; i < oldString.length; i++)
	{
		if(oldString.charAt(i) == '<') inTag = true;
		if(oldString.charAt(i) == '>')
		{
			if(oldString.charAt(i+1)=="<")
			{
				//dont do anything
			}
			else
			{
				inTag = false;
				i++;
			}
		}
		if(!inTag) newString += oldString.charAt(i);
	}
	return newString;
}
function str_replace(trouve, remplace_par, dans_chaine)
{
	var chaine = dans_chaine;
	var remplace = chaine.replace(trouve, remplace_par);
	while(remplace != chaine)
	{
		chaine = remplace;
		remplace = chaine.replace(trouve, remplace_par);
	}
	return remplace;
}
/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
function tableau_LC(nombre_lignes, nombre_colonnes)
{
	this.x=1;
	this.y=1;
	this.nombre_colonnes=nombre_colonnes;
	this.nombre_lignes=nombre_lignes;
	this.affiche_tout=tableau_affiche_tout;
	this.cache_ligne=tableau_cache_ligne;
	this.cache_colonne=tableau_cache_colonne;
	this.limite_lignes=tableau_limite_lignes;
	this.limite_colonnes=tableau_limite_colonnes;
	this.nombre_lignes_affiches=tableau_nombre_lignes_affiches;
	this.nombre_colonnes_affiches=tableau_nombre_colonnes_affiches;
	this.limite_affichage=tableau_limite_affichage;
	this.decale_haut=tableau_decale_haut;
	this.decale_bas=tableau_decale_bas;
	this.decale_gauche=tableau_decale_gauche;
	this.decale_droite=tableau_decale_droite;
	this.ajoute_ligne=tableau_ajoute_ligne;
	this.enleve_ligne=tableau_enleve_ligne;
	this.ajoute_colonne=tableau_ajoute_colonne;
	this.enleve_colonne=tableau_enleve_colonne;
	this.adapte_a_la_fenetre=tableau_adapte_a_la_fenetre;
	this.onresize=tableau_onresize;
}

function tableau_affiche_tout()
{
	for(l=1;l<=this.nombre_lignes;l++)
	{
		affiche("L" + l, "");
		for(c=1;c<=this.nombre_colonnes;c++) affiche("L" + l + "C" + c, "");
	}
}

function tableau_cache_ligne(ligne)
{
	cache("L" + ligne);
	for(c=1;c<=this.nombre_colonnes;c++) cache("L" + ligne + "C" + c);
}

function tableau_cache_colonne(colonne)
{
	for(l=1;l<=this.nombre_lignes;l++) cache("L" + l + "C" + colonne);
}

function tableau_limite_lignes(debut, fin)
{
	if(debut<1) debut=1;
	if(fin>this.nombre_lignes) fin=this.nombre_lignes;
	this.limite_ligne_debut=debut;
	this.limite_ligne_fin=fin;
	this.y=debut;
}

function tableau_limite_colonnes(debut, fin)
{
	if(debut<1) debut=1;
	if(fin>this.nombre_colonnes) fin=this.nombre_colonnes;
	this.limite_colonne_debut=debut;
	this.limite_colonne_fin=fin;
	this.x=debut;
}

function tableau_nombre_lignes_affiches(nla)
{
	if(nla>this.limite_ligne_fin-this.limite_ligne_debut+1) nla=this.limite_ligne_fin-this.limite_ligne_debut+1;
	this.nla=nla;
}

function tableau_nombre_colonnes_affiches(nca)
{
	if(nca>this.limite_colonnes_fin-this.limite_colonnes_debut+1) nca=this.limite_colonnes_fin-this.limite_colonnes_debut+1;
	this.nca=nca;
}

function tableau_limite_affichage()
{
	this.affiche_tout();
	for(n=this.limite_colonne_debut;n<=this.limite_colonne_fin;n++) if((n<this.x)||(n>(this.x+this.nca-1))) this.cache_colonne(n);
	for(n=this.limite_ligne_debut;n<=this.limite_ligne_fin;n++) if((n<this.y)||(n>(this.y+this.nla-1))) this.cache_ligne(n);
}

function tableau_decale_haut(n)
{
	if(n==undefined)
	{
		if(this.y>this.limite_ligne_debut)
		{
			this.y--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.decale_haut();
	}
}

function tableau_decale_bas(n)
{
	if(n==undefined)
	{
		if(this.y<this.limite_ligne_fin-this.nla+1)
		{
			this.y++;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.decale_bas();
	}	
}

function tableau_decale_gauche(n)
{
	if(n==undefined)
	{
		if(this.x>this.limite_colonne_debut)
		{
			this.x--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.decale_gauche();
	}
}

function tableau_decale_droite(n)
{
	if(n==undefined)
	{
		if(this.x<this.limite_colonne_fin-this.nca+1)
		{
			this.x++;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.decale_droite();
	}
}

function tableau_ajoute_ligne(n)
{
	if(n==undefined)
	{
		if(this.nla<this.limite_ligne_fin-this.limite_ligne_debut+1)
		{
			this.nla++;	
			if(this.nla+this.y-1>this.limite_ligne_fin) this.y--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.ajoute_ligne();
	}
}

function tableau_enleve_ligne(n)
{
	if(n==undefined)
	{
		if(this.nla>1)
		{
			this.nla--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.enleve_ligne();
	}
}

function tableau_ajoute_colonne(n)
{
	if(n==undefined)
	{
		if(this.nca<this.limite_colonne_fin-this.limite_colonne_debut+1)
		{	
			this.nca++;
			if(this.nca+this.x-1>this.limite_colonne_fin) this.x--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.ajoute_colonne();
	}
}

function tableau_enleve_colonne(n)
{
	if(n==undefined)
	{
		if(this.nca>1)
		{
			this.nca--;
			this.limite_affichage();
		}
	}
	else
	{
		for(m=1;m<=n;m++) this.ajoute_colonne();
	}
}

function tableau_adapte_a_la_fenetre(id_droite, id_bas, onresize)
{
	if(id_droite!=undefined) this.id_droite=id_droite;
	if(id_bas!=undefined) this.id_bas=id_bas;
	if(onresize==undefined) onresize=false;
	if(onresize) // se mettre sur l'evenement onresize de la fenetre
	{
		if (window.addEventListener)
		{
			window.addEventListener("resize", this.onresize, false);
		}
		else if (window.attachEvent)
		{
			window.attachEvent('onresize', this.onresize);
		}
	}
	var save_nca=this.nca;
	var save_x=this.x;
	var save_nla=this.nla;
	var save_y=this.y;	
	this.dim_fenetre=dimension_fenetre();
	this.dim_bas=dimension_element(this.id_bas);
	this.dim_droite=dimension_element(this.id_droite);
	this.pos_bas=position_element(this.id_bas);
	this.pos_droite=position_element(this.id_droite);	
	// Pas assez large ?
	while((this.nca<this.limite_colonne_fin-this.limite_colonne_debut+1)&&(this.dim_droite.largeur+this.pos_droite.x<this.dim_fenetre.largeur))
	{
		this.ajoute_colonne();
		this.pos_droite=position_element(this.id_droite);
	}
	// Pas assez haut ?
	while((this.nla<this.limite_ligne_fin-this.limite_ligne_debut+1)&&(this.dim_bas.hauteur+this.pos_bas.y<this.dim_fenetre.hauteur))
	{
		this.ajoute_ligne();
		this.pos_bas=position_element(this.id_bas);
	}
	// Trop large ?
	while((this.nca>1)&&(this.dim_droite.largeur+this.pos_droite.x>this.dim_fenetre.largeur))
	{
		this.enleve_colonne();
		this.pos_droite=position_element(this.id_droite);
	}
	// Trop haut ?
	while((this.nla>1)&&(this.dim_bas.hauteur+this.pos_bas.y>this.dim_fenetre.hauteur))
	{
		this.enleve_ligne();
		this.pos_bas=position_element(this.id_bas);
	}
	if(save_nca==this.nca) this.x=save_x;
	if(save_nla==this.nla) this.y=save_y;
}

function tableau_onresize(e)
{
	tableau.adapte_a_la_fenetre();
}
function actualise_zone_vue()
{
	var left;
	var top;
	if(document.all)
	{
		left = document.documentElement.scrollLeft;
		top = document.documentElement.scrollTop;
	}
	else
	{
		left = window.pageXOffset;
		top = window.pageYOffset;
	}
	var zone_vue = document.getElementById("zone_vue");
	zone_vue.style.top = top + "px";
	zone_vue.style.left = left + "px";
}

window.onscroll=actualise_zone_vue;
definit_transparence("zone_vue", 50);
definit_z_index("zone_vue", -1);
actualise_zone_vue();
function actualise_envoyer_ami(adresse, titre)
{
	// Facebook
	var u = document.getElementById('u_facebook');
	u.value = adresse;
	setInnerHTML("adresse_partage_facebook", adresse);
	var t = document.getElementById('t');
	t.value = titre;
	// Twitter
	var url = document.getElementById('url_twitter');
	url.value = adresse;
	setInnerHTML("adresse_partage_twitter", adresse);
	var text = document.getElementById('text');
	text.value = titre;
	setInnerHTML("message_twitter", titre);
	// Delicious
	var url_d = document.getElementById('url_delicious');
	url_d.value = adresse;
	setInnerHTML("adresse_partage_delicious", adresse);
	var title = document.getElementById('title');
	title.value = titre;
	setInnerHTML("titre_partage_delicious", titre);
}
var pas_affiche=2;var pas_cache=2 * pas_affiche;
var fin=4;  // exemple 10 => 10% de transparence à la fin
var fin2=0;
var sous_menus = new Array("lovamine_c_est_quoi", "lovamine_pour_moi", "lovamine_et_moi", "etudes_cliniques", "contactez_nous", "bonne_annee");
var sous_menu_affiche = "";
var sous_menu_transparence = new Array();
var commander_menu_transparence=100;
for(menu in sous_menus)
{
	if(typeof(sous_menus[menu]) == "string")
	{
		sous_menu_transparence[sous_menus[menu]] = 100;
	}
}

function affiche_sous_menu(sous_menu)
{
	if(sous_menu==undefined)
	{
		sous_menu_affiche="";
	}
	else
	{
		sous_menu_affiche=sous_menu;
	}
	gere_affiche_sous_menu();
	gere_affiche_commander_menu();
}

function gere_affiche_commander_menu()
{
	var travail = false;
	if(sous_menu_affiche != "")
	{
		if(commander_menu_transparence == 100) affiche('commander_menu');
		if(commander_menu_transparence < fin2)
		{
			commander_menu_transparence = fin2;
			definit_transparence('commander_menu', fin2);
			definit_z_index('commander_menu', 200);	
			if(sous_menu_affiche=="bonne_annee")
			{
				cache('commander_menu');
			}
			else
			{
				affiche('commander_menu');
			}
		}
		else
		{
			commander_menu_transparence -= pas_affiche;
			definit_transparence('commander_menu', commander_menu_transparence);
			definit_z_index('commander_menu', 200);
			travail=true;
		}
	}
	else
	{
		if(commander_menu_transparence >= 99)
		{
			commander_menu_transparence = 100;
			definit_transparence('commander_menu', 100);
			definit_z_index('commander_menu', 100);
			cache('commander_menu');
		}
		if(commander_menu_transparence < 100)
		{
			commander_menu_transparence += pas_cache;
			definit_transparence('commander_menu', commander_menu_transparence);
			definit_z_index('commander_menu', 200);
			travail=true;
		}
	}
	if(travail) setTimeout("gere_affiche_commander_menu();", 1);
}

function gere_affiche_sous_menu()
{
	var travail = false;	
	if(sous_menu_affiche != "")
	{
		change_image(sous_menu_affiche + '_image', 'images/lovamine.fr/menu/' + sous_menu_affiche + '_survol.gif');	
		if(sous_menu_transparence[sous_menu_affiche] == 100) affiche(sous_menu_affiche);
		if(sous_menu_transparence[sous_menu_affiche] < fin)
		{
			sous_menu_transparence[sous_menu_affiche] = fin;
			definit_transparence(sous_menu_affiche, fin);
			definit_z_index(sous_menu_affiche, 200);	
		}
		else
		{
			sous_menu_transparence[sous_menu_affiche] -= pas_affiche;
			definit_transparence(sous_menu_affiche, sous_menu_transparence[sous_menu_affiche]);
			definit_z_index(sous_menu_affiche, 200);
			travail=true;
		}
		for(menu in sous_menus)
		{
			if(typeof(sous_menus[menu]) == "string")
			if(sous_menus[menu] != sous_menu_affiche)
			{
				change_image(sous_menus[menu] + '_image', 'images/lovamine.fr/menu/' + sous_menus[menu] + '.gif');
				if(sous_menu_transparence[sous_menus[menu]] >= 99)
				{
					sous_menu_transparence[sous_menus[menu]] = 100;
					definit_transparence(sous_menus[menu], 100);
					definit_z_index(sous_menus[menu], 100);
					cache(sous_menus[menu]);
				}
				if(sous_menu_transparence[sous_menus[menu]] < 100)
				{
					sous_menu_transparence[sous_menus[menu]] += pas_cache;
					definit_transparence(sous_menus[menu], sous_menu_transparence[sous_menus[menu]]);
					definit_z_index(sous_menus[menu], 200 - sous_menu_transparence[sous_menus[menu]]);
					travail=true;
				}
			}
		}
	}
	else
	{
		for(menu in sous_menus)
		{
			if(typeof(sous_menus[menu]) == "string")
			{
				change_image(sous_menus[menu] + '_image', 'images/lovamine.fr/menu/' + sous_menus[menu] + '.gif');
				if(sous_menu_transparence[sous_menus[menu]] >= 99)
				{
					sous_menu_transparence[sous_menus[menu]] = 100;
					definit_transparence(sous_menus[menu], 100);
					definit_z_index(sous_menus[menu], 100);
					cache(sous_menus[menu]);
				}
				if(sous_menu_transparence[sous_menus[menu]] < 100)
				{
					sous_menu_transparence[sous_menus[menu]] += pas_cache;
					definit_transparence(sous_menus[menu], sous_menu_transparence[sous_menus[menu]]);
					definit_z_index(sous_menus[menu], 200 - sous_menu_transparence[sous_menus[menu]]);
					travail=true;
				}
			}
		}
	}
	if(travail) setTimeout("gere_affiche_sous_menu();", 1);
}

function change_couleur(id, couleur)
{
	element = document.getElementById(id);
	element.style.color = couleur;
}
function apparition_progressive(id, z_index, y_depart)
{
	if(y_depart==undefined)
	{
		alert("apparition_progressive -> " + id + " -> y_depart non définit");	
		return;
	}
	var n = 20;
	definit_transparence(id, 100);
	definit_z_index(id, z_index);
	var objet = document.getElementById(id);
	objet.style.top=y_depart + "px";
	affiche(id);
	var y_arrive = y_depart - n;
	gere_apparition_progressive(id, y_arrive, 100/n, 4*(100/n));
}

function gere_apparition_progressive(id, y, t, n)
{
	var travail = false;
	var objet = document.getElementById(id);
	_y = objet.offsetTop;	
	if(y!=_y)
	{
		_y-=4;
		objet.style.top=_y + "px";
		definit_transparence(id, 100-t);
		t=t+n;
		travail=true;
	}
	else
	{
		definit_transparence(id, 0);
	}
	if(travail) setTimeout("gere_apparition_progressive('" + id + "', " + y + ", " + t + ", " + n + ");", 1);
}
function decoche(id)
{
	var champ = document.getElementById(id);
	champ.value = "0";
	setInnerHTML("case_" + id, "<img src='images/lovamine.fr/case_non_cochee.gif' width='14' height='13' border='0' onclick=\"javascript:coche('" + id + "');\">");
}

function coche(id)
{
	var champ = document.getElementById(id);
	champ.value = "1";
	setInnerHTML("case_" + id, "<img src='images/lovamine.fr/case_cochee.gif' width='14' height='13' border='0' onclick=\"javascript:decoche('" + id + "');\">");
}
function change_image(id, source)
{
	var i=document.getElementById(id);
	if (i != null) i.src = source;
}
function clic_copie()
{
	var copie = document.getElementById("copie");
	if(copie.value=="1")
	{
		decoche("copie");
	}
	else
	{
		coche("copie");
	}
}
function delicious()
{
	var message = document.getElementById("message_delicious");
	var notes = document.getElementById("notes");
	notes.value = message.value
	var formulaire = document.getElementById("formulaire_envoyer_delicious");
	formulaire.submit();
}
var pas_enroule = 5;var temps_enroule = 25;var deroule_enroule = new Array();
function deroule(id, max)
{
	deroule_enroule[id] = "d";
	var objet = document.getElementById(id);
	objet.style.height = pas_enroule + "px";
	affiche(id);
	gere_deroule(id, max);
}

function gere_deroule(id, max)
{
	if(deroule_enroule[id] == "d")
	{
		var objet = document.getElementById(id);
		if(objet != null)
		{
			h = objet.clientHeight;
			if(h < max)
			{
				h = h + pas_enroule;
				if (h > max) h = max;
				objet.style.height = h + "px";
				setTimeout("gere_deroule('" + id + "', " + max + ");", temps_enroule);
			}
		}
		else
		{
			setTimeout("gere_deroule('" + id + "', " + max + ");", temps_enroule);
		}
	}
}

function enroule(id)
{
	deroule_enroule[id] = "e";
	var objet = document.getElementById(id);
	h = objet.clientHeight - pas_enroule;
	if (h >= 0) objet.style.height = h + "px";
	gere_enroule(id);
}

function gere_enroule(id)
{
	if(deroule_enroule[id] == "e")
	{
		var objet = document.getElementById(id);
		if(objet != null)
		{
			h = objet.clientHeight;
			if (h > 0)
			{
				h = h - pas_enroule;
				if (h < 0) h = 0;
				objet.style.height = h + "px";
				setTimeout("gere_enroule('" + id + "');", temps_enroule);
			}
			else if(h==0)
			{
				cache(id);
			}
		}
		else
		{
			setTimeout("gere_enroule('" + id + "');", temps_enroule);
		}
	}
}
function disparition_progressive(id, commande)
{
	var n = 20;
	var objet = document.getElementById(id);
	var y_depart = objet.offsetTop;
	var y_arrive = y_depart + n;	
	gere_disparition_progressive(id, y_arrive, 100-(100/n), 4*(100/n), commande);
}

function gere_disparition_progressive(id, y, t, n, commande)
{
	var travail = false;
	var objet = document.getElementById(id);
	_y = objet.offsetTop;	
	if(y!=_y)
	{
		_y+=4;
		objet.style.top=_y + "px";
		definit_transparence(id, 100-t);
		t=t-n;
		travail=true;
	}
	else
	{
		cache(id);
	}
	if(travail)
	{
		setTimeout("gere_disparition_progressive('" + id + "', " + y + ", " + t + ", " + n + ", \"" + commande + "\");", 1);
	}
	else
	{	
		setTimeout(commande, 1);
	}
}
var adresse_ami = "";
var modele_ami = "simple";
var temoignage_courant = 0;
var recette = 0;

function envoyer()
{
	var post = new Array();	
	ajoute_variable_post(post, "nom", document.getElementById("nom_envoyer").value);
	ajoute_variable_post(post, "email", document.getElementById("email_envoyer").value);
	ajoute_variable_post(post, "copie", document.getElementById("copie").value);
	ajoute_variable_post(post, "nom_ami", document.getElementById("nom_ami").value);
	ajoute_variable_post(post, "email_ami", document.getElementById("email_ami").value);
	ajoute_variable_post(post, "message_perso", document.getElementById("message_perso").value);
	ajoute_variable_post(post, "tid", temoignage_courant);
	ajoute_variable_post(post, "rid", recette);
	if(adresse_ami == "")
	{
		ajoute_variable_post(post, "adresse", "www.lovamine.fr/index.htm");
	}
	else
	{
		ajoute_variable_post(post, "adresse", adresse_ami);	
	}
	ajoute_variable_post(post, "modele", modele_ami);
	ajax_read("ajax_data_envoyer", "envoyer_ami.htm?action=valider", "", "", post);
}
function envoyer_ami()
{
	fond_gris(4);
	apparition_progressive("envoyer_ami", 5, 81+20);
}
function envoyer_ami_ok()
{
	disparition_progressive("envoyer_ami");
	apparition_progressive("envoyer_ami_ok", 5, 81+20);
}
function envoyer_autre()
{
	disparition_progressive("envoyer_ami_ok");
	setvalue("nom_ami", "");
	setvalue("email_ami", "");
	apparition_progressive("envoyer_ami", 5, 81+20);
}
function envoyer_email()
{
	affiche("envoyer_email_zone");
	cache("envoyer_facebook_zone");
	cache("envoyer_twitter_zone");
	cache("envoyer_delicious_zone");
}

function envoyer_facebook()
{
	cache("envoyer_email_zone");
	affiche("envoyer_facebook_zone");
	cache("envoyer_twitter_zone");
	cache("envoyer_delicious_zone");
}

function envoyer_twitter()
{
	cache("envoyer_email_zone");
	cache("envoyer_facebook_zone");
	affiche("envoyer_twitter_zone");
	cache("envoyer_delicious_zone");
}

function envoyer_delicious()
{
	cache("envoyer_email_zone");
	cache("envoyer_facebook_zone");
	cache("envoyer_twitter_zone");
	affiche("envoyer_delicious_zone");
}
function ferme_envoyer()
{
	disparition_progressive("envoyer_ami", "fond_gris(0);");
}
function ferme_envoyer_ok()
{
	setvalue("nom_ami", "");
	setvalue("email_ami", "");
	disparition_progressive("envoyer_ami_ok", "fond_gris(0);");
}
function ferme_popup_noel()
{
	if(popup_noel_est_affiche==true)
	{
		disparition_progressive("popup_noel", "fond_gris(0, 'fond_gris_noel');popup_noel_est_affiche=false;");
	}
}
function ferme_suivre()
{
	if(suivre_ma_commande_est_affiche==true)
	{
		disparition_progressive("suivre_ma_commande_contenu", "fond_gris(0, 'fond_gris_2');if(suivre_commande_maj==true) { ajax_read('suivre_ma_commande_contenu', 'suivre_commande', '', ''); } suivre_ma_commande_est_affiche=false;");
	}
}
var images_survol = new Array();

function fondu_affiche(id)
{
	images_survol[id] = 'survol';
	fondu(id);
}

function fondu_cache(id)
{
	images_survol[id] = 'normal';
	fondu(id);
}

function fondu(id)
{
	var pas_fondu = 0.4;
	var image_survol = document.getElementById(id + "_survol");
	var opacite = image_survol.style.opacity;
	var transparence = 100 - (100*opacite);
	if(images_survol[id] == "survol")
	{
		if(transparence > 0)
		{
			transparence -= pas_fondu;
			definit_transparence(id + "_survol", transparence);
			setTimeout("fondu('" + id + "');", 10);
		}
	}
	else
	{
		if(transparence < 100)
		{
			transparence += pas_fondu;
			definit_transparence(id + "_survol", transparence);
			setTimeout("fondu('" + id + "');", 10);
		}
	}
}
function fond_gris(z_index, id)
{
	if(id==undefined) id="fond_gris";
	if(z_index==0)
	{
		cache(id);
		definit_transparence(id, 100);
		definit_z_index(id, 0);
	}
	else
	{
		affiche(id);
		definit_transparence(id, 50);
		definit_z_index(id, z_index);
	}
}
function partager_video(n)
{
	alert("partager !");
	
	fond_gris(4);
	
	
}
var popup_noel_est_affiche=false;

function popup_noel()
{
	if(popup_noel_est_affiche==false)
	{
		fond_gris(6, "fond_gris_noel");
		definit_transparence('fond_gris_noel', 10);
		apparition_progressive("popup_noel", 7, 45+20);
		popup_noel_est_affiche=true;
	}
}
var deplacement_v='b';
var deplacement_v_q = 12;

function glisse_bandeau_haut()
{
	var dim_b = dimension_element("bandeau_vertical_deroulant");
	var bandeau = document.getElementById("bandeau_vertical_deroulant");
	if(deplacement_v=='h')
	if(dim_b.hauteur > (3*141+2*38))
	{
		bandeau.style.height = (dim_b.hauteur - deplacement_v_q) + "px"
		setTimeout("glisse_bandeau_haut();", 1);
	}
	else
	{
		bandeau.style.height = (3*141+2*38) + "px"
		deplacement_v='b';
	}
}

function glisse_bandeau_bas()
{
	var dim_b = dimension_element("bandeau_vertical_deroulant");
	var bandeau = document.getElementById("bandeau_vertical_deroulant");
	if(deplacement_v=='b')
	if(dim_b.hauteur < (6*141+5*38))
	{
		bandeau.style.height = (dim_b.hauteur + deplacement_v_q) + "px"
		setTimeout("glisse_bandeau_bas();", 1);
	}
	else
	{
		bandeau.style.height = (6*141+5*38) + "px"
		deplacement_v='h';
	}
}
var suivre_ma_commande_est_affiche=false;

function suivre_ma_commande()
{
	if(suivre_ma_commande_est_affiche==false)
	{
		fond_gris(6, "fond_gris_2");
		apparition_progressive("suivre_ma_commande_contenu", 7, 86+20);
		suivre_ma_commande_est_affiche=true;
	}
}
function suivre_ma_commande_envoyer()
{
	var post = new Array();
//	ajoute_variable_post(post, "nom", document.getElementById("champ_suivre_nom").value);
//	ajoute_variable_post(post, "email", document.getElementById("champ_suivre_email").value);
	ajoute_variable_post(post, "numero", document.getElementById("champ_suivre_numero").value);
	ajax_read("ajax_data_suivre", "suivre_commande?action=envoyer", "", "", post);
}
function suivre_ma_commande_validation()
{
	var colispart = document.getElementById("colispart");
	if (colispart.value == "")
	{
		change_image('suivre_numero', 'images/lovamine.fr/suivre_ma_commande/numero_d_expedition_erreur.gif');
		change_image('suivre_numero_2', 'images/lovamine.fr/suivre_ma_commande/il_est_indique_erreur.gif');
		alert('Veuillez corriger les erreurs (champs en rouge).');
		return false;
	}
	else
	{
		change_image('suivre_numero', 'images/lovamine.fr/suivre_ma_commande/numero_d_expedition.gif');
		change_image('suivre_numero_2', 'images/lovamine.fr/suivre_ma_commande/il_est_indique.gif');
		ferme_suivre();
		return true;
	}
}
function twitter()
{
	var message = document.getElementById("message_twitter");
	var adresse = document.getElementById("url_twitter");
	var text = document.getElementById("text");
	text.value = message.value + "\n" + adresse.value;
	var formulaire = document.getElementById("formulaire_envoyer_twitter");
	formulaire.submit();
	_gaq.push('_trackSocial', 'twitter', 'tweet', adresse.value);
}
var deplacement='d';
var deplacement_q = 12;

function glisse_bandeau_droite()
{
	var dim_b = dimension_element("bandeau_deroulant");
	var bandeau = document.getElementById("bandeau_deroulant");
	if(deplacement=='d')
	if(dim_b.largeur < (6*256+5*63))
	{
		bandeau.style.width = (dim_b.largeur + deplacement_q) + "px"
		setTimeout("glisse_bandeau_droite();", 1);
	}
	else
	{
		bandeau.style.width = (6*256+5*63) + "px"
		deplacement='g';
	}
}

function glisse_bandeau_gauche()
{
	var dim_b = dimension_element("bandeau_deroulant");
	var bandeau = document.getElementById("bandeau_deroulant");
	if(deplacement=='g')
	if(dim_b.largeur > (3*256+2*63))
	{
		bandeau.style.width = (dim_b.largeur - deplacement_q) + "px"
		setTimeout("glisse_bandeau_gauche();", 1);
	}
	else
	{
		bandeau.style.width = (3*256+2*63) + "px"
		deplacement='d';
	}
}

