/*
 * 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('<div class="jspPane" />').css("padding",aI).append(D.children());am=b('<div class="jspContainer" />').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('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=am.find(">.jspVerticalBar");aq=U.find(">.jspTrack");av=aq.find(">.jspDrag");if(az.showArrows){ar=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aE(0,-1)).bind("click.jsp",aC);af=b('<a class="jspArrow jspArrowDown" />').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('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));an=am.find(">.jspHorizontalBar");G=an.find(">.jspTrack");h=G.find(">.jspDrag");if(az.showArrows){ay=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aE(-1,0)).bind("click.jsp",aC);x=b('<a class="jspArrow jspArrowRight" />').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('<div class="jspCorner" />').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(au<az.horizontalDragMinWidth){au=az.horizontalDragMinWidth}}h.width(au+"px");j=l-au;ae(aa)}if(aA){A=Math.ceil(1/q*t);if(A>az.verticalDragMaxHeight){A=az.verticalDragMaxHeight}else{if(A<az.verticalDragMinHeight){A=az.verticalDragMinHeight}}av.height(A+"px");i=t-A;ad(I)}}function al(aK,aM,aJ,s){var aO="before",aL="after",aN;if(aM=="os"){aM=/Mac/.test(navigator.platform)?"after":"split"}if(aM==aO){aL=aM}else{if(aM==aL){aO=aM;aN=aJ;aJ=s;s=aN}}aK[aO](aJ)[aL](s)}function aE(aJ,s,aK){return function(){H(aJ,s,this,aK);this.blur();return false}}function H(aM,aL,aP,aO){aP=b(aP).addClass("jspActive");var aN,aK,aJ=true,s=function(){if(aM!==0){Q.scrollByX(aM*az.arrowButtonSpeed)}if(aL!==0){Q.scrollByY(aL*az.arrowButtonSpeed)}aK=setTimeout(s,aJ?az.initialDelay:az.arrowRepeatFreq);aJ=false};s();aN=aO?"mouseout.jsp":"mouseup.jsp";aO=aO||b("html");aO.bind(aN,function(){aP.removeClass("jspActive");aK&&clearTimeout(aK);aK=null;aO.unbind(aN)})}function p(){w();if(aA){aq.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageY-aP.top-I,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageY-aS.top-A/2,aQ=v*az.scrollPagePercent,aR=i*aQ/(Z-v);if(aN<0){if(I-aR>aT){Q.scrollByY(-aQ)}else{V(aT)}}else{if(aN>0){if(I+aR<aT){Q.scrollByY(aQ)}else{V(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}if(aF){G.bind("mousedown.jsp",function(aO){if(aO.originalTarget===c||aO.originalTarget==aO.currentTarget){var aM=b(this),aP=aM.offset(),aN=aO.pageX-aP.left-aa,aK,aJ=true,s=function(){var aS=aM.offset(),aT=aO.pageX-aS.left-au/2,aQ=ak*az.scrollPagePercent,aR=j*aQ/(T-ak);if(aN<0){if(aa-aR>aT){Q.scrollByX(-aQ)}else{W(aT)}}else{if(aN>0){if(aa+aR<aT){Q.scrollByX(aQ)}else{W(aT)}}else{aL();return}}aK=setTimeout(s,aJ?az.initialDelay:az.trackClickRepeatFreq);aJ=false},aL=function(){aK&&clearTimeout(aK);aK=null;b(document).unbind("mouseup.jsp",aL)};s();b(document).bind("mouseup.jsp",aL);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(aq){aq.unbind("mousedown.jsp")}}function ax(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(av){av.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aJ){if(!aA){return}if(s<0){s=0}else{if(s>i){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(s<aJ||aR){aS=s-az.verticalGutter}else{if(s+aL>aP){aS=s-v+aL+az.verticalGutter}}if(aS){M(aS,aK)}aQ=aD();aT=aQ+ak;if(aV<aQ||aR){aU=aV-az.horizontalGutter}else{if(aV+aM>aT){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);
// /* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
//  * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
//  * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
//  * 
//  * See http://kelvinluck.com/assets/jquery/jScrollPane/
//  * $Id: jScrollPane.js 90 2010-01-25 03:52:10Z kelvin.luck $
//  */
// 
// /**
//  * Replace the vertical scroll bars on any matched elements with a fancy
//  * styleable (via CSS) version. With JS disabled the elements will
//  * gracefully degrade to the browsers own implementation of overflow:auto.
//  * If the mousewheel plugin has been included on the page then the scrollable areas will also
//  * respond to the mouse wheel.
//  *
//  * @example jQuery(".scroll-pane").jScrollPane();
//  *
//  * @name jScrollPane
//  * @type jQuery
//  * @param Object	settings	hash with options, described below.
//  *								scrollbarWidth	-	The width of the generated scrollbar in pixels
//  *								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
//  *								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
//  *								showArrows		-	Whether to display arrows for the user to scroll with
//  *								arrowSize		-	The height of the arrow buttons if showArrows=true
//  *								animateTo		-	Whether to animate when calling scrollTo and scrollBy
//  *								dragMinHeight	-	The minimum height to allow the drag bar to be
//  *								dragMaxHeight	-	The maximum height to allow the drag bar to be
//  *								animateInterval	-	The interval in milliseconds to update an animating scrollPane (default 100)
//  *								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
//  *								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
//  *								tabIndex		-	The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
//  *								enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
//  *								animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
//  *								scrollbarOnLeft	-	Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
//  *								reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
//  *								topCapHeight	-	The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons
//  *								bottomCapHeight	-	The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons
//  *								observeHash		-	Whether jScrollPane should attempt to automagically scroll to the correct place when an anchor inside the scrollpane is linked to (default true)
//  * @return jQuery
//  * @cat Plugins/jScrollPane
//  * @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
//  */
// 
// (function($) {
// 
// $.jScrollPane = {
// 	active : []
// };
// $.fn.jScrollPane = function(settings)
// {
// 	settings = $.extend({}, $.fn.jScrollPane.defaults, settings);
// 
// 	var rf = function() { return false; };
// 	
// 	return this.each(
// 		function()
// 		{
// 			var $this = $(this);
// 			var paneEle = this;
// 			var currentScrollPosition = 0;
// 			var paneWidth;
// 			var paneHeight;
// 			var trackHeight;
// 			var trackOffset = settings.topCapHeight;
// 			var $container;
// 			
// 			if ($(this).parent().is('.jScrollPaneContainer')) {
// 				$container = $(this).parent();
// 				currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
// 				var $c = $(this).parent();
// 				paneWidth = $c.innerWidth();
// 				paneHeight = $c.outerHeight();
// 				$('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove();
// 				$this.css({'top':0});
// 			} else {
// 				$this.data('originalStyleTag', $this.attr('style'));
// 				// Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
// 				$this.css('overflow', 'hidden');
// 				this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
// 				this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
// 				paneWidth = $this.innerWidth();
// 				paneHeight = $this.innerHeight();
// 				$container = $('<div></div>')
// 					.attr({'className':'jScrollPaneContainer'})
// 					.css(
// 						{
// 							'height':paneHeight+'px', 
// 							'width':paneWidth+'px'
// 						}
// 					);
// 				if (settings.enableKeyboardNavigation) {
// 					$container.attr(
// 						'tabindex', 
// 						settings.tabIndex
// 					);
// 				}
// 				$this.wrap($container);
// 				$container = $this.parent();
// 				// deal with text size changes (if the jquery.em plugin is included)
// 				// and re-initialise the scrollPane so the track maintains the
// 				// correct size
// 				$(document).bind(
// 					'emchange', 
// 					function(e, cur, prev)
// 					{
// 						$this.jScrollPane(settings);
// 					}
// 				);
// 				
// 			}
// 			trackHeight = paneHeight;
// 			
// 			if (settings.reinitialiseOnImageLoad) {
// 				// code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
// 				// except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
// 				// TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
// 				var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
// 				var loadedImages = [];
// 				
// 				if ($imagesToLoad.length) {
// 					$imagesToLoad.each(function(i, val)	{
// 						$(this).bind('load readystatechange', function() {
// 							if($.inArray(i, loadedImages) == -1){ //don't double count images
// 								loadedImages.push(val); //keep a record of images we've seen
// 								$imagesToLoad = $.grep($imagesToLoad, function(n, i) {
// 									return n != val;
// 								});
// 								$.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
// 								var s2 = $.extend(settings, {reinitialiseOnImageLoad:false});
// 								$this.jScrollPane(s2); // re-initialise
// 							}
// 						}).each(function(i, val) {
// 							if(this.complete || this.complete===undefined) { 
// 								//needed for potential cached images
// 								this.src = this.src; 
// 							} 
// 						});
// 					});
// 				};
// 			}
// 
// 			var p = this.originalSidePaddingTotal;
// 			var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;
// 
// 			var cssToApply = {
// 				'height':'auto',
// 				'width': realPaneWidth + 'px'
// 			}
// 
// 			if(settings.scrollbarOnLeft) {
// 				cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
// 			} else {
// 				cssToApply.paddingRight = settings.scrollbarMargin + 'px';
// 			}
// 
// 			$this.css(cssToApply);
// 
// 			var contentHeight = $this.outerHeight();
// 			var percentInView = paneHeight / contentHeight;
// 			
// 			var isScrollable = percentInView < .99;
// 			$container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable');
// 
// 			if (isScrollable) {
// 				$container.append(
// 					$('<div></div>').addClass('jScrollCap jScrollCapTop').css({height:settings.topCapHeight}),
// 					$('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(
// 						$('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(
// 							$('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),
// 							$('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'})
// 						)
// 					),
// 					$('<div></div>').addClass('jScrollCap jScrollCapBottom').css({height:settings.bottomCapHeight})
// 				);
// 				
// 				var $track = $('>.jScrollPaneTrack', $container);
// 				var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);
// 				
// 				
// 				var currentArrowDirection;
// 				var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
// 				var currentArrowInc;
// 				var whileArrowButtonDown = function() 
// 				{
// 					if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
// 						positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
// 					}
// 					currentArrowInc++;
// 				};
// 
// 				if (settings.enableKeyboardNavigation) {
// 					$container.bind(
// 						'keydown.jscrollpane',
// 						function(e) 
// 						{
// 							switch (e.keyCode) {
// 								case 38: //up
// 									currentArrowDirection = -1;
// 									currentArrowInc = 0;
// 									whileArrowButtonDown();
// 									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
// 									return false;
// 								case 40: //down
// 									currentArrowDirection = 1;
// 									currentArrowInc = 0;
// 									whileArrowButtonDown();
// 									currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
// 									return false;
// 								case 33: // page up
// 								case 34: // page down
// 									// TODO
// 									return false;
// 								default:
// 							}
// 						}
// 					).bind(
// 						'keyup.jscrollpane',
// 						function(e) 
// 						{
// 							if (e.keyCode == 38 || e.keyCode == 40) {
// 								for (var i = 0; i < currentArrowTimerArr.length; i++) {
// 									clearInterval(currentArrowTimerArr[i]);
// 								}
// 								return false;
// 							}
// 						}
// 					);
// 				}
// 
// 				if (settings.showArrows) {
// 					
// 					var currentArrowButton;
// 					var currentArrowInterval;
// 
// 					var onArrowMouseUp = function(event)
// 					{
// 						$('html').unbind('mouseup', onArrowMouseUp);
// 						currentArrowButton.removeClass('jScrollActiveArrowButton');
// 						clearInterval(currentArrowInterval);
// 					};
// 					var onArrowMouseDown = function() {
// 						$('html').bind('mouseup', onArrowMouseUp);
// 						currentArrowButton.addClass('jScrollActiveArrowButton');
// 						currentArrowInc = 0;
// 						whileArrowButtonDown();
// 						currentArrowInterval = setInterval(whileArrowButtonDown, 100);
// 					};
// 					$container
// 						.append(
// 							$('<a></a>')
// 								.attr(
// 									{
// 										'href':'javascript:;', 
// 										'className':'jScrollArrowUp', 
// 										'tabindex':-1
// 									}
// 								)
// 								.css(
// 									{
// 										'width':settings.scrollbarWidth+'px',
// 										'top':settings.topCapHeight + 'px'
// 									}
// 								)
// 								.html('Scroll up')
// 								.bind('mousedown', function()
// 								{
// 									currentArrowButton = $(this);
// 									currentArrowDirection = -1;
// 									onArrowMouseDown();
// 									this.blur();
// 									return false;
// 								})
// 								.bind('click', rf),
// 							$('<a></a>')
// 								.attr(
// 									{
// 										'href':'javascript:;', 
// 										'className':'jScrollArrowDown', 
// 										'tabindex':-1
// 									}
// 								)
// 								.css(
// 									{
// 										'width':settings.scrollbarWidth+'px',
// 										'bottom':settings.bottomCapHeight + 'px'
// 									}
// 								)
// 								.html('Scroll down')
// 								.bind('mousedown', function()
// 								{
// 									currentArrowButton = $(this);
// 									currentArrowDirection = 1;
// 									onArrowMouseDown();
// 									this.blur();
// 									return false;
// 								})
// 								.bind('click', rf)
// 						);
// 					var $upArrow = $('>.jScrollArrowUp', $container);
// 					var $downArrow = $('>.jScrollArrowDown', $container);
// 				}
// 				
// 				if (settings.arrowSize) {
// 					trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
// 					trackOffset += settings.arrowSize;
// 				} else if ($upArrow) {
// 					var topArrowHeight = $upArrow.height();
// 					settings.arrowSize = topArrowHeight;
// 					trackHeight = paneHeight - topArrowHeight - $downArrow.height();
// 					trackOffset += topArrowHeight;
// 				}
// 				trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
// 				$track.css({'height': trackHeight+'px', top:trackOffset+'px'})
// 				
// 				var $pane = $(this).css({'position':'absolute', 'overflow':'visible'});
// 				
// 				var currentOffset;
// 				var maxY;
// 				var mouseWheelMultiplier;
// 				// store this in a seperate variable so we can keep track more accurately than just updating the css property..
// 				var dragPosition = 0;
// 				var dragMiddle = percentInView*paneHeight/2;
// 				
// 				// pos function borrowed from tooltip plugin and adapted...
// 				var getPos = function (event, c) {
// 					var p = c == 'X' ? 'Left' : 'Top';
// 					return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
// 				};
// 				
// 				var ignoreNativeDrag = function() {	return false; };
// 				
// 				var initDrag = function()
// 				{
// 					ceaseAnimation();
// 					currentOffset = $drag.offset(false);
// 					currentOffset.top -= dragPosition;
// 					maxY = trackHeight - $drag[0].offsetHeight;
// 					mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
// 				};
// 				
// 				var onStartDrag = function(event)
// 				{
// 					initDrag();
// 					dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
// 					$('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
// 					if ($.browser.msie) {
// 						$('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
// 					}
// 					return false;
// 				};
// 				var onStopDrag = function()
// 				{
// 					$('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
// 					dragMiddle = percentInView*paneHeight/2;
// 					if ($.browser.msie) {
// 						$('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
// 					}
// 				};
// 				var positionDrag = function(destY)
// 				{
// 					$container.scrollTop(0);
// 					destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
// 					dragPosition = destY;
// 					$drag.css({'top':destY+'px'});
// 					var p = destY / maxY;
// 					$this.data('jScrollPanePosition', (paneHeight-contentHeight)*-p);
// 					$pane.css({'top':((paneHeight-contentHeight)*p) + 'px'});
// 					$this.trigger('scroll');
// 					if (settings.showArrows) {
// 						$upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
// 						$downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
// 					}
// 				};
// 				var updateScroll = function(e)
// 				{
// 					positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
// 				};
// 				
// 				var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight);
// 				
// 				$drag.css(
// 					{'height':dragH+'px'}
// 				).bind('mousedown', onStartDrag);
// 				
// 				var trackScrollInterval;
// 				var trackScrollInc;
// 				var trackScrollMousePos;
// 				var doTrackScroll = function()
// 				{
// 					if (trackScrollInc > 8 || trackScrollInc%4==0) {
// 						positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
// 					}
// 					trackScrollInc ++;
// 				};
// 				var onStopTrackClick = function()
// 				{
// 					clearInterval(trackScrollInterval);
// 					$('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
// 				};
// 				var onTrackMouseMove = function(event)
// 				{
// 					trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
// 				};
// 				var onTrackClick = function(event)
// 				{
// 					initDrag();
// 					onTrackMouseMove(event);
// 					trackScrollInc = 0;
// 					$('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
// 					trackScrollInterval = setInterval(doTrackScroll, 100);
// 					doTrackScroll();
// 					return false;
// 				};
// 				
// 				$track.bind('mousedown', onTrackClick);
// 				
// 				$container.bind(
// 					'mousewheel',
// 					function (event, delta) {
// 						delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
// -event.detail/3 : 0);
// 						initDrag();
// 						ceaseAnimation();
// 						var d = dragPosition;
// 						positionDrag(dragPosition - delta * mouseWheelMultiplier);
// 						var dragOccured = d != dragPosition;
// 						return !dragOccured;
// 					}
// 				);
// 
// 				var _animateToPosition;
// 				var _animateToInterval;
// 				function animateToPosition()
// 				{
// 					var diff = (_animateToPosition - dragPosition) / settings.animateStep;
// 					if (diff > 1 || diff < -1) {
// 						positionDrag(dragPosition + diff);
// 					} else {
// 						positionDrag(_animateToPosition);
// 						ceaseAnimation();
// 					}
// 				}
// 				var ceaseAnimation = function()
// 				{
// 					if (_animateToInterval) {
// 						clearInterval(_animateToInterval);
// 						delete _animateToPosition;
// 					}
// 				};
// 				var scrollTo = function(pos, preventAni)
// 				{
// 					if (typeof pos == "string") {
// 						// Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
// 						// errors from the lookup...
// 						try {
// 							$e = $(pos, $this);
// 						} catch (err) {
// 							return;
// 						}
// 						if (!$e.length) return;
// 						pos = $e.offset().top - $this.offset().top;
// 					}
// 					ceaseAnimation();
// 					var maxScroll = contentHeight - paneHeight;
// 					pos = pos > maxScroll ? maxScroll : pos;
// 					$this.data('jScrollPaneMaxScroll', maxScroll);
// 					var destDragPosition = pos/maxScroll * maxY;
// 					if (preventAni || !settings.animateTo) {
// 						positionDrag(destDragPosition);
// 					} else {
// 						$container.scrollTop(0);
// 						_animateToPosition = destDragPosition;
// 						_animateToInterval = setInterval(animateToPosition, settings.animateInterval);
// 					}
// 				};
// 				$this[0].scrollTo = scrollTo;
// 				
// 				$this[0].scrollBy = function(delta)
// 				{
// 					var currentPos = -parseInt($pane.css('top')) || 0;
// 					scrollTo(currentPos + delta);
// 				};
// 				
// 				initDrag();
// 				
// 				scrollTo(-currentScrollPosition, true);
// 			
// 				// Deal with it when the user tabs to a link or form element within this scrollpane
// 				$('*', this).bind(
// 					'focus',
// 					function(event)
// 					{
// 						var $e = $(this);
// 						
// 						// loop through parents adding the offset top of any elements that are relatively positioned between
// 						// the focused element and the jScrollPaneContainer so we can get the true distance from the top
// 						// of the focused element to the top of the scrollpane...
// 						var eleTop = 0;
// 						
// 						while ($e[0] != $this[0]) {
// 							eleTop += $e.position().top;
// 							$e = $e.offsetParent();
// 						}
// 						
// 						var viewportTop = -parseInt($pane.css('top')) || 0;
// 						var maxVisibleEleTop = viewportTop + paneHeight;
// 						var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
// 						if (!eleInView) {
// 							var destPos = eleTop - settings.scrollbarMargin;
// 							if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
// 								destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
// 							}
// 							scrollTo(destPos);
// 						}
// 					}
// 				)
// 				
// 				
// 				if (settings.observeHash) {
// 					if (location.hash && location.hash.length > 1) {
// 						setTimeout(function(){
// 							scrollTo(location.hash);
// 						}, $.browser.safari ? 100 : 0);
// 					}
// 					
// 					// use event delegation to listen for all clicks on links and hijack them if they are links to
// 					// anchors within our content...
// 					$(document).bind('click', function(e){
// 						$target = $(e.target);
// 						if ($target.is('a')) {
// 							var h = $target.attr('href');
// 							if (h && h.substr(0, 1) == '#' && h.length > 1) {
// 								setTimeout(function(){
// 									scrollTo(h, !settings.animateToInternalLinks);
// 								}, $.browser.safari ? 100 : 0);
// 							}
// 						}
// 					});
// 				}
// 				
// 				// Deal with dragging and selecting text to make the scrollpane scroll...
// 				function onSelectScrollMouseDown(e)
// 				{
// 				   $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
// 				   $(document).bind('mouseup.jScrollPaneDragging',   onSelectScrollMouseUp);
// 				  
// 				}
// 				
// 				var textDragDistanceAway;
// 				var textSelectionInterval;
// 				
// 				function onTextSelectionInterval()
// 				{
// 					direction = textDragDistanceAway < 0 ? -1 : 1;
// 					$this[0].scrollBy(textDragDistanceAway / 2);
// 				}
// 
// 				function clearTextSelectionInterval()
// 				{
// 					if (textSelectionInterval) {
// 						clearInterval(textSelectionInterval);
// 						textSelectionInterval = undefined;
// 					}
// 				}
// 				
// 				function onTextSelectionScrollMouseMove(e)
// 				{
// 					var offset = $this.parent().offset().top;
// 					var maxOffset = offset + paneHeight;
// 					var mouseOffset = getPos(e, 'Y');
// 					textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
// 					if (textDragDistanceAway == 0) {
// 						clearTextSelectionInterval();
// 					} else {
// 						if (!textSelectionInterval) {
// 							textSelectionInterval  = setInterval(onTextSelectionInterval, 100);
// 						}
// 					}
// 				}
// 
// 				function onSelectScrollMouseUp(e)
// 				{
// 				   $(document)
// 					  .unbind('mousemove.jScrollPaneDragging')
// 					  .unbind('mouseup.jScrollPaneDragging');
// 				   clearTextSelectionInterval();
// 				}
// 
// 				$container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);
// 
// 				
// 				$.jScrollPane.active.push($this[0]);
// 				
// 			} else {
// 				$this.css(
// 					{
// 						'height':paneHeight+'px',
// 						'width':paneWidth-this.originalSidePaddingTotal+'px',
// 						'padding':this.originalPadding
// 					}
// 				);
// 				$this[0].scrollTo = $this[0].scrollBy = function() {};
// 				// clean up listeners
// 				$this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
// 			}
// 			
// 		}
// 	)
// };
// 
// $.fn.jScrollPaneRemove = function()
// {
// 	$(this).each(function()
// 	{
// 		$this = $(this);
// 		var $c = $this.parent();
// 		if ($c.is('.jScrollPaneContainer')) {
// 			$this.css(
// 				{
// 					'top':'',
// 					'height':'',
// 					'width':'',
// 					'padding':'',
// 					'overflow':'',
// 					'position':''
// 				}
// 			);
// 			$this.attr('style', $this.data('originalStyleTag'));
// 			$c.after($this).remove();
// 		}
// 	});
// }
// 
// $.fn.jScrollPane.defaults = {
// 	scrollbarWidth : 17,
// 	scrollbarMargin : 10,
// 	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
// };
// 
// // clean up the scrollTo expandos
// $(window)
// 	.bind('unload', function() {
// 		var els = $.jScrollPane.active; 
// 		for (var i=0; i<els.length; i++) {
// 			els[i].scrollTo = els[i].scrollBy = null;
// 		}
// 	}
// );
// 
// })(jQuery);
