(function(a){a.jScrollPane={active:[]};a.fn.jScrollPane=function(b){b=a.extend({},a.fn.jScrollPane.defaults,b);var i=function(){return false};return this.each(function(){var d=a(this),R=this,S=0,m,f,q,r=b.topCapHeight,g;if(a(this).parent().is(".jScrollPaneContainer")){g=a(this).parent();S=b.maintainPosition?d.position().top:0;var j=a(this).parent();m=j.innerWidth();f=j.outerHeight();a(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap",j).remove();d.css({top:0})}else{d.data("originalStyleTag",
d.attr("style"));d.css("overflow","hidden");this.originalPadding=d.css("paddingTop")+" "+d.css("paddingRight")+" "+d.css("paddingBottom")+" "+d.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(d.css("paddingLeft"))||0)+(parseInt(d.css("paddingRight"))||0);m=d.innerWidth();f=d.innerHeight();g=a("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:f+"px",width:m+"px"});b.enableKeyboardNavigation&&g.attr("tabindex",b.tabIndex);d.wrap(g);g=d.parent();a(document).bind("emchange",
function(){d.jScrollPane(b)})}q=f;if(b.reinitialiseOnImageLoad){var w=a.data(R,"jScrollPaneImagesToLoad")||a("img",d),T=[];w.length&&w.each(function(c,e){a(this).bind("load readystatechange",function(){if(a.inArray(c,T)==-1){T.push(e);w=a.grep(w,function(l){return l!=e});a.data(R,"jScrollPaneImagesToLoad",w);var h=a.extend(b,{reinitialiseOnImageLoad:false});d.jScrollPane(h)}}).each(function(){if(this.complete||this.complete===undefined)this.src=this.src})})}j={height:"auto",width:m-b.scrollbarWidth-
b.scrollbarMargin-this.originalSidePaddingTotal+"px"};if(b.scrollbarOnLeft)j.paddingLeft=b.scrollbarMargin+b.scrollbarWidth+"px";else j.paddingRight=b.scrollbarMargin+"px";d.css(j);var x=d.outerHeight(),A=f/x;j=A<0.99;g[j?"addClass":"removeClass"]("jScrollPaneScrollable");if(j){g.append(a("<div></div>").addClass("jScrollCap jScrollCapTop").css({height:b.topCapHeight}),a("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:b.scrollbarWidth+"px"}).append(a("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:b.scrollbarWidth+
"px"}).append(a('<div class="begun-top"><div class="begun-bottom"><div class="begun-bg">&nbsp;</div></div></div>'),a("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:b.scrollbarWidth+"px"}),a("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:b.scrollbarWidth+"px"}))),a("<div></div>").addClass("jScrollCap jScrollCapBottom").css({height:b.bottomCapHeight}));m=a(">.jScrollPaneTrack",g);var B=a(">.jScrollPaneTrack .jScrollPaneDrag",g),y,s=[],t,u=function(){if(t>4||t%
4==0)o(k+y*L);t++};b.enableKeyboardNavigation&&g.bind("keydown.jscrollpane",function(c){switch(c.keyCode){case 38:y=-1;t=0;u();s[s.length]=setInterval(u,100);return false;case 40:y=1;t=0;u();s[s.length]=setInterval(u,100);return false;case 33:case 34:return false;default:}}).bind("keyup.jscrollpane",function(c){if(c.keyCode==38||c.keyCode==40){for(c=0;c<s.length;c++)clearInterval(s[c]);return false}});if(b.showArrows){var C,U,V=function(){a("html").unbind("mouseup",V);C.removeClass("jScrollActiveArrowButton");
clearInterval(U)},W=function(){a("html").bind("mouseup",V);C.addClass("jScrollActiveArrowButton");t=0;u();U=setInterval(u,100)};g.append(a("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp",tabindex:-1}).css({width:b.scrollbarWidth+"px",top:b.topCapHeight+"px"}).html("Scroll up").bind("mousedown",function(){C=a(this);y=-1;W();this.blur();return false}).bind("click",i),a("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown",tabindex:-1}).css({width:b.scrollbarWidth+"px",bottom:b.bottomCapHeight+
"px"}).html("Scroll down").bind("mousedown",function(){C=a(this);y=1;W();this.blur();return false}).bind("click",i));var M=a(">.jScrollArrowUp",g),X=a(">.jScrollArrowDown",g)}if(b.arrowSize){q=f-b.arrowSize-b.arrowSize;r+=b.arrowSize}else if(M){j=M.height();b.arrowSize=j;q=f-j-X.height();r+=j}q-=b.topCapHeight+b.bottomCapHeight;m.css({height:q+"px",top:r+"px"});var N=a(this).css({position:"absolute",overflow:"visible"}),z,p,L,k=0,D=A*f/2,E=function(c,e){var h=e=="X"?"Left":"Top";return c["page"+e]||
c["client"+e]+(document.documentElement["scroll"+h]||document.body["scroll"+h])||0},F=function(){return false},H=function(){G();z=B.offset(false);z.top-=k;p=q-B[0].offsetHeight;L=2*b.wheelSpeed*p/x},O=function(){a("html").unbind("mouseup",O).unbind("mousemove",Y);D=A*f/2;a.browser.msie&&a("html").unbind("dragstart",F).unbind("selectstart",F)},o=function(c){g.scrollTop(0);k=c=c<0?0:c>p?p:c;B.css({top:c+"px"});var e=c/p;d.data("jScrollPanePosition",(f-x)*-e);N.css({top:(f-x)*e+"px"});d.trigger("scroll");
if(b.showArrows){M[c==0?"addClass":"removeClass"]("disabled");X[c==p?"addClass":"removeClass"]("disabled")}},Y=function(c){o(E(c,"Y")-z.top-D)};r=Math.max(Math.min(A*(f-b.arrowSize*2),b.dragMaxHeight),b.dragMinHeight);B.css({height:r+"px"}).bind("mousedown",function(c){H();D=E(c,"Y")-k-z.top;a("html").bind("mouseup",O).bind("mousemove",Y).bind("mouseleave",O);a.browser.msie&&a("html").bind("dragstart",F).bind("selectstart",F);return false});a(".begun-bg").css({height:r-10+"px"});var Z,I,$,aa=function(){if(I>
8||I%4==0)o(k-(k-$)/2);I++},ba=function(){clearInterval(Z);a("html").unbind("mouseup",ba).unbind("mousemove",P)},P=function(c){$=E(c,"Y")-z.top-D};m.bind("mousedown",function(c){H();P(c);I=0;a("html").bind("mouseup",ba).bind("mousemove",P);Z=setInterval(aa,100);aa();return false});g.bind("mousewheel",function(c,e){e=e||(c.wheelDelta?c.wheelDelta/120:c.detail?-c.detail/3:0);H();G();var h=k;o(k-e*L);return h==k});var J,Q,ca=function(){var c=(J-k)/b.animateStep;if(c>1||c<-1)o(k+c);else{o(J);G()}},G=
function(){if(Q){clearInterval(Q);delete J}},v=function(c,e){if(typeof c=="string"){try{$e=a(c,d)}catch(h){return}if(!$e.length)return;c=$e.offset().top-d.offset().top}G();var l=x-f;c=c>l?l:c;d.data("jScrollPaneMaxScroll",l);l=c/l*p;if(e||!b.animateTo)o(l);else{g.scrollTop(0);J=l;Q=setInterval(ca,b.animateInterval)}};d[0].scrollTo=v;d[0].scrollBy=function(c){var e=-parseInt(N.css("top"))||0;v(e+c)};H();v(-S,true);a("*",this).bind("focus",function(){for(var c=a(this),e=0,h=100;c[0]!=d[0];){e+=c.position().top;
c=c.offsetParent();if(!h--)return}c=-parseInt(N.css("top"))||0;h=c+f;if(!(e>c&&e<h)){h=e-b.scrollbarMargin;if(e>c)h+=a(this).height()+15+b.scrollbarMargin-f;v(h)}});if(b.observeHash){if(location.hash&&location.hash.length>1)setTimeout(function(){v(location.hash)},a.browser.safari?100:0);a(document).bind("click",function(c){$target=a(c.target);if($target.is("a")){var e=$target.attr("href");if(e&&e.substr(0,1)=="#"&&e.length>1)setTimeout(function(){v(e,!b.animateToInternalLinks)},a.browser.safari?100:
0)}})}var K,n,da=function(){direction=K<0?-1:1;d[0].scrollBy(K/2)},ea=function(c){var e=d.parent().offset().top,h=e+f;c=E(c,"Y");K=c<e?c-e:c>h?c-h:0;if(K==0){if(n){clearInterval(n);n=undefined}}else n||(n=setInterval(da,100))},fa=function(){a(document).unbind("mousemove.jScrollPaneDragging").unbind("mouseup.jScrollPaneDragging");if(n){clearInterval(n);n=undefined}};g.bind("mousedown.jScrollPane",function(){a(document).bind("mousemove.jScrollPaneDragging",ea);a(document).bind("mouseup.jScrollPaneDragging",
fa)});a.jScrollPane.active.push(d[0])}else{d.css({height:f+"px",width:m-this.originalSidePaddingTotal+"px",padding:this.originalPadding});d[0].scrollTo=d[0].scrollBy=function(){};d.parent().unbind("mousewheel").unbind("mousedown.jScrollPane").unbind("keydown.jscrollpane").unbind("keyup.jscrollpane")}})};a.fn.jScrollPaneRemove=function(){a(this).each(function(){$this=a(this);var b=$this.parent();if(b.is(".jScrollPaneContainer")){$this.css({top:"",height:"",width:"",padding:"",overflow:"",position:""});
$this.attr("style",$this.data("originalStyleTag"));b.after($this).remove()}})};a.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,tabIndex:0,enableKeyboardNavigation:true,animateToInternalLinks:false,topCapHeight:0,bottomCapHeight:0,observeHash:true};a(window).bind("unload",function(){for(var b=
a.jScrollPane.active,i=0;i<b.length;i++)b[i].scrollTo=b[i].scrollBy=null})})(jQuery);
jQuery(function(a){a.em=a.extend({version:"1.0",delay:200,element:a("<div />").css({left:"-100em",position:"absolute",width:"100em"}).prependTo("body")[0],action:function(){var b=a.em.element.offsetWidth/100;if(b!=a.em.current){a.em.previous=a.em.current;a.em.current=b;a.event.trigger("emchange",[a.em.current,a.em.previous])}}},a.em);a.fn.emchange=function(b){return b?this.bind("emchange",b):this.trigger("emchange")};a.em.current=a.em.element.offsetWidth/100;a.em.iid=setInterval(a.em.action,a.em.delay)});
(function(a){a.event.special.mousewheel={setup:function(){var b=a.event.special.mousewheel.handler;a.browser.mozilla&&a(this).bind("mousemove.mousewheel",function(i){a.data(this,"mwcursorposdata",{pageX:i.pageX,pageY:i.pageY,clientX:i.clientX,clientY:i.clientY})});if(this.addEventListener)this.addEventListener(a.browser.mozilla?"DOMMouseScroll":"mousewheel",b,false);else this.onmousewheel=b},teardown:function(){var b=a.event.special.mousewheel.handler;a(this).unbind("mousemove.mousewheel");if(this.removeEventListener)this.removeEventListener(a.browser.mozilla?
"DOMMouseScroll":"mousewheel",b,false);else this.onmousewheel=function(){};a.removeData(this,"mwcursorposdata")},handler:function(b){var i=Array.prototype.slice.call(arguments,1);b=a.event.fix(b||window.event);a.extend(b,a.data(this,"mwcursorposdata")||{});var d=0;if(b.wheelDelta)d=b.wheelDelta/120;if(b.detail)d=-b.detail/3;b.data=b.data||{};b.type="mousewheel";i.unshift(d);i.unshift(b);return a.event.handle.apply(this,i)}};a.fn.extend({mousewheel:function(b){return b?this.bind("mousewheel",b):this.trigger("mousewheel")},
unmousewheel:function(b){return this.unbind("mousewheel",b)}})})(jQuery);
