$(function(){

  // fancybox
  $(".accesFancy").fancybox({'hideOnContentClick':false, 'frameHeight': 320, 'frameWidth': 470});

});

$().ready(function() {
jQuery.validator.messages.required = "";
jQuery.validator.messages.email = "";
  $("#contact").validate({
    invalidHandler: function(form, validator) {
      var errors = validator.numberOfInvalids();
      if (errors) {
        var message = errors == 1
          ? 'Il vous reste 1 champ à remplir'
          : 'Vous devez remplir les ' + errors + ' champs restants. Ils ont été surlignés en rouge.';
        $(".warning").html(message);
        $(".warning").fadeIn("slow");
      } else {
        $(".warning").fadeOut("slow");
      }
    }
  });
  $.validator.addMethod("ruleNom", function(value) {
    return value != "Nom";
  }, '');
  $.validator.addMethod("ruleEntreprise", function(value) {
    return value != "Entreprise";
  }, '');
  $.validator.addMethod("ruleTelephone", function(value) {
    return value != "Téléphone";
  }, '');
  $.validator.addMethod("ruleEmail", function(value) {
    return value != "Email";
  }, '');
  $.validator.addMethod("ruleComment", function(value) {
    return value != "Votre commentaire";
  }, '');

  $("#sideForm").validate();

  jQuery.validator.addClassRules("validNom", {
    ruleNom: true
  });
  jQuery.validator.addClassRules("validEntreprise", {
    ruleEntreprise: true
  });
  jQuery.validator.addClassRules("validTelephone", {
    ruleTelephone: true
  });
  jQuery.validator.addClassRules("validEmail", {
    ruleEmail: true
  });
  jQuery.validator.addClassRules("validComment", {
    ruleComment: true
  });

});


$(function(){

  $("#formCol-btn a").click(function() {
    $("#formCol-content").slideDown("normal");
    $("#formCol-btn a").fadeOut("fast", function() { $("#formCol-btn span").fadeIn("fast"); });
    return false;
  });

  $("#formCol-content #closeForm").click(function() {
    $("#formCol-content").slideUp("normal");
    $("#formCol-btn span").fadeOut("fast", function() { $("#formCol-btn a").fadeIn("fast"); });
    return false;
  });


});
