/*
* jScrollPane - v2.0.0beta10 - 2011-04-17
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2010 Kelvin Luck
* Dual licensed under the MIT and GPL licenses.
*/
(function(a,c,b){a.fn.jScrollPane=function(f){function d(y,ao){var au,T=this,aa,ac,ab,p,u,q,ad,ae,S,R,aB,x,aD,C,w,D,aA,aE,ap,aF,aC,n,j,B,F,G,E,k,l,ai,Y,Z,ah,aJ=true,aH=true,aG=false,aI=false,X=y.clone(false,false).empty(),U=a.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";Y=y.css("paddingTop")+" "+y.css("paddingRight")+" "+y.css("paddingBottom")+" "+y.css("paddingLeft");Z=(parseInt(y.css("paddingLeft"),10)||0)+(parseInt(y.css("paddingRight"),10)||0);function J(aS){var aL,aM,aN,aK,aR,aQ,aO=false,aP=false;au=aS;if(aa===b){aR=y.scrollTop();aQ=y.scrollLeft();y.css({overflow:"hidden",padding:0});ac=y.innerWidth()+Z;ab=y.innerHeight();y.width(ac);aa=a('<div class="jspPane" />').css("padding",Y).append(y.children());p=a('<div class="jspContainer" />').css({width:ac+"px",height:ab+"px"}).append(aa).appendTo(y)}else{y.css("width","");aO=au.stickToBottom&&P();aP=au.stickToRight&&Q();aK=y.innerWidth()+Z!=ac||y.outerHeight()!=ab;if(aK){ac=y.innerWidth()+Z;ab=y.innerHeight();p.css({width:ac+"px",height:ab+"px"})}if(!aK&&ah==u&&aa.outerHeight()==q){y.width(ac);return}ah=u;aa.css("width","");y.width(ac);p.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}aa.css("overflow","auto");if(aS.contentWidth){u=aS.contentWidth}else{u=aa[0].scrollWidth}q=aa[0].scrollHeight;aa.css("overflow","");ad=u/ac;ae=q/ab;S=ae>1;R=ad>1;if(!(R||S)){y.removeClass("jspScrollable");aa.css({top:0,width:p.width()-Z});am();ak();al();aj();ax()}else{y.addClass("jspScrollable");aL=au.maintainPosition&&(aD||D);if(aL){aM=r();aN=t()}L();K();an();if(aL){ar(aP?(u-ac):aM,false);at(aO?(q-ab):aN,false)}I();N();O();if(au.enableKeyboardNavigation){M()}if(au.clickOnTrack){H()}W();if(au.hijackInternalLinks){A()}}if(au.autoReinitialise&&!ai){ai=setInterval(function(){J(au)},au.autoReinitialiseDelay)}else{if(!au.autoReinitialise&&ai){clearInterval(ai)}}aR&&y.scrollTop(0)&&at(aR,false);aQ&&y.scrollLeft(0)&&ar(aQ,false);y.trigger("jsp-initialised",[R||S])}function L(){if(S){p.append(a('<div class="jspVerticalBar" />').append(a('<div class="jspCap jspCapTop" />'),a('<div class="jspTrack" />').append(a('<div class="jspDrag" />').append(a('<div class="jspDragTop" />'),a('<div class="jspDragBottom" />'))),a('<div class="jspCap jspCapBottom" />')));aA=p.find(">.jspVerticalBar");aE=aA.find(">.jspTrack");aB=aE.find(">.jspDrag");if(au.showArrows){n=a('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",z(0,-1)).bind("click.jsp",V);j=a('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",z(0,1)).bind("click.jsp",V);if(au.arrowScrollOnHover){n.bind("mouseover.jsp",z(0,-1,n));j.bind("mouseover.jsp",z(0,1,j))}i(aE,au.verticalArrowPositions,n,j)}aF=ab;p.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){aF-=a(this).outerHeight()});aB.hover(function(){aB.addClass("jspHover")},function(){aB.removeClass("jspHover")}).bind("mousedown.jsp",function(s){a("html").bind("dragstart.jsp selectstart.jsp",V);aB.addClass("jspActive");var aK=s.pageY-aB.position().top;a("html").bind("mousemove.jsp",function(aL){ag(aL.pageY-aK,false)}).bind("mouseup.jsp mouseleave.jsp",o);return false});aw()}}function aw(){aE.height(aF+"px");aD=0;ap=au.verticalGutter+aE.outerWidth();aa.width(ac-ap-Z);try{if(aA.position().left===0){aa.css("margin-left",ap+"px")}}catch(s){}}function K(){if(R){p.append(a('<div class="jspHorizontalBar" />').append(a('<div class="jspCap jspCapLeft" />'),a('<div class="jspTrack" />').append(a('<div class="jspDrag" />').append(a('<div class="jspDragLeft" />'),a('<div class="jspDragRight" />'))),a('<div class="jspCap jspCapRight" />')));B=p.find(">.jspHorizontalBar");F=B.find(">.jspTrack");C=F.find(">.jspDrag");if(au.showArrows){k=a('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",z(-1,0)).bind("click.jsp",V);l=a('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",z(1,0)).bind("click.jsp",V);if(au.arrowScrollOnHover){k.bind("mouseover.jsp",z(-1,0,k));l.bind("mouseover.jsp",z(1,0,l))}i(F,au.horizontalArrowPositions,k,l)}C.hover(function(){C.addClass("jspHover")},function(){C.removeClass("jspHover")}).bind("mousedown.jsp",function(s){a("html").bind("dragstart.jsp selectstart.jsp",V);C.addClass("jspActive");var aK=s.pageX-C.position().left;a("html").bind("mousemove.jsp",function(aL){af(aL.pageX-aK,false)}).bind("mouseup.jsp mouseleave.jsp",o);return false});G=p.innerWidth();av()}}function av(){p.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){G-=a(this).outerWidth()});F.width(G+"px");D=0}function an(){if(R&&S){var s=F.outerHeight(),aK=aE.outerWidth();aF-=s;a(B).find(">.jspCap:visible,>.jspArrow").each(function(){G+=a(this).outerWidth()});G-=aK;ab-=aK;ac-=s;F.parent().append(a('<div class="jspCorner" />').css("width",s+"px"));aw();av()}if(R){aa.width((p.outerWidth()-Z)+"px")}q=aa.outerHeight();ae=q/ab;if(R){E=Math.ceil(1/ad*G);if(E>au.horizontalDragMaxWidth){E=au.horizontalDragMaxWidth}else{if(E<au.horizontalDragMinWidth){E=au.horizontalDragMinWidth}}C.width(E+"px");w=G-E;if(w!=0){g(D)}}if(S){if(ae==0||aF==0){return}aC=Math.ceil(1/ae*aF);if(aC>au.verticalDragMaxHeight){aC=au.verticalDragMaxHeight}else{if(aC<au.verticalDragMinHeight){aC=au.verticalDragMinHeight}}aB.height(aC+"px");x=aF-aC;if(x!=0){h(aD)}}}function i(aM,aN,s,aK){var aO="before",aP="after",aL;if(aN=="os"){aN=/Mac/.test(navigator.platform)?"after":"split"}if(aN==aO){aP=aN}else{if(aN==aP){aO=aN;aL=s;s=aK;aK=aL}}aM[aO](s)[aP](aK)}function z(s,aK,aL){return function(){m(s,aK,this,aL);this.blur();return false}}function m(aK,aL,s,aN){s=a(s).addClass("jspActive");var aO,aQ,aP=true,aM=function(){if(aK!==0){T.scrollByX(aK*au.arrowButtonSpeed)}if(aL!==0){T.scrollByY(aL*au.arrowButtonSpeed)}aQ=setTimeout(aM,aP?au.initialDelay:au.arrowRepeatFreq);aP=false};aM();aO=aN?"mouseout.jsp":"mouseup.jsp";aN=aN||a("html");aN.bind(aO,function(){s.removeClass("jspActive");aQ&&clearTimeout(aQ);aQ=null;aN.unbind(aO)})}function H(){aj();if(S){aE.bind("mousedown.jsp",function(aN){if(aN.originalTarget===b||aN.originalTarget==aN.currentTarget){var aK=a(this),aP=aK.offset(),aL=aN.pageY-aP.top-aD,aQ,aO=true,aM=function(){var aT=aK.offset(),aU=aN.pageY-aT.top-aC/2,aR=ab*au.scrollPagePercent,aS=x*aR/(q-ab);if(aL<0){if(aD-aS>aU){T.scrollByY(-aR)}else{ag(aU)}}else{if(aL>0){if(aD+aS<aU){T.scrollByY(aR)}else{ag(aU)}}else{s();return}}aQ=setTimeout(aM,aO?au.initialDelay:au.trackClickRepeatFreq);aO=false},s=function(){aQ&&clearTimeout(aQ);aQ=null;a(document).unbind("mouseup.jsp",s)};aM();a(document).bind("mouseup.jsp",s);return false}})}if(R){F.bind("mousedown.jsp",function(aN){if(aN.originalTarget===b||aN.originalTarget==aN.currentTarget){var aK=a(this),aP=aK.offset(),aL=aN.pageX-aP.left-D,aQ,aO=true,aM=function(){var aT=aK.offset(),aU=aN.pageX-aT.left-E/2,aR=ac*au.scrollPagePercent,aS=w*aR/(u-ac);if(aL<0){if(D-aS>aU){T.scrollByX(-aR)}else{af(aU)}}else{if(aL>0){if(D+aS<aU){T.scrollByX(aR)}else{af(aU)}}else{s();return}}aQ=setTimeout(aM,aO?au.initialDelay:au.trackClickRepeatFreq);aO=false},s=function(){aQ&&clearTimeout(aQ);aQ=null;a(document).unbind("mouseup.jsp",s)};aM();a(document).bind("mouseup.jsp",s);return false}})}}function aj(){if(F){F.unbind("mousedown.jsp")}if(aE){aE.unbind("mousedown.jsp")}}function o(){a("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(aB){aB.removeClass("jspActive")}if(C){C.removeClass("jspActive")}}function ag(aK,s){if(!S){return}if(aK<0){aK=0}else{if(aK>x){aK=x}}if(s===b){s=au.animateScroll}if(s){T.animate(aB,"top",aK,h)}else{aB.css("top",aK);h(aK)}}function h(aK){if(aK===b){aK=aB.position().top}p.scrollTop(0);aD=aK;var aM=aD===0,aL=aD==x,aN=aK/x,s=-aN*(q-ab);if(aJ!=aM||aG!=aL){aJ=aM;aG=aL;y.trigger("jsp-arrow-change",[aJ,aG,aH,aI])}az(aM,aL);aa.css("top",s);y.trigger("jsp-scroll-y",[-s,aM,aL]).trigger("scroll")}function af(aK,s){if(!R){return}if(aK<0){aK=0}else{if(aK>w){aK=w}}if(s===b){s=au.animateScroll}if(s){T.animate(C,"left",aK,g)}else{C.css("left",aK);g(aK)}}function g(aK){if(aK===b){aK=C.position().left}p.scrollTop(0);D=aK;var aL=D===0,aM=D==w,aN=aK/w,s=-aN*(u-ac);if(aH!=aL||aI!=aM){aH=aL;aI=aM;y.trigger("jsp-arrow-change",[aJ,aG,aH,aI])}ay(aL,aM);aa.css("left",s);y.trigger("jsp-scroll-x",[-s,aL,aM]).trigger("scroll")}function az(aK,s){if(au.showArrows){n[aK?"addClass":"removeClass"]("jspDisabled");j[s?"addClass":"removeClass"]("jspDisabled")}}function ay(s,aK){if(au.showArrows){k[s?"addClass":"removeClass"]("jspDisabled");l[aK?"addClass":"removeClass"]("jspDisabled")}}function at(aK,s){var aL=aK/(q-ab);ag(aL*x,s)}function ar(aK,s){var aL=aK/(u-ac);af(aL*w,s)}function aq(aN,aV,s){var aM,aO,aR,aQ=0,aP=0,aX,aW,aU,aT,aL,aK;try{aM=a(aN)}catch(aS){return}aO=aM.outerHeight();aR=aM.outerWidth();p.scrollTop(0);p.scrollLeft(0);while(!aM.is(".jspPane")){aQ+=aM.position().top;aP+=aM.position().left;aM=aM.offsetParent();if(/^body|html$/i.test(aM[0].nodeName)){return}}aX=t();aU=aX+ab;if(aQ<aX||aV){aL=aQ-au.verticalGutter}else{if(aQ+aO>aU){aL=aQ-ab+aO+au.verticalGutter}}if(aL){at(aL,s)}aW=r();aT=aW+ac;if(aP<aW||aV){aK=aP-au.horizontalGutter}else{if(aP+aR>aT){aK=aP-ac+aR+au.horizontalGutter}}if(aK){ar(aK,s)}}function r(){return -aa.position().left}function t(){return -aa.position().top}function P(){var s=q-ab;return(s>20)&&(s-t()<10)}function Q(){var s=u-ac;return(s>20)&&(s-r()<10)}function N(){p.unbind(U).bind(U,function(aO,s,aK,aL){var aM=D,aN=aD;T.scrollBy(aK*au.mouseWheelSpeed,-aL*au.mouseWheelSpeed,false);return aM==D&&aN==aD})}function am(){p.unbind(U)}function V(){return false}function I(){aa.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){aq(s.target,false)})}function ak(){aa.find(":input,a").unbind("focus.jsp")}function M(){var aK,s,aM=[];R&&aM.push(B[0]);S&&aM.push(aA[0]);aa.focus(function(){y.focus()});y.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aP){if(aP.target!==this&&!(aM.length&&a(aP.target).closest(aM).length)){return}var aN=D,aO=aD;switch(aP.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:aK=aP.keyCode;aL();break;case 35:at(q-ab);aK=null;break;case 36:at(0);aK=null;break}s=aP.keyCode==aK&&aN!=D||aO!=aD;return !s}).bind("keypress.jsp",function(aN){if(aN.keyCode==aK){aL()}return !s});if(au.hideFocus){y.css("outline","none");if("hideFocus" in p[0]){y.attr("hideFocus",true)}}else{y.css("outline","");if("hideFocus" in p[0]){y.attr("hideFocus",false)}}function aL(){var aN=D,aO=aD;switch(aK){case 40:T.scrollByY(au.keyboardSpeed,false);break;case 38:T.scrollByY(-au.keyboardSpeed,false);break;case 34:case 32:T.scrollByY(ab*au.scrollPagePercent,false);break;case 33:T.scrollByY(-ab*au.scrollPagePercent,false);break;case 39:T.scrollByX(au.keyboardSpeed,false);break;case 37:T.scrollByX(-au.keyboardSpeed,false);break}s=aN!=D||aO!=aD;return s}}function al(){y.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function W(){if(location.hash&&location.hash.length>1){var s,aL;try{s=a(location.hash)}catch(aK){return}if(s.length&&aa.find(location.hash)){if(p.scrollTop()===0){aL=setInterval(function(){if(p.scrollTop()>0){aq(location.hash,true);a(document).scrollTop(p.position().top);clearInterval(aL)}},50)}else{aq(location.hash,true);a(document).scrollTop(p.position().top)}}}}function ax(){a("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function A(){ax();a("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var aK=this.href.split("#"),s;if(aK.length>1){s=aK[1];if(s.length>0&&aa.find("#"+s).length>0){aq("#"+s,true);return false}}})}function O(){var aL,aM,aN,aO,s,aK=false;p.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aP){var aQ=aP.originalEvent.touches[0];aL=r();aM=t();aN=aQ.pageX;aO=aQ.pageY;s=false;aK=true}).bind("touchmove.jsp",function(aR){if(!aK){return}var aS=aR.originalEvent.touches[0],aP=D,aQ=aD;T.scrollTo(aL+aN-aS.pageX,aM+aO-aS.pageY);s=s||Math.abs(aN-aS.pageX)>5||Math.abs(aO-aS.pageY)>5;return aP==D&&aQ==aD}).bind("touchend.jsp",function(aP){aK=false}).bind("click.jsp-touchclick",function(aP){if(s){s=false;return false}})}function v(){var aK=t(),s=r();y.removeClass("jspScrollable").unbind(".jsp");y.replaceWith(X.append(aa.children()));X.scrollTop(aK);X.scrollLeft(s)}a.extend(T,{reinitialise:function(aK){aK=a.extend({},au,aK);J(aK)},scrollToElement:function(aK,aL,s){aq(aK,aL,s)},scrollTo:function(aK,aL,s){ar(aK,s);at(aL,s)},scrollToX:function(aK,s){ar(aK,s)},scrollToY:function(aK,s){at(aK,s)},scrollToPercentX:function(aK,s){ar(aK*(u-ac),s)},scrollToPercentY:function(aK,s){at(aK*(q-ab),s)},scrollBy:function(aK,aL,s){T.scrollByX(aK,s);T.scrollByY(aL,s)},scrollByX:function(aK,s){var aL=r()+aK,aM=aL/(u-ac);af(aM*w,s)},scrollByY:function(aK,s){var aL=t()+aK,aM=aL/(q-ab);ag(aM*x,s)},positionDragX:function(aK,s){af(aK,s)},positionDragY:function(aK,s){ag(aK,s)},animate:function(s,aL,aN,aM){var aK={};aK[aL]=aN;s.animate(aK,{duration:au.animateDuration,ease:au.animateEase,queue:false,step:aM})},getContentPositionX:function(){return r()},getContentPositionY:function(){return t()},getContentWidth:function(){return u},getContentHeight:function(){return q},getPercentScrolledX:function(){return r()/(u-ac)},getPercentScrolledY:function(){return t()/(q-ab)},getIsScrollableH:function(){return R},getIsScrollableV:function(){return S},getContentPane:function(){return aa},scrollToBottom:function(s){ag(x,s)},hijackInternalLinks:function(){A()},destroy:function(){v()}});J(ao)}f=a.extend({},a.fn.jScrollPane.defaults,f);a.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){f[this]=f[this]||f.speed});var e;this.each(function(){var g=a(this),h=g.data("jsp");if(h){h.reinitialise(f)}else{h=new d(g,f);g.data("jsp",h)}e=e?e.add(g):g});return e};a.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:true,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:b,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);
/* Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
* 
* Requires: 1.2.2+
*/
(function(a){var c=["DOMMouseScroll","mousewheel"];a.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=c.length;d;){this.addEventListener(c[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=c.length;d;){this.removeEventListener(c[--d],b,false)}}else{this.onmousewheel=null}}};a.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(h){var i=h||window.event,d=[].slice.call(arguments,1),e=0,j=true,f=0,g=0;h=a.event.fix(i);h.type="mousewheel";if(h.wheelDelta){e=h.wheelDelta/120}if(h.detail){e=-h.detail/3}g=e;if(i.axis!==undefined&&i.axis===i.HORIZONTAL_AXIS){g=0;f=-1*e}if(i.wheelDeltaY!==undefined){g=i.wheelDeltaY/120}if(i.wheelDeltaX!==undefined){f=-1*i.wheelDeltaX/120}d.unshift(h,e,f,g);return a.event.handle.apply(this,d)}})(jQuery);
