(function(a){a(function(){var d=a("main");var g=a("#side aside");var i=a("#scrollad");if(d.length===0||g.length===0||i.length===0){return}var c=a(window);var e;var k;var j;var f=function(){if(typeof e!=="undefined"){return}e={wrapper:{height:i.outerHeight(),offset:{top:i.offset().top}},side:{offset:{left:g.offset().left},margin:{top:g.css("margin-top")?g.css("margin-top"):0,right:g.css("margin-right")?g.css("margin-right"):0,bottom:g.css("margin-bottom")?g.css("margin-bottom"):0,left:g.css("margin-left")?g.css("margin-left"):0}}}};var h=function(){if(window.matchMedia&&window.matchMedia("screen and (min-width: 960px)").matches){return true}return false};var l=function(){var p=g.outerHeight();var r=d.outerHeight();var o=d.offset().top+r;var m=c.scrollTop();var n=c.height();var q=(m>e.wrapper.offset.top)&&(r>p)?true:false;k=c.scrollLeft();j=!q?"static":(m+e.wrapper.height)>o?"absolute":"fixed";if(j==="fixed"){g.css({position:j,top:"",bottom:n-e.wrapper.height,left:e.side.offset.left-k,margin:0});g.addClass("is-fixed")}else{if(j==="absolute"){g.css({position:j,top:o-p,bottom:"",left:e.side.offset.left,margin:0});g.addClass("is-fixed")}else{g.css({position:j,marginTop:e.side.margin.top,marginRight:e.side.margin.right,marginBottom:e.side.margin.bottom,marginLeft:e.side.margin.left});g.removeClass("is-fixed")}}};var b=function(){if(!h()){g.css({position:"static"});g.removeClass("is-fixed");return}g.css({position:"static",marginTop:e.side.margin.top,marginRight:e.side.margin.right,marginBottom:e.side.margin.bottom,marginLeft:e.side.margin.left});e.side.offset.left=g.offset().left;k=c.scrollLeft();if(j==="fixed"){g.css({position:j,left:e.side.offset.left-k,margin:0});g.addClass("is-fixed")}else{if(j==="absolute"){g.css({position:j,left:e.side.offset.left,margin:0});g.addClass("is-fixed")}else{g.removeClass("is-fixed")}}};if(h()){f();l()}c.on("scroll",function(){if(h()){f();l()}});c.on("resize",function(){if(h()){f();l()}b()})})})(jQuery);