function contract(path)
{
	largeurF=600
	hauteurF=400
	
	leleft=(screen.width-largeurF)/2
	letop=(screen.height-hauteurF)/2
	
	Contrat=window.open(path+"contrat.html" , "Contrat", "width="+largeurF+",height="+hauteurF+",toolbar=0,scrollbars=1,statusbar=0,menubar=0,resizable=0,left="+leleft+",top="+letop+"");
	Contrat.focus()
}

//-------------------EMAIL----------------
//-------------------EMAIL----------------
//-------------------EMAIL----------------

function validEmail(email)
{
	if (email.length>=7)
	{
		domaine=false
		if ((email.indexOf(".",email.indexOf("@")))<(email.indexOf("@")+3))
		domaine=true
		
		if (!domaine)
		{
			acom=false
			if ((email.indexOf("@",email.lastIndexOf("."))!=-1) || (email.indexOf("@")!=email.lastIndexOf("@")) || (email.indexOf("@")<1))
			acom=true
			
			if (!acom)
			{
				nbpoints=false
				combien=0
				for (y=email.indexOf("@"); y<email.length; y++)
				{
					if (email.charAt(y)==".")
					combien++
					
					if (combien==3)
					break
				}
				
				if (((combien==2) && (email.indexOf(".",email.indexOf("@"))!=email.lastIndexOf(".")-3) && (email.indexOf(".",email.indexOf("@"))!=email.lastIndexOf(".")-5)) || (combien>3))
				nbpoints=true
				
				if (!nbpoints)
				{
					extension=false
					if (combien==1)
					{
						if ((email.lastIndexOf(".")>(email.length-3)) || (email.lastIndexOf(".")<(email.length-5)))
						extension=true
					}
					else if (combien==2)
					{
						if (email.lastIndexOf(".")!=(email.length-3))
						extension=true
					}
					else if (combien==3)
					{
						if ((email.charAt(email.indexOf(".",email.indexOf("@"))+5)!=".") || (email.charAt(email.lastIndexOf(".")-3)!=".") || (email.lastIndexOf(".")!=(email.length-3)))
						extension=true
					}
					
					if (!extension)
					{
						points=false
						if ((email.charAt(email.indexOf(".")+1)==".") || (email.indexOf(".",email.indexOf("@"))==-1) || (email.indexOf(".")==0) || (email.charAt(email.indexOf("@")-1)=="."))
						points=true
						
						if (!points)
						{
							leschar=false
							charValid="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._-"
							for (x=0; x<email.length; x++)
							{
								if (charValid.indexOf(email.charAt(x))==-1)
								{
									leschar=true
									break
								}
							}
						}
					}
				}
			}
		}
	}
	
	if ((email.length<7) || domaine || acom || nbpoints || extension || points || leschar)
	return false
	else
	return true
}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

//-------------------CHAT-----------------
//-------------------CHAT-----------------
//-------------------CHAT-----------------

function chat(salle){
	/*largeurF=728
	hauteurF=452
	
	leleft=(screen.width-largeurF)/2
	letop=(screen.height-hauteurF)/2
	
	document.formchat.chatroomId.value=salle;
	window.open('','pubWindow',"status=0,toolbar=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=452,width=728,left="+leleft+",top="+letop);
	var a = window.setTimeout("document.formchat.submit();",500);
	*/
	largeurF=630
	hauteurF=600
	
	leleft=(screen.width-largeurF)/2
	letop=(screen.height-hauteurF)/2
	
	document.formchat.chatroomId.value=salle;
	window.open('','newWindow',"status=0,toolbar=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=600,width=630,id=0',left="+leleft+",top="+letop);
	var a = window.setTimeout("document.formchat.submit();",500);
}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

//-------------------RECHERCHE ME CHERCHE-----------------
//-------------------RECHERCHE ME CHERCHE-----------------
//-------------------RECHERCHE ME CHERCHE-----------------

