var  envoi = false ;
function  affiche_photo(x) {
	var chemin ='defile.php?id='+x ;
	envoi = window.open(chemin,'PHOTOS','height=500,width=600');
}

function PopupImage(img) { 
	titre="Agence Altis";
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</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+60); window.focus();} else { setTimeout('checksize()',1250) } }</"+"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='Agence Altis'>"); 
	w.document.write("</TD></TR></TABLE>");
	w.document.write("</BODY></HTML>"); 
	w.document.close(); 
} 


function retour() {
	window.history.back();
}
//koddi 20060622
function PopupPicture(URL) { 

 // hauteur=300;
  //largeur=300;563

  hauteur=853;
  largeur=375;
  var top=(screen.height-hauteur)/2;
  var left=(screen.width-largeur)/2;
  window.open("popup.php?"+URL, "", "top="+top+",left="+left+",width="+largeur+",height="+hauteur+",resizable=1");
}
function get_element(id)
{
if (document.getElementById) 
myElementRef = document.getElementById(id);
else if (document.all) myElementRef = document.all[id]; 
else if (document.layers) myElementRef = document.layers[id];
return myElementRef;
}
//---------------------------------------------------
//fonction de la suppression d'une annonce
function verify(){ 
msg = "ATTENTION, vous êtes sur le point de supprimer dévinitivement une annonce, \"OK\" pour valider votre choix, ou \"ANNULER\""; 
return confirm(msg); 
} 

// fonbction  disabled
function pocheck(){
	var nom  = document.form.nom.value.replace(/(^\s*)|(\s*$)/g,''); 
	//var prenom  = document.form.prenom.value.replace(/(^\s*)|(\s*$)/g,''); 
	var email  = document.form.email.value.replace(/(^\s*)|(\s*$)/g,'');
	var phone  = document.form.phone.value.replace(/(^\s*)|(\s*$)/g,''); 	 	

if (nom!='' && email!='' && phone!='' && document.form.control.value!=''){
document.form.envoi.disabled=false; 
	}
else{
document.form.envoi.disabled=true; 	
}
}


//fonction de validation des champs du formulaire	contact.php
function estnum(y) {
	var temoin="0123456789/"
	for (i=0;i<y.length;i++) {
		c=y.substring(i,i+1)
		if (temoin.indexOf(c,0)==-1) return false
	}
	return true
}
function validForm() {
//contrôle des champs obligatoires
	if (document.form.nom.value=='') {
		alert ("Merci de saisir votre Nom")
		document.form.nom.focus();
		return false;
	}
	if (document.form.adresse.value=='') {
		alert ("Merci de saisir votre adresse")
		document.form.adresse.focus();
		return false;
	}
	if (document.form.ville.value=='') {
		alert ("Merci de saisir votre Ville")
		document.form.ville.focus();
		return false;
	}

	if (document.form.email.value=='') {
		alert ("Merci de saisir une adresse Mail valide")
		document.form.email.focus();
		return false;
	}    
	if (document.form.commentaire.value=='') {
		alert ("Merci de saisir votre Commentaire")
		document.form.commentaire.focus();
		return false;
	}
	return true;
}

function validIdForm() {
	var oForm = document.form_id;
	if (oForm.agentname.value=='') {
		alert ("Merci de saisir votre Login")
		oForm.agentname.focus();
		return false;
	}
	if (oForm.agentpassword.value=='') {
		alert ("Merci de saisir votre Mot de passe")
		oForm.agentpassword.focus();
		return false;
	}
	return true;
}

function validRech() {
//contrôle des champs obligatoires
	if (document.rech.title.value==''){
		alert ("Merci de choisir une Rubrique")
		document.rech.title.focus();
		return false;
	}
	
	if (document.rech.typechoice.value==''){
		alert ("Merci de choisir le Type de bien")
		document.rech.typechoice.focus();
		return false;
	}
	if (document.rech.state.value==''){
		alert ("Merci de choisir un Département")
		document.rech.state.focus();
		return false;
	}
	return true;
}


//function check_spam

function check_spam(){
		var interdit=document.form.commentaire.value;
		var interdit=interdit.toLowerCase();

	  if ((interdit.indexOf("[/url]")>=0)||(interdit.indexOf("http://")>=0)||(interdit.indexOf("url=")>=0)) {
         alert("Commentaire invalide !");
		}
		else{
		check_control();
		//document.form.submit();
		}

}

function check_control(){
if(form.control.value==form.control_rep.value){
		form.submit();
		}
		else{
		form.control.focus();
		alert("Réponse fausse dans le contrôle anti-spam : merci de vérifier votre calcul...");
		}
}
