// JavaScript Document

function Controle_login(){	
			
		if(document.access.login.value==''){
		
					alert('Vérifier le champ identifiant !');
					document.access.login.focus();
					return false;
				}	
		else if(document.access.password.value==''){
		
					alert('Vérifier le champ Mot de passe !');
					document.access.password.focus();
					return false;
				}				
		
		else{
			document.access.action="?load=login";
			document.access.submit();
			return true;
			
			}
 	 }

function Controle_add_news(){
	
	if(document.add_news.title_fr.value=='' || document.add_news.title_es.value=='' || document.add_news.title_en.value==''){
		
					alert('Veuillez laisser un titre !');
					return false;
				}	
	else if(document.add_news.content_fr.value=='' || document.add_news.content_es.value=='' || document.add_news.content_en.value==''){
		
					alert('Veuillez laisser le contenu !');
					return false;
				}	
		else{
			document.add_news.action="?load=admin&inc=news";
			document.add_news.submit();
			return true;
			
			}
			
	
	}
	
function Controle_update_news(){
	
	if(document.update_news.title_fr.value=='' || document.update_news.title_es.value=='' || document.update_news.title_en.value==''){
		
					alert('Veuillez laisser un titre  !');
					return false;
				}	
	else if(document.update_news.content_fr.value=='' || document.update_news.content_es.value=='' || document.update_news.content_en.value==''){
		
					alert('Veuillez laisser le contenu !');
					return false;
				}	
		else{
			document.update_news.action="?load=admin&inc=news";
			document.update_news.submit();
			return true;
			
			}
			
	
	}
function Controle_update_metas(){
	
	if(document.update_metas.keywords_fr.value=='' || document.update_metas.keywords_es.value=='' || document.update_metas.keywords_en.value==''){
		
					alert('Veuillez laisser des mots clés !');
					return false;
				}	
	else if(document.update_metas.description_fr.value=='' || document.update_metas.description_es.value=='' || document.update_metas.description_en.value==''){
		
					alert('Veuillez laisser la description !');
					return false;
				}	
		else{
			document.update_metas.action="?load=admin&inc=metas";
			document.update_metas.submit();
			return true;
			
			}
			
	
	}
function Controle_create_category(){
	
	
	if(document.create_category.operation.value=='select'){
		
					alert('Veuillez choisir un type d\'opération !');
					document.create_category.operation.focus();
					return false;
				}	
	else if(document.create_category.name_fr.value=='' || document.create_category.name_es.value=='' || document.create_category.name_en.value==''){
		
					alert('Vérifier le champ nom de la catégorie !');
					return false;
				}	
		else{
			document.create_category.action="?load=admin&inc=category";
			document.create_category.submit();
			return true;
			
			}
			
	}
function Controle_update_category(){
	
	
	if(document.update_category.operation.value=='select'){
		
					alert('Veuillez choisir un type d\'opération !');
					document.update_category.operation.focus();
					return false;
				}	
	else if(document.update_category.name_fr.value=='' || document.update_category.name_es.value=='' || document.update_category.name_en.value==''){
		
					alert('Vérifier le champ nom de la catégorie !');
					return false;
				}				
				
		else{
			document.update_category.action="?load=admin&inc=category";
			document.update_category.submit();
			return true;
			
			}
			
	}
function delete_category(id){

	if(confirm("êtes-vous sûr de supprimer cette catégorie ? \n Attention : Quand on supprime une catégorie c-à-d que tous les biens de cette catégorie seront supprimés avec !")){
			
			document.location="?load=admin&inc=category&task=delete&id_category="+id+"";
			
	}
	
	else {return false;}

}
function delete_property(id){

	if(confirm("êtes-vous sûr de supprimer ce bien ?")){
			
			document.location="?load=admin&inc=property&task=delete&id_property="+id+"";
			
	}
	
	else {return false;}

}
function delete_news(id){
	
	if(confirm("êtes-vous sûr de supprimer cette actualité ?")){
			
			document.location="?load=admin&inc=news&task=delete&id_news="+id+"";
			
	}
	
	else {return false;}
}
function Controle_create_operation(){
	
	if(document.create_operation.name_fr.value=='' || document.create_operation.name_es.value=='' || document.create_operation.name_en.value==''){
		
					alert('Vérifier le champ nom de l\'opération !');
					return false;
				}				
		
		else{
			document.create_operation.action="?load=admin&inc=operation";
			document.create_operation.submit();
			return true;
			
			}
			
	}