function validMeCherche(path){
	var noerror=true;
	var rech=trim(document.recherchemecherche_form.recherchemecherche.value);
	
	if(rech=='')
	noerror = false;
	else{
		rech=rech.replace(/&/,'%26');
		rech=rech.replace(/'/,'%27');
		
		document.recherchemecherche_form.action=path+"recherche.php?id=2&query=" + rech
	}
	
	return noerror;
}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

//-------------------RECHERCHE RAPIDE-----------------
//-------------------RECHERCHE RAPIDE-----------------
//-------------------RECHERCHE RAPIDE-----------------

function validRapide(path){
	var noerror=true;
	var rech=trim(document.rechercheRapide_form.rechercheRapide.value);
	
	if(rech=='')
	noerror = false;
	else{
		rech=rech.replace(/&/,'%26');
		rech=rech.replace(/'/,'%27');
		
		document.rechercheRapide_form.action=path+"recherche.php?id=3&query=" + rech
	}
	
	return noerror;
}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

//-------------------RECHERCHE PAR RÉGIONS-----------------
//-------------------RECHERCHE PAR RÉGIONS-----------------
//-------------------RECHERCHE PAR RÉGIONS-----------------
function validRegion(){
	var noerror=true;
	var reg=document.rechercheRegion_form.reg.value;
	var vil=parseInt(document.rechercheRegion_form.vil.value);
	
	if (isNaN(vil))
	vil="";
	
	if(reg==-1 || reg=='')
	noerror = false;
	else
	document.rechercheRegion_form.action="recherche.php?id=1&query=" + reg+";"+vil
	

	return noerror;
}

//------------------------------------------------
//------------------------------------------------
//------------------------------------------------

function trim(val)
{
	if (!val) return val;

		while(val.charAt(0)==' ') val=val.substring(1,val.length);
		while(val.charAt(val.length-1)==' ')  val=val.substring(0,val.length-1);
		
	 return val;
}

function strip_tags(val)
{
	return val.replace(/[\<\>]/gi, "")
}

function CleNombre(nomFormulaire, nomObject)
{
	eval("var oCurrentNombre = document."+nomFormulaire+"."+nomObject);
	oCurrentNombre.value = oCurrentNombre.value.split(/[^\d]/i).join("");
	return true;
}

function Espace(nomFormulaire, nomObject)
{
	eval("var oCurrentNombre = document."+nomFormulaire+"."+nomObject);
	oCurrentNombre.value = oCurrentNombre.value.split(" ").join("");
	return true;
}

villesRegionAvant=null
villesRegionAvantannonce=null
function changeRegion(quelleRegion,page)
{
	if (quelleRegion=="select")
	quelleRegion=-1
	
	eval("noRegionAvant=villesRegionAvant"+page)
	
	if (quelleRegion!=-1)
	{
		eval("villes"+page+"=document.getElementById('"+page+"villes"+quelleRegion+"').style")
		eval("villes"+page+".display='block'")
		
		if (page=="annonce")
		displayTitre="block"
	}
	else if (page=="annonce")
	displayTitre="none"
	
	if (page=="annonce")
	{
		titreVilles=document.getElementById("titresVille").style
		titreVilles.display=displayTitre
	}
	
	if (noRegionAvant && noRegionAvant!=-1)
	{
		eval("villesAvant"+page+"=document.getElementById('"+page+"villes"+noRegionAvant+"').style")
		eval("villesAvant"+page+".display='none'")
		
		eval("listeVillesAvant"+page+"=document.getElementById('"+page+"listeVilles"+noRegionAvant+"')")
		eval("listeVillesAvant"+page+".selectedIndex=0")
	}
	
	eval("villesRegionAvant"+page+"="+quelleRegion)
	
	document.rechercheRegion_form.reg.value=quelleRegion;
}

function changeRegion2(quelleRegion,page)
{
	if (quelleRegion=="select")
	quelleRegion=-1
	
	eval("noRegionAvant=villesRegionAvant"+page)
	
	if (quelleRegion!=-1)
	{
		eval("villes"+page+"=document.getElementById('"+page+"villes"+quelleRegion+"').style")
		eval("villes"+page+".display='block'")
		
		if (page=="annonce")
		displayTitre="block"
	}
	else if (page=="annonce")
	displayTitre="none"
	
	if (page=="annonce")
	{
		titreVilles=document.getElementById("titresVille").style
		titreVilles.display=displayTitre
	}
	
	if (noRegionAvant && noRegionAvant!=-1)
	{
		eval("villesAvant"+page+"=document.getElementById('"+page+"villes"+noRegionAvant+"').style")
		eval("villesAvant"+page+".display='none'")
		
		eval("listeVillesAvant"+page+"=document.getElementById('"+page+"listeVilles"+noRegionAvant+"')")
		eval("listeVillesAvant"+page+".selectedIndex=0")
	}
	
	eval("villesRegionAvant"+page+"="+quelleRegion)
	
	document.rech_avancee.reg.value=quelleRegion;
}

function changeVille(quelleVille){

		document.rechercheRegion_form.vil.value=quelleVille;
}

function changeVille2(quelleVille){

		document.rech_avancee.vil.value=quelleVille;
}

function validationLogin(type)
{
	nobug=true
	msg=""
	
	leForm=eval("document.login_form")
	
	nom=leForm.nom.value=trim(leForm.nom.value)
	pwd=leForm.pwd.value=trim(leForm.pwd.value)
	
	if (nom=="")
	{
		msg+="Veuillez entrer votre nom d'utilisateur\n"
		bug("nom")
	}
	
	if (pwd=="")
	{
		msg+="Veuillez entrer un mot de passe\n"
		bug("pwd")
	}
	
	if (!nobug)
	alert(msg)
	
	return nobug;
}

function bug(champ)
{
	if (nobug)
	eval("leForm."+champ+".focus()")
	
	nobug=false
}

function valide_rechavancee(){
	var nobug=true;
	
	var query=trim(document.rech_avancee.query.value);

	var sexe=parseInt(document.rech_avancee.sexe_v.value);
	var region=parseInt(document.rech_avancee.reg.value);
	var ville=parseInt(document.rech_avancee.vil.value);

	if ((query=='' || (document.rech_avancee.r1.checked !=true && document.rech_avancee.r2.checked!=true))  && isNaN(sexe) && isNaN(region) && isNaN(ville))
	nobug=false;
	
	return nobug;
}

function changeSexe(valeur){
	document.rech_avancee.sexe_v.value=valeur;
}

function envoyer(path)
{
	largeurF=600
	hauteurF=150
	
	leleft=(screen.width-largeurF)/2
	letop=(screen.height-hauteurF)/2
	
	envoyerSite=window.open(path+"envoyersite.php" , "envoyerSite", "width="+largeurF+",height="+hauteurF+",toolbar=0,scrollbars=1,statusbar=0,menubar=0,resizable=0,left="+leleft+",top="+letop+"");
	envoyerSite.focus()
}

function sizeEnvoyerSite()
{
	window.resizeTo(600,220);
}

maxEmail=10
function ajoutAmis(no,type)
{
	document.envoyerAmi_form.nbEmail.value=parseInt(document.envoyerAmi_form.nbEmail.value)+1
	
	document.getElementById('btnAjout'+(no-1)).style.visibility="hidden";
	
	nextEmail='';
	nextEmail+='<table width="100%" cellpadding="0" align="center" cellspacing="5" border="0">';
		nextEmail+='<tr align="center">';
			nextEmail+='<td width="20%">Ami N&deg;'+no+':</td>';
			nextEmail+='<td><input type="text" name="email'+no+'" maxlength="50" size="60" /></td>';
			nextEmail+='<td class="lien"><a href="javascript:ajoutAmis('+(no+1)+','+type+')" id="btnAjout'+no+'" alt="Ajout" title="Ajout">Ajout</a></td>';
		nextEmail+='</tr>';
	nextEmail+='</table>';
	nextEmail+='<div id="leEmail'+(no+1)+'">';
		nextEmail+='<input class="bouton" type="submit" value="Envoyer" />';
	nextEmail+='</div>';
	
	//document.getElementById('leEmail'+no).innerHTML="<table width='100%' cellpadding='0' align='center' cellspacing='5' border='0'><tr align='center'><td width='20%'>Ami N&deg;"+no+":</td><td><input type='text' name='email"+no+"' maxlength='50' size='60' /></td><td class='lien'><a href='javascript:ajoutAmis("+(no+1)+","+type+");' id='btnAjout"+no+"' alt='Ajout' title='Ajout'>Ajout</a></td></tr></table><div id='leEmail"+(no+1)+"'></div>"
	document.getElementById('leEmail'+no).innerHTML=nextEmail;
	
	if (type)
	window.resizeBy(0,35);
	
	if (no>=maxEmail)
	document.getElementById('btnAjout'+no).style.visibility="hidden";
}