var $window = $(window); var $header = $('#header'); var $inview = $('#header .inview'); var $navigation = $('#header .navigation'); var $absBox = $('.abs-container'); var $blankHeader = $('#blank-header'); var timer = null; function mouseEnterAction(){ if (timer == null){ $inview.show(); $navigation.show(); showNavBar(true); }else{ clearTimeout(timer); timer = null; } } function mouseLeaveAction(){ $inview.show(); $navigation.show(); showNavBar(false); $header.one('mouseover', function(){ mouseEnterAction(); }); } function showNavBar(show){ if (show){ $navigation.stop(false,true).delay(250).animate({ marginTop: 0 },'fast'); $inview.stop(false,true).animate({ marginTop: -1 * $header.height() },'slow', 'easeInOutBack'); }else{ $inview.stop(false,true).animate({ marginTop: 0 },'slow', 'easeInOutBack'); $navigation.stop(false,true).animate({ marginTop: -1 * $header.height() },'fast'); } } function introMenuAnimation(){ if (!$header.data('opened')){ /* $header.data('opened', true); showNavBar(true); */ timer = setTimeout(function(){ clearTimeout(timer); timer = null; $inview.show(); $header.one('mouseover', function(){ mouseEnterAction(); }); $header.bind('mouseleave', function(){ mouseLeaveAction(); }); showNavBar(false); },0); } } $(window).load(function(){ $breakpoint = $( window ).width(); if ($breakpoint > 600) { $('#header').show(); introMenuAnimation(); } else { return; } });