$(document).ready(function(){
		
	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
			
		//Calculate width of all ul's
		(function($) {
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :'378px'});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			$(this).find(".sub").css({'width' : '378px'});
			
		}
	}
	
	function megaHoverOut(){
	 $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide();
	  });
	  $("#onglet_conseil").removeClass("current");
	  $("#onglet_design").removeClass("current");
	  $("#onglet_technique").removeClass("current");
	} 
 
	var config = {
		 sensitivity: 2,		// number = sensitivity threshold (must be 1 or higher)    
		 interval: 0, 			// number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver,   // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, 			// number = milliseconds delay before onMouseOut    
		 out: megaHoverOut 		// function = onMouseOut callback (REQUIRED)    
	};
 
	$("ul#topnav_technique li .sub").css({'opacity':'0'});
	$("ul#topnav_technique li").hoverIntent(config);
	
	if ($("a[rel^='prettyPhoto'], a[rel^='lightbox']").length) {
		jQuery("a[rel^='prettyPhoto'], a[rel^='lightbox']").prettyPhoto({
		"theme": 'light_square' 																
		});
	}
	
	$("ul#topnav_conseil li .sub").css({'opacity':'0'});
	$("ul#topnav_conseil li").hoverIntent(config);
	
	$("ul#topnav_design li .sub").css({'opacity':'0'});
	$("ul#topnav_design li").hoverIntent(config);	

	// Delete the border for the last li of the submenu
	$("ul#topnav .sub ul li:last-child a").css("border", "none");
	
	$('#featured').orbit({
		animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
		animationSpeed: 800,                // how fast animtions are
		timer: true, 			 // true or false to have the timer
		advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
		pauseOnHover: false, 		 // if you hover pauses the slider
		startClockOnMouseOut: false, 	 // if clock should start on MouseOut
		startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
		directionalNav: false, 		 // manual advancing directional navs
		captions: true, 			 // do you want captions?
		captionAnimation: 'none', 		 // fade, slideOpen, none
		captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		bullets: true,			 // true or false to activate the bullet navigation
		bulletThumbs: true,		 // thumbnails for the bullets
		bulletThumbLocation: '',		 // location from this file where thumbs will be
		afterSlideChange: function(){} 	 // empty function 
	});	
 
});
