(function(){var c,d;c=this.jQuery;d=function(){function b(a){this.content=this.pane=this.slider=null;this.contentY=this.contentH=this.offsetY=this.sliderY=this.paneH=this.sliderH=this.scrollH=0;this.isDrag=!1;this.target=a;this.generate();this.createEvents();this.assignEvents();this.reset()}b.prototype.createEvents=function(){var a;a=this;return this.handler={down:function(b){a.isDrag=!0;a.offsetY=b.clientY-a.slider.offset().top;a.pane.addClass("active");c(document).bind("mousemove",a.handler.drag);
c(document).bind("mouseup",a.handler.up);return!1},drag:function(b){a.sliderY=b.clientY-a.target.offset().top-a.offsetY;a.scroll();return!1},up:function(){a.isDrag=!1;a.pane.removeClass("active");c(document).unbind("mousemove",a.handler.drag);c(document).unbind("mouseup",a.handler.up);return!1},resize:function(){a.reset();return a.scroll()},panedown:function(b){a.sliderY=b.clientY-a.target.offset().top-0.5*a.sliderH;a.scroll();return a.handler.down(b)},scroll:function(){if(!0!==a.isDrag)return a.slider.css({top:Math.floor(a.content[0].scrollTop/
a.content[0].scrollHeight*(a.paneH+5))})}}};b.prototype.assignEvents=function(){c(window).bind("resize",this.handler.resize);this.slider.bind("mousedown",this.handler.down);this.pane.bind("mousedown",this.handler.panedown);return this.content.bind("scroll",this.handler.scroll)};b.prototype.removeEventListeners=function(){c(window).unbind("resize",this.handler.resize);this.slider.unbind("mousedown",this.handler.down);this.pane.unbind("mousedown",this.handler.panedown);return this.content.unbind("scroll",
this.handler.scroll)};b.prototype.getScrollbarWidth=function(){var a,b,c;b=document.createElement("div");b.style.position="absolute";b.style.width="100px";b.style.height="100px";b.style.overflow="scroll";document.body.appendChild(b);a=b.offsetWidth;c=b.scrollWidth;document.body.removeChild(b);return a-c};b.prototype.generate=function(){this.target.append('<div class="pane"><div class="slider"></div></div>');this.content=c(this.target.children()[0]);this.slider=this.target.find(".slider");this.pane=
this.target.find(".pane");this.scrollW=this.getScrollbarWidth();if(0===this.scrollbarWidth)this.scrollW=0;this.content.css({right:-this.scrollW+"px"});null!=c.browser.msie&&8>parseInt(c.browser.version)&&this.pane.hide()};b.prototype.reset=function(){if(!0===this.isDead)this.isDead=!1,this.pane.show(),this.assignEvents();this.contentH=this.content[0].scrollHeight;this.paneH=this.pane.height();this.sliderH=this.paneH/this.contentH*this.paneH;this.scrollH=this.paneH-this.sliderH;this.slider.height(this.sliderH)};
b.prototype.scroll=function(){var a;if(0>this.sliderY)this.sliderY=0;if(this.sliderY>this.scrollH)this.sliderY=this.scrollH;a=this.paneH-this.contentH+this.scrollW;a=a*this.sliderY/this.scrollH;this.content.scrollTop(-a);return this.slider.css({top:this.sliderY})};b.prototype.scrollBottom=function(){this.reset();this.sliderY=this.scrollH;this.scroll()};b.prototype.scrollTop=function(){this.reset();this.sliderY=0;this.scroll()};b.prototype.stop=function(){this.isDead=!0;this.removeEventListeners();
this.pane.hide()};return b}();c.fn.nanoScroller=function(b){var a,b=b||{};a=this.data("scrollbar");if(void 0===a)a=new d(this,b),this.data({scrollbar:a});else return"bottom"===b.scroll?a.scrollBottom():"top"===b.scroll?a.scrollTop():!0===b.stop?a.stop():a.reset()}}).call(this);
