(function(d,e,f){d.fn.jScrollPane=function(a){function b(bs,bc){var bj,ba=this,a2,bF,aL,bD,a7,a1,s,aP,bY,bT,br,aX,bi,aY,aW,bP,a6,bz,a3,aN,bx,by,bK,bC,bm,aU,bt,bl,aJ,bp,bQ,a0,bf,bG=true,bb=true,bR=false,aV=false,bA=bs.clone(false,false).empty(),bN=d.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";bQ=bs.css("paddingTop")+" "+bs.css("paddingRight")+" "+bs.css("paddingBottom")+" "+bs.css("paddingLeft");a0=(parseInt(bs.css("paddingLeft"),10)||0)+(parseInt(bs.css("paddingRight"),10)||0);function bv(h){var m,k,l,o,g,i,j=false,n=false;bj=h;if(a2===f){g=bs.scrollTop();i=bs.scrollLeft();bs.css({overflow:"hidden",padding:0});bF=bs.innerWidth()+a0;aL=bs.innerHeight();bs.width(bF);a2=d('<div class="jspPane" />').css("padding",bQ).append(bs.children());bD=d('<div class="jspContainer" />').css({width:bF+"px",height:aL+"px"}).append(a2).appendTo(bs)}else{bs.css("width","");j=bj.stickToBottom&&bg();n=bj.stickToRight&&bw();o=bs.innerWidth()+a0!=bF||bs.outerHeight()!=aL;if(o){bF=bs.innerWidth()+a0;aL=bs.innerHeight();bD.css({width:bF+"px",height:aL+"px"})}if(!o&&bf==a7&&a2.outerHeight()==a1){bs.width(bF);return}bf=a7;a2.css("width","");bs.width(bF);bD.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}a2.css("overflow","auto");if(h.contentWidth){a7=h.contentWidth}else{a7=a2[0].scrollWidth}a1=a2[0].scrollHeight;a2.css("overflow","");s=a7/bF;aP=a1/aL;bY=aP>1;bT=s>1;if(!(bT||bY)){bs.removeClass("jspScrollable");a2.css({top:0,width:bD.width()-a0});aS();bq();a9();aK();bH()}else{bs.addClass("jspScrollable");m=bj.maintainPosition&&(bi||bP);if(m){k=bV();l=bX()}bS();c();bo();if(m){bd(n?(a7-bF):k,false);be(j?(a1-aL):l,false)}bh();bJ();bB();if(bj.enableKeyboardNavigation){a8()}if(bj.clickOnTrack){aQ()}bu();if(bj.hijackInternalLinks){aT()}}if(bj.autoReinitialise&&!bp){bp=setInterval(function(){bv(bj)},bj.autoReinitialiseDelay)}else{if(!bj.autoReinitialise&&bp){clearInterval(bp)}}g&&bs.scrollTop(0)&&be(g,false);i&&bs.scrollLeft(0)&&bd(i,false);bs.trigger("jsp-initialised",[bT||bY])}function bS(){if(bY){bD.append(d('<div class="jspVerticalBar" />').append(d('<div class="jspCap jspCapTop" />'),d('<div class="jspTrack" />').append(d('<div class="jspDrag" />').append(d('<div class="jspDragTop" />'),d('<div class="jspDragBottom" />'))),d('<div class="jspCap jspCapBottom" />')));a6=bD.find(">.jspVerticalBar");bz=a6.find(">.jspTrack");br=bz.find(">.jspDrag");if(bj.showArrows){by=d('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",bU(0,-1)).bind("click.jsp",bW);bK=d('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",bU(0,1)).bind("click.jsp",bW);if(bj.arrowScrollOnHover){by.bind("mouseover.jsp",bU(0,-1,by));bK.bind("mouseover.jsp",bU(0,1,bK))}bE(bz,bj.verticalArrowPositions,by,bK)}aN=aL;bD.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){aN-=d(this).outerHeight()});br.hover(function(){br.addClass("jspHover")},function(){br.removeClass("jspHover")}).bind("mousedown.jsp",function(h){d("html").bind("dragstart.jsp selectstart.jsp",bW);br.addClass("jspActive");var g=h.pageY-br.position().top;d("html").bind("mousemove.jsp",function(i){a5(i.pageY-g,false)}).bind("mouseup.jsp mouseleave.jsp",bn);return false});aR()}}function aR(){bz.height(aN+"px");bi=0;a3=bj.verticalGutter+bz.outerWidth();a2.width(bF-a3-a0);try{if(a6.position().left===0){a2.css("margin-left",a3+"px")}}catch(g){}}function c(){if(bT){bD.append(d('<div class="jspHorizontalBar" />').append(d('<div class="jspCap jspCapLeft" />'),d('<div class="jspTrack" />').append(d('<div class="jspDrag" />').append(d('<div class="jspDragLeft" />'),d('<div class="jspDragRight" />'))),d('<div class="jspCap jspCapRight" />')));bC=bD.find(">.jspHorizontalBar");bm=bC.find(">.jspTrack");aY=bm.find(">.jspDrag");if(bj.showArrows){bl=d('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",bU(-1,0)).bind("click.jsp",bW);aJ=d('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",bU(1,0)).bind("click.jsp",bW);if(bj.arrowScrollOnHover){bl.bind("mouseover.jsp",bU(-1,0,bl));aJ.bind("mouseover.jsp",bU(1,0,aJ))}bE(bm,bj.horizontalArrowPositions,bl,aJ)}aY.hover(function(){aY.addClass("jspHover")},function(){aY.removeClass("jspHover")}).bind("mousedown.jsp",function(h){d("html").bind("dragstart.jsp selectstart.jsp",bW);aY.addClass("jspActive");var g=h.pageX-aY.position().left;d("html").bind("mousemove.jsp",function(i){a4(i.pageX-g,false)}).bind("mouseup.jsp mouseleave.jsp",bn);return false});aU=bD.innerWidth();bI()}}function bI(){bD.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){aU-=d(this).outerWidth()});bm.width(aU+"px");bP=0}function bo(){if(bT&&bY){var h=bm.outerHeight(),g=bz.outerWidth();aN-=h;d(bC).find(">.jspCap:visible,>.jspArrow").each(function(){aU+=d(this).outerWidth()});aU-=g;aL-=g;bF-=h;bm.parent().append(d('<div class="jspCorner" />').css("width",h+"px"));aR();bI()}if(bT){a2.width((bD.outerWidth()-a0)+"px")}a1=a2.outerHeight();aP=a1/aL;if(bT){bt=Math.ceil(1/s*aU);if(bt>bj.horizontalDragMaxWidth){bt=bj.horizontalDragMaxWidth}else{if(bt<bj.horizontalDragMinWidth){bt=bj.horizontalDragMinWidth}}aY.width(bt+"px");aW=aU-bt;bL(bP)}if(bY){bx=Math.ceil(1/aP*aN);if(bx>bj.verticalDragMaxHeight){bx=bj.verticalDragMaxHeight}else{if(bx<bj.verticalDragMinHeight){bx=bj.verticalDragMinHeight}}br.height(bx+"px");aX=aN-bx;bM(bi)}}function bE(l,j,m,i){var g="before",k="after",h;if(j=="os"){j=/Mac/.test(navigator.platform)?"after":"split"}if(j==g){k=j}else{if(j==k){g=j;h=m;m=i;i=h}}l[g](m)[k](i)}function bU(i,g,h){return function(){bk(i,g,this,h);this.blur();return false}}function bk(k,l,g,h){g=d(g).addClass("jspActive");var j,m,n=true,i=function(){if(k!==0){ba.scrollByX(k*bj.arrowButtonSpeed)}if(l!==0){ba.scrollByY(l*bj.arrowButtonSpeed)}m=setTimeout(i,n?bj.initialDelay:bj.arrowRepeatFreq);n=false};i();j=h?"mouseout.jsp":"mouseup.jsp";h=h||d("html");h.bind(j,function(){g.removeClass("jspActive");m&&clearTimeout(m);m=null;h.unbind(j)})}function aQ(){aK();if(bY){bz.bind("mousedown.jsp",function(h){if(h.originalTarget===f||h.originalTarget==h.currentTarget){var k=d(this),g=k.offset(),j=h.pageY-g.top-bi,m,n=true,i=function(){var o=k.offset(),r=h.pageY-o.top-bx/2,q=aL*bj.scrollPagePercent,p=aX*q/(a1-aL);if(j<0){if(bi-p>r){ba.scrollByY(-q)}else{a5(r)}}else{if(j>0){if(bi+p<r){ba.scrollByY(q)}else{a5(r)}}else{l();return}}m=setTimeout(i,n?bj.initialDelay:bj.trackClickRepeatFreq);n=false},l=function(){m&&clearTimeout(m);m=null;d(document).unbind("mouseup.jsp",l)};i();d(document).bind("mouseup.jsp",l);return false}})}if(bT){bm.bind("mousedown.jsp",function(h){if(h.originalTarget===f||h.originalTarget==h.currentTarget){var k=d(this),g=k.offset(),j=h.pageX-g.left-bP,m,n=true,i=function(){var o=k.offset(),r=h.pageX-o.left-bt/2,q=bF*bj.scrollPagePercent,p=aW*q/(a7-bF);if(j<0){if(bP-p>r){ba.scrollByX(-q)}else{a4(r)}}else{if(j>0){if(bP+p<r){ba.scrollByX(q)}else{a4(r)}}else{l();return}}m=setTimeout(i,n?bj.initialDelay:bj.trackClickRepeatFreq);n=false},l=function(){m&&clearTimeout(m);m=null;d(document).unbind("mouseup.jsp",l)};i();d(document).bind("mouseup.jsp",l);return false}})}}function aK(){if(bm){bm.unbind("mousedown.jsp")}if(bz){bz.unbind("mousedown.jsp")}}function bn(){d("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(br){br.removeClass("jspActive")}if(aY){aY.removeClass("jspActive")}}function a5(g,h){if(!bY){return}if(g<0){g=0}else{if(g>aX){g=aX}}if(h===f){h=bj.animateScroll}if(h){ba.animate(br,"top",g,bM)}else{br.css("top",g);bM(g)}}function bM(k){if(k===f){k=br.position().top}bD.scrollTop(0);bi=k;var h=bi===0,j=bi==aX,i=k/aX,g=-i*(a1-aL);if(bG!=h||bR!=j){bG=h;bR=j;bs.trigger("jsp-arrow-change",[bG,bR,bb,aV])}aM(h,j);a2.css("top",g);bs.trigger("jsp-scroll-y",[-g,h,j]).trigger("scroll")}function a4(h,g){if(!bT){return}if(h<0){h=0}else{if(h>aW){h=aW}}if(g===f){g=bj.animateScroll}if(g){ba.animate(aY,"left",h,bL)}else{aY.css("left",h);bL(h)}}function bL(k){if(k===f){k=aY.position().left}bD.scrollTop(0);bP=k;var h=bP===0,i=bP==aW,j=k/aW,g=-j*(a7-bF);if(bb!=h||aV!=i){bb=h;aV=i;bs.trigger("jsp-arrow-change",[bG,bR,bb,aV])}aO(h,i);a2.css("left",g);bs.trigger("jsp-scroll-x",[-g,h,i]).trigger("scroll")}function aM(h,g){if(bj.showArrows){by[h?"addClass":"removeClass"]("jspDisabled");bK[g?"addClass":"removeClass"]("jspDisabled")}}function aO(h,g){if(bj.showArrows){bl[h?"addClass":"removeClass"]("jspDisabled");aJ[g?"addClass":"removeClass"]("jspDisabled")}}function be(g,i){var h=g/(a1-aL);a5(h*aX,i)}function bd(i,g){var h=i/(a7-bF);a4(h*aW,g)}function bO(h,m,u){var p,t,r,v=0,i=0,g,n,o,k,l,j;try{p=d(h)}catch(q){return}t=p.outerHeight();r=p.outerWidth();bD.scrollTop(0);bD.scrollLeft(0);while(!p.is(".jspPane")){v+=p.position().top;i+=p.position().left;p=p.offsetParent();if(/^body|html$/i.test(p[0].nodeName)){return}}g=bX();o=g+aL;if(v<g||m){l=v-bj.verticalGutter}else{if(v+t>o){l=v-aL+t+bj.verticalGutter}}if(l){be(l,u)}n=bV();k=n+bF;if(i<n||m){j=i-bj.horizontalGutter}else{if(i+r>k){j=i-bF+r+bj.horizontalGutter}}if(j){bd(j,u)}}function bV(){return -a2.position().left}function bX(){return -a2.position().top}function bg(){var g=a1-aL;return(g>20)&&(g-bX()<10)}function bw(){var g=a7-bF;return(g>20)&&(g-bV()<10)}function bJ(){bD.unbind(bN).bind(bN,function(i,h,j,l){var k=bP,g=bi;ba.scrollBy(j*bj.mouseWheelSpeed,-l*bj.mouseWheelSpeed,false);return k==bP&&g==bi})}function aS(){bD.unbind(bN)}function bW(){return false}function bh(){a2.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(g){bO(g.target,false)})}function bq(){a2.find(":input,a").unbind("focus.jsp")}function a8(){var g,j,h=[];bT&&h.push(bC[0]);bY&&h.push(a6[0]);a2.focus(function(){bs.focus()});bs.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(k){if(k.target!==this&&!(h.length&&d(k.target).closest(h).length)){return}var l=bP,m=bi;switch(k.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:g=k.keyCode;i();break;case 35:be(a1-aL);g=null;break;case 36:be(0);g=null;break}j=k.keyCode==g&&l!=bP||m!=bi;return !j}).bind("keypress.jsp",function(k){if(k.keyCode==g){i()}return !j});if(bj.hideFocus){bs.css("outline","none");if("hideFocus" in bD[0]){bs.attr("hideFocus",true)}}else{bs.css("outline","");if("hideFocus" in bD[0]){bs.attr("hideFocus",false)}}function i(){var k=bP,l=bi;switch(g){case 40:ba.scrollByY(bj.keyboardSpeed,false);break;case 38:ba.scrollByY(-bj.keyboardSpeed,false);break;case 34:case 32:ba.scrollByY(aL*bj.scrollPagePercent,false);break;case 33:ba.scrollByY(-aL*bj.scrollPagePercent,false);break;case 39:ba.scrollByX(bj.keyboardSpeed,false);break;case 37:ba.scrollByX(-bj.keyboardSpeed,false);break}j=k!=bP||l!=bi;return j}}function a9(){bs.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function bu(){if(location.hash&&location.hash.length>1){var h,j,i=escape(location.hash);try{h=d(i)}catch(g){return}if(h.length&&a2.find(i)){if(bD.scrollTop()===0){j=setInterval(function(){if(bD.scrollTop()>0){bO(i,true);d(document).scrollTop(bD.position().top);clearInterval(j)}},50)}else{bO(i,true);d(document).scrollTop(bD.position().top)}}}}function bH(){d("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function aT(){bH();d("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var g=this.href.split("#"),h;if(g.length>1){h=g[1];if(h.length>0&&a2.find("#"+h).length>0){bO("#"+h,true);return false}}})}function bB(){var k,l,i,j,h,g=false;bD.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(n){var m=n.originalEvent.touches[0];k=bV();l=bX();i=m.pageX;j=m.pageY;h=false;g=true}).bind("touchmove.jsp",function(m){if(!g){return}var n=m.originalEvent.touches[0],o=bP,p=bi;ba.scrollTo(k+i-n.pageX,l+j-n.pageY);h=h||Math.abs(i-n.pageX)>5||Math.abs(j-n.pageY)>5;return o==bP&&p==bi}).bind("touchend.jsp",function(m){g=false}).bind("click.jsp-touchclick",function(m){if(h){h=false;return false}})}function aZ(){var g=bX(),h=bV();bs.removeClass("jspScrollable").unbind(".jsp");bs.replaceWith(bA.append(a2.children()));bA.scrollTop(g);bA.scrollLeft(h)}d.extend(ba,{reinitialise:function(g){g=d.extend({},bj,g);bv(g)},scrollToElement:function(h,i,g){bO(h,i,g)},scrollTo:function(h,g,i){bd(h,i);be(g,i)},scrollToX:function(h,g){bd(h,g)},scrollToY:function(g,h){be(g,h)},scrollToPercentX:function(h,g){bd(h*(a7-bF),g)},scrollToPercentY:function(h,g){be(h*(a1-aL),g)},scrollBy:function(i,g,h){ba.scrollByX(i,h);ba.scrollByY(g,h)},scrollByX:function(g,i){var j=bV()+Math[g<0?"floor":"ceil"](g),h=j/(a7-bF);a4(h*aW,i)},scrollByY:function(g,i){var j=bX()+Math[g<0?"floor":"ceil"](g),h=j/(a1-aL);a5(h*aX,i)},positionDragX:function(g,h){a4(g,h)},positionDragY:function(h,g){a5(h,g)},animate:function(k,h,g,i){var j={};j[h]=g;k.animate(j,{duration:bj.animateDuration,easing:bj.animateEase,queue:false,step:i})},getContentPositionX:function(){return bV()},getContentPositionY:function(){return bX()},getContentWidth:function(){return a7},getContentHeight:function(){return a1},getPercentScrolledX:function(){return bV()/(a7-bF)},getPercentScrolledY:function(){return bX()/(a1-aL)},getIsScrollableH:function(){return bT},getIsScrollableV:function(){return bY},getContentPane:function(){return a2},scrollToBottom:function(g){a5(aX,g)},hijackInternalLinks:function(){aT()},destroy:function(){aZ()}});bv(bc)}a=d.extend({},d.fn.jScrollPane.defaults,a);d.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){a[this]=a[this]||a.speed});return this.each(function(){var h=d(this),c=h.data("jsp");if(c){c.reinitialise(a)}else{c=new b(h,a);h.data("jsp",c)}})};d.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:f,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);
