$(document).ready(function(){
   // FONCTION QUI PERMET DE FAIRE UN EFFET CONCOURT DE TEXTE
   $('#example0').FontEffect({ outline:true });
   $('#example1').FontEffect({ outline:true });
   $('#example2').FontEffect({ outline:true });
   $('#example3').FontEffect({ outline:true });
   $('#example4').FontEffect({ outline:true });
   
   // FONCTION QUI PERMET L'AJOUT DE POLICE EXOTIQUE 
   Cufon.replace('.contact h4',{ hover: true });
   Cufon.replace('.navLink',{ hover: true });
   Cufon.replace('#present_sur h4',{ hover: true });
   Cufon.replace('.blog_date',{ hover: true });
   Cufon.replace('.blog h2',{ hover: true });
   
   Cufon.replace('.blog_date',{ hover: true });
   Cufon.replace('.design h2',{ hover: true });
   Cufon.replace('.pad10_20 h4',{ hover: true });
   
   Cufon.replace('.nice_titles',{ hover: true });
   
   Cufon.replace('.titre_cb',{ hover: true });
   Cufon.replace('.ct-content h2',{ hover: true });
   Cufon.replace('#page-title h2',{ hover: true });
   Cufon.replace('.ct-recent h2',{ hover: true });
   
   
   $("a[rel='realisation']").colorbox();
   $('#alert').jqm({overlay: 0, modal: true, trigger: false});
   
});

function slideSwitch() {
   var $active = $('#slideshow IMG.active');
   if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

   // use this to pull the images in the order they appear in the markup
   var $next =  $active.next().length ? $active.next()
           : $('#slideshow IMG:first');

   // uncomment the 3 lines below to pull the images in random order
   
   // var $sibs  = $active.siblings();
   // var rndNum = Math.floor(Math.random() * $sibs.length );
   // var $next  = $( $sibs[ rndNum ] );


   $active.addClass('last-active');

   $next.css({opacity: 0.0})
      .addClass('active')
      .animate({opacity: 1.0}, 1000, function() {
         $active.removeClass('active last-active');
      });
}

$(function() {
      setInterval( "slideSwitch()", 4000 );
});

$(document).ready(function() { 
   $.localScroll();
});


// Switch between list and grid item in Works page
$(document).ready(function(){
   $("a.switch_thumb").toggle(function(){
      $(this).addClass("swap"); 
      $("ul.display").fadeOut("fast", function(){
         $(this).fadeIn("fast").addClass("thumb_view"); 
      });
      
   }, function (){
      $(this).removeClass("swap");
      $("ul.display").fadeOut("fast", function() {
         $(this).fadeIn("fast").removeClass("thumb_view");
      });
   }); 
});

function alert(msg) {
   $('#alert').fadeIn().jqmShow().find('div.jqmAlertContent').html(msg);
}

function verification_formulaire(){
   var error = 0;
   var msgError = "";
   if($('#nom').val() == ""){
      error++;
      msgError += " - Votre Nom - Pr&eacute;nom / Soci&eacute;t&eacute; <br/>";
   }
   if($('#email').val() == ""){
      error++;
      msgError += " - Votre adresse mail <br/>";
   }
   if(!$('#email').val().match("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$")){
      error++;
      msgError += " - Votre adresse mail est invalide <br/>";
   }
   if($('#objet').val() == ""){
      error++;
      msgError += " - L'objet du mail <br/>";
   }
   if($('#message').val() == ""){
      error++;
      msgError += " - Votre message <br/>";
   }
   
   if (error > 0 ){
      alert (msgError);
      return false;
   }else{
      return true;
   }
}

