(function(b){function n(a,b,c){for(var d=0;d<b.length;d++)c(a,b[d])}function h(){var a=document.getElementsByTagName("script");var b=a[a.length-1].src.split("?")[0];return b.split("/").length>0?b.split("/").slice(0,-1).join("/")+"/":""}var c=false;var d=false;var e=false;var f=5e3;var g=2e3;var i=h();var j=function(a,e){var h=this;this.version="2.6.5";this.name="nicescroll";this.me=e;this.opt={doc:b("body"),win:false,zindex:9e3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:8*5,touchbehavior:false,hwacceleration:true,usetransition:true,boxzoom:false,dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:"",iframeautoresize:true,cursorminheight:20,preservenativescrolling:true,railoffset:false,bouncescroll:false};if(a||false){for(var j in h.opt){if(typeof a[j]!="undefined")h.opt[j]=a[j]}}this.id=h.opt.doc?h.opt.doc.eq(0).id||"":"";this.doc=h.opt.doc;this.ispage=/BODY|HTML/.test(h.doc[0].nodeName);this.haswrapper=h.opt.win!==false;this.win=h.opt.win||(this.ispage?b(window):this.doc);this.docscroll=this.ispage?b(window):this.win;this.iframe=false;this.isiframe=this.doc[0].nodeName=="IFRAME"&&this.win[0].nodeName=="IFRAME";this.istextarea=this.win[0].nodeName=="TEXTAREA";this.onmousedown=false;this.onmouseup=false;this.onmousemove=false;this.onmousewheel=false;this.onkeypress=false;this.ongesturezoom=false;this.view=false;this.page=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;this.scrollmom=false;do{this.id="ascrail"+g++}while(document.getElementById(this.id));this.rail=false;this.cursor=false;this.cursorfreezed=false;this.zoom=false;this.zoomactive=false;this.hasfocus=false;this.hasmousefocus=false;this.visibility=true;this.locked=false;h.nativescrollingarea=false;this.events=[];this.saved={};var l=document.createElement("DIV");this.isopera="opera"in window;this.isie="all"in document&&"attachEvent"in l&&!this.isopera;this.isieold=this.isie&&!("msInterpolationMode"in l.style);this.isie7=this.isie&&!this.isieold&&(!("documentMode"in document)||document.documentMode==7);this.isie8=this.isie&&"documentMode"in document&&document.documentMode==8;this.isie9=this.isie&&"performance"in window&&document.documentMode>=9;this.ismozilla="MozAppearance"in l.style;this.ischrome="chrome"in window;this.cantouch="ontouchstart"in document.documentElement;this.isios=this.cantouch&&/iphone|ipad|ipod/i.test(navigator.platform);this.isios4=this.isios&&!("seal"in Object);if(h.opt.hwacceleration){this.trstyle=window.opera?"OTransform":document.all?"msTransform":l.style.webkitTransform!==undefined?"webkitTransform":l.style.MozTransform!==undefined?"MozTransform":false;if(this.trstyle&&typeof l.style[this.trstyle]=="undefined")this.trstyle=false;this.hastransform=this.trstyle!=false;if(this.hastransform){l.style[this.trstyle]="translate3d(1px,2px,3px)";this.hastranslate3d=/translate3d/.test(l.style[this.trstyle])}this.transitionstyle=false;this.prefixstyle="";this.transitionend=false;var m=["transition","webkitTransition","MozTransition","OTransition","msTransition","KhtmlTransition"];var n=["","-webkit-","-moz-","-o-","-ms-","-khtml-"];var o=["transitionEnd","webkitTransitionEnd","transitionend","oTransitionEnd","msTransitionEnd","KhtmlTransitionEnd"];for(var j=0;j<m.length;j++){if(m[j]in l.style){this.transitionstyle=m[j];this.prefixstyle=n[j];this.transitionend=o[j];break}}this.hastransition=this.transitionstyle}else{this.trstyle=false;this.hastransform=false;this.hastranslate3d=false;this.transitionstyle=false;this.hastransition=false;this.transitionend=false}this.cursorgrabvalue="";if(h.opt.grabcursorenabled&&h.opt.touchbehavior){function p(){if(!h.ischrome&&(!h.isie||h.isie9)){var a=["grab","-moz-grab","-webkit-grab"];for(var b=0;b<a.length;b++){var c=a[b];l.style["cursor"]=c;if(l.style["cursor"]==c)return c}}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}this.cursorgrabvalue=p()}l=null;this.ishwscroll=h.hastransform&&h.opt.hwacceleration&&h.haswrapper;this.css=function(a,b){for(var c in b){h.saved.css.push([a,c,a.css(c)]);a.css(c,b[c])}};this.scrollTop=function(a){return typeof a=="undefined"?h.getScrollTop():h.setScrollTop(a)};if(this.ishwscroll){h.doc.translate={x:0,y:0};this.getScrollTop=function(){return h.doc.translate.y};if(document.createEvent){this.notifyScrollEvent=function(a){var b=document.createEvent("UIEvents");b.initUIEvent("scroll",false,true,window,1);a.dispatchEvent(b)}}else if(document.fireEvent){this.notifyScrollEvent=function(a){var b=document.createEventObject();a.fireEvent("onscroll");b.cancelBubble=true}}else{this.notifyScrollEvent=function(a){}}if(this.hastranslate3d){this.setScrollTop=function(a,b){h.doc.css(h.trstyle,"translate3d(0px,"+a*-1+"px,0px)");h.doc.translate.y=a;if(!b)h.notifyScrollEvent(h.win[0])}}else{this.setScrollTop=function(a,b){h.doc.css(h.trstyle,"translate(0px,"+a*-1+"px)");h.doc.translate.y=a;if(!b)h.notifyScrollEvent(h.win[0])}}}else{this.getScrollTop=function(){return h.docscroll.scrollTop()};this.setScrollTop=function(a){return h.docscroll.scrollTop(a)}}this.getTarget=function(a){if(!a)return false;if(a.target)return a.target;if(a.srcElement)return a.srcElement;return false};this.hasParent=function(a,b){if(!a)return false;var c=a.target||a.srcElement||a||false;while(c&&c.id!=b){c=c.parentNode||false}return c!==false};this.updateScrollBar=function(a){if(h.ishwscroll){h.rail.css({height:h.win.innerHeight()})}else{var b=h.win.offset();b.top+=2;var c=(h.win.outerWidth()-h.win.innerWidth())/2;b.left+=h.win.innerWidth()+c-h.rail.width-1;var d=h.opt.railoffset;if(d){if(d.top)b.top+=d.top;if(d.left)b.left+=d.left}h.rail.css({top:b.top,left:b.left,height:a?a.h:h.win.innerHeight()});if(h.zoom)h.zoom.css({top:b.top+1,left:b.left-20})}};var q=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||false}();var r=function(){return window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||false}();h.hasanimationframe=q;h.hascancelanimationframe=r;if(!h.hasanimationframe){q=function(a){return setTimeout(a,1e3/60)};r=clearInterval}else if(!h.hascancelanimationframe)r=function(){h.cancelAnimationFrame=true};this.init=function(){h.saved.css=[];if(!h.ispage||!h.cantouch&&!h.isieold){h.ispage?h.css(h.doc,{"overflow-y":"hidden"}):h.css(h.docscroll,{"overflow-y":"hidden"});if(h.ispage&&h.isie7&&h.win[0].nodeName=="BODY")h.css(b("html"),{"overflow-y":"hidden"});var a=b(document.createElement("div"));a.css({position:"relative",top:0,"float":"right",width:h.opt.cursorwidth,height:"0px","background-color":h.opt.cursorcolor,border:h.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":h.opt.cursorborderradius,"-moz-border-radius":h.opt.cursorborderradius,"border-radius":h.opt.cursorborderradius});a.hborder=parseFloat(a.outerHeight()-a.innerHeight());h.cursor=a;var e=b(document.createElement("div"));e.attr("id",h.id);e.width=1+Math.max(parseFloat(h.opt.cursorwidth),a.outerWidth());e.css({"padding-left":"0px","padding-right":"1px",width:e.width+"px",zIndex:h.ispage?h.opt.zindex:h.opt.zindex+2,background:h.opt.background});e.append(a);h.rail=e;var g=false;if(h.opt.boxzoom&&!h.ispage&&!h.isieold){g=document.createElement("div");h.bind(g,"click",h.doZoom);h.zoom=b(g);h.zoom.css({cursor:"pointer","z-index":h.opt.zindex,backgroundImage:"url("+i+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"});if(h.opt.dblclickzoom)h.bind(h.win,"dblclick",h.doZoom);if(h.cantouch&&h.opt.gesturezoom){h.ongesturezoom=function(a){if(a.scale>1.5)h.doZoomIn(a);if(a.scale<.8)h.doZoomOut(a);return h.cancelEvent(a)};h.bind(h.win,"gestureend",h.ongesturezoom)}}if(h.ispage){e.css({position:"fixed",top:"0px",right:"0px",height:"100%"});b("body").append(e)}else{if(h.ishwscroll){if(h.win.css("position")=="static")h.css(h.win,{position:"relative"});if(h.zoom){h.zoom.css({position:"absolute",top:1,right:0,"margin-right":e.width+4});h.win.append(h.zoom)}e.css({position:"absolute",top:0,right:0});h.win.append(e)}else{e.css({position:"absolute"});if(h.zoom)h.zoom.css({position:"absolute"});h.updateScrollBar();b("body").append(e);if(h.zoom)b("body").append(h.zoom)}}if(h.opt.autohidemode===false){h.autohidedom=false}else if(h.opt.autohidemode===true){h.autohidedom=h.rail}else if(h.opt.autohidemode=="cursor"){h.autohidedom=h.cursor}h.bind(window,"resize",h.onResize);h.bind(window,"orientationchange",h.onResize);if(!h.ispage&&!h.haswrapper){h.bind(h.win,h.isie&&!h.isie9?"propertychange":"DOMAttrModified",h.onAttributeChange)}if(!h.ispage&&h.opt.boxzoom)h.bind(window,"resize",h.resizeZoom);if(h.istextarea)h.bind(h.win,"mouseup",h.onResize);h.onResize();if(h.cantouch||h.opt.touchbehavior){h.scrollmom={y:new k(h)};h.onmousedown=function(a){if(!h.locked){h.cancelScroll();h.rail.drag={x:a.screenX,y:a.screenY,sx:h.scroll.x,sy:h.scroll.y,st:h.getScrollTop()};h.hasmoving=false;h.scrollmom.y.reset(a.screenY);if(!h.cantouch)return h.cancelEvent(a)}};h.onmouseup=function(a){if(h.rail.drag){h.scrollmom.y.doMomentum();h.rail.drag=false;if(h.hasmoving){h.hasmoving=false;return h.cancelEvent(a)}}};h.onmousemove=function(a){if(h.rail.drag){h.hasmoving=true;var b=a.screenY-h.rail.drag.y;var c=a.screenY;var d=h.rail.drag.st-b;if(h.ishwscroll){if(d<0){d=Math.round(d/2);c=0}else if(d>h.page.maxh){d=h.page.maxh+Math.round((d-h.page.maxh)/2);c=0}}else{if(d<0)d=0;if(d>h.page.maxh)d=h.page.maxh}h.showCursor(d);if(h.prepareTransition)h.prepareTransition(0);h.setScrollTop(d);h.scrollmom.y.update(c);return h.cancelEvent(a)}};if(h.cursorgrabvalue){h.css(h.win,{cursor:h.cursorgrabvalue});h.css(h.rail,{cursor:h.cursorgrabvalue})}}else{h.onmousedown=function(a){if(h.locked)return h.cancelEvent(a);h.cancelScroll();h.rail.drag={x:a.screenX,y:a.screenY,sx:h.scroll.x,sy:h.scroll.y};return h.cancelEvent(a)};h.onmouseup=function(a){if(h.rail.drag){h.rail.drag=false;return h.cancelEvent(a)}};h.onmousemove=function(a){if(h.rail.drag){h.scroll.y=h.rail.drag.sy+(a.screenY-h.rail.drag.y);if(h.scroll.y<0)h.scroll.y=0;var b=h.scrollvaluemax;if(h.scroll.y>b)h.scroll.y=b;h.showCursor();h.cursorfreezed=true;h.doScroll(Math.round(h.scroll.y*h.scrollratio.y));return h.cancelEvent(a)}else{h.checkarea=true}}}if(h.cantouch||h.opt.touchbehavior)h.bind(h.win,"mousedown",h.onmousedown);h.bind(h.win,"mouseup",h.onmouseup);h.bind(h.cursor,"mousedown",h.onmousedown);h.bind(h.cursor,"mouseup",function(a){h.rail.drag=false;h.hasmoving=false;h.hideCursor();return h.cancelEvent(a)});h.bind(document,"mouseup",h.onmouseup);h.bind(document,"mousemove",h.onmousemove);if(!h.cantouch){h.rail.mouseenter(function(){h.showCursor();h.rail.active=true});h.rail.mouseleave(function(){h.rail.active=false;if(!h.rail.drag)h.hideCursor()});if(!h.isiframe)h.bind(h.isie&&h.ispage?document:h.docscroll,"mousewheel",h.onmousewheel);h.bind(h.rail,"mousewheel",h.onmousewheel)}if(h.zoom){h.zoom.mouseenter(function(){h.showCursor();h.rail.active=true});h.zoom.mouseleave(function(){h.rail.active=false;if(!h.rail.drag)h.hideCursor()})}if(!h.ispage&&!h.cantouch){if(!h.win.attr("tabindex"))h.win.attr({tabindex:f++});h.win.focus(function(a){c=h.getTarget(a).id||true;h.hasfocus=true;h.noticeCursor()});h.win.blur(function(a){c=false;h.hasfocus=false});h.win.mouseenter(function(a){d=h.getTarget(a).id||true;h.hasmousefocus=true;h.noticeCursor()});h.win.mouseleave(function(){d=false;h.hasmousefocus=false})}h.onkeypress=function(a){a=a?a:window.e;var b=h.getTarget(a);if(b&&/INPUT|TEXTAREA|SELECT/.test(b.nodeName)){var e=b.getAttribute("type")||b.type||false;if(!e||!/submit|button|cancel/i.tp)return true}if(h.hasfocus||h.hasmousefocus&&!c||h.ispage&&!c&&!d){var f=a.keyCode;if(h.locked&&f!=27)return h.cancelEvent(a);var g=false;switch(f){case 38:case 63233:h.doScrollBy(24*3);g=true;break;case 40:case 63235:h.doScrollBy(-24*3);g=true;break;case 33:case 63276:h.doScrollBy(h.view.h);g=true;break;case 34:case 63277:h.doScrollBy(-h.view.h);g=true;break;case 36:case 63273:h.doScrollTo(0);g=true;break;case 35:case 63275:h.doScrollTo(h.page.maxh);g=true;break;case 27:if(h.zoomactive){h.doZoom();g=true}break}if(g)return h.cancelEvent(a)}};h.bind(document,h.isopera?"keypress":"keydown",h.onkeypress)}if(this.doc[0].nodeName=="IFRAME"){function j(a){h.iframexd=false;try{var c="contentDocument"in this?this.contentDocument:this.contentWindow.document;var d=c.domain}catch(a){h.iframexd=true;c=false}if(h.iframexd)return true;if(h.isiframe){h.docscroll=b(c);h.iframe={html:h.doc.contents().find("html")[0],body:h.doc.contents().find("body")[0]}}if(h.opt.iframeautoresize&&!h.isiframe){h.win.scrollTop(0);h.doc.height("");var e=Math.max(c.getElementsByTagName("html")[0].scrollHeight,c.body.scrollHeight);h.doc.height(e)}h.onResize();if(h.isie7)h.css(b(c).find("html"),{"overflow-y":"hidden"});h.css(b(c.body),{"overflow-y":"hidden"});if("contentWindow"in this){h.bind(this.contentWindow,"scroll",h.onscroll)}else{h.bind(c,"scroll",h.onscroll)}h.bind(c,"mouseup",h.onmouseup);h.bind(c,"mousewheel",h.onmousewheel);h.bind(c,h.isopera?"keypress":"keydown",h.onkeypress);if(h.cantouch||h.opt.touchbehavior){h.bind(c,"mousedown",h.onmousedown);if(h.cursorgrabvalue)h.css(b(c),{cursor:h.cursorgrabvalue})}h.bind(c,"mousemove",h.onmousemove);if(h.zoom){if(h.opt.dblclickzoom)h.bind(c,"dblclick",h.doZoom);if(h.ongesturezoom)h.bind(c,"gestureend",h.ongesturezoom)}}if(this.doc[0].readyState&&this.doc[0].readyState=="complete"){setTimeout(function(){j.call(h.doc[0],false)},500)}h.bind(this.doc,"load",j)}};this.showCursor=function(a){if(h.cursortimeout){clearTimeout(h.cursortimeout);h.cursortimeout=0}if(!h.rail)return;if(h.autohidedom)h.autohidedom.stop().css({opacity:h.opt.cursoropacitymax});if(typeof a!="undefined"){h.scroll.y=Math.round(a*1/h.scrollratio.y)}h.cursor.css({height:h.cursorheight,top:h.scroll.y});if(h.zoom)h.zoom.stop().css({opacity:h.opt.cursoropacitymax})};this.hideCursor=function(a){if(h.cursortimeout)return;if(!h.rail)return;if(!h.autohidedom)return;h.cursortimeout=setTimeout(function(){if(!h.rail.active){h.autohidedom.stop().animate({opacity:h.opt.cursoropacitymin});if(h.zoom)h.zoom.stop().animate({opacity:h.opt.cursoropacitymin})}h.cursortimeout=0},a||400)};this.noticeCursor=function(a){h.showCursor();h.hideCursor(a)};this.getContentSize=function(){var a=h.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)-offsetheight}:h.haswrapper?{w:h.doc.outerWidth()+parseInt(h.win.css("paddingLeft"))+parseInt(h.win.css("paddingRight")),h:h.doc.outerHeight()+parseInt(h.win.css("paddingTop"))+parseInt(h.win.css("paddingBottom"))}:h.iframe?{w:Math.max(h.iframe.html.scrollWidth,h.iframe.body.scrollWidth),h:Math.max(h.iframe.html.scrollHeight,h.iframe.body.scrollHeight)}:{w:h.docscroll[0].scrollWidth,h:h.docscroll[0].scrollHeight};return a};this.onAttributeChange=function(a){if(a&&a.target){if(a.target!==h.win[0]&&a.target!==h.doc[0])return true;var b="attrChange"in a?a.attrName:"propertyName"in a?a.propertyName:false;if(b&&/width|height|style|block/i.test(b)){if(h.lastattributechange)h.lastattributechange=clearTimeout(h.lastattributechange);h.lastattributechange=setTimeout(function(){h.lastattributechange=0;h.onResize()},60)}}};this.onResize=function(){if(!h.haswrapper&&!h.ispage){var a=h.win.css("display")!="none";if(a&&!h.visibility)h.show();if(!a&&h.visibility)h.hide();if(!h.visibility)return false}h.view={w:h.ispage?h.win.width():h.win.innerWidth(),h:h.ispage?h.win.height():h.win.innerHeight()};if(h.ispage){h.view.h-=offsetheight}h.page=h.getContentSize();h.page.maxh=Math.max(0,h.page.h-h.view.h);if(h.page.maxh==0){h.hide();h.scrollvaluemax=0;h.scroll.y=0;h.scrollratio={x:0,y:0};h.cursorheight=0;h.locked=true;h.setScrollTop(0);return false}else if(!h.visibility)h.show();h.locked=false;if(h.istextarea&&h.win.css("resize")&&h.win.css("resize")!="none")h.view.h-=20;if(!h.ispage)h.updateScrollBar(h.view);h.cursorheight=Math.min(h.view.h,Math.round(h.view.h*(h.view.h/h.page.h)));h.cursorheight=Math.max(h.opt.cursorminheight,h.cursorheight);h.scrollvaluemax=h.view.h-h.cursorheight-h.cursor.hborder;h.scrollratio={x:0,y:h.page.maxh/h.scrollvaluemax};h.scroll.y=Math.round(h.getScrollTop()*(1/h.scrollratio.y));h.noticeCursor();return h};this.resize=this.onResize;this._bind=function(a,b,c,d){h.events.push({e:a,n:b,f:c});if(a.addEventListener){a.addEventListener(b,c,d||false)}else if(a.attachEvent){a.attachEvent("on"+b,c)}else{a["on"+b]=c}};this.bind=function(a,b,c,d){var e="jquery"in a?a[0]:a;if(e.addEventListener){if(h.cantouch&&/mouseup|mousedown|mousemove/.test(b)){var f=b=="mousedown"?"touchstart":b=="mouseup"?"touchend":"touchmove";h._bind(e,f,function(a){if(a.touches.length<2){var b=a.touches.length>0?a.touches[0]:a;b.original=a;c.call(this,b)}},d||false)}h._bind(e,b,c,d||false);if(b=="mousewheel")h._bind(e,"DOMMouseScroll",c,d||false);if(h.cantouch&&b=="mouseup")h._bind(e,"touchcancel",c,d||false)}else{h._bind(e,b,function(a){a=a||window.event||false;if(a){if(a.srcElement)a.target=a.srcElement;if("screenY"in a){a.pageX=a.screenX;a.pageY=a.screenY}}return c.call(e,a)===false||d===false?h.cancelEvent(a):true})}};this._unbind=function(a,b,c){if(a.removeEventListener){a.removeEventListener(b,c,false)}else if(a.detachEvent){a.detachEvent("on"+b,c)}else{a["on"+b]=false}};this.unbindAll=function(){for(var a=0;a<h.events.length;a++){var b=h.events[a];h._unbind(b.e,b.n,b.f)}};this.cancelEvent=function(a){if(h.cantouch){a=a.original?a.original:a||false}else{a=a?a:window.event||false}if(!a)return false;if(a.stopPropagation)a.stopPropagation();if(a.preventDefault)a.preventDefault();a.cancelBubble=true;a.cancel=true;a.returnValue=false;return false};this.show=function(){h.visibility=true;h.rail.css("display","block");return h};this.hide=function(){h.visibility=false;h.rail.css("display","none");return h};this.remove=function(){h.doZoomOut();h.unbindAll();h.events=[];h.rail.remove();if(h.zoom)h.zoom.remove();h.cursor=false;h.rail=false;h.zoom=false;for(var a=0;a<h.saved.css.length;a++){var b=h.saved.css[a];b[0].css(b[1],typeof b[2]=="undefined"?"":b[2])}h.saved=false;h.me.data("__nicescroll","");return h};this.isScrollable=function(a){var c=a.target?a.target:a;while(c&&c.nodeName&&!/BODY|HTML/.test(c.nodeName)){var d=b(c);var e=d.css("overflowY")||d.css("overflow")||"";if(/scroll|auto/.test(e))return c.clientHeight!=c.scrollHeight;c=c.parentNode?c.parentNode:false}return false};this.onmousewheel=function(a){if(h.opt.preservenativescrolling&&h.checkarea){h.checkarea=false;h.nativescrollingarea=h.isScrollable(a)}if(h.nativescrollingarea)return true;if(h.locked)return h.cancelEvent(a);if(h.rail.drag)return h.cancelEvent(a);var b=0;var b=a.detail?a.detail*-1:a.wheelDelta/40;if(b){if(h.scrollmom)h.scrollmom.y.stop();h.doScrollBy(b*h.opt.mousescrollstep)}return h.cancelEvent(a)};this.stop=function(){h.cancelScroll();if(h.scrollmon)h.scrollmon.stop();h.cursorfreezed=false;h.scroll.y=Math.round(h.getScrollTop()*(1/h.scrollratio.y));h.noticeCursor();return h};if(h.ishwscroll&&h.hastransition&&h.opt.usetransition){this.prepareTransition=function(a,b){var c=Math.round(h.opt.scrollspeed*10);var d=Math.min(c,Math.round(a/20*h.opt.scrollspeed));var e=d>20?h.prefixstyle+"transform "+d+"ms ease-out 0s":"";if(!h.lasttransitionstyle||h.lasttransitionstyle!=e){h.lasttransitionstyle=e;h.doc.css(h.transitionstyle,e)}};this.doScroll=function(a){var b=h.getScrollTop();if(a<0&&b<=0)return h.noticeCursor();else if(a>h.page.maxh&&b>=h.page.maxh)return h.noticeCursor();h.newscrolly=a;if(h.timer)return false;if(!h.scrollendtrapped){h.scrollendtrapped=true;h.bind(h.doc,h.transitionend,h.onScrollEnd,false)}h.timer=setTimeout(function(){var a=h.getScrollTop();var b=Math.abs(a-h.newscrolly);h.prepareTransition(b);h.timer=setTimeout(function(){if(h.newscrolly<0&&!h.opt.bouncescroll)h.newscrolly=0;else if(h.newscrolly>h.page.maxh&&!h.opt.bouncescroll)h.newscrolly=h.page.maxh;if(h.newscrolly==h.getScrollTop()){h.timer=0;h.onScrollEnd()}else{h.setScrollTop(h.newscrolly);h.timer=0}},15)},h.opt.scrollspeed);h.noticeCursor()};this.cancelScroll=function(){h.scrollendtrapped=false;h._unbind(h.doc,h.transitionend,h.onScrollEnd);var a=h.getScrollTop();h.prepareTransition(0);h.setScrollTop(a);h.noticeCursor();return h};this.onScrollEnd=function(){h.scrollendtrapped=false;h._unbind(h.doc,h.transitionend,h.onScrollEnd);var a=h.getScrollTop();if(a<0)h.doScroll(0);else if(a>h.page.maxh)h.doScroll(h.page.maxh)}}else{this.doScroll=function(a){function i(){if(h.cancelAnimationFrame)return true;e=(new Date).getTime();if(e<f)return h.timer=q(i)||1;f=Math.floor(e+g);e=0;var a=h.getScrollTop();var b=0;if(h.newspeedy){var c=a+h.newspeedy.v;b=h.newspeedy.v;if(h.newspeedy.v>0){if(c>=h.newspeedy.x)h.newspeedy=false}else{if(c<=h.newspeedy.x)h.newspeedy=false}}else{var j=h.newscrolly-h.getScrollTop();var k=j>0?Math.ceil(j*d):Math.floor(j*d);var c=k?h.getScrollTop()+k:h.newscrolly;b=k}if(b<0&&c<h.newscrolly||b>0&&c>h.newscrolly)c=h.newscrolly;h.setScrollTop(c);if(c==h.newscrolly){h.timer=0;h.cursorfreezed=false;if(c<0)h.doScroll(0);else if(c>h.page.maxh)h.doScroll(h.page.maxh)}else{h.timer=q(i)||1}}var b=h.getScrollTop();h.newscrolly=a;var c=a-b;h.newspeedy={x:a-Math.round(c/4),v:Math.round(c/12)};if(Math.abs(h.newspeedy.v)<5){h.newspeedy={x:a-Math.round(c/4),v:Math.round(c/4*3)}}if(h.newspeedy.v==0)h.newspeedy=false;if(!h.bouncescroll){if(h.newscrolly<0){if(h.newspeedy)h.newspeedy.x=0;h.newscrolly=0}else if(h.newscrolly>h.page.maxh){if(h.newspeedy)h.newspeedy.x=h.page.maxh;h.newscrolly=h.page.maxh}}if(h.timer)return;var d=1/4;var e=0;var f=0;var g=h.opt.scrollspeed/2;h.cancelAnimationFrame=false;h.timer=q(i)||1;h.noticeCursor()};this.cancelScroll=function(){if(h.timer)r(h.timer);h.timer=0;return h}}this.doScrollBy=function(a,b){var c=0;if(b){c=Math.floor((h.scroll.y-a)*h.scrollratio.y)}else{var d=h.timer?h.newscrolly:h.getScrollTop();c=d-a}if(h.bouncescroll){var e=Math.round(h.view.h/2);if(c<-e)c=-e;else if(c>h.page.maxh+e)c=h.page.maxh+e}h.cursorfreezed=false;h.doScroll(c)};this.doScrollTo=function(a,b){var c=b?Math.round(a*h.scrollratio.y):a;if(c<0)c=0;else if(c>h.page.maxh)c=h.page.maxh;h.cursorfreezed=false;h.doScroll(a)};h.onscroll=function(a){var b=(new Date).getTime();if(!h.lastcontentcheck||h.lastcontentcheck<b){h.lastcontentcheck=b+500;var c=h.getContentSize();if(c.h!=h.page.h)h.onResize()}if(h.rail.drag)return;if(!h.cursorfreezed)h.scroll.y=Math.round(h.getScrollTop()*(1/h.scrollratio.y));h.noticeCursor()};h.bind(h.docscroll,"scroll",h.onscroll);this.doZoomIn=function(a){if(h.zoomactive)return;h.zoomactive=true;h.zoomrestore={style:{}};var c=["position","top","left","zIndex","backgroundColor","marginTop","marginBottom","marginLeft","marginRight"];var d=h.win[0].style;for(var e in c){var f=c[e];h.zoomrestore.style[f]=typeof d[f]!="undefined"?d[f]:""}h.zoomrestore.style.width=h.win.css("width");h.zoomrestore.style.height=h.win.css("height");h.zoomrestore.padding={w:h.win.outerWidth()-h.win.width(),h:h.win.outerHeight()-h.win.height()};if(h.isios4){h.zoomrestore.scrollTop=b(window).scrollTop();b(window).scrollTop(0)}h.win.css({position:h.isios4?"absolute":"fixed",top:0,left:0,"z-index":h.opt.zindex+100,margin:"0px"});var g=h.win.css("backgroundColor");if(g==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(g))h.win.css("backgroundColor","#fff");h.rail.css({"z-index":h.opt.zindex+110});h.zoom.css({"z-index":h.opt.zindex+112});h.zoom.css("backgroundPosition","0px -18px");h.resizeZoom();return h.cancelEvent(a)};this.doZoomOut=function(a){if(!h.zoomactive)return;h.zoomactive=false;h.win.css("margin","");h.win.css(h.zoomrestore.style);if(h.isios4){b(window).scrollTop(h.zoomrestore.scrollTop)}h.rail.css({"z-index":h.ispage?h.opt.zindex:h.opt.zindex+2});h.zoom.css({"z-index":h.opt.zindex});h.zoomrestore=false;h.zoom.css("backgroundPosition","0px 0px");h.onResize();return h.cancelEvent(a)};this.doZoom=function(a){return h.zoomactive?h.doZoomOut(a):h.doZoomIn(a)};this.resizeZoom=function(){if(!h.zoomactive)return;var a=h.getScrollTop();h.win.css({width:b(window).width()-h.zoomrestore.padding.w+"px",height:b(window).height()-h.zoomrestore.padding.h+"px"});h.onResize();h.setScrollTop(Math.min(h.page.maxh,a))};this.init()};var k=function(a){var b=this;this.nc=a;this.lasty=0;this.speedy=0;this.lasttime=0;this.snapy=false;this.demuly=0;this.timer=0;this.time=function(){return(new Date).getTime()};this.reset=function(a){b.stop();b.lasttime=b.time();b.speedy=0;b.lasty=a};this.update=function(c){b.lasttime=b.time();var d=c-b.lasty;var e=a.getScrollTop();var f=e+d;b.snapy=f<0||f>b.nc.page.maxh;b.speedy=d;b.lasty=c};this.stop=function(){if(b.timer){clearTimeout(b.timer);b.timer=0}};this.doSnapy=function(a){if(a<0){b.nc.doScrollTo(0,true)}else if(a>b.nc.page.maxh){b.nc.doScrollTo(b.nc.page.maxh,true)}};this.doMomentum=function(){var a=b.lasttime;var c=b.time();b.speedy=Math.min(60,b.speedy);var d=a&&c-a<=50;var e=b.speedy&&d?b.speedy:false;if(e){var f=c-a;var g=b.nc.page.maxh;b.demuly=0;var h=function(){var a=Math.floor(b.nc.getScrollTop()-b.speedy*(1-b.demuly));if(a<0||a>g){b.demuly+=.08}else{b.demuly+=.01}b.nc.setScrollTop(a);b.nc.showCursor(a);if(b.demuly<1){b.timer=setTimeout(h,f)}else{b.timer=0;b.nc.hideCursor();b.doSnapy(a)}};h()}else{if(b.snapy){b.doSnapy(b.nc.getScrollTop())}}}};var l=jQuery.fn.scrollTop;var m=function(c){var d=this;this.length=0;this.name="nicescrollarray";this.each=function(a){for(var b=0;b<d.length;b++)a.call(d[b]);return d};this.push=function(a){d[d.length]=a;d.length++};this.eq=function(a){return d[a]};if(c){for(a=0;a<c.length;a++){var e=b.data(c[a],"__nicescroll")||false;if(e){this[this.length]=e;this.length++}}}return this};n(m.prototype,["show","hide","onResize","resize","remove","stop"],function(a,b){a[b]=function(){return this.each(function(){this[b].call()})}});jQuery.fn.getNiceScroll=function(a){if(typeof a=="undefined"){return new m(this)}else{var c=b.data(this[a],"__nicescroll")||false;return c}};jQuery.extend(jQuery.expr[":"],{nicescroll:function(a){return b.data(a,"__nicescroll")?true:false}});b.fn.niceScroll=function(a,c){if(typeof c=="undefined"){if(typeof a=="object"&&!("jquery"in a)){c=a;a=false}}var d=new m;if(typeof c=="undefined")c={};if(a||false){c.doc=b(a);c.win=b(this)}var e=!("doc"in c);if(!e&&!("win"in c))c.win=b(this);this.each(function(){var a=b(this).data("__nicescroll")||false;if(!a){c.doc=e?b(this):c.doc;a=new j(c,b(this));b(this).data("__nicescroll",a)}d.push(a)});return d.length==1?d[0]:d}})(jQuery)
