(function(B){B.jScrollPane={active:[]};B.fn.jScrollPane=function(A){A=B.extend({},B.fn.jScrollPane.defaults,A);var D=function(){return false;};return this.each(function(){var AJ=B(this);AJ.css("overflow","hidden");var AA=this;if(B(this).parent().is(".jScrollPaneContainer")){var Ae=A.maintainPosition?AJ.position().top:0;var AM=B(this).parent();var Ay=AM.innerWidth();var AY=AM.outerHeight();var AL=AY;B(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",AM).remove();AJ.css({top:0});}else{var Ae=0;this.originalPadding=AJ.css("paddingTop")+" "+AJ.css("paddingRight")+" "+AJ.css("paddingBottom")+" "+AJ.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(AJ.css("paddingLeft"))||0)+(parseInt(AJ.css("paddingRight"))||0);var Ay=AJ.innerWidth();var AY=AJ.innerHeight();var AL=AY;AJ.wrap(B("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:AY+"px",width:Ay+"px"}));B(document).bind("emchange",function(F,E,G){AJ.jScrollPane(A);});}if(A.reinitialiseOnImageLoad){var AK=B.data(AA,"jScrollPaneImagesToLoad")||B("img",AJ);var AR=[];if(AK.length){AK.each(function(F,E){B(this).bind("load",function(){if(B.inArray(F,AR)==-1){AR.push(E);AK=B.grep(AK,function(G,H){return G!=E;});B.data(AA,"jScrollPaneImagesToLoad",AK);A.reinitialiseOnImageLoad=false;AJ.jScrollPane(A);}}).each(function(H,G){if(this.complete||this.complete===undefined){this.src=this.src;}});});}}var An=this.originalSidePaddingTotal;var Aq={height:"auto",width:Ay-A.scrollbarWidth-A.scrollbarMargin-An+"px"};if(A.scrollbarOnLeft){Aq.paddingLeft=A.scrollbarMargin+A.scrollbarWidth+"px";}else{Aq.paddingRight=A.scrollbarMargin+"px";}AJ.css(Aq);var Ap=AJ.outerHeight();var At=AY/Ap;if(At<0.99){var AQ=AJ.parent();AQ.append(B("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:A.scrollbarWidth+"px"}).append(B("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:A.scrollbarWidth+"px"}).append(B("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:A.scrollbarWidth+"px"}),B("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:A.scrollbarWidth+"px"}))));var AV=B(">.jScrollPaneTrack",AQ);var AI=B(">.jScrollPaneTrack .jScrollPaneDrag",AQ);if(A.showArrows){var Av;var Ag;var AF;var Al;var As=function(){if(Al>4||Al%4==0){AW(Ai+Ag*A0);}Al++;};var AN=function(E){B("html").unbind("mouseup",AN);Av.removeClass("jScrollActiveArrowButton");clearInterval(AF);};var C=function(){B("html").bind("mouseup",AN);Av.addClass("jScrollActiveArrowButton");Al=0;As();AF=setInterval(As,100);};AQ.append(B("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp"}).css({width:A.scrollbarWidth+"px"}).html("Scroll up").bind("mousedown",function(){Av=B(this);Ag=-1;C();this.blur();return false;}).bind("click",D),B("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown"}).css({width:A.scrollbarWidth+"px"}).html("Scroll down").bind("mousedown",function(){Av=B(this);Ag=1;C();this.blur();return false;}).bind("click",D));var AH=B(">.jScrollArrowUp",AQ);var AO=B(">.jScrollArrowDown",AQ);if(A.arrowSize){AL=AY-A.arrowSize-A.arrowSize;AV.css({height:AL+"px",top:A.arrowSize+"px"});}else{var Ak=AH.height();A.arrowSize=Ak;AL=AY-Ak-AO.height();AV.css({height:AL+"px",top:Ak+"px"});}}var AZ=B(this).css({position:"absolute",overflow:"visible"});var AU;var p;var A0;var Ai=0;var AC=At*AY/2;var A1=function(G,E){var F=E=="X"?"Left":"Top";return G["page"+E]||(G["client"+E]+(document.documentElement["scroll"+F]||document.body["scroll"+F]))||0;};var Aw=function(){return false;};var Af=function(){Ao();AU=AI.offset(false);AU.top-=Ai;p=AL-AI[0].offsetHeight;A0=2*A.wheelSpeed*p/Ap;};var AT=function(E){Af();AC=A1(E,"Y")-Ai-AU.top;B("html").bind("mouseup",AE).bind("mousemove",Au);if(B.browser.msie){B("html").bind("dragstart",Aw).bind("selectstart",Aw);}return false;};var AE=function(){B("html").unbind("mouseup",AE).unbind("mousemove",Au);AC=At*AY/2;if(B.browser.msie){B("html").unbind("dragstart",Aw).unbind("selectstart",Aw);}};var AW=function(F){F=F<0?0:(F>p?p:F);Ai=F;AI.css({top:F+"px"});var E=F/p;AZ.css({top:((AY-Ap)*E)+"px"});AJ.trigger("scroll");if(A.showArrows){AH[F==0?"addClass":"removeClass"]("disabled");AO[F==p?"addClass":"removeClass"]("disabled");}};var Au=function(E){AW(A1(E,"Y")-AU.top-AC);};var Am=Math.max(Math.min(At*(AY-A.arrowSize*2),A.dragMaxHeight),A.dragMinHeight);AI.css({height:Am+"px"}).bind("mousedown",AT);var Ar;var AG;var AP;var Aj=function(){if(AG>8||AG%4==0){AW((Ai-((Ai-AP)/2)));}AG++;};var Ah=function(){clearInterval(Ar);B("html").unbind("mouseup",Ah).unbind("mousemove",Ax);};var Ax=function(E){AP=A1(E,"Y")-AU.top-AC;};var AD=function(E){Af();Ax(E);AG=0;B("html").bind("mouseup",Ah).bind("mousemove",Ax);Ar=setInterval(Aj,100);Aj();};AV.bind("mousedown",AD);AQ.bind("mousewheel",function(G,E){Af();Ao();var F=Ai;AW(Ai-E*A0);var H=F!=Ai;return !H;});var AS;var AB;function Az(){var E=(AS-Ai)/A.animateStep;if(E>1||E<-1){AW(Ai+E);}else{AW(AS);Ao();}}var Ao=function(){if(AB){clearInterval(AB);delete AS;}};var AX=function(E,G){if(typeof E=="string"){$e=B(E,AJ);if(!$e.length){return ;}E=$e.offset().top-AJ.offset().top;}AQ.scrollTop(0);Ao();var F=-E/(AY-Ap)*p;if(G||!A.animateTo){AW(F);}else{AS=F;AB=setInterval(Az,A.animateInterval);}};AJ[0].scrollTo=AX;AJ[0].scrollBy=function(E){var F=-parseInt(AZ.css("top"))||0;AX(F+E);};Af();AX(-Ae,true);B("*",this).bind("focus",function(G){var H=B(this);var E=0;while(H[0]!=AJ[0]){E+=H.position().top;H=H.offsetParent();}var K=-parseInt(AZ.css("top"))||0;var F=K+AY;var I=E>K&&E<F;if(!I){var J=E-A.scrollbarMargin;if(E>K){J+=B(this).height()+15+A.scrollbarMargin-AY;}AX(J);}});if(location.hash){AX(location.hash);}B(document).bind("click",function(E){$target=B(E.target);if($target.is("a")){var F=$target.attr("href");if(F.substr(0,1)=="#"){AX(F);}}});B.jScrollPane.active.push(AJ[0]);}else{AJ.css({height:AY+"px",width:Ay-this.originalSidePaddingTotal+"px",padding:this.originalPadding});AJ.parent().unbind("mousewheel");}});};B.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};B(window).bind("unload",function(){var A=B.jScrollPane.active;for(var D=0;D<A.length;D++){A[D].scrollTo=A[D].scrollBy=null;}});})(jQuery);
