 //Browsercheck
  function Browsercheck(){
 	this.ver=navigator.appVersion
 	this.agent=navigator.userAgent
 	this.dom=document.getElementById?1:0
 	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
 	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
 	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
 	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
 	this.ie=this.ie4||this.ie5||this.ie6
 	this.mac=this.agent.indexOf("Mac")>-1
 	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
 	this.ns4=(document.layers && !this.dom)?1:0;
 	
 	return this
 }
var testbrowser=Browsercheck()



 function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }
 
 function MM_preloadImages() { //v3.0
   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
 }
 
 function MM_findObj(n, d) { //v4.01
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
   if(!x && d.getElementById) x=d.getElementById(n); return x;
 }
 
 function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}






function Confirm(text,url,submit,nomchamp,valeur)
{
	if(confirm(text)) 
	{
		if (nomchamp)
		{
			action="document.forms[0]."+nomchamp+".value='"+valeur+"'";
			eval(action);
		}		
		if (submit==1)
		{
			window.document.forms[0].submit();
		}
		else
		{
			window.location.href=url;
		}
	}
}



//-----------------------------------------------------------------------------
//ouverture de fenêtre
//---------------------------------
function Fenetre(url,nom_page,width,height,menubar)
{
	//rewr_path est defini dans meta.php
	
	if (!width) 	width=700;
	if (!height)  height=500;
	if (url.substr(0,7)=="galerie") 
	{
		width=700;
		height=500;
		menubar="status,menubar,resizable";
		
	}
	if (!menubar)	menubar="status,menubar,resizable,scrollbars";
	if (!nom_page)   nom_page="popup";
	
	if (url.substr(0,4)!="http") 
	{
		if (url.substr(4,4)=="page") 
		{
			url=url.replace("page","wpage")
			url=rewr_path+url	
		}
		else
		{
			url=rewr_path+url;
		}
	}
	else
	{
		menubar+=",location,toolbar";
	}
	fenetre=window.open(url,nom_page,"width="+width+", height="+height+",top=100,left=60,"+menubar);

}

function Galerie(url)
{
		width=740;
		height=520;
		menubar="status,menubar,resizable";
		nom_page="popup";
		
		url=rewr_path+"galerie-"+url+".html";
		fenetre=window.open(url,nom_page,"width="+width+", height="+height+",top=100,left=60,"+menubar);

}

//-----------------------------------------------------------------------------
//petites annonces
//---------------------------------

function apply(idm,idt,ida)
{
	try
	{
		var url="applyads-"+idm+"-"+idt+"-"+ida+".html";
		//var url=window.opener.location+"&ida="+ida;
		
		window.opener.location=url;
		self.close();
	}
	catch(e){ 
		window.location=url;
	}
	
}

//-----------------------------------------------------------------------------
// back from popup
//---------------------------------

function lienback(url)
{
	try
	{
		window.opener.location=url;
		self.close();
	}
	catch(e){ alert(e)}
	
}

//-----------------------------------------------------------------------------
// TEST FORMULAIRE
//---------------------------------

function CheckForm(champsToCheck,labelToCheck)
 {
 	var isOk = true;
 	var str = "";
  	for(i=0;i<champsToCheck.length;i++)
 	 {
	 	test=eval("document.formcheck."+champsToCheck[i]+".value");
	 	if(  test== "")
	 	 {
 		 	if (labelToCheck[i])	str += "Field : "+labelToCheck[i]+" is mandatory .\n";
 			else				str += "Field : "+champsToCheck[i]+" is mandatory .\n";
		 	isOk = false;
	 	 }
	 	 else
	 	 {
			if (champsToCheck[i]=="email" && !verif(test))
		 	{
		 		str += "Please check your email adress.\n";
		 		isOk = false;
	 	 	}	 	 	
	 	 }
	 	 
	 }
		if(isOk == true)
	 	document.formcheck.submit();
	 else
	 	alert(str);
	 return;
 }
 

function verif(email) { 
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   return (reg.exec(email)!=null)
}



/*****************/
var oldnommenu="";
var timerID=0;

