$(document).ready(function() {
   
	var big_menu_holder = $('.big_menu_container'); 
   var logo_position = $('#branding').position();
   big_menu_holder.css('left', (logo_position.left-25));  
   var mask = $('#mask_bigmenu'); 
   
   var big_menu_toggle = 0;
   var click_from_menu = 0;
   
   //$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").click(function() {
	$("#menu-item-1538 a,  #menu-item-1542 a, #menu-item-8636 a").click(function() {
		
		if (big_menu_toggle == 0) {
			
			big_menu_toggle = 1;
			click_from_menu = 1;
			var offsetpos = $(this).offset();
			
			$(this).addClass('big_menu_hover');
			
			$(mask).css('width', ($(this).width()+30)).css('position','fixed').css('left',offsetpos.left).css('top', (offsetpos.top+40-$(window).scrollTop()));
		/*	$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").css('color','#0054A4');*/
			
			if ( $.browser.msie && $.browser.version == '9.0' ) {
				big_menu_holder.css('left', (($(document).width() - 910) / 2) + 'px');
			}
			
			big_menu_holder.show();
			setTimeout(function() { click_from_menu = 0; }, 200);
			
		}
		else 
		{
			big_menu_toggle = 0;
			click_from_menu = 0;
			
			$(this).removeClass('big_menu_hover');
			big_menu_holder.delay(1000).hide();
			if ($('body.tax-producttype').length != 1 && $('body.single-touch_product').length != 1) {
				/*$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").css('color','#999999');*/
				$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").removeClass('big_menu_hover');
			}
		}		
		
	});
	
	$("#page").click(function() { 
	
		if (big_menu_toggle == 1 && click_from_menu == 0) {
			
			big_menu_toggle = 0;
		
			$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").removeClass('big_menu_hover');
			big_menu_holder.delay(1000).hide();
			if ($('body.tax-producttype').length != 1 && $('body.single-touch_product').length != 1) {
				/*$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").css('color','#999999');*/
				$("#menu-item-1538 a, #menu-item-1542 a, #menu-item-8636 a").removeClass('big_menu_hover');
			}
			
		}
		
	});   
   
   $(window).resize(function() { 
   
   	big_menu_holder.css('left', (($(document).width() - 910) / 2) + 'px'); 
		var offsetpos = $("#menu-item-1538 a,  #menu-item-1542 a,  	#menu-item-8636 a").offset();
		$(mask).css('width', ($("#menu-item-1538 a,  #menu-item-1542 a,  	#menu-item-8636 a").width()+30)).css('position','fixed').css('left',offsetpos.left).css('top', (offsetpos.top+40-$(window).scrollTop()));

	});
   
   
   function checkProductMenu() {
		if ($('body.tax-producttype').length == 1 || $('body.single-touch_product').length == 1) {
			$("#menu-menu-principal li.menu-item-type-custom  , #menu-menu-principal-en li.menu-item-type-custom ").addClass('current_page_item');
		}
	}  
	checkProductMenu(); 
   
	
	/*
	$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").hover(function() {
		
		var offsetpos = $(this).offset();
		
		$(this).addClass('big_menu_hover');
		
		$(mask).css('width', ($(this).width()+30)).css('position','fixed').css('left',offsetpos.left).css('top', (offsetpos.top+40-$(window).scrollTop()));
		$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").css('color','#0054A4');
		
		if ( $.browser.msie && $.browser.version == '9.0' ) {
			big_menu_holder.css('left', (($(document).width() - 910) / 2) + 'px');
		}
							
		big_menu_holder.show().hover(
			
			function(){ 
							$(this).show(); 
							$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").addClass('big_menu_hover'); 
							$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").css('color','#0054A4');
							}, 
			function(){ 
						
							$(this).hide(); 
							$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").removeClass('big_menu_hover'); 
						
							if ($('body.tax-producttype').length != 1 && $('body.single-touch_product').length != 1) {
								$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").css('color','#999999');
							}
							}
		
		);
	
	},function() { 
			
			$(this).removeClass('big_menu_hover');
			big_menu_holder.delay(1000).hide();
			if ($('body.tax-producttype').length != 1 && $('body.single-touch_product').length != 1) {
				$("#menu-menu-principal li.menu-item-type-custom a , #menu-menu-principal-en li.menu-item-type-custom a").css('color','#999999');
			}
	
	});
	*/
	
   
   /*
	*	Boutons "Liste" pour les produits   
   */
	 $(window).scroll(function() {
	 		bindListButton();
	 });   
   
   bindListButton();
   function bindListButton() {
   	
		$('.odd .btn-product-list , .product-page-btn .btn-product-list').unbind('hover');  
	   $('.even .btn-product-list').unbind('hover'); 
	   //$('.product-list').css('position','absolute'); 	
		$(window).unbind('scroll');
   	
   	/*	items de gauche	*/
	   $('.odd .btn-product-list , .product-page-btn .btn-product-list').addClass('shadow').hover(function() {   
	   	//	Hover ON
	   	var btnoffsetpos = $(this).offset();
	   	$(this).removeClass('shadow');
	   	var mylist = $(this).parent().find('.product-list').each(function() {
	   			
	   			$(this).css('position','fixed').css('left',btnoffsetpos.left).css('top', btnoffsetpos.top - $(window).scrollTop()  ).show().hover(function() {  
		   					$(this).show();
		   					$(window).scroll(function() { 
		   						$('.product-list').each(function() { 
		   							$(this).css('top', btnoffsetpos.top - $(window).scrollTop() );
		   						});
		   					});
		   				},function() { 
		   					$(this).hide();
		   					$(this).parent().find('.btn-product-list').addClass('shadow');
		   				});   		
		   		});
	   
	   },function() {   
	   	//	Hover OFF
	   		var mylist = $(this).parent().find('.product-list').each(function() {
	   		
	   			$(this).hide();   		
	   		
	   		});  
	   
	   });
	   
	   	
	   
	   /*	items de droite	*/
	   $('.even .btn-product-list').addClass('shadow').hover(function() {   
	   	//	Hover ON
	   	var btnoffsetpos = $(this).offset();
	   	$(this).removeClass('shadow');
	   	var mylist = $(this).parent().find('.product-list').each(function() {
	   			
					//alert(btnoffsetpos.right); 
	   			//	400-324 = 76
	   			$(this).css('position','fixed').css('left',0).css('left',btnoffsetpos.left-$(this).width()+80).css('top', btnoffsetpos.top - $(window).scrollTop()  ).show().hover(function() {  
	   			//$(this).css('left',btnoffsetpos.left-$(this).width()+76).css('top', btnoffsetpos.top - $(window).scrollTop()  ).show().hover(function() { 
	   						$(window).scroll(function() { 
		   						$('.product-list').each(function() { 
		   							$(this).css('top', btnoffsetpos.top - $(window).scrollTop() );
		   						});
		   					});
		   					$(this).show();
		   				},function() { 
		   					$(this).hide();
		   					$(this).parent().find('.btn-product-list').addClass('shadow');
		   				});   		
		   		});
	   	
	   
	   },function() {   
	   	//	Hover OFF
	   	var mylist = $(this).parent().find('.product-list').each(function() {
	   		
	   		$(this).hide();   		
	   		
	   		});  
	   
	   });
   
   }
   
    $("#front-login").click(function() {
   		$("#front-login-wrapper").show();
   		return false;
   });
   $("#fl-close-button").click(function() {
   		$("#front-login-wrapper").hide();
   		return false;
   });
   
   /*	Shadow pour bigmenu dans explorer	big_menu_holder */
  /* if ($.browser.msie) {
		var elm = $(big_menu_holder);
		var pos = $(elm).position();
		$elm.after("<div class='ie-shadow'></div>");
		$(".ie-shadow").width($(elm).width()).height($(elm).height()).css("left", (pos.left + 5) + "px").css("top",(pos.top + 5) + "px");
	}*/
   
   /*	
	*	Boldify h2 titles   
   */
  /* $('.tax-producttype h2').html(function(i,html){
	    return html.replace(/^\s*([^\s]+)(\s|$)/, '<span>$1 </span>');
	});*/
	/*
	$(function(){
      $('.tax-producttype h2').each(function(item, index){
      	if ($(this).text().split(" ").length > 1) {
            var firstWord = $(this).text().split(" ")[0];
            var newText = $(this).text().replace(firstWord, "<span>"+firstWord +"</span>");
            $(this).html(newText);
         }
      });
    });
   */
   
});




