 //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 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=691;
	if (!height)  height=400;
	if (url.substr(0,4)=="send") 
	{
		width=550;
		height=250;
	}
	if (!menubar)	menubar="scrollbars,status,menubar,resizable";
	if (!nom_page)   nom_page="Actaris";
	
	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);

}



//-----------------------------------------------------------------------------
//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)
 {
 	var isOk = true;
 	var str = "";
 	var strbis="";
 	var sep="";
 	var nb=0;
  	for(i=0;i<champsToCheck.length;i++)
 	 {
	 	test=eval("document.formcheck."+champsToCheck[i]+".value");
	 	if(  test== "" ||  test== "0")
	 	 {
		 	if (champsToCheck[i]=="civilite") 	str += " title";
		 	else	
		 	{
		 		if (champsToCheck[i]=="idcp") 	str += sep+"Country,";
				else						str += sep+champsToCheck[i];
			}
		 	isOk = false;
		 	nb++;
		 	sep=", ";
	 	 }
	 	 else
	 	 {
			if ((champsToCheck[i]=="email" || champsToCheck[i]=="emailfrom") && !verif(test))
		 	{
		 		strbis = "Please check your email adress.\n";
		 		isOk = false;
		 		
	 	 	}	
	 	 	if ( champsToCheck[i]=="emailto" && !verif(test))
			{
				strbis += "Please check your friend\'s email adress.\n";
				isOk = false;
				
	 	 	}	
	 	 }
	 	 
	 }
		if(isOk == true)
	 	document.formcheck.submit();
	 else
	 {
	 	if (nb>0)
	 	{
	 		if (nb>1)	alert("Please fill all mandatory fields: "+ str + " are missing\n" +strbis);
	 		 else		alert("Please fill all mandatory fields: "+ str + " is missing\n" + strbis);
	 	}
	 	else
	 	{
	 		alert(strbis);
	 	}
	}
	 return;
 }
 

function verif(email) { 
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   return (reg.exec(email)!=null)
}


function showMenu(Nom) {
  whichEl = document.getElementById(Nom);
  if (whichEl.style.display=="") {
    whichEl.style.display = "none";
  }
  else {
    whichEl.style.display = "";
  }
}


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 == '');
 }
