$(document).ready(function(){
   $(".nav > li ul").hide();
   $(".nav > li").mouseenter(
      function(){ $("ul", this).stop(true, true).fadeIn(); }
   );
   $(".nav li").mouseleave(
      function(){ $("ul", this).stop(true, true).delay(200).fadeOut(); }
   );

   $(".teaser").hover(
      function(){ $("div", this).stop(true, true).delay(250).slideDown(); },
      function(){ $("div", this).stop(true, true).slideUp(); }
   );
   
   if($.fancybox) {
      //if(!$.browser.msie || $.browser.version >= 8) {
         $(document).ready(function() {
            $("a.gallery, a#single_image").fancybox({
               'zoomSpeedIn': 50,
               //'titleShow': false,
               'zoomSpeedOut':   200, 
               'zoomOpacity': false,
               'overlayOpacity': 0.75,
               'padding': 0,
               'imageScale': false,
               'centerOnScroll': false,
               'overlayShow': true,
               'transitionIn' : 'elastic',
               'transitionOut' : 'elastic', 
               'showNavArrows' : true,
               onComplete : function(gallery,index,content) {
                 if(pageTracker) {
                    pageTracker._trackPageview(content.href.substring(content.href.indexOf('/', 8)));
                 }
             }
          });
         });
      //};
   };
         
   if(!$.browser.msie) {
      $("h1, div.aside h2").each(function(index, element) {
          element.innerHTML += "<span class=\"shadow\"></span>";
      });
   };
   
   //ie8 en anders
   if(!$.browser.msie || $.browser.version >= 8) {
      //$(".clock").append("<div id=\"hoverclock2\"><object width=\"200\" height=\"200\"><param name=\"movie\" value=\"/swf/clock.swf\"><param name=\"url\" valuetype=\"ref\" value=\"http://www.jaeger-lecoultre.com/polo/eu/en/\"><param name=\"wmode\" value=\"transparant\"><embed src=\"/swf/clock.swf\" width=\"200\" height=\"200\"></embed></object></div>");
   }
   
   if($.browser.msie) {
      if($.browser.version <= 6) {
         //$("input[type=checkbox]").hide();
         $("input[type=checkbox]").addClass("checkbox");
         $("input[type=submit], input[type=button]").addClass("button");
      };
     
      if($.browser.version <= 7) {
         $(document).ready(function() {
            var zIndexNumber = 1000;
            $('ul.nav, ul.nav li, ul.nav ul, div.header p, div.header').each(function() {
               $(this).css('zIndex', zIndexNumber);
               zIndexNumber -= 1;
            });
         });
         
         var flyoutFix=1;
         $("ul.small.section.highlight li").hover(function() {
            $(this).css('zIndex', flyoutFix++);
         });
         
         //$(".logo").before("<div id=\"hoverclock\"><object width=\"200\" height=\"200\"><param name=\"movie\" value=\"/swf/clock.swf\"><param name=\"url\" valuetype=\"ref\" value=\"http://www.jaeger-lecoultre.com/polo/eu/en/\"><param name=\"wmode\" value=\"transparant\"><embed src=\"/swf/clock.swf\" width=\"200\" height=\"200\"></embed></object></div>");

         $("ul.brands li.clock").hover(function(){
            $("#hoverclock").show();
         });
         $("#hoverclock").mouseout(function() {
            $(this).hide();
         });
      };
      
      if($.browser.version >= 8) {
          /** rendering dropShadows does not work properly in IE < 8 **/
         $("h1, div.aside h2").each(function(index, element) {
            element.innerHTML = "<span class=\"text\">" + element.innerHTML + "</span><span class=\"shadow\"></span>";
         });
         $("h1 span.text, div.aside h2 span.text").dropShadow({left: 1, top: 0, blur: 0, opacity: 1, color: "#67645a"});
            
         $("ul.sectionHighlight a").mouseenter(
            function(){ $("span", this).dropShadow({left: 1, top: 1, blur: 0, opacity: 1, color: "#ffffff"}); }
         );
         $("ul.sectionHighlight a").mouseleave(
            function(){ $("span", this).removeShadow(); }
         );
      };
      
      $("div.article ul.section.highlight li:nth-child(odd)").addClass("odd");
   }
});