function Controle_update_operation(){
	
	if(document.update_operation.name_fr.value=='' || document.update_operation.name_es.value=='' || document.update_operation.name_en.value==''){
		
					alert('Vérifier le champ nom de la catégorie !');
					return false;
				}				
		
		else{
			document.update_operation.action="?load=admin&inc=operation";
			document.update_operation.submit();
			return true;
			
			}
			
	}
function Controle_add_property(){
	
		if(document.add_property.operation.value=='?load=admin&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 price !');
					document.add_property.price.focus();
					return false;
				}	
				
		else{
			document.add_property.action="?load=admin&inc=property";
			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 price !');
					document.update_property.price.focus();
					return false;
				}	
				
		else{
			document.update_property.action="?load=admin&inc=property";
			document.update_property.submit();
			return true;
			
			}
			
	}

function delete_operation(id){

	if(confirm("êtes-vous sûr de supprimer ce type d'opération ?")){
			
			document.location="?load=admin&inc=operation&task=delete&id_operation="+id+"";
			
	}
	
	else {return false;}

}
function Controle_number_images(nbr,operation,category){
	

	if(isNaN(document.add_property.nbr_images.value)){
		
		alert('Veuillez introduire une valeur numérique !');
			
			}
	else
	
	document.location="?load=admin&inc=property&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
	document.location="?load=admin&inc=property&task=update&id_property="+id_property+"&nbr_image="+nbr+"&operation="+operation+"&category="+category+"";
	
	}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function Controle_update_profile(){
			
		if(document.update_profile.login.value==''){
		
					alert('Vérifier le champ Identifiant !');
					document.update_profile.login.focus();
					return false;
				}	
		
		else if(document.update_profile.last_pwd.value==''){
		
					alert('Vérifier le champ Ancien Mot de passe !');
					document.update_profile.last_pwd.focus();
					return false;
				}	
		else if(document.update_profile.last_pwd.value.length<6){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.update_profile.last_pwd.focus();
					return false;
				}
		
		else if(document.update_profile.new_pwd.value==''){
		
					alert('Vérifier le champ Nouveau mot de passe !');
					document.update_profile.new_pwd.focus();
					return false;
				}
		else if(document.update_profile.new_pwd.value.length<6){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.update_profile.new_pwd.focus();
					return false;
				}
		
		else if(document.update_profile.conf_pwd.value==''){
		
					alert('Vérifier le champ Confirmer mot de passe !');
					document.update_profile.conf_pwd.focus();
					return false;
				}				
		
		else if(document.update_profile.conf_pwd.value.length<6){
		
					alert('Le mot de passe doit comporter entre 6 caractères et plus !');
					document.update_profile.conf_pwd.focus();
					return false;
				}
		
		else if(document.update_profile.new_pwd.value!=document.update_profile.conf_pwd.value){
		
					alert('Vérifier que le champ mot de passe est property confirmé  !');
					document.update_profile.conf_pwd.focus();
					return false;
				}
		
		
		else{
			document.update_profile.action="?load=admin&inc=profile";
			document.update_profile.submit();
			return true;
			
			}
 	 }
function deconnecter(){

	if(confirm("êtes-vous sûr de se déconnecter ? ")){
			
			document.location="?logout=yes";
			
	}
	
	else {return false;}

}

function PopupImage(img) { 
title="Zoom"; 
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 Controle_search(){
			
			
		if(document.search.search.value==''){
		
					alert('Veuillez introduire un critère pour votre search!');
					document.search.search.focus();
					return false;
				}	
		
		else{
			document.search.action="?load=admin&inc=property";
			document.search.submit();
			return true;
			
			}
 	 }
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 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';
					}
					
				}
