/*
* jscrollpane - v2.0.0beta11 - 2011-07-04
* http://jscrollpane.kelvinluck.com/
*
* copyright (c) 2010 kelvin luck
* dual licensed under the mit and gpl licenses.
*/
(function(b,a,c){b.fn.jscrollpane=function(e){function d(d,o){var az,q=this,y,ak,v,am,t,z,y,q,aa,af,av,i,i,h,j,aa,u,aq,x,t,a,ar,af,an,g,l,au,ay,x,aw,ai,f,l,aj=true,p=true,ah=false,k=false,ap=d.clone(false,false).empty(),ac=b.fn.mwheelintent?"mwheelintent.jsp":"mousewheel.jsp";ai=d.css("paddingtop")+" "+d.css("paddingright")+" "+d.css("paddingbottom")+" "+d.css("paddingleft");f=(parseint(d.css("paddingleft"),10)||0)+(parseint(d.css("paddingright"),10)||0);function at(ar){var am,ao,an,ak,aj,aq,ap=false,al=false;az=ar;if(y===c){aj=d.scrolltop();aq=d.scrollleft();d.css({overflow:"hidden",padding:0});ak=d.innerwidth()+f;v=d.innerheight();d.width(ak);y=b('
').css("padding",ai).append(d.children());am=b('').css({width:ak+"px",height:v+"px"}).append(y).appendto(d)}else{d.css("width","");ap=az.sticktobottom&&k();al=az.sticktoright&&b();ak=d.innerwidth()+f!=ak||d.outerheight()!=v;if(ak){ak=d.innerwidth()+f;v=d.innerheight();am.css({width:ak+"px",height:v+"px"})}if(!ak&&l==t&&y.outerheight()==z){d.width(ak);return}l=t;y.css("width","");d.width(ak);am.find(">.jspverticalbar,>.jsphorizontalbar").remove().end()}y.css("overflow","auto");if(ar.contentwidth){t=ar.contentwidth}else{t=y[0].scrollwidth}z=y[0].scrollheight;y.css("overflow","");y=t/ak;q=z/v;aa=q>1;af=y>1;if(!(af||aa)){d.removeclass("jspscrollable");y.css({top:0,width:am.width()-f});n();e();r();w();ai()}else{d.addclass("jspscrollable");am=az.maintainposition&&(i||aa);if(am){ao=ad();an=ab()}ag();z();f();if(am){n(al?(t-ak):ao,false);m(ap?(z-v):an,false)}j();ag();ao();if(az.enablekeyboardnavigation){s()}if(az.clickontrack){p()}c();if(az.hijackinternallinks){m()}}if(az.autoreinitialise&&!aw){aw=setinterval(function(){at(az)},az.autoreinitialisedelay)}else{if(!az.autoreinitialise&&aw){clearinterval(aw)}}aj&&d.scrolltop(0)&&m(aj,false);aq&&d.scrollleft(0)&&n(aq,false);d.trigger("jsp-initialised",[af||aa])}function ag(){if(aa){am.append(b('').append(b(''),b('').append(b('').append(b(''),b(''))),b('')));u=am.find(">.jspverticalbar");aq=u.find(">.jsptrack");av=aq.find(">.jspdrag");if(az.showarrows){ar=b('').bind("mousedown.jsp",ae(0,-1)).bind("click.jsp",ac);af=b('').bind("mousedown.jsp",ae(0,1)).bind("click.jsp",ac);if(az.arrowscrollonhover){ar.bind("mouseover.jsp",ae(0,-1,ar));af.bind("mouseover.jsp",ae(0,1,af))}al(aq,az.verticalarrowpositions,ar,af)}t=v;am.find(">.jspverticalbar>.jspcap:visible,>.jspverticalbar>.jsparrow").each(function(){t-=b(this).outerheight()});av.hover(function(){av.addclass("jsphover")},function(){av.removeclass("jsphover")}).bind("mousedown.jsp",function(aj){b("html").bind("dragstart.jsp selectstart.jsp",ac);av.addclass("jspactive");var s=aj.pagey-av.position().top;b("html").bind("mousemove.jsp",function(ak){v(ak.pagey-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});o()}}function o(){aq.height(t+"px");i=0;x=az.verticalgutter+aq.outerwidth();y.width(ak-x-f);try{if(u.position().left===0){y.css("margin-left",x+"px")}}catch(s){}}function z(){if(af){am.append(b('').append(b(''),b('').append(b('').append(b(''),b(''))),b('')));an=am.find(">.jsphorizontalbar");g=an.find(">.jsptrack");h=g.find(">.jspdrag");if(az.showarrows){ay=b('').bind("mousedown.jsp",ae(-1,0)).bind("click.jsp",ac);x=b('').bind("mousedown.jsp",ae(1,0)).bind("click.jsp",ac);
if(az.arrowscrollonhover){ay.bind("mouseover.jsp",ae(-1,0,ay));x.bind("mouseover.jsp",ae(1,0,x))}al(g,az.horizontalarrowpositions,ay,x)}h.hover(function(){h.addclass("jsphover")},function(){h.removeclass("jsphover")}).bind("mousedown.jsp",function(aj){b("html").bind("dragstart.jsp selectstart.jsp",ac);h.addclass("jspactive");var s=aj.pagex-h.position().left;b("html").bind("mousemove.jsp",function(ak){w(ak.pagex-s,false)}).bind("mouseup.jsp mouseleave.jsp",ax);return false});l=am.innerwidth();ah()}}function ah(){am.find(">.jsphorizontalbar>.jspcap:visible,>.jsphorizontalbar>.jsparrow").each(function(){l-=b(this).outerwidth()});g.width(l+"px");aa=0}function f(){if(af&&aa){var aj=g.outerheight(),s=aq.outerwidth();t-=aj;b(an).find(">.jspcap:visible,>.jsparrow").each(function(){l+=b(this).outerwidth()});l-=s;v-=s;ak-=aj;g.parent().append(b('').css("width",aj+"px"));o();ah()}if(af){y.width((am.outerwidth()-f)+"px")}z=y.outerheight();q=z/v;if(af){au=math.ceil(1/y*l);if(au>az.horizontaldragmaxwidth){au=az.horizontaldragmaxwidth}else{if(auaz.verticaldragmaxheight){a=az.verticaldragmaxheight}else{if(aat){q.scrollbyy(-aq)}else{v(at)}}else{if(an>0){if(i+arat){q.scrollbyx(-aq)}else{w(at)}}else{if(an>0){if(aa+ari){s=i}}if(aj===c){aj=az.animatescroll}if(aj){q.animate(av,"top",s,ad)}else{av.css("top",s);ad(s)}}function ad(aj){if(aj===c){aj=av.position().top}am.scrolltop(0);i=aj;var am=i===0,ak=i==i,al=aj/i,s=-al*(z-v);if(aj!=am||ah!=ak){aj=am;ah=ak;d.trigger("jsp-arrow-change",[aj,ah,p,k])}u(am,ak);y.css("top",s);d.trigger("jsp-scroll-y",[-s,am,ak]).trigger("scroll")}function w(aj,s){if(!af){return}if(aj<0){aj=0}else{if(aj>j){aj=j}}if(s===c){s=az.animatescroll}if(s){q.animate(h,"left",aj,ae)
}else{h.css("left",aj);ae(aj)}}function ae(aj){if(aj===c){aj=h.position().left}am.scrolltop(0);aa=aj;var am=aa===0,al=aa==j,ak=aj/j,s=-ak*(t-ak);if(p!=am||k!=al){p=am;k=al;d.trigger("jsp-arrow-change",[aj,ah,p,k])}r(am,al);y.css("left",s);d.trigger("jsp-scroll-x",[-s,am,al]).trigger("scroll")}function u(aj,s){if(az.showarrows){ar[aj?"addclass":"removeclass"]("jspdisabled");af[s?"addclass":"removeclass"]("jspdisabled")}}function r(aj,s){if(az.showarrows){ay[aj?"addclass":"removeclass"]("jspdisabled");x[s?"addclass":"removeclass"]("jspdisabled")}}function m(s,aj){var ak=s/(z-v);v(ak*i,aj)}function n(aj,s){var ak=aj/(t-ak);w(ak*j,s)}function ab(aw,ar,ak){var ao,al,am,s=0,av=0,aj,aq,ap,at,as,au;try{ao=b(aw)}catch(an){return}al=ao.outerheight();am=ao.outerwidth();am.scrolltop(0);am.scrollleft(0);while(!ao.is(".jsppane")){s+=ao.position().top;av+=ao.position().left;ao=ao.offsetparent();if(/^body|html$/i.test(ao[0].nodename)){return}}aj=ab();ap=aj+v;if(sap){as=s-v+al+az.verticalgutter}}if(as){m(as,ak)}aq=ad();at=aq+ak;if(avat){au=av-ak+am+az.horizontalgutter}}if(au){n(au,ak)}}function ad(){return -y.position().left}function ab(){return -y.position().top}function k(){var s=z-v;return(s>20)&&(s-ab()<10)}function b(){var s=t-ak;return(s>20)&&(s-ad()<10)}function ag(){am.unbind(ac).bind(ac,function(am,an,al,aj){var ak=aa,s=i;q.scrollby(al*az.mousewheelspeed,-aj*az.mousewheelspeed,false);return ak==aa&&s==i})}function n(){am.unbind(ac)}function ac(){return false}function j(){y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function e(){y.find(":input,a").unbind("focus.jsp")}function s(){var s,aj,al=[];af&&al.push(an[0]);aa&&al.push(u[0]);y.focus(function(){d.focus()});d.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(ao){if(ao.target!==this&&!(al.length&&b(ao.target).closest(al).length)){return}var an=aa,am=i;switch(ao.keycode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=ao.keycode;ak();break;case 35:m(z-v);s=null;break;case 36:m(0);s=null;break}aj=ao.keycode==s&&an!=aa||am!=i;return !aj}).bind("keypress.jsp",function(am){if(am.keycode==s){ak()}return !aj});if(az.hidefocus){d.css("outline","none");if("hidefocus" in am[0]){d.attr("hidefocus",true)}}else{d.css("outline","");if("hidefocus" in am[0]){d.attr("hidefocus",false)}}function ak(){var an=aa,am=i;switch(s){case 40:q.scrollbyy(az.keyboardspeed,false);break;case 38:q.scrollbyy(-az.keyboardspeed,false);break;case 34:case 32:q.scrollbyy(v*az.scrollpagepercent,false);break;case 33:q.scrollbyy(-v*az.scrollpagepercent,false);break;case 39:q.scrollbyx(az.keyboardspeed,false);break;case 37:q.scrollbyx(-az.keyboardspeed,false);break}aj=an!=aa||am!=i;return aj}}function r(){d.attr("tabindex","-1").removeattr("tabindex").unbind("keydown.jsp keypress.jsp")}function c(){if(location.hash&&location.hash.length>1){var al,aj,ak=escape(location.hash);try{al=b(ak)}catch(s){return}if(al.length&&y.find(ak)){if(am.scrolltop()===0){aj=setinterval(function(){if(am.scrolltop()>0){ab(ak,true);b(document).scrolltop(am.position().top);clearinterval(aj)}},50)}else{ab(ak,true);b(document).scrolltop(am.position().top)}}}}function ai(){b("a.jsphijack").unbind("click.jsp-hijack").removeclass("jsphijack")}function m(){ai();b("a[href^=#]").addclass("jsphijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aj;if(s.length>1){aj=s[1];if(aj.length>0&&y.find("#"+aj).length>0){ab("#"+aj,true);return false}}})}function ao(){var ak,aj,am,al,an,s=false;am.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(ao){var ap=ao.originalevent.touches[0];ak=ad();aj=ab();am=ap.pagex;al=ap.pagey;an=false;s=true}).bind("touchmove.jsp",function(ar){if(!s){return}var aq=ar.originalevent.touches[0],ap=aa,ao=i;q.scrollto(ak+am-aq.pagex,aj+al-aq.pagey);an=an||math.abs(am-aq.pagex)>5||math.abs(al-aq.pagey)>5;
return ap==aa&&ao==i}).bind("touchend.jsp",function(ao){s=false}).bind("click.jsp-touchclick",function(ao){if(an){an=false;return false}})}function g(){var s=ab(),aj=ad();d.removeclass("jspscrollable").unbind(".jsp");d.replacewith(ap.append(y.children()));ap.scrolltop(s);ap.scrollleft(aj)}b.extend(q,{reinitialise:function(aj){aj=b.extend({},az,aj);at(aj)},scrolltoelement:function(ak,aj,s){ab(ak,aj,s)},scrollto:function(ak,s,aj){n(ak,aj);m(s,aj)},scrolltox:function(aj,s){n(aj,s)},scrolltoy:function(s,aj){m(s,aj)},scrolltopercentx:function(aj,s){n(aj*(t-ak),s)},scrolltopercenty:function(aj,s){m(aj*(z-v),s)},scrollby:function(aj,s,ak){q.scrollbyx(aj,ak);q.scrollbyy(s,ak)},scrollbyx:function(s,ak){var aj=ad()+math[s<0?"floor":"ceil"](s),al=aj/(t-ak);w(al*j,ak)},scrollbyy:function(s,ak){var aj=ab()+math[s<0?"floor":"ceil"](s),al=aj/(z-v);v(al*i,ak)},positiondragx:function(s,aj){w(s,aj)},positiondragy:function(aj,s){v(aj,s)},animate:function(aj,am,s,al){var ak={};ak[am]=s;aj.animate(ak,{duration:az.animateduration,easing:az.animateease,queue:false,step:al})},getcontentpositionx:function(){return ad()},getcontentpositiony:function(){return ab()},getcontentwidth:function(){return t},getcontentheight:function(){return z},getpercentscrolledx:function(){return ad()/(t-ak)},getpercentscrolledy:function(){return ab()/(z-v)},getisscrollableh:function(){return af},getisscrollablev:function(){return aa},getcontentpane:function(){return y},scrolltobottom:function(s){v(i,s)},hijackinternallinks:function(){m()},destroy:function(){g()}});at(o)}e=b.extend({},b.fn.jscrollpane.defaults,e);b.each(["mousewheelspeed","arrowbuttonspeed","trackclickspeed","keyboardspeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.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:c,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);