function showMenu(Nom) {
//clearTimeout(timerID)
//timerID = setTimeout("showMenu()", 3000);
try{
	if (oldnommenu)
	{
		whichEl = document.getElementById(oldnommenu);
		whichEl.style.display = "none";
	}
	oldnommenu=Nom;
	whichEl = document.getElementById(Nom);
	  if (whichEl.style.display=="") {
	    whichEl.style.display = "none";
	  }
	  else {
	    whichEl.style.display = "";
	  }
	  

  }
  catch(e) {}
}


  function m_over_menu() {
	clearTimeout(timerID);
  }
  function m_out_menu(r) {
    timerID = setTimeout("showMenu()", 500);
  }
  
  

function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}



function chg_visu(nom,x)
{
	newfile="medias/visuel/"+nom+"_"+x+".jpg"
	document.visuel.src=newfile;
}
 
 
 function CheckFormulaire(champsToCheck,champsName,monform)
  {
  	if (!monform) monform="formcheck";
  	var isOk = true;
  	var str = "";
   	for(i=0;i<champsToCheck.length;i++)
  	 {
 	 	test=eval("document."+monform+"."+champsToCheck[i]+".value");
 	 	if(  test== "" ||  test== "0")
 	 	 {
 		 	if (champsName[i])	str += "Field : "+champsName[i]+" is mandatory .\n";
 			else				str += "Field : "+champsToCheck[i]+" is mandatory .\n";
 			isOk = false;
 	 	 }
 	 	 else
 	 	 {
 			if ((champsToCheck[i]=="email" || champsToCheck[i]=="emailfrom") && !verif(test))
 		 	{
 		 		str += "Please check your email adress.\n";
 		 		isOk = false;
 	 	 	}	
 	 	 	if ( champsToCheck[i]=="emailto" && !verif(test))
 			{
 				str += "Please check your friend\'s email adress.\n";
 				isOk = false;
 	 	 	}	
 	 	 }
 	 	 
 	 }
 	   
 	if(isOk == false)	 	alert(str);
 	document.CheckFormValue = (str == '');
 }
 
 
   function m_over_admin(button) {
 	button.style.backgroundColor = "#FF9900";
  }
  function m_out_admin(button) {
 	button.style.backgroundColor = 'transparent';
  }
 	
 function m_down_admin(button) {
 	button.style.backgroundColor = "#8592b5";
 }
 
 
 
 function InitlistePays(sForm,idinit)
 {
 	init=0;
 	myForm=eval('document.'+sForm);
 	for(i=myForm.idpays.options.length-1;i>0;i--) myForm.idpays.options[i] = null;
 	for(rnum=1;rnum<999;rnum++)
 	{
		if(!liste_pays[rnum])
		{

			break;
		}
		else
		{
			if (liste_pays[rnum][0]==idinit) init=rnum;
			newOption = new Option(liste_pays[rnum][1]);
			newOption.value= liste_pays[rnum][0];
			myForm.idpays.options[rnum]=newOption;
		}
 	}
 	myForm.idpays.selectedIndex=init;
 
 }
 function InitlisteBatiment(sForm,idinit)
 {
 	init=0;
 	myForm=eval('document.'+sForm);
 	for(i=myForm.idf.options.length-1;i>0;i--) myForm.idf.options[i] = null;
 	for(rnum=1;rnum<999;rnum++)
 	{
 			if(!liste_batiment[rnum])
 			{
 
 				break;
 			}
 			else
 			{
 				if (liste_batiment[rnum][0]==idinit) init=rnum;
 				newOption = new Option(liste_batiment[rnum][1]);
 				newOption.value= liste_batiment[rnum][0];
 				myForm.idf.options[rnum]=newOption;
 
 			}
 	}
 	myForm.idf.selectedIndex=init;
 
 }
 
 
 function set_batiment(sForm,idinit)
 {
 	init=0;
 	myForm=eval('document.'+sForm);
 	idpays=myForm.idpays.selectedIndex;
 	
 	for(i=myForm.idf.options.length-1;i>0;i--) myForm.idf.options[i] = null;
 		if(idpays!=0 )
 		{
 			for(rnum=0;rnum<199;rnum++)
 			{
 
 				if(!liste_ref[idpays][rnum])
 				{
 
 					break;
 				}
 				else
 				{
 					if (rnum==0)
 					{
 
 						newOption = new Option(TRAD["choixbat"]);
 						newOption.value= '';
 						myForm.idf.options[0]=newOption;
 					}
 					idbat=liste_ref[idpays][rnum];
 					if (idbat==idinit) init=rnum+1;
 					newOption = new Option(get_bat(idbat));
 					newOption.value= idbat;
 					myForm.idf.options[rnum+1]=newOption;
 				}
 			}
 
 		}
 
 	myForm.idf.selectedIndex=init;
 }
 
 
 function get_bat(idbat)
 {
 	var label="";
 	for(i=1;i<50;i++)
 	{
 		if(!liste_batiment[i])
 		{
 			label= "Error";
 			break;
 		}
 		if(liste_batiment[i][0]==idbat)
 		{
 			label= liste_batiment[i][1];
 			break;
 		}
 	}
 	return label;
 
 }
 
 
 function set_pays(sForm,idinit)
 {
 	init=0;
 	myForm=eval('document.'+sForm);
 
	idbatiment=myForm.idf.selectedIndex;
	idf=myForm.idf.options[idbatiment].value;
	var thenum=0;

	for(i=myForm.idpays.options.length-1;i>0;i--) myForm.idpays.options[i] = null;
	if(idbatiment!=0 )
	{
		for(rnum=1;rnum<50;rnum++)
		{

			if(!liste_ref[rnum])
			{
				break;
			}
			else
			{

				if (rnum==1)
				{

					newOption = new Option(TRAD["choixpays"]);
					newOption.value= '';
					myForm.idpays.options[0]=newOption;
				}

				if (liste_ref[rnum].in_array(idf))
				{
					thenum++;
					if (liste_pays[rnum][0]==idinit) init=thenum;
					newOption = new Option(liste_pays[rnum][1]);
					newOption.value= liste_pays[rnum][0];
					myForm.idpays.options[thenum]=newOption;
				}

			}
		}

	}

 	myForm.idpays.selectedIndex=init;
 }
 
 Array.prototype.in_array = function(val) {
    for (var i in this) {
     if (this[i] == val) return true;
    }
    return false;
};

