//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));
}
