// Validation Email.
function check_email(e) {
 ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
  for(i=0; i < e.length ;i++){
      if(ok.indexOf(e.charAt(i))<0){ 
        return (false);
      }	
  } 
  if (document.images) {
      re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
      re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
      if (!e.match(re) && e.match(re_two)) {
        return (-1);		
      } 
  }
}

// Suppression des intitulés des cases au clic (focus)
function FocusText(BoxName) {
	if (BoxName.value == BoxName.defaultValue)
	{
		BoxName.value = '';
	}
}
function BlurText(BoxName) {
	if (BoxName.value == '')
	{
		BoxName.value = BoxName.defaultValue;
	}
}

// TESTS proprement dit !
var compteur=0;
var pop_merci;

function check_form(f) { 

// Test EMAIL
if(!check_email(f.email.value)){
alert("Votre adresse e-mail ne semble pas valide");
f.email.focus(); 
if(document.all || document.getElementByID){
f.email.style.background = "#FAD8DF";
}
return (false);
}

// Test PRENOM
if ((f.nom.value.length < 2) || (f.nom.value == "Votre prénom*") || (f.nom.value == "Surname")) {
alert("Merci d'indiquer votre prénom");
f.nom.focus();
if(document.all || document.getElementByID){
f.nom.style.background = "#FAD8DF";
}
return (false);
}

// TEST DOUBLE-ENVOIE !!! [Fonctionne en ligne car temps + long!]
if (compteur == 0){
compteur++;
//pop_merci=window.open("../merci.html","merci","width=280,height=160,top=0,left=0,resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no");
return true;
}
else{
//alert("Transmission en cours!\n \nTransmission in progress!");
return false;
}
return (true);
}

function check_form_plus(f) { 

// Test EMAIL
if(!check_email(f.email.value)){
alert("Votre adresse e-mail ne semble pas valide");
f.email.focus(); 
if(document.all || document.getElementByID){
f.email.style.background = "#FAD8DF";
}
return (false);
}

// Test PRENOM
if ((f.nom.value.length < 2) || (f.nom.value == "Votre prénom*") || (f.nom.value == "Surname")) {
alert("Merci d'indiquer votre prénom");
f.nom.focus();
if(document.all || document.getElementByID){
f.nom.style.background = "#FAD8DF";
}
return (false);
}

// test date
if(f.dateNaissance.value.length > 0 && !check_date(f.dateNaissance.value)) {
alert("Votre date de naissance ne semble pas valide. Format dd/mm/yyyyy");
f.email.focus(); 
if(document.all || document.getElementByID){
f.email.style.background = "#FAD8DF";
}
return (false);	
}

// TEST DOUBLE-ENVOIE !!! [Fonctionne en ligne car temps + long!]
if (true){
compteur++;
//pop_merci=window.open("../merci.html","merci","width=280,height=160,top=0,left=0,resizable=no,scrollbars=no,menubar=no,toolbar=no,status=no,location=no");
return true;
}
else{
//alert("Transmission en cours!\n \nTransmission in progress!");
return false;
}
return (true);
}

function check_date(e) {
	var date_regexp=/^(\d{1,2}\/){2}\d{4}$/;
	if (!e.match(date_regexp)) {
        return false;		
    }
    return true;
}
//-->