function Diapo(url)
{
		width=740;
		height=620;
		menubar="status,menubar,resizable";
		nom_page="popup";
		
		url=rewr_path+"diapo-"+url+".html";
		fenetre=window.open(url,nom_page,"width="+width+", height="+height+",top=100,left=60,"+menubar);

}

/********* mp3 ***********************/

//var  monlecteur="";
function openmp(url)
{
		width=310;
		height=180;
		menubar="location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no";
		nom_page="mp";
		
		url=rewr_path+url
		
		
		try
		{			
			 top.monlecteur.focus()
			
		}
		catch(e){ 
			
			
			top.monlecteur=window.open(url,nom_page,"width="+width+", height="+height+",top=100,left=60,"+menubar);
			
			//SetCookie ( "tmp", monlecteur ) ;
			
		}
}




function controlPlayer(func,param) {
	try
	{			
		top.monlecteur.focus();
		thisMovie("mp3player").jsControl(func,param);
	}
	catch(e){ 

		openmp('lecteur.html')

	}
		
	
}

function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return top.monlecteur.window[movieName]
    }
    else {
        return top.monlecteur.document[movieName]
    }
}
/********************************/
function getCookie(name) {
    var cookies = document.cookie.split(';');
        for(var i=0; i<cookies.length; i++){
            var cookie=cookies[i].replace(/^\s+/, '');
            if (cookie.indexOf(name+'=')==0) return cookie.substring(name.length+1);
        }
    return null;
}

function SetCookie (name, value,days)
{
 if(days){
        (time = new Date()).setTime(new Date().getTime()+days*24*60*60*1000);
        var exp = '; expires='+time.toGMTString();
    }else{
        var exp='';
    }
    document.cookie=name+"="+value+exp+"; path=/";
}