jQuery(document).ready(function () {
 jQuery('input[name^=email]').each(function() {
  var $this = jQuery(this);
  $this.after("<div id='checkMail_" + $this.attr('id') + "' class='checkmail' />");
  var $check = jQuery("#checkMail_" + $this.attr('id'));
  $this.bind("blur", function (){
   $check.html("<img src='" + checkMailPath + "ajax-loader.gif' />");
   jQuery.ajax({
    type: "GET",
    url: checkMailPath + 'checkMail_test.php',
    data: "email=" + $this.val(),
    success: function (msg) {
     $check.attr('class', 'checkmail');
     switch(msg) {
      case "1" :
       // mail ok
       $check.html("<img src='" + checkMailPath + "bullet_square_green.png' />");
       break;
      case "-6" :
       $check.html("<img src='" + checkMailPath + "bullet_square_blue.png' title=\"Votre email pourrait être incorrect, n'hésitez pas à le vérifier\" />Votre email pourrait être incorrect, n'hésitez pas à le vérifier");
       break;
      case "-5" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Merci de renseigner un email valide ' />Merci de renseigner un email valide");
       break;
      case "-4" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Merci de renseigner un email valide' />Merci de renseigner un email valide");
       break;
      case "-3" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Merci de renseigner un email valide : certains caractères ne sont pas compatibles avec une adresse email' />Merci de renseigner un email valide : certains caractères ne sont pas compatibles avec une adresse email");
       break;
      case "-2" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Votre adresse email doit comporter un @' />Votre adresse email doit comporter un @");
       break;
      case "-1" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Merci de renseigner un email valide : 255 caractères maximum' />Merci de renseigner un email valide : 255 caractères maximum");
       break;
      case "0" :
       $check.html("<img src='" + checkMailPath + "bullet_square_red.png' title='Merci de renseigner un email valide : 7 caractères minimum' />Merci de renseigner un email valide : 7 caractères minimum");
       break;
     }
    }
   });
  });
 });
});
