jQuery(function ($) {
    
    $(".scroll").click(function(event){
        //prevent the default action for the click event
        event.preventDefault();
        
        //get the anchor's offset top
        var trgt = $(this).attr("href");
        var targetS = $(trgt).offset();
		targetS = targetS.top;
		
        //goto that anchor by setting the body scroll top to anchor top
        $('html, body').animate({scrollTop:targetS}, 700);
    });
        
});      

jQuery(window).load(function(){

	jQuery('#nivoSlider').nivoSlider({pauseTime:5000, effect:'fold', slices:1, controlNav:false, pauseOnHover:true, captionOpacity:1, directionNavHide:false, keyboardNav:true});
	
	jQuery('a.box-it').fancybox({
		'titlePosition' : 'inside',
		'titleFormat' : 'formatTitle'
	});
});

jQuery(document).ready(function(){

    /*regular expressions*/
    validateIt_num = new RegExp("^[0-9]+$");
    validateIt_num_fixe = new RegExp("^0262([0-9]){6}$");
    validateIt_num_portable = new RegExp("^069(2|3)([0-9]){6}$");
    validateIt_cp = new RegExp("^974([0-9]){2}$");
    validateIt_mail = new RegExp("^[a-z0-9._-].+@([a-z.-])+([.])([a-z]){2,4}$");
    validateIt_nom = new RegExp("^[a-zA-ZéçèàêëîïôöûüâäÉÀÈËËÏÎÖÔÛÜÄÂ'-][a-zA-ZéçèàêëîïôöûüâäÉÀÈËËÏÎÖÔÛÜÄÂ' -]{2,50}$");
    validateIt_date = new RegExp("^[0-9]{2}/[0-9]{2}/[0-9]{4}$");
    validateIt_url = new RegExp("^http://");   	
   	
   	/*required*/
   	jQuery("*[rel*='required']").blur(function(){
   	
   		jQuery("#validateIt-error-"+jQuery(this).attr("id")).remove();
   		
   		if(jQuery(this).val() == ""){
   			jQuery(this).after("<span class=\"validateIt-error\" id=\"validateIt-error-"+jQuery(this).attr("id")+"\">"+jQuery(this).attr("title")+"</span>");
   		}
   	});
   	
   	/*mail*/
   	jQuery("*[rel*='mail']").blur(function(){
   	
   		jQuery("#validateIt-error-"+jQuery(this).attr("id")).remove();
   		
   		if(!validateIt_mail.test(jQuery(this).val())){
   			jQuery(this).after("<span class=\"validateIt-error\" id=\"validateIt-error-"+jQuery(this).attr("id")+"\">"+jQuery(this).attr("title")+"</span>");
   		}
   	});
     
});
    


