//VERIFICATION TELEPHONE FAX
function verifierTelephone(input){
	if(input.value.length==10){
		var reg = new RegExp('^[0-9]{10}$','g');
		if(reg.test(input.value)){
			return true;
		}else{
			window.alert("Votre numéro de "+input.id+" doit être composé de 10 chiffres.");
			input.style.backgroundColor="#f6cb62";
			return false;
		}
	}else{
		window.alert("Votre numéro de "+input.id+" doit être composé de 10 chiffres.");
		input.style.backgroundColor="#f6cb62";
		return false;
	}
}

// VERIFICATION EMAIL
function verifierMail(input){
	if(input.value.length>4){
		var reg = new RegExp('^[a-z0-9._-]+@[a-z0-9.-]+[.][a-z]{2,4}$','i');
		if(reg.test(input.value)){
			return true;
		}else{
			window.alert("Veuillez saisir une adresse mail valide.");
			input.style.backgroundColor="#f6cb62";
			return false;
		}
	}else{
		window.alert("Veuillez saisir une adresse mail valide.");
		input.style.backgroundColor="#f6cb62";
		return false;
	}
}

// VERIFICATION CODE POSTAL
function verifierCode(input){
	if(input.value.length==5){
		var reg = new RegExp('^[0-9]{5}$','i');
		if(reg.test(input.value)){
			return true;
		}else{
			window.alert("Votre code postal doit être composé de 5 chiffres.");
			input.style.backgroundColor="#f6cb62";
			return false;
		}
	}else{
		window.alert("Votre code postal doit être composé de 5 chiffres.");
		input.style.backgroundColor="#f6cb62";
		return false;
	}
}

function checkForm(){
	var inputNom=window.document.getElementById("nom");
	var inputPrenom=window.document.getElementById("prenom");
	var inputTelephone=window.document.getElementById("telephone");
	var inputMail=window.document.getElementById("email");
	var inputCommentaires=window.document.getElementById("commentaires");
	
	if(verifierTelephone(inputTelephone) && verifierMail(inputMail)){
		if(inputNom.value.length!=0 && inputPrenom.value.length!=0 && inputCommentaires.value.length!=0){
			return true;
		}else{
			window.alert("Veuillez remplir le champs mentionnés d'une astérisque");
			return false;
		}
	}else{return false;}
}


function popup(nom_image, type, w, h){
	var path="popup-image.php?nom_image="+nom_image+"&type="+type;
	largeur=w;
	hauteur=h;
	wind = window.open(path, '', 'width='+largeur+', height='+hauteur+', resizable=0, scrollbars=0, menubar=0, status=0, location=0, toolbar=0');
	var screenW = screen.width;
	var screenH = screen.height;
	wind.moveTo((screenW/2)-(largeur/2), (screenH/2)-(hauteur/2));
}



function popups(url, w, h){
	var path=url
	largeur=w;
	hauteur=h;
	wind = window.open(path, '', 'width='+largeur+', height='+hauteur+', resizable=0, scrollbars=0, menubar=0, status=0, location=0, toolbar=0');
	var screenW = screen.width;
	var screenH = screen.height;
	wind.moveTo((screenW/2)-(largeur/2), (screenH/2)-(hauteur/2));
}


function PopupImage(img) {
	w=open("",'image','width=500,height=400,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>Zoom Image .:: Auberge des Acacias ::..</TITLE>");
	w.document.write("<link href='texte.css' rel='stylesheet' type='text/css'>");
	w.document.write("</HEAD><SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+65); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><a href='javascript:window.close()'><IMG src='"+img+"' border=0 alt='Fermer la fenêtre'></a>");
	w.document.write("<br><div align='center'><font face='verdana' size='1'><a href='javascript:window.close ()' class='liens'>Fermer</a></font>");	
	w.document.write("</BODY></HTML>");
	w.document.close();
}