// JavaScript Document

<!--
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]))!=Void){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
function Controle_contact(){
			
			var email=document.contact.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
			

		if(document.contact.name.value==''){
		
					alert('Vérifier le champ nom & prénom!');
					document.contact.name.focus();
					
					return false;
					
				}	
		else if(document.contact.country.value==''){
		
					alert('Vérifier le champ pays !');
					document.contact.country.focus();
					
					return false;
					
				}	
		else if(document.contact.tel.value!='' && isNaN(document.contact.tel.value)){
		
					alert('Vérifier le champ tel !');
					document.contact.tel.focus();
					
					return false;
					
				}	
	
		else if((at < 3)||(point + 2 > email.length)||(point < at+3))
						
							{
							alert('Vérifier le champ e-mail !');
							document.contact.email.focus();
								return false;
							}	
		else if(document.contact.subject.value==''){
		
					alert('Vérifier le champ sujet !');
					document.contact.subject.focus();
					return false;
					
				}	
		else if(document.contact.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.contact.captcha.focus();
					return false;
					
				}	
						
		else{
			
			document.contact.action="?inc=contact";
			document.contact.submit();
			return true;
			
			}
 	 }
function Controle_propose_biz(){
	
			var email=document.propose_biz.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
		
		if(document.propose_biz.ope.value==''){
		
					alert('Veuillez choisir une opération !');
					document.propose_biz.operation.focus();
					return false;
				}	
				
		
		else if(document.propose_biz.category.value=='Sélectionner'){
		
					alert('Veuillez choisir une catégorie !');
					document.propose_biz.category.focus();
					return false;
				}	
				
		
		else if(document.propose_biz.area.value==''){
		
					alert('Vérifier le champ region !');
					document.propose_biz.area.focus();
					return false;
				}
				
		else if(document.propose_biz.city.value==''){
		
					alert('Vérifier le champ ville !');
					document.propose_biz.city.focus();
					return false;
				}
				
	else if(document.propose_biz.price.value==''){
		
					alert('Veuillez champ prix !');
					document.propose_biz.price.focus();
					return false;
				}		
			
	else if(document.propose_biz.name.value==''){
		
					alert('Vérifier le champ Nom & prénom !');
					document.propose_biz.name.focus();
					return false;
				}
		else if(document.propose_biz.tel.value=='' || isNaN(document.propose_biz.tel.value)){
		
					alert('Vérifier le champ Téléphone !');
					document.propose_biz.tel.focus();
					return false;
				}
		
		else if(((at < 3)||(point + 2 > email.length)||(point < at+3)) || (email==''))
						
							{
							alert('Vérifier le champ e-mail !');
							document.propose_biz.email.focus();
								return false;
							}	
		else if(document.propose_biz.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.propose_biz.captcha.focus();
					return false;
					
				}	
									
				
		else{
			
			
			
			document.propose_biz.action="?inc=propose";
			document.propose_biz.submit();
			return true;
			
			}
			
	}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function popuptarget(url,name,width,height) {
var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
new_window = window.open(url, name, options);
window.self.name = "main";
new_window.moveTo(((screaten.availWidth/2)-(width/2)),((screaten.availHeight/2)-(height/2)))
new_window.focus();
}
function PopupImage(img) { 
title="Agrandissement"; 
w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
w.document.write("<HTML><HEAD><TITLE>"+title+"</TITLE></HEAD>"); 
w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
w.document.write("<BODY onload='checksize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
w.document.write("<TD valign='middle' align='center'><IMG src='"+img+"' border=0 alt='Mon image'>"); 
w.document.write("</TD></TR></TABLE>");
w.document.write("</BODY></HTML>"); 
w.document.close(); 
}
function show_gal(){
	
	if(document.show_gallery.check.checked==true){
		
		document.getElementById("dhtmlgoodies_slideshow").style.display='none';
		document.getElementById("title_check").innerHTML='Afficher la galerie photo';
		}
	
	else {document.getElementById("dhtmlgoodies_slideshow").style.display='';
		document.getElementById("title_check").innerHTML='Masquer la galerie photo';}
	
	}
function controle_order(){
			
			var email=document.order.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
			

		if(document.order.name.value==''){
		
					alert('Vérifier le champ nom & prénom!');
					document.order.name.focus();
					
					return false;
					
				}	
		else if(document.order.country.value==''){
		
					alert('Vérifier le champ pays !');
					document.order.country.focus();
					
					return false;
					
				}	
		else if(document.order.tel.value!='' && isNaN(document.order.tel.value)){
		
					alert('Vérifier le champ tel !');
					document.order.tel.focus();
					
					return false;
					
				}	
	
		else if((at < 3)||(point + 2 > email.length)||(point < at+3))
						
							{
							alert('Vérifier le champ e-mail !');
							document.order.email.focus();
								return false;
							}	
		else if(document.order.announce.value==''){
		
					alert('Vérifier le champ annonce !');
					document.order.announce.focus();
					return false;
					
				}	
		else if(document.order.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.order.captcha.focus();
					return false;
					
				}	
						
		else{
			
			document.order.action="?inc=order";
			document.order.submit();
			return true;
			
			}
 	 }
function controle_sendTofriend(){
			
			var email=document.sendTofriend.email_friend.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
			

		if(document.sendTofriend.your_name.value==''){
		
					alert('Vérifier le champ Votre nom !');
					document.sendTofriend.your_name.focus();
					
					return false;
					
				}	
		else if((document.sendTofriend.email_friend.value=='') || ((at < 3)||(point + 2 > email.length)||(point < at+3))){
		
					alert('Vérifier le champ Email de votre ami !');
					document.sendTofriend.email_friend.focus();
					
					return false;
					
				}	
		else if(document.sendTofriend.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.sendTofriend.captcha.focus();
					return false;
					
				}	
		
		else{
			
			document.sendTofriend.action="#";
			document.sendTofriend.submit();
			return true;
			
			}
 	 }
function Controle_auth(){	
			
		if(document.auth.username.value==''){
		
					alert('Vérifier le champ identifiant !');
					document.auth.username.focus();
					return false;
				}	
		else if(document.auth.password.value==''){
		
					alert('Vérifier le champ mot de passe !');
					document.auth.password.focus();
					return false;
				}				
		else{
			
			document.auth.action="login.php";
			document.auth.submit();
			
			
			}
 	 }
function accept_licence(){
			
			if(document.signup.accept.checked==true){
			
				document.signup.btn_signup.disabled=false;				
	
				}
			
			else{
						
			document.signup.btn_signup.disabled=true;	
			
				
				}
 	 }
function Controle_signup(){
			
			var email=document.signup.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
			

		
		if(document.signup.agency.value==''){
		
					alert('Vérifier le champ Agence !');
					document.signup.agency.focus();
					
					return false;
					
				}	
		else if(document.signup.name.value==''){
		
					alert('Vérifier le champ nom & prénom!');
					document.signup.name.focus();
					
					return false;
					
				}	
		else if(document.signup.tel.value!='' && isNaN(document.signup.tel.value)){
		
					alert('Vérifier le champ tel !');
					document.signup.tel.focus();
					
					return false;
					
				}	
	
		else if((at < 3)||(point + 2 > email.length)||(point < at+3))
						
							{
							alert('Vérifier le champ e-mail !');
							document.signup.email.focus();
								return false;
							}	
		else if(document.signup.username.value==''){
		
					alert('Vérifier le champ Identifiant !');
					document.signup.username.focus();
					return false;
				}
		else if(document.signup.password.value==''){
		
					alert('Vérifier le champ mot de passe !');
					document.signup.password.focus();
					return false;
				}
		else if(document.signup.password.value.length<6){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.signup.password.focus();
					return false;
				}
		
		else if(document.signup.conf_password.value==''){
		
					alert('Vérifier le champ Confirmer mot de passe !');
					document.signup.conf_password.focus();
					return false;
				}				
		
		else if(document.signup.conf_password.value.length<6){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.signup.conf_password.focus();
					return false;
				}
		
		else if(document.signup.password.value!=document.signup.conf_password.value){
		
					alert('Vérifier que le champ mot de passe est bien confirmé  !');
					document.signup.conf_password.focus();
					return false;
				}
		else if(document.signup.signup_jx_email.value==2){
		
					alert('Vous avez introduit des données qui sont déjà existées \n Voir (Champ E-mail) !');
						
					document.signup.email.focus();
					return false;
				}
		else if(document.signup.signup_jx_email.value==3){
		
					alert('Vous avez introduit des données qui sont incorrecte \n Voir (Champ E-mail) !');
						
					document.signup.email.focus();
					return false;
				}
					
		else if(document.signup.signup_jx_username.value==2){
		
					alert('Vous avez introduit des données qui sont déjà existées \n Voir (Champ Identifiant) !');
					document.signup.username.focus();
					return false;
				}
		else if(document.signup.signup_jx_username.value==3){
		
					alert('Vous avez introduit des données qui sont incorrecte \n Voir (Champ Identifiant) !');
					document.signup.username.focus();
					return false;
				}
		else if(document.signup.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.signup.captcha.focus();
					return false;
					
				}	
						
		else{
			
			document.signup.action="?inc=signup";
			document.signup.submit();
			return true;
			
			}
 	 }
function Controle_myprofile(){
			
			var email=document.myprofile.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");
			

		if(document.myprofile.agency.value==''){
		
					alert('Vérifier le champ Agence !');
					document.myprofile.agency.focus();
					
					return false;
					
				}	
		else if(document.myprofile.name.value==''){
		
					alert('Vérifier le champ nom & prénom!');
					document.myprofile.name.focus();
					
					return false;
					
				}	
		else if(document.myprofile.city.value==''){
		
					alert('Vérifier le champ ville !');
					document.myprofile.city.focus();
					
					return false;
					
				}	
		else if(document.myprofile.tel.value!='' && isNaN(document.myprofile.tel.value)){
		
					alert('Vérifier le champ tel !');
					document.myprofile.tel.focus();
					
					return false;
					
				}	
	
		else if((at < 3)||(point + 2 > email.length)||(point < at+3))
						
							{
							alert('Vérifier le champ e-mail !');
							document.myprofile.email.focus();
								return false;
							}	
		
		else if(document.myprofile.last_pwd.value=='' && document.myprofile.new_pwd.value!=''){
		
					alert('Vérifier le champ mot de passe !');
					document.myprofile.last_pwd.focus();
					return false;
				}
		else if(document.myprofile.last_pwd.value.length<6 && document.myprofile.new_pwd.value!=''){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.myprofile.last_pwd.focus();
					return false;
				}
		else if(document.myprofile.new_pwd.value.length<6 && document.myprofile.new_pwd.value!=''){
		
					alert('Le nouveau mot de passe doit comporter entre 6 caractères et plus !');
					document.myprofile.new_pwd.focus();
					return false;
				}
		
		else if(document.myprofile.conf_pwd.value=='' && document.myprofile.new_pwd.value!=''){
		
					alert('Vérifier le champ Confirmer mot de passe !');
					document.myprofile.conf_pwd.focus();
					return false;
				}				
		
		else if(document.myprofile.conf_pwd.value.length<6 && document.myprofile.new_pwd.value!=''){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.myprofile.conf_pwd.focus();
					return false;
				}
		
		else if(document.myprofile.new_pwd.value!=document.myprofile.conf_pwd.value){
		
					alert('Vérifier que le champ mot de passe est bien confirmé  !');
					document.myprofile.conf_pwd.focus();
					return false;
				}
		else if(document.myprofile.update_profile_jx_email.value==2){
		
					alert('Vous avez introduit des données qui sont déjà existées \n Voir (Champ E-mail) !');
						
					document.myprofile.email.focus();
					return false;
				}
		else if(document.myprofile.update_profile_jx_email.value==3){
		
					alert('Vous avez introduit des données qui sont incorrecte \n Voir (Champ E-mail) !');
						
					document.myprofile.email.focus();
					return false;
				}
					
			
		else{
			
			document.myprofile.action="?inc=MyProfile";
			document.myprofile.submit();
			return true;
			
			}
 	 }
///////////////////////////////AJAX/////////////////////////////////////


function writediv_email(texte)
		
			{
		document.getElementById('error_email').innerHTML = texte;
			}
			
function writediv_username(texte)
		
			{
		document.getElementById('error_username').innerHTML = texte;
			}

function verifEmail_signup(email)
   
     {

	texte = file('ajax_verification.php?email='+escape(email));

		
		if(email == ''){
		  		
				document.signup.signup_jx_email.value="2";
                writediv_email('');}
		else if(texte == 1){
		  		
				document.signup.signup_jx_email.value="2";
                writediv_email('Désolé, Votre E-mail est déjà existé !');}
		else if(texte == 3){
		  		
				document.signup.signup_jx_email.value="3";
                writediv_email('Désolé, Votre E-mail est incorrecte !');}
		
        else{  
		  	
			document.signup.signup_jx_email.value="1";
                writediv_email(''); }
						   
     }
	 
function verifUsername_signup(username)
   
     {
	 
	 
       texte = file('ajax_verification.php?username='+escape(username));

                  
        if(username == ''){
			
			document.signup.signup_jx_username.value="2";
               writediv_username('');}
	   
	   else if(texte == 1){
			
			document.signup.signup_jx_username.value="2";
               writediv_username('<b>'+username+' :</b> ce identifiant est déjà pris');}
		else if(texte == 3){
			
			document.signup.signup_jx_username.value="2";
               writediv_username('<b>'+username+' :</b> ce identifiant est incorrecte');}
		 
         
		 else{ document.signup.signup_jx_username.value="1";
               writediv_username(''); }
					   
     }
function verifEmail_updateProfile(email)
   
     {

	texte = file('ajax_verification.php?email='+escape(email));

		
		if(email == ''){
		  		
				document.myprofile.update_profile_jx_email.value="2";
                writediv_email('');}
		else if(texte == 1 &&  (document.myprofile.email.value!=document.myprofile.current_email.value)){
		  		
				document.myprofile.update_profile_jx_email.value="2";
                writediv_email('Désolé, Votre E-mail est déjà existé !');}
		
		else if(texte == 3){
		  		
				document.myprofile.update_profile_jx_email.value="3";
                writediv_email('Désolé, Votre E-mail est incorrecte !');}
				
        else{  
		  	
			document.myprofile.update_profile_jx_email.value="1";
                writediv_email(''); }
						   
     }
	 function file(file)
     {
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest(); 
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
     else 
          return(false); 
     xhr_object.open("GET", file, false); 
     xhr_object.send(null); 
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
     }
///////////////////////////////////////////////////////////////////////////////////////////////	 

function Controle_add_property(){
	
		if(document.add_property.operation.value=='?inc=MyProperties&inc=property&task=add'){
		
					alert('Veuillez choisir un type d\'opération !');
					document.add_property.operation.focus();
					return false;
				}				
	
		else if(document.add_property.category.value=='select'){
		
					alert('Veuillez choisir une catégorie !');
					document.add_property.category.focus();
					return false;
				}	
		
		else if(document.add_property.city.value==''){
		
					alert('Vérifier le champ ville !');
					document.add_property.city.focus();
					return false;
				}
		else if((document.add_property.price.value=='' || isNaN(document.add_property.price.value)) && document.add_property.price.disabled==false){
	
					alert('Veuillez champ prix !');
					document.add_property.price.focus();
					return false;
				}	
				
		else{
			document.add_property.action="?inc=MyProperties";
			document.add_property.submit();
			return true;
			
			}
			
	}
function Controle_update_property(){
	
		if(document.update_property.operation.value=='?load=admin&inc=property&task=update'){
		
					alert('Veuillez choisir un type d\'opération !');
					document.update_property.operation.focus();
					return false;
				}				

	
	else if(document.update_property.category.value=='select'){
		
					alert('Veuillez choisir une catégorie !');
					document.update_property.category.focus();
					return false;
				}	
				
		else if(document.update_property.city.value==''){
		
					alert('Vérifier le champ ville !');
					document.update_property.city.focus();
					return false;
				}
	
	else if((document.update_property.price.value=='' || isNaN(document.update_property.price.value))  && document.update_property.price.disabled==false){
		
					alert('Veuillez champ prix !');
					document.update_property.price.focus();
					return false;
				}	
				
		else{
			document.update_property.action="?inc=MyProperties";
			document.update_property.submit();
			return true;
			
			}
			
	}
function Controle_number_images(nbr,operation,category){
	

	if(isNaN(document.add_property.nbr_images.value)){
		
		alert('Veuillez introduire une valeur numérique !');
			
			}
	else if(document.add_property.nbr_images.value>document.add_property.nbr_picture_allowed.value){
		
			alert('Vous êtes autorisé à uploader juste '+document.add_property.nbr_picture_allowed.value+' photos (et en format *.jpg) !');
			
			}
	
	else
	
	document.location="?inc=MyProperties&task=add&nbr_image="+nbr+"&operation="+operation+"&category="+category+"";
	
	}
function Controle_number_images_update(nbr,operation,category,id_property){
	

	if(isNaN(document.update_property.nbr_images.value)){
		
		alert('Veuillez introduire une valeur numérique !');
			
			}
	else if(document.update_property.nbr_images.value>document.update_property.nbr_picture_allowed.value){
		
			alert('Vous êtes autorisé à uploader juste '+document.update_property.nbr_picture_allowed.value+' photos (et en format *.jpg) !');
			
			}
	else
	document.location="?inc=MyProperties&task=update&id_property="+id_property+"&nbr_image="+nbr+"&operation="+operation+"&category="+category+"";
	
	}

function disabled_field(){
	
				if(document.update_property.noprice.checked==true){
					  document.update_property.price.value='';
					  document.getElementById('price').disabled=true; 
					  document.getElementById('price').style.backgroundColor ='#DDDDDD';
					  }
				  else{
					  document.getElementById('price').disabled=false;
					  document.getElementById('price').style.backgroundColor ='#FFFFFF';
					}
					
				}
function Controle_search_property(){
						
		if(document.search_form.search.value==''){
		
					alert('Veuillez introduire un critère pour votre search!');
					document.search_form.search.focus();
					return false;
					
				}	
		
		else{

			document.search.action="?inc=MyProperties";
			document.search.submit();
			return true;
			
			}
 	 }	
function Controle_search_agent(){
						
		if(document.search_form.search.value==''){
		
					alert('Veuillez introduire un critère pour votre search!');
					document.search_form.search.focus();
					return false;
					
				}	
		
		else{

			document.search.action="?inc=agent";
			document.search.submit();
			return true;
			
			}
 	 }		 
function delete_property(id){

	if(confirm("êtes-vous sûr de supprimer ce bien ?")){
			
			document.location="?inc=MyProperties&task=delete&id_property="+id+"";
			
	}
	
	else {return false;}

}
function show_agent(){
	
	if(document.show_agentInfo.check.checked==true){		
	
		document.getElementById("tab_details").style.display='';
	
	}
	
	else {
	
	document.getElementById("tab_details").style.display='none';
	}
		
}
function Controle_forgot_password(){
	
	var email=document.forgot_password.email.value;
			
		    var at = email.indexOf("@");
			var point = email.lastIndexOf(".");

	if((at < 3)||(point + 2 > email.length)||(point < at+3) || document.forgot_password.email.value=='')
						
							{
							alert('Vérifier le champ e-mail !');
							document.forgot_password.email.focus();
								return false;
							}	
	else if(document.forgot_password.captcha.value==''){
		
					alert('Vérifier le champ code !');
					document.forgot_password.captcha.focus();
					return false;
					
				}	

	else{ 	
			document.forgot_password.action="#";
			document.forgot_password.submit();
			return true;
			
	}

		
}
function Controle_number_images_propose(nbr,operation,category,id_property){
	

	if(isNaN(document.propose.nbr_images.value)){
		
		alert('Veuillez introduire une valeur numérique !');
			
			}
	else if(document.propose.nbr_images.value>document.propose.nbr_picture_allowed.value){
		
			alert('Vous êtes autorisé à uploader juste '+document.propose.nbr_picture_allowed.value+' photos (et en format *.jpg) !');
			
			}
	else
	document.location="?inc=propose&nbr_image="+nbr+"";
	
}