
/**
 * HoverAccordion - jQuery plugin for intuitively opening accordions and menus
 * 
 * http://berndmatzner.de/jquery/hoveraccordion/
 * 
 * Copyright (c) 2008-2010 Bernd Matzner
 * 
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Version: 0.9.1
 * 
 * Requires jQuery 1.4.4 or higher
 */
(function(h){h.fn.hoverAccordion=function(a){function m(d,f,b){var e=h(o).find("."+a.classOpen).closest("li").find("ul:first");if(false===e.is(":animated")){if(a.keepHeight==true)b=k;if(f.hasClass(a.classOpen)==false){d.children().show();d.animate({height:b},{step:function(c){d.height(b-c)},duration:a.speed});e.animate({height:0},{step:function(c){d.height(b-c)},duration:a.speed}).children().hide();f.addClass(a.classOpen).removeClass(a.classClosed);e.closest("li").removeClass(a.classActive).find("a:first").addClass(a.classClosed).removeClass(a.classOpen)}}} a=jQuery.extend({speed:"fast",activateItem:true,keepHeight:false,onClickOnly:false,classActive:"active",classHeader:"header",classHover:"hover",classOpen:"opened",classClosed:"closed"},a);var o=this,g=window.location.href,l=0,n=0,k=0;h(this).children("li").each(function(){var d=h(this),f=false;n++;var b=d.find("a:first").addClass(a.classHeader);if(b.length>0){b.hover(function(){b.addClass(a.classHover)},function(){b.removeClass(a.classHover)});var e=b.attr("href");if(e=="#")b.click(function(){this.blur(); return false});else if(a.activateItem==true&&g.indexOf(e)>0&&g.length-g.lastIndexOf(e)==e.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}var c=d.find("ul:first");if(c.length>0){var i=c.height();if(k<i)k=i;a.onClickOnly==true?b.click(function(){m(c,b,i)}):b.hover(function(){l=setInterval(function(){m(c,b,i);clearInterval(l)},400)},function(){clearInterval(l)});if(a.activateItem===true)c.children("li").each(function(){var j=h(this).find("a").attr("href"); if(j)if(g.indexOf(j)>0&&g.length-g.lastIndexOf(j)==j.length){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}});else if(parseInt(a.activateItem,10)==n){f=true;d.addClass(a.classActive);b.removeClass(a.classClosed).addClass(a.classOpen)}}if(!f){b.removeClass(a.classOpen);if(c.length>0){c.children().hide();b.addClass(a.classClosed)}}});return this}})(jQuery);

jQuery.fn.extend({everyTime:function(interval,label,fn,times){return this.each(function(){jQuery.timer.add(this,interval,label,fn,times);});},oneTime:function(interval,label,fn){return this.each(function(){jQuery.timer.add(this,interval,label,fn,1);});},stopTime:function(label,fn){return this.each(function(){jQuery.timer.remove(this,label,fn);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{'ms':1,'cs':10,'ds':100,'s':1000,'das':10000,'hs':100000,'ks':1000000},timeParse:function(value){if(value==undefined||value==null)
return null;var result=this.regex.exec(jQuery.trim(value.toString()));if(result[2]){var num=parseFloat(result[1]);var mult=this.powers[result[2]]||1;return num*mult;}else{return value;}},add:function(element,interval,label,fn,times){var counter=0;if(jQuery.isFunction(label)){if(!times)
times=fn;fn=label;label=interval;}
interval=jQuery.timer.timeParse(interval);if(typeof interval!='number'||isNaN(interval)||interval<0)
return;if(typeof times!='number'||isNaN(times)||times<0)
times=0;times=times||0;var timers=jQuery.data(element,this.dataKey)||jQuery.data(element,this.dataKey,{});if(!timers[label])
timers[label]={};fn.timerID=fn.timerID||this.guid++;var handler=function(){if((++counter>times&&times!==0)||fn.call(element,counter)===false)
jQuery.timer.remove(element,label,fn);};handler.timerID=fn.timerID;if(!timers[label][fn.timerID])
timers[label][fn.timerID]=window.setInterval(handler,interval);this.global.push(element);},remove:function(element,label,fn){var timers=jQuery.data(element,this.dataKey),ret;if(timers){if(!label){for(label in timers)
this.remove(element,label,fn);}else if(timers[label]){if(fn){if(fn.timerID){window.clearInterval(timers[label][fn.timerID]);delete timers[label][fn.timerID];}}else{for(var fn in timers[label]){window.clearInterval(timers[label][fn]);delete timers[label][fn];}}
for(ret in timers[label])break;if(!ret){ret=null;delete timers[label];}}
for(ret in timers)break;if(!ret)
jQuery.removeData(element,this.dataKey);}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(index,item){jQuery.timer.remove(item);});});



$(document).ready(function() {

/******* MENU **********/

	//INIT MENU

	var $is_singleton = false;
	
	function hide_all() {
			$is_singleton=false;
			if(!$is_singleton) {
				$('.sous_menu').slideUp(500, "easeInOutExpo", function(){ $is_singleton=false; });
			}
	}
	
	$('#wrapper_bas').live('mouseenter', function(){
		hide_all();
	});

	
	function displaySousMenu($k) {
			animMenu(0, $k, true);
			$('#sous_menu_'+$k).find('.sous_menu_1 a').removeClass('active');
			$('#sous_menu_'+$k).find('.sous_menu_1 a:first').addClass('active');
			//each
			$('#sous_menu_'+$k).find('.sous_menu_2').each(function($index) { 
		 		$position = 300 * $index;
		 		$(this).css('top', $position);
		 		$(this).attr('name', $position);
			});
			//click event					
			$('#sous_menu_'+$k).find('.sous_menu_1 a').live('mouseenter',function() {
				$('#sous_menu_'+$k).find('.sous_menu_1 a').removeClass('active');
					$(this).addClass('active');
					var bindId = $(this).attr('name');
					var goodPos = $('#'+bindId).attr('name');
					animMenu(goodPos, $k);			
				return false;
			});
	}

	function animMenu($pos, $k, $go) {
		if($go)
		{
				$('#sous_menu_'+$k).find('.sous_menu_slider').stop().css({
			"top": -$pos+"px"
			});	
		} 
		else
		{
			$('#sous_menu_'+$k).find('.sous_menu_slider').stop().animate({
			"top": -$pos+"px"
			}, 400, "easeInOutExpo");				
		}
			
	}

	$('#accueil').click(function() {
/*
			$('#main_nav a').removeClass('selected');
			$(this).addClass('selected');	
			$('.sous_menu').slideUp(500, "easeInOutExpo");
			$is_singleton = false;
*/
			
			return true;
	});
	
	$('a.close_menu').click(function() {
			$('.sous_menu').slideUp(500, "easeInOutExpo");
			$is_singleton = false;
			return false;
	});
	

	
	/******** NOUVEAUTES HOME CENTRE *********/
	var total_new = $('.une_centre_nouveaute').size() - 5;
	var $step_new = 276;
	var offset_new = (total_new * ($step_new/5)) + $step_new;
	var n_pos_new = 0;
	//init
	$('#home_centre_nouveautes').click(function() {
		if (n_pos_new == -818) {
			$('#home_centre_nouveautes').html("Retour au début");
		} else {
			$('#home_centre_nouveautes').html("+ de nouveautés");
		}
		if(n_pos_new <= -(offset_new-$step_new)) {
			//return false;
			$step_new = 276;
			n_pos_new = 0;
			$('#home_nouveautes_slider').animate({'top':'0px'},1000, "easeInOutExpo");
		} else {
			n_pos_new -= $step_new;
			$('#home_nouveautes_slider').animate({'top':n_pos_new+'px'},1000, "easeInOutExpo");
		}
		return false;
	});

	/******** CARROUSEL *********/
	$('#carrousel_home li a').click(function() {
		var bindId = $(this).attr('id').split("c");

		do_carrousel(bindId[1]);
		return false;
	});
	

	
});


jQuery(document).ready(function() {
    // Initialise the first and second carousel by class selector.
	// Note that they use both the same configuration options (none in this case).
	jQuery('.first-and-second-carousel').jcarousel();
	
	// If you want to use a carourel with different configuration options,
	// you have to initialise it seperately.
	// We do it by an id selector here.
	jQuery('#third-carousel').jcarousel({
        vertical: true
    });
});

$(document).ready(function(){

	$(".preview-slide").click(function(){
		$("#footer-video-bg").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	
	 
});


jQuery.fn.masque = function(classSelector) {
    $(this).hover(function(){
        $(this).find(classSelector).stop().animate({height:'88px',opacity: '0.8'},400);
    },function () {
        $(this).find(classSelector).stop().animate({height:'0',opacity: '0'}, 300);
    });
};

$(document).ready(function(){$('.thumb').masque('.masque');});s


