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

