
$(document).ready(function () {   
    $("form#info").submit(function() {
      var email =  $("#mail").val();
      
      if(verifierMail(email))
      {
      $('#ajax-loader').remove();
      $.ajax({
        type: "POST",
        url: "insertBdd.php",
        data: "&mail="+ email,
        beforeSend : function() { 
          $('form#info').html('<img style="float: left; margin-left: 10px;" src="style/img/ajax-loader.gif" alt="loader" id="ajax-loader" />');
          },           
        success : function(data){
          $('#ajax-loader').remove(); 
          $('form#info').fadeOut("slow");
          $('#success').fadeIn("slow");
          $('#success').html('<p class="next">Vous serez prochainement informé de l\'ouverture de notre nouvel espace.</p>');
          },
        dataType: "json"
      });
      }  
        return false;
   });
});






 
function verifierMail(mail) { 
  var regexp = new RegExp("^[a-zA-Z0-9_\\-\\.]{3,}@[a-zA-Z0-9\\-_]{2,}\\.[a-zA-Z]{2,4}$", "g");
  if (!regexp.test(mail)) {
    alert("L'adresse e-mail n'est pas valide.");
    return false;
    }
  return true;
}

