(function($){var windowSel=$(window);var bodySel=$('body');var fixedSel=$('.mkhb-fixed');var stickySel=$('.mkhb-sticky');var normalRespNav=$('.mkhb-navigation-resp__normal');var stickyRespNav=$('.mkhb-navigation-resp__sticky');var windowHeight=windowSel.height();var adminBarHeight=0;function mkhbGetOffset(offset,device){var deviceEl=$('.mkhb-'+device);var $deviceHeight=deviceEl.height();var $offset=0;if(typeof offset==='string'&&offset!=='header'){$offset=Math.round((parseInt(offset)/100)*windowHeight);}else if(typeof offset==='number'){$offset=parseInt(offset);}
if(0==$offset||isNaN($offset)){$offset=$deviceHeight;if(deviceEl.hasClass('mkhb-overlap')){$offset=deviceEl.children('.mkhb-device-container').height();}}
if($deviceHeight>$offset){$offset=$deviceHeight;}
return $offset;}
function mkhbUpdateTop(){adminBarHeight=$('#wpadminbar').height();adminBarHeight=(adminBarHeight==null)?0:adminBarHeight;}
function mkhbSetFixedHeight(selector){selector.each(function(e){var thisSel=$(this);if(!thisSel.hasClass('mkhb-overlap')){var childHeight=thisSel.children('.mkhb-device-container').height();thisSel.height(childHeight);}});}
function mkhbSlideDown(current,offset,device,curHeight){var onScroll=function onScroll(){var addOffset=mkhbAddRespNormal(offset,device);if(windowSel.scrollTop()>addOffset){current.css({'top':adminBarHeight});current.addClass('mkhb-sticky--active');}else{current.css({'top':-curHeight});current.removeClass('mkhb-sticky--active');current.find('.mkhb-search-el__overlay').removeClass('mkhb-search-el__overlay--show');mkhbHideRespBurger();}};onScroll();windowSel.on('scroll',onScroll);}
function mkhbLazy(current,offset,device,curHeight){var lastScrollPos=0;var onScroll=function onScroll(){var addOffset=mkhbAddRespNormal(offset,device);var scrollPos=windowSel.scrollTop();if(scrollPos>addOffset&&scrollPos<lastScrollPos){current.css({'top':adminBarHeight});current.addClass('mkhb-sticky--active');}else{current.css({'top':-curHeight});current.removeClass('mkhb-sticky--active');current.find('.mkhb-search-el__overlay').removeClass('mkhb-search-el__overlay--show');mkhbHideRespBurger();}
lastScrollPos=scrollPos;};onScroll();windowSel.on('scroll',onScroll);}
function mkhbHideRespBurger(){if(stickyRespNav.length<=0){return;}
if($('body[class*="mkhb-navigation-resp--opened"]')<=0){return;}
stickyRespNav.each(function(){var wrap=$(this);var id=wrap.attr('id').replace('-wrap','');var current=$('#'+id).find('.mkhb-navigation-resp');if(bodySel.hasClass('mkhb-navigation-resp--opened-'+id)){current.removeClass('is-active').find('.mkhb-navigation-resp__container').removeClass('fullscreen-active');bodySel.removeClass('mkhb-navigation-resp--opened-'+id).addClass('mkhb-navigation-resp--closed-'+id).trigger('mkhb-navigation-resp--closed-'+id);wrap.hide();}});}
function mkhbAddRespNormal(offset,device){if(normalRespNav.length<=0){return offset;}
if($('body[class*="mkhb-navigation-resp--opened"]')<=0){return offset;}
var deviceEl=$('.mkhb-'+device);var deviceHeight=deviceEl.height();normalRespNav.each(function(){var current=$(this);var height=current.height();var id=current.attr('id').replace('-wrap','');if(bodySel.hasClass('mkhb-navigation-resp--opened-'+id)){var newOffset=deviceHeight+parseInt(height);if(newOffset>offset){offset=newOffset;}
return offset;}});return offset;}
var resizeHeader=function resizeHeader(){var fixedRsz=$('.mkhb-fixed');if(fixedRsz.length>0){mkhbSetFixedHeight(fixedRsz);}}
if(fixedSel.length>0){mkhbSetFixedHeight(fixedSel);windowSel.on('resize',resizeHeader);}
var initialAction=function initialAction(){if(stickySel.length>0){stickySel.each(function(e){var current=$(this);var offset=current.data('offset');var device=current.data('device');offset=mkhbGetOffset(offset,device);mkhbUpdateTop();var curHeight=current.height();current.css({'top':-curHeight});var effect=current.data('effect');if(effect=='slide-down'){mkhbSlideDown(current,offset,device,curHeight);}else if(effect=='lazy'){mkhbLazy(current,offset,device,curHeight);}});}}
windowSel.on('load',initialAction);windowSel.on('resize',mkhbUpdateTop);})(jQuery);