(function(e){e.fn.customScrollbar=function(t,n){var r={skin:undefined,hScroll:true,vScroll:true,updateOnWindowResize:false,animationSpeed:300,onCustomScroll:undefined,swipeSpeed:1,wheelSpeed:40,fixedThumbWidth:undefined,fixedThumbHeight:undefined,preventDefaultScroll:false};var i=function(t,n){this.$element=e(t);this.options=n;this.addScrollableClass();this.addSkinClass();this.addScrollBarComponents();if(this.options.vScroll)this.vScrollbar=new s(this,new u);if(this.options.hScroll)this.hScrollbar=new s(this,new o);this.$element.data("scrollable",this);this.initKeyboardScrolling();this.bindEvents()};i.prototype={addScrollableClass:function(){if(!this.$element.hasClass("scrollable")){this.scrollableAdded=true;this.$element.addClass("scrollable")}},removeScrollableClass:function(){if(this.scrollableAdded)this.$element.removeClass("scrollable")},addSkinClass:function(){if(typeof this.options.skin=="string"&&!this.$element.hasClass(this.options.skin)){this.skinClassAdded=true;this.$element.addClass(this.options.skin)}},removeSkinClass:function(){if(this.skinClassAdded)this.$element.removeClass(this.options.skin)},addScrollBarComponents:function(){this.assignViewPort();if(this.$viewPort.length==0){this.$element.wrapInner('
');this.assignViewPort();this.viewPortAdded=true}this.assignOverview();if(this.$overview.length==0){this.$viewPort.wrapInner('');this.assignOverview();this.overviewAdded=true}this.addScrollBar("vertical","prepend");this.addScrollBar("horizontal","append")},removeScrollbarComponents:function(){this.removeScrollbar("vertical");this.removeScrollbar("horizontal");if(this.overviewAdded)this.$element.unwrap();if(this.viewPortAdded)this.$element.unwrap()},removeScrollbar:function(e){if(this[e+"ScrollbarAdded"])this.$element.find(".scroll-bar."+e).remove()},assignViewPort:function(){this.$viewPort=this.$element.find(".viewport")},assignOverview:function(){this.$overview=this.$viewPort.find(".overview")},addScrollBar:function(e,t){if(this.$element.find(".scroll-bar."+e).length==0){this.$element[t](" ");this[e+"ScrollbarAdded"]=true}},resize:function(e){if(this.vScrollbar)this.vScrollbar.resize(e);if(this.hScrollbar)this.hScrollbar.resize(e)},scrollTo:function(e){if(this.vScrollbar)this.vScrollbar.scrollToElement(e);if(this.hScrollbar)this.hScrollbar.scrollToElement(e)},scrollToXY:function(e,t){this.scrollToX(e);this.scrollToY(t)},scrollToX:function(e){if(this.hScrollbar)this.hScrollbar.scrollOverviewTo(e,true)},scrollToY:function(e){if(this.vScrollbar)this.vScrollbar.scrollOverviewTo(e,true)},scrollByX:function(e){if(this.hScrollbar)this.scrollToX(this.hScrollbar.overviewPosition()+e)},scrollByY:function(e){if(this.vScrollbar)this.scrollToY(this.vScrollbar.overviewPosition()+e)},remove:function(){this.removeScrollableClass();this.removeSkinClass();this.removeScrollbarComponents();this.$element.data("scrollable",null);this.removeKeyboardScrolling();if(this.vScrollbar)this.vScrollbar.remove();if(this.hScrollbar)this.hScrollbar.remove()},setAnimationSpeed:function(e){this.options.animationSpeed=e},isInside:function(t,n){var r=e(t);var i=e(n);var s=r.offset();var o=i.offset();return s.top>=o.top&&s.left>=o.left&&s.top+r.height()<=o.top+i.height()&&s.left+r.width()<=o.left+i.width()},initKeyboardScrolling:function(){var e=this;this.elementKeydown=function(t){if(document.activeElement===e.$element[0]){if(e.vScrollbar)e.vScrollbar.keyScroll(t);if(e.hScrollbar)e.hScrollbar.keyScroll(t)}};this.$element.attr("tabindex","-1").keydown(this.elementKeydown)},removeKeyboardScrolling:function(){this.$element.removeAttr("tabindex").unbind("keydown",this.elementKeydown)},bindEvents:function(){if(this.options.onCustomScroll)this.$element.on("customScroll",this.options.onCustomScroll)}};var s=function(e,t){this.scrollable=e;this.sizing=t;this.$scrollBar=this.sizing.scrollBar(this.scrollable.$element);this.$thumb=this.$scrollBar.find(".thumb");this.setScrollPosition(0,0);this.resize();this.initMouseMoveScrolling();this.initMouseWheelScrolling();this.initTouchScrolling();this.initMouseClickScrolling();this.initWindowResize()};s.prototype={resize:function(e){this.overviewSize=this.sizing.size(this.scrollable.$overview);this.calculateViewPortSize();this.sizing.size(this.scrollable.$viewPort,this.viewPortSize);this.ratio=this.viewPortSize/this.overviewSize;this.sizing.size(this.$scrollBar,this.viewPortSize);this.thumbSize=this.calculateThumbSize();this.sizing.size(this.$thumb,this.thumbSize);this.maxThumbPosition=this.calculateMaxThumbPosition();this.maxOverviewPosition=this.calculateMaxOverviewPosition();this.enabled=this.overviewSize>this.viewPortSize;if(this.scrollPercent===undefined)this.scrollPercent=0;if(this.enabled)this.rescroll(e);else this.setScrollPosition(0,0);this.$scrollBar.toggle(this.enabled)},calculateViewPortSize:function(){var e=this.sizing.size(this.scrollable.$element);if(e>0&&!this.maxSizeUsed){this.viewPortSize=e;this.maxSizeUsed=false}else{var t=this.sizing.maxSize(this.scrollable.$element);this.viewPortSize=Math.min(t,this.overviewSize);this.maxSizeUsed=true}},calculateThumbSize:function(){var e=this.sizing.fixedThumbSize(this.scrollable.options);var t;if(e)t=e;else t=this.ratio*this.viewPortSize;return Math.max(t,this.sizing.minSize(this.$thumb))},initMouseMoveScrolling:function(){var t=this;this.$thumb.mousedown(function(e){if(t.enabled)t.startMouseMoveScrolling(e)});this.documentMouseup=function(e){t.stopMouseMoveScrolling(e)};e(document).mouseup(this.documentMouseup);this.documentMousemove=function(e){t.mouseMoveScroll(e)};e(document).mousemove(this.documentMousemove);this.$thumb.click(function(e){e.stopPropagation()})},removeMouseMoveScrolling:function(){this.$thumb.unbind();e(document).unbind("mouseup",this.documentMouseup);e(document).unbind("mousemove",this.documentMousemove)},initMouseWheelScrolling:function(){var e=this;this.scrollable.$element.mousewheel(function(t,n,r,i){if(e.enabled){var s=e.mouseWheelScroll(r,i);e.stopEventConditionally(t,s)}})},removeMouseWheelScrolling:function(){this.scrollable.$element.unbind("mousewheel")},initTouchScrolling:function(){if(document.addEventListener){var e=this;this.elementTouchstart=function(t){if(e.enabled)e.startTouchScrolling(t)};this.scrollable.$element[0].addEventListener("touchstart",this.elementTouchstart);this.documentTouchmove=function(t){e.touchScroll(t)};document.addEventListener("touchmove",this.documentTouchmove);this.elementTouchend=function(t){e.stopTouchScrolling(t)};this.scrollable.$element[0].addEventListener("touchend",this.elementTouchend)}},removeTouchScrolling:function(){if(document.addEventListener){this.scrollable.$element[0].removeEventListener("touchstart",this.elementTouchstart);document.removeEventListener("touchmove",this.documentTouchmove);this.scrollable.$element[0].removeEventListener("touchend",this.elementTouchend)}},initMouseClickScrolling:function(){var e=this;this.scrollBarClick=function(t){e.mouseClickScroll(t)};this.$scrollBar.click(this.scrollBarClick)},removeMouseClickScrolling:function(){this.$scrollBar.unbind("click",this.scrollBarClick)},initWindowResize:function(){if(this.scrollable.options.updateOnWindowResize){var t=this;this.windowResize=function(){t.resize()};e(window).resize(this.windowResize)}},removeWindowResize:function(){e(window).unbind("resize",this.windowResize)},isKeyScrolling:function(e){return this.keyScrollDelta(e)!=null},keyScrollDelta:function(e){for(var t in this.sizing.scrollingKeys)if(t==e)return this.sizing.scrollingKeys[e](this.viewPortSize);return null},startMouseMoveScrolling:function(t){this.mouseMoveScrolling=true;e("body").addClass("not-selectable");this.setUnselectable(e("body"),"on");this.setScrollEvent(t);t.preventDefault()},stopMouseMoveScrolling:function(t){this.mouseMoveScrolling=false;e("body").removeClass("not-selectable");this.setUnselectable(e("body"),null)},setUnselectable:function(e,t){if(e.attr("unselectable")!=t){e.attr("unselectable",t);e.find(":not(input)").attr("unselectable",t)}},mouseMoveScroll:function(e){if(this.mouseMoveScrolling){var t=this.sizing.mouseDelta(this.scrollEvent,e);this.scrollThumbBy(t);this.setScrollEvent(e)}},startTouchScrolling:function(e){if(e.touches&&e.touches.length==1){this.setScrollEvent(e.touches[0]);this.touchScrolling=true;e.stopPropagation()}},touchScroll:function(e){if(this.touchScrolling&&e.touches&&e.touches.length==1){var t=-this.sizing.mouseDelta(this.scrollEvent,e.touches[0])*this.scrollable.options.swipeSpeed;var n=this.scrollOverviewBy(t);if(n)this.setScrollEvent(e.touches[0]);this.stopEventConditionally(e,n)}},stopTouchScrolling:function(e){this.touchScrolling=false;e.stopPropagation()},mouseWheelScroll:function(e,t){var n=-this.sizing.wheelDelta(e,t)*this.scrollable.options.wheelSpeed;if(n!=0)return this.scrollOverviewBy(n)},mouseClickScroll:function(e){var t=this.viewPortSize-20;if(e["page"+this.sizing.scrollAxis()]