/*!
 * Theia Sticky Sidebar v1.4.0
 * https://github.com/WeCodePixels/theia-sticky-sidebar
 *
 * Glues your website's sidebars, making them permanently visible while scrolling.
 *
 * Copyright 2013-2016 WeCodePixels and other contributors
 * Released under the MIT license
 */(function(a){a.fn.theiaStickySidebar=function(b){var d={containerSelector:'',additionalMarginTop:0,additionalMarginBottom:0,updateSidebarHeight:!0,minWidth:0,disableOnResponsiveLayouts:!0,sidebarBehavior:'modern'};b=a.extend(d,b),b.additionalMarginTop=parseInt(b.additionalMarginTop)||0,b.additionalMarginBottom=parseInt(b.additionalMarginBottom)||0,e(b,this);function e(b,d){var e=c(b,d);e||(console.log('TST: Body width smaller than options.minWidth. Init is delayed.'),a(document).scroll(function(b,d){return function(e){var f=c(b,d);f&&a(this).unbind(e)}}(b,d)),a(window).resize(function(b,d){return function(e){var f=c(b,d);f&&a(this).unbind(e)}}(b,d)))}function c(b,c){return b.initialized===!0||(!(a('body').width()<b.minWidth)&&(f(b,c),!0))}function f(b,c){b.initialized=!0,a('head').append(a('<style>.theiaStickySidebar:after {content: ""; display: table; clear: both;}</style>')),c.each(function(){var c={},e,f;c.sidebar=a(this),c.options=b||{},c.container=a(c.options.containerSelector),c.container.size()==0&&(c.container=c.sidebar.parent()),c.sidebar.parents().css('-webkit-transform','none'),c.sidebar.css({position:'relative',overflow:'visible','-webkit-box-sizing':'border-box','-moz-box-sizing':'border-box','box-sizing':'border-box'}),c.stickySidebar=c.sidebar.find('.theiaStickySidebar'),c.stickySidebar.length==0&&(c.sidebar.find('script').remove(),c.stickySidebar=a('<div>').addClass('theiaStickySidebar').append(c.sidebar.children()),c.sidebar.append(c.stickySidebar)),c.marginTop=parseInt(c.sidebar.css('margin-top')),c.marginBottom=parseInt(c.sidebar.css('margin-bottom')),c.paddingTop=parseInt(c.sidebar.css('padding-top')),c.paddingBottom=parseInt(c.sidebar.css('padding-bottom')),e=c.stickySidebar.offset().top,f=c.stickySidebar.outerHeight(),c.stickySidebar.css('padding-top',1),c.stickySidebar.css('padding-bottom',1),e-=c.stickySidebar.offset().top,f=c.stickySidebar.outerHeight()-f-e,e==0?(c.stickySidebar.css('padding-top',0),c.stickySidebarPaddingTop=0):c.stickySidebarPaddingTop=1,f==0?(c.stickySidebar.css('padding-bottom',0),c.stickySidebarPaddingBottom=0):c.stickySidebarPaddingBottom=1,c.previousScrollTop=null,c.fixedScrollTop=0,d(),c.onScroll=function(c){var r,f,h,t,s,n,o,k,i,u,p,q,e,l,m,j;if(!c.stickySidebar.is(":visible"))return;if(a('body').width()<c.options.minWidth){d();return}if(c.options.disableOnResponsiveLayouts)if(r=c.sidebar.outerWidth(c.sidebar.css('float')=='none'),r+50>c.container.width()){d();return}f=a(document).scrollTop(),h='static',f>=c.container.offset().top+(c.paddingTop+c.marginTop-c.options.additionalMarginTop)&&(t=c.paddingTop+c.marginTop+b.additionalMarginTop,s=c.paddingBottom+c.marginBottom+b.additionalMarginBottom,n=c.container.offset().top,o=c.container.offset().top+g(c.container),k=0+b.additionalMarginTop,u=c.stickySidebar.outerHeight()+t+s<a(window).height(),u?i=k+c.stickySidebar.outerHeight():i=a(window).height()-c.marginBottom-c.paddingBottom-b.additionalMarginBottom,p=n-f+c.paddingTop+c.marginTop,q=o-f-c.paddingBottom-c.marginBottom,e=c.stickySidebar.offset().top-f,l=c.previousScrollTop-f,c.stickySidebar.css('position')=='fixed'&&c.options.sidebarBehavior=='modern'&&(e+=l),c.options.sidebarBehavior=='stick-to-top'&&(e=b.additionalMarginTop),c.options.sidebarBehavior=='stick-to-bottom'&&(e=i-c.stickySidebar.outerHeight()),l>0?e=Math.min(e,k):e=Math.max(e,i-c.stickySidebar.outerHeight()),e=Math.max(e,p),e=Math.min(e,q-c.stickySidebar.outerHeight()),m=c.container.height()==c.stickySidebar.outerHeight(),!m&&e==k?h='fixed':!m&&e==i-c.stickySidebar.outerHeight()?h='fixed':f+e-c.sidebar.offset().top-c.paddingTop<=b.additionalMarginTop?h='static':h='absolute'),h=='fixed'?c.stickySidebar.css({position:'fixed',width:c.sidebar.width(),top:e,left:c.sidebar.offset().left+parseInt(c.sidebar.css('padding-left'))}):h=='absolute'?(j={},c.stickySidebar.css('position')!='absolute'&&(j.position='absolute',j.top=f+e-c.sidebar.offset().top-c.stickySidebarPaddingTop-c.stickySidebarPaddingBottom),j.width=c.sidebar.width(),j.left='',c.stickySidebar.css(j)):h=='static'&&d(),h!='static'&&c.options.updateSidebarHeight==!0&&c.sidebar.css({'min-height':c.stickySidebar.outerHeight()+c.stickySidebar.offset().top-c.sidebar.offset().top+c.paddingBottom}),c.previousScrollTop=f},c.onScroll(c),a(document).scroll(function(a){return function(){a.onScroll(a)}}(c)),a(window).resize(function(a){return function(){a.stickySidebar.css({position:'static'}),a.onScroll(a)}}(c));function d(){c.fixedScrollTop=0,c.sidebar.css({'min-height':'1px'}),c.stickySidebar.css({position:'static',width:''})}function g(c){var b=c.height();return c.children().each(function(){b=Math.max(b,a(this).height())}),b}})}}})(jQuery)