/*!
* Theia Sticky Sidebar v1.2.2
* https://github.com/WeCodePixels/theia-sticky-sidebar
*
* Glues your website's sidebars, making them permanently visible while scrolling.
*
* Copyright 2013-2014 WeCodePixels and other contributors
* Released under the MIT license
*/
(function(a){a.fn.theiaStickySidebar=function(b){var c={containerSelector:"",additionalMarginTop:0,additionalMarginBottom:0,updateSidebarHeight:true,minWidth:0};b=a.extend(c,b);b.additionalMarginTop=parseInt(b.additionalMarginTop)||0;b.additionalMarginBottom=parseInt(b.additionalMarginBottom)||0;a("head").append(a(''));this.each(function(){var h={};h.sidebar=a(this);h.options=b||{};h.container=a(h.options.containerSelector);if(h.container.size()==0){h.container=h.sidebar.parent()}h.sidebar.parents().css("-webkit-transform","none");h.sidebar.css({position:"relative",overflow:"visible","-webkit-box-sizing":"border-box","-moz-box-sizing":"border-box","box-sizing":"border-box"});h.stickySidebar=h.sidebar.find(".theiaStickySidebar");if(h.stickySidebar.length==0){h.sidebar.find("script").remove();h.stickySidebar=a("
").addClass("theiaStickySidebar").append(h.sidebar.children());h.sidebar.append(h.stickySidebar)}h.marginTop=parseInt(h.sidebar.css("margin-top"));h.marginBottom=parseInt(h.sidebar.css("margin-bottom"));h.paddingTop=parseInt(h.sidebar.css("padding-top"));h.paddingBottom=parseInt(h.sidebar.css("padding-bottom"));var e=h.stickySidebar.offset().top;var g=h.stickySidebar.outerHeight();h.stickySidebar.css("padding-top",1);h.stickySidebar.css("padding-bottom",1);e-=h.stickySidebar.offset().top;g=h.stickySidebar.outerHeight()-g-e;if(e==0){h.stickySidebar.css("padding-top",0);h.stickySidebarPaddingTop=0}else{h.stickySidebarPaddingTop=1}if(g==0){h.stickySidebar.css("padding-bottom",0);h.stickySidebarPaddingBottom=0}else{h.stickySidebarPaddingBottom=1}h.previousScrollTop=null;h.fixedScrollTop=0;d();h.onScroll=function(i){if(!i.stickySidebar.is(":visible")){return}if(a("body").width()
i.container.width()){d();return}var j=a(document).scrollTop();var n="static";if(j>=i.container.offset().top+(i.paddingTop+i.marginTop-i.options.additionalMarginTop)){var k=i.paddingTop+i.marginTop+b.additionalMarginTop;var l=i.paddingBottom+i.marginBottom+b.additionalMarginBottom;var m=i.container.offset().top;var v=i.container.offset().top+f(i.container);var s=0+b.additionalMarginTop;var q;var r=(i.stickySidebar.outerHeight()+k+l)0){u=Math.min(u,s)}else{u=Math.max(u,q-i.stickySidebar.outerHeight())}u=Math.max(u,x);u=Math.min(u,w-i.stickySidebar.outerHeight());var y=i.container.height()==i.stickySidebar.outerHeight();if(!y&&u==s){n="fixed"}else{if(!y&&u==q-i.stickySidebar.outerHeight()){n="fixed"}else{if(j+u-i.sidebar.offset().top-i.paddingTop<=b.additionalMarginTop){n="static"}else{n="absolute"}}}}if(n=="fixed"){i.stickySidebar.css({position:"fixed",width:i.sidebar.width(),top:u,left:i.sidebar.offset().left+parseInt(i.sidebar.css("padding-left"))})}else{if(n=="absolute"){var p={};if(i.stickySidebar.css("position")!="absolute"){p.position="absolute";p.top=j+u-i.sidebar.offset().top-i.stickySidebarPaddingTop-i.stickySidebarPaddingBottom}p.width=i.sidebar.width();p.left="";i.stickySidebar.css(p)}else{if(n=="static"){d()}}}if(n!="static"){if(i.options.updateSidebarHeight==true){i.sidebar.css({"min-height":i.stickySidebar.outerHeight()+i.stickySidebar.offset().top-i.sidebar.offset().top+i.paddingBottom})}}i.previousScrollTop=j};h.onScroll(h);a(document).scroll(function(i){return function(){i.onScroll(i)}}(h));a(window).resize(function(i){return function(){i.stickySidebar.css({position:"static"});i.onScroll(i)}}(h));function d(){h.fixedScrollTop=0;h.sidebar.css({"min-height":"1px"});h.stickySidebar.css({position:"static",width:""})}function f(j){var i=j.height();j.children().each(function(){i=Math.max(i,a(this).height())});return i}})}})(jQuery);