$(function() {
  
  $("#home #button, #home #learn_button").click(function() {
    $("body").removeClass("clean");
    $("body").addClass("dirt");
    $("#home #button_text").hide();
    $("#home #button").hide();
    // $("#home #learn_button").hide();
    $("#home #learn_button2").hide();
    $("#home #learn_button").hide();
    $("#home #learn_button3").show();
    // $("#home #paper1").hide();
    // $("#home #paper2").show();
  });
  
  $("#menu_one").hover(function () {
    $("#menu_one").show();
    $("#menu").removeClass("menu_default");
    $("#menu").addClass("menu_one");
  }, function () {
    $("#menu").removeClass("menu_one");
    $("#menu").addClass("menu_default");
    $("#menu_one").hide();
  });
  
  $("#menu_two").hover(function () {
    $("#menu_two").show();
    $("#menu").removeClass("menu_default");
    $("#menu").addClass("menu_two");
  }, function () {
    $("#menu").removeClass("menu_two");
    $("#menu").addClass("menu_default");
    $("#menu_two").hide();
  });
  
  $("#menu_three").hover(function () {
    $("#menu_three").show();
    $("#menu").removeClass("menu_default");
    $("#menu").addClass("menu_three");
  }, function () {
    $("#menu").removeClass("menu_three");
    $("#menu").addClass("menu_default");
    $("#menu_three").hide();
  });
  
  $("#menu_four").hover(function () {
    $("#menu_four").show();
    $("#menu").removeClass("menu_default");
    $("#menu").addClass("menu_four");
  }, function () {
    $("#menu").removeClass("menu_four");
    $("#menu").addClass("menu_default");
    $("#menu_four").hide();
  });
  
  $("#menu").hover(function () {
  
    $("#menu .left #one a").hover(function () {
      $("#menu").removeClass("menu_two");
      $("#menu").removeClass("menu_three");
      $("#menu").removeClass("menu_four");
      $(".submenu").hide();
      $("#menu_one").show();
      $("#menu").removeClass("menu_default");
      $("#menu").addClass("menu_one");
    }, function () {});
    
    $("#menu .left #two a").hover(function () {
      $("#menu").removeClass("menu_one");
      $("#menu").removeClass("menu_three");
      $("#menu").removeClass("menu_four");
      $(".submenu").hide();
      $("#menu_two").show();
      $("#menu").removeClass("menu_default");
      $("#menu").addClass("menu_two");
    }, function () {});
    
    $("#menu .right #three a").hover(function () {
      $("#menu").removeClass("menu_one");
      $("#menu").removeClass("menu_two");
      $("#menu").removeClass("menu_four");
      $(".submenu").hide();
      $("#menu_three").show();
      $("#menu").removeClass("menu_default");
      $("#menu").addClass("menu_three");
    }, function () {});
    
    $("#menu .right #four a").hover(function () {
      $("#menu").removeClass("menu_one");
      $("#menu").removeClass("menu_two");
      $("#menu").removeClass("menu_three");
      $(".submenu").hide();
      $("#menu_four").show();
      $("#menu").removeClass("menu_default");
      $("#menu").addClass("menu_four");
    }, function () {});
    
  }, function () {
  
    $("#menu").removeClass("menu_one");
    $("#menu").removeClass("menu_two");
    $("#menu").removeClass("menu_three");
    $("#menu").removeClass("menu_four");
    $("#menu").addClass("menu_default");
    $("#menu_two").hide();
    $("#menu_one").hide();
    $("#menu_three").hide();
    $("#menu_four").hide();
    
  });
  
  $("#logo").click(function () {
    $(location).attr('href',$("#logo a").attr('href'));
  });
  
  $("#entretient #entretient_hours #e1h").hover(function () {
    $(this).attr('src','/images/entretient/1h2.png'); 
    $("#entretient #entretient_hours_pics #desinfection1").show();
    $("#entretient #entretient_hours_pics #desinfection2").hide();
    $("#entretient #entretient_hours_pics #desinfection3").hide();
    $("#entretient #entretient_hours #e5h").attr('src','/images/entretient/5h1.png');
    $("#entretient #entretient_hours #e1j").attr('src','/images/entretient/1j1.png');
    $("#entretient #numbers_of_bacteries").text('300 millions de bactéries');
  }, function () {
    $("#entretient #entretient_hours_pics #desinfection1").show();
    $("#entretient #entretient_hours_pics #desinfection2").hide();
    $("#entretient #entretient_hours_pics #desinfection3").hide();
    $("#entretient #entretient_hours #e5h").attr('src','/images/entretient/5h1.png');
    $("#entretient #entretient_hours #e1j").attr('src','/images/entretient/1j1.png');
    $("#entretient #numbers_of_bacteries").text('300 millions de bactéries');
  });
  
  $("#entretient #entretient_hours #e5h").hover(function () {
    $(this).attr('src','/images/entretient/5h2.png');
    $("#entretient #entretient_hours_pics #desinfection1").hide();
    $("#entretient #entretient_hours_pics #desinfection2").show();
    $("#entretient #entretient_hours_pics #desinfection3").hide();
    $("#entretient #entretient_hours #e1h").attr('src','/images/entretient/1h1.png');
    $("#entretient #entretient_hours #e1j").attr('src','/images/entretient/1j1.png');
    $("#entretient #numbers_of_bacteries").text('Les bactéries se développent de manière exponentielle');
  }, function () {
    $(this).attr('src','/images/entretient/5h1.png');
    $("#entretient #entretient_hours_pics #desinfection1").show();
    $("#entretient #entretient_hours_pics #desinfection2").hide();
    $("#entretient #entretient_hours_pics #desinfection3").hide();
    $("#entretient #entretient_hours #e1h").attr('src','/images/entretient/1h2.png');
    $("#entretient #entretient_hours #e5h").attr('src','/images/entretient/5h1.png');
    $("#entretient #entretient_hours #e1j").attr('src','/images/entretient/1j1.png');
    $("#entretient #numbers_of_bacteries").text('300 millions de bactéries');
  });
  
  $("#entretient #entretient_hours #e1j").hover(function () {
    $(this).attr('src','/images/entretient/1j2.png');
    $("#entretient #entretient_hours_pics #desinfection1").hide();
    $("#entretient #entretient_hours_pics #desinfection2").hide();
    $("#entretient #entretient_hours_pics #desinfection3").show();
    $("#entretient #entretient_hours #e1h").attr('src','/images/entretient/1h1.png');
    $("#entretient #entretient_hours #e5h").attr('src','/images/entretient/5h1.png');
    $("#entretient #numbers_of_bacteries").text('8 milliards de bactéries');
  }, function () {
    $(this).attr('src','/images/entretient/1j1.png');
    $("#entretient #entretient_hours_pics #desinfection1").show();
    $("#entretient #entretient_hours_pics #desinfection2").hide();
    $("#entretient #entretient_hours_pics #desinfection3").hide();
    $("#entretient #entretient_hours #e1h").attr('src','/images/entretient/1h2.png');
    $("#entretient #entretient_hours #e5h").attr('src','/images/entretient/5h1.png');
    $("#entretient #entretient_hours #e1j").attr('src','/images/entretient/1j1.png');
    $("#entretient #numbers_of_bacteries").text('300 millions de bactéries');
  });
  
  $("#entretient .entretient_bright").find("p:first").show("blind", 666);
  $("#entretient .entretient_bright").find("h2:first").css("color", "#e71f25");
  
  $("#entretient .entretient_bright .bright_head").click(function () {
    $(".entretient_bright").find("p:visible").hide("blind", 666);
    $(".entretient_bright").find("ul:visible").hide("blind", 666);
    $(".entretient_bright").find("h2").css("color", "#268bcc");
    $("#entretient .entretient_bright .bright_head .fleche").attr('src','/images/entretient/fleche1.jpg');
    $(this).next().find("p").show("blind", 666);
    $(this).next().find("ul").show("blind", 666);
    $(this).find("h2").css("color", "#e71f25");
    $(this).find(".fleche").attr('src','/images/entretient/fleche2.jpg');
  });
  
  $('#entretient .entretient_bright .danger').tinyTips('light', 'title');
  
  $("a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});
    
  $("#entretient .infos, #entretient .marques_partenaires, #entretient .contact").hover(function () {
    $(this).addClass("infos2");
  }, function () {
    $(this).removeClass("infos2");
  });
  
  $("#actualite .actualites").click(function () {
    $(location).attr('href',$(this).find('a').attr('href'));
  });
  
  $("#entretient .infos").click(function () {
    $(location).attr('href',$(this).find('a').attr('href'));
  });
  
  $("#one_product .produits_bg .menu ul li:first").addClass("menuhover");
  
  $("#one_product .produits_bg .menu #cdescription").click(function() {
    $("#one_product .produits_bg #description").show();
    $("#one_product .produits_bg #emploi").hide();
    $("#one_product .produits_bg #reco").hide();
    $("#one_product .produits_bg #astuce").hide();
    $("#one_product .produits_bg .menu").find('li').removeClass("menuhover");
    $(this).addClass("menuhover");
  });
  
  $("#one_product .produits_bg .menu #cemploi").click(function() {
    $("#one_product .produits_bg #description").hide();
    $("#one_product .produits_bg #emploi").show();
    $("#one_product .produits_bg #reco").hide();
    $("#one_product .produits_bg #astuce").hide();
    $("#one_product .produits_bg .menu").find('li').removeClass("menuhover");
    $(this).addClass("menuhover");
  });
  
  $("#one_product .produits_bg .menu #creco").click(function() {
    $("#one_product .produits_bg #description").hide();
    $("#one_product .produits_bg #emploi").hide();
    $("#one_product .produits_bg #reco").show();
    $("#one_product .produits_bg #astuce").hide();
    $("#one_product .produits_bg .menu").find('li').removeClass("menuhover");
    $(this).addClass("menuhover");
  });
  
  $("#one_product .produits_bg .menu #castuce").click(function() {
    $("#one_product .produits_bg #description").hide();
    $("#one_product .produits_bg #emploi").hide();
    $("#one_product .produits_bg #reco").hide();
    $("#one_product .produits_bg #astuce").show();
    $("#one_product .produits_bg .menu").find('li').removeClass("menuhover");
    $(this).addClass("menuhover");
  });
  
  $("#one_product .produits_bg .menu").corner("top 10px");
  
  $("#saga #timeline ul li").hover(function () {
    $("#saga #timeline ul").find("li").css("color","#154aa8"); 
    $("#saga #timeline").removeClass();
    $("#saga #the_saga #color").css("width","62px");
    $(this).css("color","#34bfed");
    $("#saga #timeline").addClass($(this).attr('id'));
    if ($(this).attr('id') == "timeline1") { $("#saga #the_saga #color").css("left","1px"); $(".saga_date").hide(); $("#saga_1929").show(); }
    if ($(this).attr('id') == "timeline2") { $("#saga #the_saga #color").css("left","64px"); $(".saga_date").hide(); $("#saga_1950").show(); $("#saga #the_saga #color").css("width","114px"); }
    if ($(this).attr('id') == "timeline3") { $("#saga #the_saga #color").css("left","179px"); $(".saga_date").hide(); $("#saga_1978").show(); $("#saga #the_saga #color").css("width","76px"); }
    if ($(this).attr('id') == "timeline4") { $("#saga #the_saga #color").css("left","256px"); $(".saga_date").hide(); $("#saga_1987").show(); $("#saga #the_saga #color").css("width","129px"); }
    if ($(this).attr('id') == "timeline5") { $("#saga #the_saga #color").css("left","386px"); $(".saga_date").hide(); $("#saga_1992").show(); $("#saga #the_saga #color").css("width","84px"); }
    if ($(this).attr('id') == "timeline6") { $("#saga #the_saga #color").css("left","471px"); $(".saga_date").hide(); $("#saga_1999").show(); $("#saga #the_saga #color").css("width","115px"); }
    if ($(this).attr('id') == "timeline7") { $("#saga #the_saga #color").css("left","587px"); $(".saga_date").hide(); $("#saga_2003").show(); $("#saga #the_saga #color").css("width","62px"); }
    if ($(this).attr('id') == "timeline8") { $("#saga #the_saga #color").css("left","649px"); $(".saga_date").hide(); $("#saga_2007").show(); $("#saga #the_saga #color").css("width","63px"); }
    if ($(this).attr('id') == "timeline9") { $("#saga #the_saga #color").css("left","713px"); $(".saga_date").hide(); $("#saga_2008").show(); $("#saga #the_saga #color").css("width","62px"); }
    if ($(this).attr('id') == "timeline10") { $("#saga #the_saga #color").css("left","776px"); $(".saga_date").hide(); $("#saga_2009").show(); $("#saga #the_saga #color").css("width","61px"); }
    if ($(this).attr('id') == "timeline11") { $("#saga #the_saga #color").css("left","838px"); $(".saga_date").hide(); $("#saga_2010").show(); $("#saga #the_saga #color").css("width","61px"); }
    if ($(this).attr('id') == "timeline12") { $("#saga #the_saga #color").css("left","900px"); $(".saga_date").hide(); $("#saga_2011").show(); $("#saga #the_saga #color").css("width","74px"); }
  });
  
  $("#saga #timeline ul li:first").css("color","#34bfed");
  $("#saga #timeline:first").addClass($("#saga #timeline ul li:first").attr('id'));
  
  
  
  /*
  
  if ($.browser.msie){
  
    $('#gamme .plus').each(function(){
      var newsrc = $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src').substr(0,25);
      newsrc = newsrc+"2.png";
      $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src',newsrc);     
    });
    
    $("#gamme .plus").hover(function () {
      $(this).attr("src","/images/produits/plus.png");
      $(".gtext").hide();
      $("#g"+$(this).attr("id").substr(1)).show();
      var newsrc = $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src').substr(0,25);
      newsrc = newsrc+".png";
      $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src',newsrc);
    }, function () {
      $(this).attr("src","/images/produits/plus1.png");
      var newsrc = $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src').substr(0,25);
      newsrc = newsrc+"2.png";
      $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).attr('src',newsrc);
    });
    
  }
  else {
    
    $('#gamme .desaturate').each(function(){
      var el = $(this);
      el.css({"position":"absolute"}).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","opacity":"0"}).insertBefore(el).queue(function(){
        var el = $(this);
        el.parent().css({"width":this.width,"height":this.height});
        el.dequeue();
      });
      // if($.browser.msie){
        // this.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=1)';
      // } else {
        this.src = grayscale(this.src);
      // }
    });
    
    $('.img_grayscale').stop().animate({opacity:1}, 10);
    
    $("#gamme .plus").hover(function () {
      $(this).attr("src","/images/produits/plus.png");
      $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).stop().animate({opacity:0}, 500);
      $('.img_grayscale').stop().animate({opacity:1}, 500);
      $(".gtext").hide();
      $("#g"+$(this).attr("id").substr(1)).show();

    }, function () {
      $(this).attr("src","/images/produits/plus1.png");
      $(this).parent().parent().find("#"+$(this).attr("id").substr(1)).stop().animate({opacity:1}, 500);
    });

  }
  
  */

  
  
  $("#gamme .plus").hover(function () {
      $(this).attr("src","/images/produits/plus.png");
      $(".gtext").hide();
      $("#g"+$(this).attr("id").substr(1)).show();
    }, function () {
      $(this).attr("src","/images/produits/plus1.png");
      $(".gtext").hide();
      $("#gamme_paper #gproduit").show();
    });
    
    
    $.preloadCssImages();
    
});
