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