function verifMail(a) {
  testm = false ;
  for (var j=1 ; j<(a.length) ; j++) {
    if (a.charAt(j)=='@') { 
      if (j<(a.length-4)){ 
        for (var k=j ; k<(a.length-2) ; k++) { 
          if (a.charAt(k)=='.') testm = true; 
        }
      } 
    } 
  } 
  return (testm);
}

function Validate( ) {
  AlertMsg = "___________________________________________________\n\n"
  AlertMsg = AlertMsg + "Votre demande n'a pas pu aboutir.\n"
  AlertMsg = AlertMsg + "Corriger d'abord le(s) erreur(s) suivant(es):\n"
  AlertMsg = AlertMsg + "___________________________________________________\n\n"
  
  var flag = true;
  
    if ($('enseigne').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Enseigne' est vide.\n";flag = false;
  }
     if ($('raison_Sociale').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Raison Sociale' est vide.\n";flag = false;
  }
      if ($('adresse').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Adresse' est vide.\n";flag = false;
  }
      if ($('code_postal').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Code postal' est vide.\n";flag = false;
  }
      if ($('ville').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Ville' est vide.\n";flag = false;
  }
        if ($('nom').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Nom' est vide.\n";flag = false;
  }
        if ($('telephone').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Téléphone' est vide.\n";flag = false;
  }
          if ($('departement').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Département' est vide.\n";flag = false;
  }
          if ($('villes').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Les villes' est vide.\n";flag = false;
  }
          if ($('email').value == "") {
    AlertMsg = AlertMsg + "Le champ 'Email' est vide.\n";flag = false;
  }
          
          if (verifMail($('email').value) == false) {
    AlertMsg = AlertMsg + "Votre e-mail semble incorrecte.\n";flag = false;
  }
  
  
  if (flag == false) {
    alert(AlertMsg)
  }
  else
  {
  var url     = './xmlrpcnet.php';		
	var pars    =	'mode=send_essai&'+Form.serialize('form_essai');
	var target	= 'div_formulaire';	
  var myAjax	= new Ajax.Updater(target, url,	{method: 'get', parameters: pars});
  }
}