jQuery.jScrollPane={active:[]};jQuery.fn.jScrollPane=function(W){W=jQuery.extend({scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:undefined,animateTo:false,dragMinHeight:1,dragMaxHeight:99999},W);return this.each(function(){var e=jQuery(this);if(jQuery(this).parent().is('.jScrollPaneContainer')){var f=jQuery(this).parent();var g=f.innerWidth();var h=f.outerHeight();var i=h;if(f.unmousewheel){f.unmousewheel()}jQuery('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown',f).remove();e.css({'top':0})}else{this.originalPadding=e.css('paddingTop')+' '+e.css('paddingRight')+' '+e.css('paddingBottom')+' '+e.css('paddingLeft');this.originalSidePaddingTotal=(parseInt(e.css('paddingLeft'))||0)+(parseInt(e.css('paddingRight'))||0);var g=e.innerWidth();var h=e.innerHeight();var i=h;e.wrap(jQuery('<div>').attr({'className':'jScrollPaneContainer'}).css({'height':h+'px','width':g+'px'}))}var p=this.originalSidePaddingTotal;e.css({'height':'auto','width':g-W.scrollbarWidth-W.scrollbarMargin-p+'px','paddingRight':W.scrollbarMargin+'px'});var j=e.outerHeight();var k=h/j;if(k<.98){var l=e.parent();l.append(jQuery('<div>').attr({'className':'jScrollPaneTrack'}).css({'width':W.scrollbarWidth+'px'}).append(jQuery('<div>').attr({'className':'jScrollPaneDrag'}).css({'width':W.scrollbarWidth+'px'}).append(jQuery('<div>').attr({'className':'jScrollPaneDragTop'}).css({'width':W.scrollbarWidth+'px'}),jQuery('<div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':W.scrollbarWidth+'px'}))));var m=jQuery('>.jScrollPaneTrack',l);var n=jQuery('>.jScrollPaneTrack .jScrollPaneDrag',l);if(W.showArrows){var o;var q;var r;var s;var t=function(){if(s>4||s%4==0){I(B+q*A)}s++};var u=function(a){jQuery('body').unbind('mouseup',u);o.removeClass('jScrollActiveArrowButton');clearInterval(r)};var v=function(){jQuery('body').bind('mouseup',u);o.addClass('jScrollActiveArrowButton');s=0;t();r=setInterval(t,100)};l.append(jQuery('<a>').attr({'href':'javascript:;','className':'jScrollArrowUp'}).css({'width':W.scrollbarWidth+'px'}).html('Scroll up').bind('mousedown',function(){o=$(this);q=-1;v();this.blur();return false}),jQuery('<a>').attr({'href':'javascript:;','className':'jScrollArrowDown'}).css({'width':W.scrollbarWidth+'px'}).html('Scroll down').bind('mousedown',function(){o=$(this);q=1;v();this.blur();return false}));if(W.arrowSize){i=h-W.arrowSize-W.arrowSize;m.css({'height':i+'px',top:W.arrowSize+'px'})}else{var w=jQuery('>.jScrollArrowUp',l).height();i=h-w-jQuery('>.jScrollArrowDown',l).height();m.css({'height':i+'px',top:w+'px'})}}var x=jQuery(this).css({'position':'absolute','overflow':'visible'});var y;var z;var A;var B=0;var C=k*h/2;var D=function(a,b){var p=b=='X'?'Left':'Top';return a['page'+b]||(a['client'+b]+(document.documentElement['scroll'+p]||document.body['scroll'+p]))||0};var E=function(){return false};var F=function(){U();y=n.offset(false);y.top-=B;z=i-n[0].offsetHeight;A=2*W.wheelSpeed*z/j};var G=function(a){F();C=D(a,'Y')-B-y.top;jQuery('body').bind('mouseup',H).bind('mousemove',J);if(jQuery.browser.msie){jQuery('body').bind('dragstart',E).bind('selectstart',E)}return false};var H=function(){jQuery('body').unbind('mouseup',H).unbind('mousemove',J);C=k*h/2;if(jQuery.browser.msie){jQuery('body').unbind('dragstart',E).unbind('selectstart',E)}};var I=function(a){a=a<0?0:(a>z?z:a);B=a;n.css({'top':a+'px'});var p=a/z;x.css({'top':((h-j)*p)+'px'})};var J=function(a){I(D(a,'Y')-y.top-C)};var K=Math.max(Math.min(k*h,W.dragMaxHeight),W.dragMinHeight);n.css({'height':K+'px'}).bind('mousedown',G);var L;var M;var N;var O=function(){if(M>8||M%4==0){I((B-((B-N)/2)))}M++};var P=function(){clearInterval(L);jQuery('body').unbind('mouseup',P).unbind('mousemove',Q)};var Q=function(a){N=D(a,'Y')-y.top-C};var R=function(a){F();Q(a);M=0;jQuery('body').bind('mouseup',P).bind('mousemove',Q);L=setInterval(O,100);O()};m.bind('mousedown',R);if(l.mousewheel){l.mousewheel(function(a,b){F();U();var d=B;I(B-b*A);var c=d!=B;return!c},false)}var S;var T;function animateToPosition(){var a=(S-B)/3;if(a>1||a<-1){I(B+a)}else{I(S);U()}}var U=function(){if(T){clearInterval(T);delete S}};var V=function(a){U();var b=-a/(h-j)*z;if(W.animateTo){S=b;T=setInterval(animateToPosition,100)}else{I(b)}};e[0].scrollTo=V;e[0].scrollBy=function(a){var b=-parseInt(x.css('top'))||0;V(b+a)};F();jQuery.jScrollPane.active.push(e[0])}else{e.css({'height':h+'px','width':g-this.originalSidePaddingTotal+'px','padding':this.originalPadding})}})};jQuery(window).bind('unload',function(){var a=jQuery.jScrollPane.active;for(var i=0;i<a.length;i++){a[i].scrollTo=a[i].scrollBy=null}});