$(window).load(function() { /*--------------- Intro and header diaporama ---------------*/ if(document.getElementById('header_slide')){ var header_actu=0; var cible=0; var header_total=$('#header_slide > .header_picture').length; var slide_home=function(cible, auto){ if(auto && header_actu+1 < header_total){ cible=header_actu+1; }else if(auto){ cible=0; } if(cible!=header_actu){ $('#header_picture_'+header_actu).css({zIndex:header_total+1}); $('#header_picture_'+cible).css({zIndex:header_total}); $('#header_picture_'+header_actu).fadeOut(1200, function(){ $('#header_picture_'+cible).css({zIndex:header_total+2}); $(this).css({zIndex:1}).show(); }); header_actu=cible; } clearTimeout(time_home); time_home = window.setTimeout(function(){slide_home(false, true);}, 6000); } time_home = window.setTimeout(function(){slide_home(false, true);}, 6000); } /*--------------- Menu slide ---------------*/ if(document.getElementById('navigation')){ $('.menu_custom_slide').each(function(){ $(this).css({marginLeft:-($(this).width()/2)}).attr('id', $(this).height()); $(this).children('.menu_slide_margin').attr('id', $(this).width()); }); $('.menu_slide').hover(function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).attr('id'), width:$(this).children(".menu_custom_slide").children(".menu_slide_margin").attr('id')}).slideDown(); }, function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).attr('id'), width:$(this).children(".menu_custom_slide").children(".menu_slide_margin").attr('id')}).slideUp(); }); } /*--------------- News slide ---------------*/ if(document.getElementById('news_mask')){ var slide_height = $('#news_slide').height(); var mask_height = $('#news_mask').height(); var slide_news = function(same_position, speedNews, first) { if (!same_position) { $('#news_slide').css({marginTop:0, top:mask_height}); } if (first) { $('#news_slide').animate({marginTop:-slide_height}, speedNews, 'linear', function(){ slide_news(false, (slide_height+mask_height)*40, false); }); } else { $('#news_slide').animate({marginTop:-(slide_height+mask_height)}, speedNews, 'linear', function(){ slide_news(false, (slide_height+mask_height)*40, false); }); } } time_news = window.setTimeout(function(){ $('#news_slide').hover(function(){ $('#news_slide').stop(); }, function(){ slide_news(true, (slide_height+mask_height)*30, false); }); slide_news(true, slide_height*40, true); }, 1500); } });