// JavaScript Document
var popUpWin=0;
function openWin(img) { 
	titre="Agrandissement"; 
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
	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+40); 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 VerifMail(str) { // vérif validité email par REGEXP
   var reg = /^[A-Za-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   return (reg.exec(str)!=null)
}
function VerifCP(str) { // vérif validité email par REGEXP
   var reg = /^[0-9]{5}$/
   return (reg.exec(str)!=null)
}
function VerifStr(str) { // vérif validité email par REGEXP
   //var reg = /^[.]+$/
   //return (reg.exec(str)!=null)
	 if(str=='') return false;
	 else return true;
}
function verif() {
	var color_focus ="#FCF5A4";
	var prefixe ="- Veuillez saisir ";
	theform=document.formulaire_contact;
	mess = "";
	if (!VerifStr(theform.Nom.value)) {
		mess += "- Veuillez verifier votre nom.\n";
		theform.Nom.focus();
		theform.Nom.style.background=color_focus;
	}
	if (!VerifStr(theform.Prenom.value)) {
		mess += "- Veuillez verifier votre prenom.\n";	
		theform.Prenom.focus();
		theform.Prenom.style.background=color_focus;
		
	}
	if (!VerifMail(theform.Email.value)) {
		mess += "- Veuillez verifiez votre adresse email.\n";
		theform.Email.focus();
		theform.Email.style.background=color_focus;		
		
	}
	if (theform.Fonction.value=="") {
		mess += prefixe+ " votre fonction (Message vide).\n";
		theform.Fonction.focus();
		theform.Fonction.style.background=color_focus;
	}
	if (theform.Secteur_activite.value=="") {
		mess += prefixe+ " votre secteur d'activite.\n";				
		theform.Secteur_activite.focus();
		theform.Secteur_activite.style.background=color_focus;
	}
	if (!VerifCP(theform.Code_postal.value)) {
		mess += "- Veuillez verifier votre code postal.\n";				
		theform.Code_postal.focus();
		theform.Code_postal.style.background=color_focus;
	}
	if (theform.Sujet.value=="") {
		mess += prefixe+ " un sujet de message.\n";		
		theform.Sujet.focus();
		theform.Sujet.style.background=color_focus;		
	}
	if (theform.Message.value=="") {
		mess += prefixe+ " votre message.\n";				
		theform.Message.focus();
		theform.Message.style.background=color_focus;				
	}
	if (theform.connu_comment[0].checked==false && theform.connu_comment[1].checked==false && (theform.connu_comment[2].checked==false || (theform.connu_comment[2].checked==true && theform.Autre_precision.value==""))) {
		mess += "- Comment nous avez vous connu.\n";	
		if(theform.connu_comment[2].checked==true) {
			theform.Autre_precision.focus();
			theform.Autre_precision.style.background=color_focus;			
		}
	}
	if (mess=="") {
		theform.submit();
		return true;
	}	
	else {
		alert("Avant de valider, verifier les informations suivantes :\n\n"+mess);
		return false;
	}
}
