jQuery(document).ready(function() {
								
	//MENU
	Cufon.replace('#slidingMenu a, #slidingMenuDesc span, #navigation a').CSS.ready(function() {
		var $menu 		= $("#slidingMenu");
		
		/**
		* the first item in the menu, 
		* which is selected by default
		*/
		var $selected	= $menu.find("li.actif");
		
		/**
		* this is the absolute element,
		* that is going to move across the menu items
		* it has the width of the selected item
		* and the top is the distance from the item to the top
		*/
		var $moving		= $('<li />',{
			className	: 'move',
			top			: $selected[0].offsetTop + 'px',
			width		: $selected[0].offsetWidth + 'px'
		});
		$moving.css('top',$selected[0].offsetTop + 'px');
		/**
		* each sliding div (descriptions) will have the same top
		* as the corresponding item in the menu
		*/
		$('#slidingMenuDesc > div').each(function(i){
			var $this = $(this);
			$this.css('top',$menu.find('li:nth-child('+parseInt(i+2)+')')[0].offsetTop + 'px');
		});
		
		/**
		* append the absolute div to the menu;
		* when we mouse out from the menu 
		* the absolute div moves to the top (like innitially);
		* when hovering the items of the menu, we move it to its position 
		*/
		$menu.bind('mouseleave',function(){
				moveTo($selected,400);
			  })
			 .append($moving)
			 .find('li')
			 .not('.move')
			 .bind('mouseenter',function(){
				var $this = $(this);
				var offsetLeft = $this.offset().left - 20;
				//slide in the description
				$('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':offsetLeft+'px'},400, 'easeOutExpo');
				//move the absolute div to this item
				moveTo($this,400);
			  })
			  .bind('mouseleave',function(){
				var $this = $(this);
				var offsetLeft = $this.offset().left - 20;
				//slide out the description
				$('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':'0px'},400, 'easeOutExpo');
			  });;
		
		/**
		* moves the absolute div, 
		* with a certain speed, 
		* to the position of $elem
		*/
		function moveTo($elem,speed){
			$moving.stop(true).animate({
				top		: $elem[0].offsetTop + 'px',
				width	: $elem[0].offsetWidth + 'px'
			}, speed, 'easeOutExpo');
		}
	}) ;
	
	if ($("#coda-slider-1").length > 0){
		//coups de coeur défilant
		jQuery('#coda-slider-1').codaSlider();
	}
	
	if ($("#du").length > 0){
		/* Date Piker */
		var dates = $('#du, #au').datepicker({
			defaultDate: "+1w",
			changeMonth: false,
			numberOfMonths: 3,
			onSelect: function(selectedDate) {
				var option = this.id == "du" ? "minDate" : "maxDate";
				var instance = $(this).data("datepicker");
				var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
				var pattern = /^sat/i;
				$("#sat"+instance.id).hide();
				if(pattern.test(date)){
					$("#sat"+instance.id).show("slow");	
				}
				dates.not(this).datepicker("option", option, date);
			}
		});
	}
	
	$('#hresult').hide(); 

});
