(function(factory){if(typeof define==='function'&&amd){define(['jquery'],factory);}else if(typeof exports==='object'){exports=factory(require('jquery'));}else{factory(jQuery);}}(function(jQuery){"use strict";var domfocus=false;var mousefocus=false;var tabindexcounter=0;var ascrailcounter=2000;var globalmaxzindex=0;var $=jQuery;function getScriptPath(){var scripts=getelementsbytagname('script');var path=length?scripts[length-1]split('?')[0]:'';return(split('/').length>0)?split('/').slice(0,-1).join('/')+'/':'';} var vendors=['webkit','ms','moz','o'];var setAnimationFrame=requestanimationframe||false;var clearAnimationFrame=cancelanimationframe||false;if(!setAnimationFrame){for(var vx in vendors){var v=vendors[vx];setAnimationFrame=window[v+'RequestAnimationFrame'];if(setAnimationFrame){clearAnimationFrame=window[v+'CancelAnimationFrame']||window[v+'CancelRequestAnimationFrame'];break;}}} var ClsMutationObserver=mutationobserver||webkitmutationobserver||false;var _globaloptions={zindex:"auto",cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"6px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:8*3,touchbehavior:false,hwacceleration:true,usetransition:true,boxzoom:false,dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:"",iframeautoresize:true,cursorminheight:32,preservenativescrolling:true,railoffset:false,railhoffset:false,bouncescroll:true,spacebarenabled:true,railpadding:{top:0,right:0,left:0,bottom:0},disableoutline:true,horizrailenabled:true,railalign:"right",railvalign:"bottom",enabletranslate3d:true,enablemousewheel:true,enablekeyboard:true,smoothscroll:true,sensitiverail:true,enablemouselockapi:true,cursorfixedheight:false,directionlockdeadzone:6,hidecursordelay:400,nativeparentscrolling:true,enablescrollonselection:true,overflowx:true,overflowy:true,cursordragspeed:0.3,rtlmode:"auto",cursordragontouch:false,oneaxismousemode:"auto",scriptpath:getScriptPath(),preventmultitouchscrolling:true,disablemutationobserver:false};var browserdetected=false;var getBrowserDetection=function(){if(browserdetected)return browserdetected;var _el=createelement('DIV'),_style=style,_agent=useragent,_platform=platform,d={};haspointerlock="pointerLockElement"in document||"webkitPointerLockElement"in document||"mozPointerLockElement"in document;isopera=("opera"in window);isopera12=(isopera&&("getUserMedia"in navigator));isoperamini=(call(operamini)==="[object OperaMini]");isie=(("all"in document)&&("attachEvent"in _el)&&!isopera);isieold=(isie&&!("msInterpolationMode"in _style));isie7=isie&&!isieold&&(!("documentMode"in document)||(documentmode==7));isie8=isie&&("documentMode"in document)&&(documentmode==8);isie9=isie&&("performance"in window)&&(documentmode==9);isie10=isie&&("performance"in window)&&(documentmode==10);isie11=("msRequestFullscreen"in _el)&&(documentmode>=11);isieedge12=(match(/Edge\/12\./));isieedge=("msOverflowStyle"in _el);ismodernie=isie11||isieedge;isie9mobile=/iemobile.9/test(_agent);if(isie9mobile)isie9=false;isie7mobile=(!isie9mobile&&isie7)&&/iemobile/test(_agent);ismozilla=("MozAppearance"in _style);iswebkit=("WebkitAppearance"in _style);ischrome=("chrome"in window);ischrome38=(ischrome&&("touchAction"in _style));ischrome22=(!ischrome38)&&(ischrome&&haspointerlock);ischrome26=(!ischrome38)&&(ischrome&&("transition"in _style));cantouch=("ontouchstart"in documentelement)||("ontouchstart"in window);hasw3ctouch=(pointerevent||false)&&((maxtouchpoints>0)||(msmaxtouchpoints>0));hasmstouch=(!hasw3ctouch)&&(mspointerevent||false);ismac=/^mac$/test(_platform);isios=(cantouch&&/iphone|ipad|ipod/test(_platform));isios4=((isios)&&!("seal"in Object));isios7=((isios)&&("webkitHidden"in document));isios8=((isios)&&("hidden"in document));isandroid=(/android/test(_agent));haseventlistener=("addEventListener"in _el);trstyle=false;hastransform=false;hastranslate3d=false;transitionstyle=false;hastransition=false;transitionend=false;var a;var check=['transform','msTransform','webkitTransform','MozTransform','OTransform'];for(a=0;a0){if(dom[0].nodeType==9)return false;var zi=css('zIndex');if(!isNaN(zi)&&zi!=0)return parseInt(zi);dom=parent();} return false;} var _convertBorderWidth={"thin":1,"medium":3,"thick":5};function getWidthToPixel(dom,prop,chkheight){var wd=css(prop);var px=parseFloat(wd);if(isNaN(px)){px=_convertBorderWidth[wd]||0;var brd=(px==3)?((chkheight)?(outerheight()innerheight()):(outerwidth()innerwidth())):1;if(isie8&&px)px+=1;return(brd)?px:0;} return px;} getdocumentscrolloffset=function(){return{top:pageyoffset||scrolltop,left:pagexoffset||scrollleft};};getoffset=function(){if(isfixed){var ofs=offset();var scrl=getdocumentscrolloffset();top-=top;left-=left;return ofs;} var ww=offset();if(!viewport)return ww;var vp=offset();return{top:top,left:left};};updatescrollbar=function(len){var pos,off;if(ishwscroll){css({height:innerheight()-(top+bottom)});if(railh)css({width:innerwidth()-(left+right)});}else{var wpos=getoffset();pos={top:top,left:left-(left+right)};top+=getWidthToPixel(win,'border-top-width',true);left+=(align)?outerwidth()-getWidthToPixel(win,'border-right-width')width:getWidthToPixel(win,'border-left-width');off=railoffset;if(off){if(top)top+=top;if(left)left+=left;} if(!railslocked)css({top:top,left:left,height:((len)?len.h:innerheight())-(top+bottom)});if(zoom){css({top:top+1,left:(align==1)?left-20:left+width+4});} if(railh&&!railslocked){pos={top:top,left:left};off=railhoffset;if(off){if(top)top+=top;if(left)left+=left;} var y=(align)?top+getWidthToPixel(win,'border-top-width',true)+innerheight()height:top+getWidthToPixel(win,'border-top-width',true);var x=left+getWidthToPixel(win,'border-left-width');css({top:y-(top+bottom),left:x,width:width});}}};dorailclick=function(e,dbl,hr){var fn,pg,cur,pos;if(railslocked)return;cancelevent(e);if(dbl){fn=(hr)?doscrollleft:doscrolltop;cur=(hr)?((offset().left-(cursorwidth/2))*scrollratio.x):((offset().top-(cursorheight/2))*scrollratio.y);fn(cur);}else{fn=(hr)?doscrollleftby:doscrollby;cur=(hr)?scroll.x:scroll.y;pos=(hr)?offset().left:offset().top;pg=(hr)?view.w:view.h;fn((cur>=pos)?pg:-pg);}};hasanimationframe=(setAnimationFrame);hascancelanimationframe=(clearAnimationFrame);if(!hasanimationframe){setAnimationFrame=function(fn){return setTimeout(fn,floor((+new Date())/1000)%16);};clearAnimationFrame=clearTimeout;}else if(!hascancelanimationframe)clearAnimationFrame=function(){cancelanimationframe=true;};init=function(){css=[];if(isie7mobile)return true;if(isoperamini)return true;var _touchaction=(isie10)?'-ms-touch-action':'touch-action';if(hasmstouch)css((ispage)?$("html"):win,{_touchaction:'none'});var _scrollyhidden=(ismodernie||isie10)?{'-ms-overflow-style':'none'}:{'overflow-y':'hidden'};zindex="auto";if(!ispage&&zindex=="auto"){zindex=getZIndex()||"auto";}else{zindex=zindex;} if(!ispage&&zindex!="auto"&&zindex>globalmaxzindex){globalmaxzindex=zindex;} if(isie&&zindex==0&&zindex=="auto"){zindex="auto";} if(!ispage||(!cantouch&&!isieold&&!isie9mobile)){var cont=docscroll;if(ispage)cont=(haswrapper)?win:doc;if(!isie9mobile)css(cont,_scrollyhidden);if(ispage&&isie7){if(doc[0].nodeName=='BODY')css($("html"),{'overflow-y':'hidden'});else if(doc[0].nodeName=='HTML')css($("body"),_scrollyhidden);} if(isios&&!ispage&&!haswrapper)css($("body"),{"-webkit-overflow-scrolling":"touch"});var cursor=$(createelement('div'));css({position:"relative",top:0,"float":"right",width:cursorwidth,height:0,'background-color':cursorcolor,border:cursorborder,'background-clip':'padding-box','-webkit-border-radius':cursorborderradius,'-moz-border-radius':cursorborderradius,'border-radius':cursorborderradius});hborder=parseFloat(outerheight()innerheight());addclass('nicescroll-cursors');cursor=cursor;var rail=$(createelement('div'));attr('id',id);addclass('nicescroll-rails nicescroll-rails-vr');var v,a,kp=["left","right","top","bottom"];for(var n in kp){a=kp[n];v=railpadding[a];(v)?css("padding-"+a,v+"px"):railpadding[a]=0;} append(cursor);width=max(parseFloat(cursorwidth),outerwidth());css({width:width+"px",zIndex:zindex,background:background,cursor:"default"});visibility=true;scrollable=true;align=(railalign=="left")?0:1;rail=rail;drag=false;var zoom=false;if(boxzoom&&!ispage&&!isieold){zoom=createelement('div');bind(zoom,"click",dozoom);bind(zoom,"mouseenter",function(){css('opacity',cursoropacitymax);});bind(zoom,"mouseleave",function(){css('opacity',cursoropacitymin);});zoom=$(zoom);css({cursor:"pointer",zIndex:zindex,backgroundImage:'url('+scriptpath+'png)',height:18,width:18,backgroundPosition:'0px 0px'});if(dblclickzoom)bind(win,"dblclick",dozoom);if(cantouch&&gesturezoom){ongesturezoom=function(e){if(scale>1.5)dozoomin(e);if(scale<0.8)dozoomout(e);return cancelevent(e);};bind(win,"gestureend",ongesturezoom);}} railh=false;var railh;if(horizrailenabled){css(cont,{overflowX:'hidden'});var cursor=$(createelement('div'));css({position:"absolute",top:0,height:cursorwidth,width:0,backgroundColor:cursorcolor,border:cursorborder,backgroundClip:'padding-box','-webkit-border-radius':cursorborderradius,'-moz-border-radius':cursorborderradius,'border-radius':cursorborderradius});if(isieold)css('overflow','hidden');wborder=parseFloat(outerwidth()innerwidth());addclass('nicescroll-cursors');cursorh=cursor;railh=$(createelement('div'));attr('id',id+'-hr');addclass('nicescroll-rails nicescroll-rails-hr');height=max(parseFloat(cursorwidth),outerheight());css({height:height+"px",'zIndex':zindex,"background":background});append(cursor);visibility=true;scrollable=true;align=(railvalign=="top")?0:1;railh=railh;drag=false;} if(ispage){css({position:"fixed",top:0,height:"100%"});(align)?css({right:0}):css({left:0});append(rail);if(railh){css({position:"fixed",left:0,width:"100%"});(align)?css({bottom:0}):css({top:0});append(railh);}}else{if(ishwscroll){if(css('position')=='static')css(win,{'position':'relative'});var bd=(win[0].nodeName=='HTML')?body:win;$(bd).scrollTop(0).scrollLeft(0);if(zoom){css({position:"absolute",top:1,right:0,"margin-right":width+4});append(zoom);} css({position:"absolute",top:0});(align)?css({right:0}):css({left:0});append(rail);if(railh){css({position:"absolute",left:0,bottom:0});(align)?css({bottom:0}):css({top:0});append(railh);}}else{isfixed=(css("position")=="fixed");var rlpos=(isfixed)?"fixed":"absolute";if(!isfixed)viewport=getviewport(win[0]);if(viewport){body=viewport;if((/fixed|absolute/.test(css("position")))==false)css(viewport,{"position":"relative"});} css({position:rlpos});if(zoom)css({position:rlpos});updatescrollbar();append(rail);if(zoom)append(zoom);if(railh){css({position:rlpos});append(railh);}} if(isios)css(win,{'-webkit-tap-highlight-color':'rgba(0,0,0,0)','-webkit-touch-callout':'none'});if(isie&&disableoutline)attr("hideFocus","true");if(iswebkit&&disableoutline)css('outline','none');} if(autohidemode===false){autohidedom=false;css({opacity:cursoropacitymax});if(railh)css({opacity:cursoropacitymax});}else if((autohidemode===true)||(autohidemode==="leave")){autohidedom=$().add(rail);if(isie8)autohidedom=add(cursor);if(railh)autohidedom=add(railh);if(railh&&isie8)autohidedom=add(cursorh);}else if(autohidemode=="scroll"){autohidedom=$().add(rail);if(railh)autohidedom=add(railh);}else if(autohidemode=="cursor"){autohidedom=$().add(cursor);if(railh)autohidedom=add(cursorh);}else if(autohidemode=="hidden"){autohidedom=false;hide();railslocked=false;} if(isie9mobile){scrollmom=new ScrollMomentumClass2D(self);onmangotouch=function(){var py=getscrolltop();var px=getscrollleft();if((py==lastscrolly)&&(px==lastscrollx))return true;var dfy=sy;var dfx=sx;var df=round(sqrt(pow(dfx,2)+pow(dfy,2)));if(df==0)return;var dry=(dfy<0)?-1:1;var drx=(dfx<0)?-1:1;var tm=+new Date();if(lazy)clearTimeout(lazy);if(((tm)>80)||(dry!=dry)||(drx!=drx)){stop();reset(px,py);sy=py;ly=py;sx=px;lx=px;dry=dry;drx=drx;tm=tm;}else{stop();update(sx-dfx,sy-dfy);tm=tm;var ds=max(abs(ly-py),abs(lx-px));ly=py;lx=px;if(ds>2){lazy=setTimeout(function(){lazy=false;dry=0;drx=0;tm=0;domomentum(30);},100);}}};var top=getscrolltop();var lef=getscrollleft();mangotouch={sy:top,ly:top,dry:0,sx:lef,lx:lef,drx:0,lazy:false,tm:0};bind(docscroll,"scroll",onmangotouch);}else{if(cantouch||istouchcapable||touchbehavior||hasmstouch){scrollmom=new ScrollMomentumClass2D(self);ontouchstart=function(e){if(pointertype&&pointertype!=2&&pointertype!="touch")return false;hasmoving=false;if(!railslocked){var tg;if(hasmstouch){tg=(target)?target:false;while(tg){var nc=$(tg).getNiceScroll();if((length>0)&&(nc[0].me==self))break;if(length>0)return false;if((nodename=='DIV')&&(id==id))break;tg=(parentnode)?parentnode:false;}} cancelscroll();tg=gettarget(e);if(tg){var skp=(/INPUT/test(nodename))&&(/range/test(type));if(skp)return stoppropagation(e);} if(!("clientX"in e)&&("changedTouches"in e)){clientx=changedtouches[0].clientX;clienty=changedtouches[0].clientY;} if(forcescreen){var le=e;e={"original":(original)?original:e};clientx=screenx;clienty=screeny;} drag={x:clientx,y:clienty,sx:scroll.x,sy:scroll.y,st:getscrolltop(),sl:getscrollleft(),pt:2,dl:false};if(ispage||!directionlockdeadzone){dl="f";}else{var view={w:$(window).width(),h:$(window).height()};var page={w:max(scrollwidth,scrollwidth),h:max(scrollheight,scrollheight)};var maxh=max(0,page.h-view.h);var maxw=max(0,page.w-view.w);if(!scrollable&&scrollable)ck=(maxh>0)?"v":false;else if(scrollable&&!scrollable)ck=(maxw>0)?"h":false;else ck=false;if(!ck)dl="f";} if(touchbehavior&&isiframe&&isie){var wp=position();drag.x+=left;drag.y+=top;} hasmoving=false;lastmouseup=false;reset(clientx,clienty);if(!cantouch&&!istouchcapable&&!pointertype){var ip=(tg)?/INPUT|SELECT|TEXTAREA/test(nodename):false;if(!ip){if(!ispage&&hasmousecapture)setcapture();if(touchbehavior){if(onclick&&!(tg._onclick||false)){tg._onclick=onclick;onclick=function(e){if(hasmoving)return false;call(this,e);};} return cancelevent(e);} return stoppropagation(e);} if(/SUBMIT|CANCEL|BUTTON/test($(tg).attr('type'))){preventclick={"tg":tg,"click":false};}}}};ontouchend=function(e){if(!drag)return true;if(pt==2){if(pointertype&&pointertype!=2&&pointertype!="touch")return false;domomentum();drag=false;if(hasmoving){lastmouseup=true;hidecursor();if(hasmousecapture)releasecapture();if(!cantouch)return cancelevent(e);}} else if(pt==1){return onmouseup(e);}};var moveneedoffset=(touchbehavior&&isiframe&&!hasmousecapture);ontouchmove=function(e,byiframe){if(!drag)return false;if(targettouches&&preventmultitouchscrolling){if(length>1)return false;} if(pointertype&&pointertype!=2&&pointertype!="touch")return false;if(pt==2){if(cantouch&&(isios)&&original===undefined)return true;hasmoving=true;if(preventclick&&!click){click=onclick||false;onclick=onpreventclick;} var ev=$.extend({"original":e},e);e=ev;if(("changedTouches"in e)){clientx=changedtouches[0].clientX;clienty=changedtouches[0].clientY;} if(forcescreen){var le=e;e={"original":(original)?original:e};clientx=screenx;clienty=screeny;} var ofy,ofx;ofx=ofy=0;if(moveneedoffset&&!byiframe){var wp=position();ofx=left;ofy=top;} var fy=clienty+ofy;var my=(drag.y);var fx=clientx+ofx;var mx=(drag.x);var ny=st-my;if(ishwscroll&&bouncescroll){if(ny<0){ny=round(ny/2);}else if(ny>maxh){ny=maxh+round((maxh)/2);}}else{if(ny<0){ny=0;fy=0;} if(ny>maxh){ny=maxh;fy=0;}} var nx;if(railh&&scrollable){nx=(isrtlmode)?sl:sl-mx;if(ishwscroll&&bouncescroll){if(nx<0){nx=round(nx/2);}else if(nx>maxw){nx=maxw+round((maxw)/2);}}else{if(nx<0){nx=0;fx=0;} if(nx>maxw){nx=maxw;fx=0;}}} var grabbed=false;if(dl){grabbed=true;if(dl=="v")nx=sl;else if(dl=="h")ny=st;}else{var ay=abs(my);var ax=abs(mx);var dz=directionlockdeadzone;if(ck=="v"){if(ay>dz&&(ax<=(ay*0.3))){drag=false;return true;}else if(ax>dz){dl="f";$("body").scrollTop($("body").scrollTop());}}else if(ck=="h"){if(ax>dz&&(ay<=(ax*0.3))){drag=false;return true;}else if(ay>dz){dl="f";$("body").scrollLeft($("body").scrollLeft());}}} synched("touchmove",function(){if(drag&&(pt==2)){if(preparetransition)preparetransition(0);if(scrollable)setscrolltop(ny);update(fx,fy);if(railh&&scrollable){setscrollleft(nx);showcursor(ny,nx);}else{showcursor(ny);} if(isie10)clear();}});if(ischrome&&istouchcapable)grabbed=false;if(grabbed)return cancelevent(e);} else if(pt==1){return onmousemove(e);}};ontouchstartcursor=function(e,hronly){if(drag&&pt!=3)return;if(locked)return cancelevent(e);cancelscroll();drag={x:touches[0].clientX,y:touches[0].clientY,sx:scroll.x,sy:scroll.y,pt:3,hr:(!!hronly)};var tg=gettarget(e);if(!ispage&&hasmousecapture)setcapture();if(isiframe&&!hasmousecapture){saved["csspointerevents"]=css("pointer-events");css(doc,{"pointer-events":"none"});} return cancelevent(e);};ontouchendcursor=function(e){if(drag){if(hasmousecapture)releasecapture();if(isiframe&&!hasmousecapture)css("pointer-events",saved["csspointerevents"]);if(pt!=3)return;drag=false;return cancelevent(e);}};ontouchmovecursor=function(e){if(drag){if(pt!=3)return;cursorfreezed=true;if(hr){scroll.x=sx+(touches[0]drag.x);if(scroll.x<0)scroll.x=0;var mw=scrollvaluemaxw;if(scroll.x>mw)scroll.x=mw;}else{scroll.y=sy+(touches[0]drag.y);if(scroll.y<0)scroll.y=0;var my=scrollvaluemax;if(scroll.y>my)scroll.y=my;} synched('touchmove',function(){if(drag&&(pt==3)){showcursor();if(hr)doscrollleft(round(scroll.x*scrollratio.x),cursordragspeed);else doscrolltop(round(scroll.y*scrollratio.y),cursordragspeed);}});return cancelevent(e);}};} onmousedown=function(e,hronly){if(drag&&pt!=1)return;if(railslocked)return cancelevent(e);cancelscroll();drag={x:clientx,y:clienty,sx:scroll.x,sy:scroll.y,pt:1,hr:(!!hronly)};var tg=gettarget(e);if(!ispage&&hasmousecapture)setcapture();if(isiframe&&!hasmousecapture){csspointerevents=css("pointer-events");css(doc,{"pointer-events":"none"});} hasmoving=false;return cancelevent(e);};onmouseup=function(e){if(drag){if(pt!=1)return true;if(hasmousecapture)releasecapture();if(isiframe&&!hasmousecapture)css("pointer-events",csspointerevents);drag=false;if(hasmoving)triggerscrollend();return cancelevent(e);}};onmousemove=function(e){if(drag){if(pt!=1)return;if(ischrome&&which==0)return onmouseup(e);cursorfreezed=true;hasmoving=true;if(hr){scroll.x=sx+(drag.x);if(scroll.x<0)scroll.x=0;var mw=scrollvaluemaxw;if(scroll.x>mw)scroll.x=mw;}else{scroll.y=sy+(drag.y);if(scroll.y<0)scroll.y=0;var my=scrollvaluemax;if(scroll.y>my)scroll.y=my;} synched('mousemove',function(){if(drag&&(pt==1)){showcursor();if(hr){if(hasreversehr){doscrollleft(round(scroll.x*scrollratio.x),cursordragspeed);}else{doscrollleft(round(scroll.x*scrollratio.x),cursordragspeed);}} else doscrolltop(round(scroll.y*scrollratio.y),cursordragspeed);}});return cancelevent(e);} else{checkarea=0;}};if(cantouch||touchbehavior){onpreventclick=function(e){if(preventclick){onclick=click;preventclick=false;return cancelevent(e);}};bind(win,"mousedown",ontouchstart);onclick=(isios)?false:function(e){if(lastmouseup){lastmouseup=false;return cancelevent(e);}else{return true;}};if(grabcursorenabled&&cursorgrabvalue){css((ispage)?doc:win,{'cursor':cursorgrabvalue});css(rail,{'cursor':cursorgrabvalue});}}else{var checkSelectionScroll=function(e){if(!selectiondrag)return;if(e){var ww=outerheight();var df=(top);if(df>0&&df=ww)df-=ww;df=df;} if(df==0)return;var rt=floor(df/6)*2;doscrollby(rt);debounced("doselectionscroll",function(){checkSelectionScroll();},50);};if("getSelection"in document){hastextselected=function(){return(getselection().rangeCount>0);};}else if("selection"in document){hastextselected=function(){return(type!="None");};}else{hastextselected=function(){return false;};} onselectionstart=function(e){if(ispage)return;selectiondrag=offset();};onselectionend=function(e){selectiondrag=false;};onselectiondrag=function(e){if(!selectiondrag)return;if(hastextselected())debounced("selectionscroll",function(){checkSelectionScroll(e);},250);};} if(hasw3ctouch){css(rail,{'touch-action':'none'});css(cursor,{'touch-action':'none'});bind(win,"pointerdown",ontouchstart);bind(document,"pointerup",ontouchend);bind(document,"pointermove",ontouchmove);}else if(hasmstouch){css(rail,{'-ms-touch-action':'none'});css(cursor,{'-ms-touch-action':'none'});bind(win,"MSPointerDown",ontouchstart);bind(document,"MSPointerUp",ontouchend);bind(document,"MSPointerMove",ontouchmove);bind(cursor,"MSGestureHold",function(e){preventdefault();});bind(cursor,"contextmenu",function(e){preventdefault();});}else if(istouchcapable){bind(win,"touchstart",ontouchstart);bind(document,"touchend",ontouchend);bind(document,"touchcancel",ontouchend);bind(document,"touchmove",ontouchmove);} if(cursordragontouch||(!cantouch&&!touchbehavior)){css({cursor:"default"});railh&&css({cursor:"default"});jqbind(rail,"mouseenter",function(){if(!ispage&&!is(":visible"))return false;if(canshowonmouseevent)showcursor();active=true;});jqbind(rail,"mouseleave",function(){active=false;if(!drag)hidecursor();});if(sensitiverail){bind(rail,"click",function(e){dorailclick(e,false,false);});bind(rail,"dblclick",function(e){dorailclick(e,true,false);});bind(cursor,"click",function(e){cancelevent(e);});bind(cursor,"dblclick",function(e){cancelevent(e);});} if(railh){jqbind(railh,"mouseenter",function(){if(!ispage&&!is(":visible"))return false;if(canshowonmouseevent)showcursor();active=true;});jqbind(railh,"mouseleave",function(){active=false;if(!drag)hidecursor();});if(sensitiverail){bind(railh,"click",function(e){dorailclick(e,false,true);});bind(railh,"dblclick",function(e){dorailclick(e,true,true);});bind(cursorh,"click",function(e){cancelevent(e);});bind(cursorh,"dblclick",function(e){cancelevent(e);});}}} if(cursordragontouch&&(istouchcapable||cantouch)){bind(cursor,"touchstart",ontouchstartcursor);bind(cursor,"touchmove",ontouchmovecursor);bind(cursor,"touchend",ontouchendcursor);cursorh&&bind(cursorh,"touchstart",function(e){ontouchstartcursor(e,true);});cursorh&&bind(cursorh,"touchmove",ontouchmovecursor);cursorh&&bind(cursorh,"touchend",ontouchendcursor);} if(!cantouch&&!touchbehavior){bind((hasmousecapture)?win:document,"mouseup",onmouseup);bind(document,"mousemove",onmousemove);if(onclick)bind(document,"click",onclick);bind(cursor,"mousedown",onmousedown);bind(cursor,"mouseup",onmouseup);if(railh){bind(cursorh,"mousedown",function(e){onmousedown(e,true);});bind(cursorh,"mouseup",onmouseup);} if(!ispage&&enablescrollonselection){bind(win[0],"mousedown",onselectionstart);bind(document,"mouseup",onselectionend);bind(cursor,"mouseup",onselectionend);if(cursorh)bind(cursorh,"mouseup",onselectionend);bind(document,"mousemove",onselectiondrag);} if(zoom){jqbind(zoom,"mouseenter",function(){if(canshowonmouseevent)showcursor();active=true;});jqbind(zoom,"mouseleave",function(){active=false;if(!drag)hidecursor();});}}else{bind((hasmousecapture)?win:document,"mouseup",ontouchend);bind(document,"mousemove",ontouchmove);if(onclick)bind(document,"click",onclick);if(cursordragontouch){bind(cursor,"mousedown",onmousedown);bind(cursor,"mouseup",onmouseup);cursorh&&bind(cursorh,"mousedown",function(e){onmousedown(e,true);});cursorh&&bind(cursorh,"mouseup",onmouseup);}else{bind(rail,"mousedown",function(e){preventdefault();});railh&&bind(railh,"mousedown",function(e){preventdefault();});}} if(enablemousewheel){if(!isiframe)mousewheel((isie&&ispage)?document:win,onmousewheel);mousewheel(rail,onmousewheel);if(railh)mousewheel(railh,onmousewheelhr);} if(!ispage&&!cantouch&&!(/HTML|^BODY/.test(win[0].nodeName))){if(!attr("tabindex"))attr({"tabindex":tabindexcounter++});jqbind(win,"focus",function(e){domfocus=(gettarget(e)).id||true;hasfocus=true;if(canshowonmouseevent)noticecursor();});jqbind(win,"blur",function(e){domfocus=false;hasfocus=false;});jqbind(win,"mouseenter",function(e){mousefocus=(gettarget(e)).id||true;hasmousefocus=true;if(canshowonmouseevent)noticecursor();});jqbind(win,"mouseleave",function(){mousefocus=false;hasmousefocus=false;if(!drag)hidecursor();});}} onkeypress=function(e){if(railslocked&&maxh==0)return true;e=(e)?e:window.e;var tg=gettarget(e);if(tg&&/INPUT|TEXTAREA|SELECT|OPTION/.test(nodename)){var tp=getattribute('type')||type||false;if((!tp)||!(/submit|button|cancel/tp))return true;} if($(tg).attr('contenteditable'))return true;if(hasfocus||(hasmousefocus&&!domfocus)||(ispage&&!domfocus&&!mousefocus)){var key=keycode;if(railslocked&&key!=27)return cancelevent(e);var ctrl=ctrlkey||false;var shift=shiftkey||false;var ret=false;switch(key){case 38:case 63233:doscrollby(24*3);ret=true;break;case 40:case 63235:doscrollby(-24*3);ret=true;break;case 37:case 63232:if(railh){(ctrl)?doscrollleft(0):doscrollleftby(24*3);ret=true;} break;case 39:case 63234:if(railh){(ctrl)?doscrollleft(maxw):doscrollleftby(-24*3);ret=true;} break;case 33:case 63276:doscrollby(view.h);ret=true;break;case 34:case 63277:doscrollby(view.h);ret=true;break;case 36:case 63273:(railh&&ctrl)?doscrollpos(0,0):doscrollto(0);ret=true;break;case 35:case 63275:(railh&&ctrl)?doscrollpos(maxw,maxh):doscrollto(maxh);ret=true;break;case 32:if(spacebarenabled){(shift)?doscrollby(view.h):doscrollby(view.h);ret=true;} break;case 27:if(zoomactive){dozoom();ret=true;} break;} if(ret)return cancelevent(e);}};if(enablekeyboard)bind(document,(isopera&&!isopera12)?"keypress":"keydown",onkeypress);bind(document,"keydown",function(e){var ctrl=ctrlkey||false;if(ctrl)wheelprevented=true;});bind(document,"keyup",function(e){var ctrl=ctrlkey||false;if(!ctrl)wheelprevented=false;});bind(window,"blur",function(e){wheelprevented=false;});bind(window,'resize',lazyresize);bind(window,'orientationchange',lazyresize);bind(window,"load",lazyresize);if(ischrome&&!ispage&&!haswrapper){var tmp=attr("style");var ww=parseFloat(css("width"))+1;css('width',ww);synched("chromefix",function(){attr("style",tmp);});} onattributechange=function(e){lazyresize(isieold?250:30);};if((!isie11)&&(ClsMutationObserver!==false)){observerbody=new ClsMutationObserver(function(mutations){foreach(function(mut){if(type=="attributes"){return($("body").hasClass("modal-open")&&$("body").hasClass("modal-dialog")&&!$.contains($('.modal-dialog')[0],doc[0]))?hide():show();}});if(clientwidth!=width||clientheight!=height)return lazyresize(30);});observe(body,{childList:true,subtree:true,characterData:false,attributes:true,attributeFilter:['class']});} if(!ispage&&!haswrapper){if(ClsMutationObserver!==false){observer=new ClsMutationObserver(function(mutations){foreach(onattributechange);});observe(win[0],{childList:true,characterData:false,attributes:true,subtree:false});observerremover=new ClsMutationObserver(function(mutations){foreach(function(mo){if(length>0){for(var dd in removednodes){if(!!self&&(removednodes[dd]==win[0]))return remove();}}});});observe(win[0].parentNode,{childList:true,characterData:false,attributes:false,subtree:false});}else{bind(win,(isie&&!isie9)?"propertychange":"DOMAttrModified",onattributechange);if(isie9)win[0].attachEvent("onpropertychange",onattributechange);bind(win,"DOMNodeRemoved",function(e){if(target==win[0])remove();});}} if(!ispage&&boxzoom)bind(window,"resize",resizezoom);if(istextarea){bind(win,"keydown",lazyresize);bind(win,"mouseup",lazyresize);} lazyresize(30);} if(doc[0].nodeName=='IFRAME'){var oniframeload=function(){iframexd=false;var doc;try{doc='contentDocument'in this?contentdocument:document;var a=domain;}catch(e){iframexd=true;doc=false;} if(iframexd){if("console"in window)log('NiceScroll error: policy restriced iframe');return true;} forcescreen=true;if(isiframe){iframe={"doc":$(doc),"html":contents().find('html')[0],"body":contents().find('body')[0]};getcontentsize=function(){return{w:max(scrollwidth,scrollwidth),h:max(scrollheight,scrollheight)};};docscroll=$(body);} if(!isios&&iframeautoresize&&!isiframe){scrolltop(0);height("");var hh=max(getelementsbytagname('html')[0].scrollHeight,scrollheight);height(hh);} lazyresize(30);if(isie7)css($(html),_scrollyhidden);css($(body),_scrollyhidden);if(isios&&haswrapper){css($(body),{'-webkit-transform':'translate3d(0,0,0)'});} if('contentWindow'in this){bind(contentwindow,"scroll",onscroll);}else{bind(doc,"scroll",onscroll);} if(enablemousewheel){mousewheel(doc,onmousewheel);} if(enablekeyboard)bind(doc,(isopera)?"keypress":"keydown",onkeypress);if(cantouch||touchbehavior){bind(doc,"mousedown",ontouchstart);bind(doc,"mousemove",function(e){return ontouchmove(e,true);});if(grabcursorenabled&&cursorgrabvalue)css($(body),{'cursor':cursorgrabvalue});} bind(doc,"mouseup",ontouchend);if(zoom){if(dblclickzoom)bind(doc,'dblclick',dozoom);if(ongesturezoom)bind(doc,"gestureend",ongesturezoom);}};if(doc[0].readyState&&doc[0].readyState=="complete"){setTimeout(function(){call(doc[0],false);},500);} bind(doc,"load",oniframeload);}};showcursor=function(py,px){if(cursortimeout){clearTimeout(cursortimeout);cursortimeout=0;} if(!rail)return;if(autohidedom){stop().css({opacity:cursoropacitymax});cursoractive=true;} if(!drag||pt!=1){if(py!==undefined&&py!==false){scroll.y=round(py*1/scrollratio.y);} if(px!==undefined){scroll.x=round(px*1/scrollratio.x);}} css({height:cursorheight,top:scroll.y});if(cursorh){var lx=(hasreversehr)?scroll.x:scroll.x;(!align&&visibility)?css({width:cursorwidth,left:lx+width}):css({width:cursorwidth,left:lx});cursoractive=true;} if(zoom)stop().css({opacity:cursoropacitymax});};hidecursor=function(tm){if(cursortimeout)return;if(!rail)return;if(!autohidedom)return;if(hasmousefocus&&autohidemode=="leave")return;cursortimeout=setTimeout(function(){if(!active||!showonmouseevent){stop().animate({opacity:cursoropacitymin});if(zoom)stop().animate({opacity:cursoropacitymin});cursoractive=false;} cursortimeout=0;},tm||hidecursordelay);};noticecursor=function(tm,py,px){showcursor(py,px);if(!active)hidecursor(tm);};getcontentsize=(ispage)?function(){return{w:max(scrollwidth,scrollwidth),h:max(scrollheight,scrollheight)};}:(haswrapper)?function(){return{w:outerwidth()+parseInt(css('paddingLeft'))+parseInt(css('paddingRight')),h:outerheight()+parseInt(css('paddingTop'))+parseInt(css('paddingBottom'))};}:function(){return{w:docscroll[0].scrollWidth,h:docscroll[0].scrollHeight};};onresize=function(e,page){if(!self||!win)return false;if(!haswrapper&&!ispage){if(css('display')=='none'){if(visibility)hiderail().hideRailHr();return false;}else{if(!hidden&&!visibility)showrail().showRailHr();}} var premaxh=maxh;var premaxw=maxw;var preview={h:view.h,w:view.w};view={w:(ispage)?width():parseInt(win[0].clientWidth),h:(ispage)?height():parseInt(win[0].clientHeight)};page=(page)?page:getcontentsize();maxh=max(0,view.h);maxw=max(0,view.w);if((maxh==premaxh)&&(maxw==premaxw)&&(view.w==preview.w)&&(view.h==preview.h)){if(!ispage){var pos=offset();if(lastposition){var lst=lastposition;if((top==top)&&(left==left))return self;} lastposition=pos;}else{return self;}} if(maxh==0){hiderail();scrollvaluemax=0;scroll.y=0;scrollratio.y=0;cursorheight=0;setscrolltop(0);if(rail)scrollable=false;}else{maxh-=(top+bottom);scrollable=true;} if(maxw==0){hiderailhr();scrollvaluemaxw=0;scroll.x=0;scrollratio.x=0;cursorwidth=0;setscrollleft(0);if(railh){scrollable=false;}}else{maxw-=(left+right);if(railh)scrollable=(horizrailenabled);} railslocked=(locked)||((maxh==0)&&(maxw==0));if(railslocked){if(!ispage)updatescrollbar(view);return false;} if(!hidden&&!visibility){showrail().showRailHr();} else if(railh&&(!hidden&&!visibility))showrailhr();if(istextarea&&css('resize')&&css('resize')!='none')view.h-=20;cursorheight=min(view.h,round(view.h*(view.h/page.h)));cursorheight=(cursorfixedheight)?cursorfixedheight:max(cursorminheight,cursorheight);cursorwidth=min(view.w,round(view.w*(view.w/page.w)));cursorwidth=(cursorfixedheight)?cursorfixedheight:max(cursorminheight,cursorwidth);scrollvaluemax=hborder-(top+bottom);if(railh){width=(maxh>0)?(width):view.w;scrollvaluemaxw=wborder-(left+right);} if(!ispage)updatescrollbar(view);scrollratio={x:(maxw/scrollvaluemaxw),y:(maxh/scrollvaluemax)};var sy=getscrolltop();if(sy>maxh){doscrolltop(maxh);}else{scroll.y=round(getscrolltop()*(1/scrollratio.y));scroll.x=round(getscrollleft()*(1/scrollratio.x));if(cursoractive)noticecursor();} if(scroll.y&&(getscrolltop()==0))doscrollto(floor(scroll.y*scrollratio.y));return self;};resize=onresize;hlazyresize=0;lazyresize=function(tm){if(!haswrapper)hide();if(hlazyresize)clearTimeout(hlazyresize);hlazyresize=setTimeout(function(){self&&show().resize();},240);return self;};function _modernWheelEvent(dom,name,fn,bubble){self._bind(dom,name,function(e){var e=(e)?e:event;var event={original:e,target:target||srcelement,type:"wheel",deltaMode:type=="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0,preventDefault:function(){preventdefault?preventdefault():returnvalue=false;return false;},stopImmediatePropagation:function(){(stopimmediatepropagation)?stopimmediatepropagation():cancelbubble=true;}};if(name=="mousewheel"){wheeldeltax&&(deltax=-1/40*wheeldeltax);wheeldeltay&&(deltay=-1/40*wheeldeltay);!deltay&&!deltax&&(deltay=-1/40*wheeldelta);}else{deltay=detail;} return call(dom,event);},bubble);} jqbind=function(dom,name,fn){push({e:dom,n:name,f:fn,q:true});$(dom).bind(name,fn);};mousewheel=function(dom,fn,bubble){var el=("jquery"in dom)?dom[0]:dom;if("onwheel"in createelement("div")){self._bind(el,"wheel",fn,bubble||false);}else{var wname=(onmousewheel!==undefined)?"mousewheel":"DOMMouseScroll";_modernWheelEvent(el,wname,fn,bubble||false);if(wname=="DOMMouseScroll")_modernWheelEvent(el,"MozMousePixelScroll",fn,bubble||false);}};if(haseventlistener){bind=function(dom,name,fn,bubble){var el=("jquery"in dom)?dom[0]:dom;self._bind(el,name,fn,bubble||false);};this._bind=function(el,name,fn,bubble){push({e:el,n:name,f:fn,b:bubble,q:false});addeventlistener(name,fn,bubble||false);};cancelevent=function(e){if(!e)return false;var e=(original)?original:e;if(cancelable)preventdefault();stoppropagation();if(preventmanipulation)preventmanipulation();return false;};stoppropagation=function(e){if(!e)return false;var e=(original)?original:e;stoppropagation();return false;};this._unbind=function(el,name,fn,bub){removeeventlistener(name,fn,bub);};}else{bind=function(dom,name,fn,bubble){var el=("jquery"in dom)?dom[0]:dom;self._bind(el,name,function(e){e=e||event||false;if(e&&srcelement){target=srcelement;} if(!("pageY"in e)){pagex=clientx+scrollleft;pagey=clienty+scrolltop;} return((call(el,e)===false)||bubble===false)?cancelevent(e):true;});};this._bind=function(el,name,fn,bubble){push({e:el,n:name,f:fn,b:bubble,q:false});if(attachevent){attachevent("on"+name,fn);}else{el["on"+name]=fn;}};cancelevent=function(e){var e=event||false;if(!e)return false;cancelbubble=true;cancel=true;returnvalue=false;return false;};stoppropagation=function(e){var e=event||false;if(!e)return false;cancelbubble=true;return false;};this._unbind=function(el,name,fn,bub){if(detachevent){detachevent('on'+name,fn);}else{el['on'+name]=false;}};} unbindall=function(){for(var a=0;a0)return dd;dom=(parentnode)?parentnode:false;} return false;};triggerscrollend=function(){if(!onscrollend)return;var px=getscrollleft();var py=getscrolltop();var info={type:"scrollend",current:{x:px,y:py},end:{x:px,y:py}};call(self,info);};function execScrollWheel(e,hr,chkscroll){var px,py;if(deltamode==0){px=floor(deltax*(mousescrollstep/(18*3)));py=floor(deltay*(mousescrollstep/(18*3)));}else if(deltamode==1){px=floor(deltax*mousescrollstep);py=floor(deltay*mousescrollstep);} if(hr&&oneaxismousemode&&(px==0)&&py){px=py;py=0;if(chkscroll){var hrend=(px<0)?(getscrollleft()>=maxw):(getscrollleft()<=0);if(hrend){py=px;px=0;}}} if(isrtlmode)px=-px;if(px){if(scrollmom){stop();} lastdeltax+=px;debounced("mousewheelx",function(){var dt=lastdeltax;lastdeltax=0;if(!drag){doscrollleftby(dt);}},15);} if(py){if(nativeparentscrolling&&chkscroll&&!ispage&&!zoomactive){if(py<0){if(getscrolltop()>=maxh)return true;}else{if(getscrolltop()<=0)return true;}} if(scrollmom){stop();} lastdeltay+=py;synched("mousewheely",function(){var dt=lastdeltay;lastdeltay=0;if(!drag){doscrollby(dt);}},15);} stopimmediatepropagation();return preventdefault();} onmousewheel=function(e){if(wheelprevented)return;if(railslocked){debounced("checkunlock",resize,250);return true;} if(drag)return cancelevent(e);if(oneaxismousemode=="auto"&&deltax!=0)oneaxismousemode=false;if(oneaxismousemode&&deltax==0){if(!scrollable){if(railh&&scrollable){return onmousewheelhr(e);}else{return true;}}} var nw=+(new Date());var chk=false;if(preservenativescrolling&&((checkarea+600)20)?ex:0;};if(!smoothscroll){doscrollleft=function(x,spd){var y=getscrolltop();doscrollpos(x,y,spd);};doscrolltop=function(y,spd){var x=getscrollleft();doscrollpos(x,y,spd);};doscrollpos=function(x,y,spd){var nx=(x>maxw)?maxw:x;if(nx<0)nx=0;var ny=(y>maxh)?maxh:y;if(ny<0)ny=0;synched('scroll',function(){setscrolltop(ny);setscrollleft(nx);});};cancelscroll=function(){};}else if(ishwscroll&&hastransition&&usetransition&&!!smoothscroll){preparetransition=function(dif,istime){var ex=(istime)?((dif>20)?dif:0):gettransitionspeed(dif);var trans=(ex)?prefixstyle+'transform '+ex+'ms ease-out':'';if(!lasttransitionstyle||lasttransitionstyle!=trans){lasttransitionstyle=trans;css(transitionstyle,trans);} return ex;};doscrollleft=function(x,spd){var y=(scrollrunning)?newscrolly:getscrolltop();doscrollpos(x,y,spd);};doscrolltop=function(y,spd){var x=(scrollrunning)?newscrollx:getscrollleft();doscrollpos(x,y,spd);};doscrollpos=function(x,y,spd){var py=getscrolltop();var px=getscrollleft();if(((newscrolly-py)*(y-py)<0)||((newscrollx-px)*(x-px)<0))cancelscroll();if(bouncescroll==false){if(y<0)y=0;else if(y>maxh)y=maxh;if(x<0)x=0;else if(x>maxw)x=maxw;} if(scrollrunning&&x==newscrollx&&y==newscrolly)return false;newscrolly=y;newscrollx=x;newscrollspeed=spd||false;if(timer)return false;timer=setTimeout(function(){var top=getscrolltop();var lft=getscrollleft();var dst={};dst.x=x-lft;dst.y=y-top;px=lft;py=top;var dd=round(sqrt(pow(dst.x,2)+pow(dst.y,2)));var ms=(newscrollspeed&&newscrollspeed>1)?newscrollspeed:gettransitionspeed(dd);if(newscrollspeed&&newscrollspeed<=1)ms*=newscrollspeed;preparetransition(ms,true);if(timerscroll&&tm)clearInterval(tm);if(ms>0){if(!scrollrunning&&onscrollstart){var info={"type":"scrollstart","current":{"x":lft,"y":top},"request":{"x":x,"y":y},"end":{"x":newscrollx,"y":newscrolly},"speed":ms};call(self,info);} if(transitionend){if(!scrollendtrapped){scrollendtrapped=true;bind(doc,transitionend,onscrolltransitionend,false);}}else{if(scrollendtrapped)clearTimeout(scrollendtrapped);scrollendtrapped=setTimeout(onscrolltransitionend,ms);} var py=top;var px=lft;timerscroll={bz:new BezierClass(py,newscrolly,ms,0,0,0.58,1),bh:new BezierClass(px,newscrollx,ms,0,0,0.58,1)};if(!cursorfreezed)tm=setInterval(function(){showcursor(getscrolltop(),getscrollleft());},60);} synched("doScroll-set",function(){timer=0;if(scrollendtrapped)scrollrunning=true;setscrolltop(newscrolly);setscrollleft(newscrollx);if(!scrollendtrapped)onscrolltransitionend();});},50);};cancelscroll=function(){if(!scrollendtrapped)return true;var py=getscrolltop();var px=getscrollleft();scrollrunning=false;if(!transitionend)clearTimeout(transitionend);scrollendtrapped=false;self._unbind(doc[0],transitionend,onscrolltransitionend);preparetransition(0);setscrolltop(py);if(railh)setscrollleft(px);if(timerscroll&&tm)clearInterval(tm);timerscroll=false;cursorfreezed=false;showcursor(py,px);return self;};onscrolltransitionend=function(){if(scrollendtrapped)self._unbind(doc[0],transitionend,onscrolltransitionend);scrollendtrapped=false;preparetransition(0);if(timerscroll&&tm)clearInterval(tm);timerscroll=false;var py=getscrolltop();var px=getscrollleft();setscrolltop(py);if(railh)setscrollleft(px);noticecursor(false,py,px);cursorfreezed=false;if(py<0)py=0;else if(py>maxh)py=maxh;if(px<0)px=0;else if(px>maxw)px=maxw;if((py!=newscrolly)||(px!=newscrollx))return doscrollpos(px,py,snapbackspeed);if(onscrollend&&scrollrunning){triggerscrollend();} scrollrunning=false;};}else{doscrollleft=function(x,spd){var y=(scrollrunning)?newscrolly:getscrolltop();doscrollpos(x,y,spd);};doscrolltop=function(y,spd){var x=(scrollrunning)?newscrollx:getscrollleft();doscrollpos(x,y,spd);};doscrollpos=function(x,y,spd){var y=(y===undefined||y===false)?getscrolltop(true):y;if((timer)&&(newscrolly==y)&&(newscrollx==x))return true;if(timer)clearAnimationFrame(timer);timer=0;var py=getscrolltop();var px=getscrollleft();if(((newscrolly-py)*(y-py)<0)||((newscrollx-px)*(x-px)<0))cancelscroll();newscrolly=y;newscrollx=x;if(!bouncescroll||!visibility){if(newscrolly<0){newscrolly=0;}else if(newscrolly>maxh){newscrolly=maxh;}} if(!bouncescroll||!visibility){if(newscrollx<0){newscrollx=0;}else if(newscrollx>maxw){newscrollx=maxw;}} dst={};dst.x=x-px;dst.y=y-py;px=px;py=py;var dst=round(sqrt(pow(dst.x,2)+pow(dst.y,2)));ax=dst.x/dst;ay=dst.y/dst;var pa=0;var pe=dst;if(dst.x==0){pa=py;pe=y;ay=1;py=0;}else if(dst.y==0){pa=px;pe=x;ax=1;px=0;} var ms=gettransitionspeed(dst);if(spd&&spd<=1)ms*=spd;if(ms>0){bzscroll=(bzscroll)?update(pe,ms):new BezierClass(pa,pe,ms,0,1,0,1);}else{bzscroll=false;} if(timer)return;if((py==maxh&&y>=maxh)||(px==maxw&&x>=maxw))checkcontentsize();var sync=1;function scrolling(){if(cancelanimationframe)return true;scrollrunning=true;sync=1-sync;if(sync)return(timer=setAnimationFrame(scrolling)||1);var done=0;var sx,sy;var sc=sy=getscrolltop();if(ay){sc=(bzscroll)?py+(getnow()*ay):newscrolly;var dr=sc-sy;if((dr<0&&sc0&&sc>newscrolly))sc=newscrolly;setscrolltop(sc);if(sc==newscrolly)done=1;}else{done=1;} var scx=sx=getscrollleft();if(ax){scx=(bzscroll)?px+(getnow()*ax):newscrollx;var dr=scx-sx;if((dr<0&&scx0&&scx>newscrollx))scx=newscrollx;setscrollleft(scx);if(scx==newscrollx)done+=1;}else{done+=1;} if(done==2){timer=0;cursorfreezed=false;bzscroll=false;scrollrunning=false;if(sc<0)sc=0;else if(sc>maxh)sc=max(0,maxh);if(scx<0)scx=0;else if(scx>maxw)scx=maxw;if((scx!=newscrollx)||(sc!=newscrolly))doscrollpos(scx,sc);else{if(onscrollend){triggerscrollend();}}}else{timer=setAnimationFrame(scrolling)||1;}} cancelanimationframe=false;timer=1;if(onscrollstart&&!scrollrunning){var info={"type":"scrollstart","current":{"x":px,"y":py},"request":{"x":x,"y":y},"end":{"x":newscrollx,"y":newscrolly},"speed":ms};call(self,info);} scrolling();if((py==maxh&&y>=py)||(px==maxw&&x>=px))checkcontentsize();noticecursor();};cancelscroll=function(){if(timer)clearAnimationFrame(timer);timer=0;bzscroll=false;scrollrunning=false;return self;};} doscrollby=function(stp,relative){var ny=0;if(relative){ny=floor((scroll.y-stp)*scrollratio.y);}else{var sy=(timer)?newscrolly:getscrolltop(true);ny=sy-stp;} if(bouncescroll){var haf=round(view.h/2);if(ny<-haf)ny=-haf;else if(ny>(maxh+haf))ny=(maxh+haf);} cursorfreezed=false;var py=getscrolltop(true);if(ny<0&&py<=0)return noticecursor();else if(ny>maxh&&py>=maxh){checkcontentsize();return noticecursor();} doscrolltop(ny);};doscrollleftby=function(stp,relative){var nx=0;if(relative){nx=floor((scroll.x-stp)*scrollratio.x);}else{var sx=(timer)?newscrollx:getscrollleft(true);nx=sx-stp;} if(bouncescroll){var haf=round(view.w/2);if(nx<-haf)nx=-haf;else if(nx>(maxw+haf))nx=(maxw+haf);} cursorfreezed=false;var px=getscrollleft(true);if(nx<0&&px<=0)return noticecursor();else if(nx>maxw&&px>=maxw)return noticecursor();doscrollleft(nx);};doscrollto=function(pos,relative){var ny=(relative)?round(pos*scrollratio.y):pos;if(ny<0)ny=0;else if(ny>maxh)ny=maxh;cursorfreezed=false;doscrolltop(pos);};checkcontentsize=function(){var pg=getcontentsize();if((pg.h!=page.h)||(pg.w!=page.w))resize(false,pg);};onscroll=function(e){if(drag)return;if(!cursorfreezed){synched('scroll',function(){scroll.y=round(getscrolltop()*(1/scrollratio.y));if(railh)scroll.x=round(getscrollleft()*(1/scrollratio.x));noticecursor();});}};bind(docscroll,"scroll",onscroll);dozoomin=function(e){if(zoomactive)return;zoomactive=true;zoomrestore={style:{}};var lst=['position','top','left','zIndex','backgroundColor','marginTop','marginBottom','marginLeft','marginRight'];var win=win[0].style;for(var a in lst){var pp=lst[a];style[pp]=(win[pp]!==undefined)?win[pp]:'';} width=css('width');height=css('height');padding={w:outerwidth()width(),h:outerheight()height()};if(isios4){scrolltop=$(window).scrollTop();$(window).scrollTop(0);} css({position:(isios4)?"absolute":"fixed",top:0,left:0,zIndex:globalmaxzindex+100,margin:0});var bkg=css("backgroundColor");if(bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg))css("backgroundColor","#fff");css({zIndex:globalmaxzindex+101});css({zIndex:globalmaxzindex+102});css('backgroundPosition','0px -18px');resizezoom();if(onzoomin)call(self);return cancelevent(e);};dozoomout=function(e){if(!zoomactive)return;zoomactive=false;css("margin","");css(style);if(isios4){$(window).scrollTop(scrolltop);} css({"z-index":zindex});css({"z-index":zindex});zoomrestore=false;css('backgroundPosition','0px 0px');onresize();if(onzoomout)call(self);return cancelevent(e);};dozoom=function(e){return(zoomactive)?dozoomout(e):dozoomin(e);};resizezoom=function(){if(!zoomactive)return;var py=getscrolltop();css({width:$(window).width()padding.w+"px",height:$(window).height()padding.h+"px"});onresize();setscrolltop(min(maxh,py));};init();$push(this);};var ScrollMomentumClass2D=function(nc){var self=this;nc=nc;lastx=0;lasty=0;speedx=0;speedy=0;lasttime=0;steptime=0;snapx=false;snapy=false;demulx=0;demuly=0;lastscrollx=-1;lastscrolly=-1;chkx=0;chky=0;timer=0;time=function(){return+new Date();};reset=function(px,py){stop();var now=time();steptime=0;lasttime=now;speedx=0;speedy=0;lastx=px;lasty=py;lastscrollx=-1;lastscrolly=-1;};update=function(px,py){var now=time();steptime=lasttime;lasttime=now;var dy=lasty;var dx=lastx;var sy=getscrolltop();var sx=getscrollleft();var newy=sy+dy;var newx=sx+dx;snapx=(newx<0)||(newx>maxw);snapy=(newy<0)||(newy>maxh);speedx=dx;speedy=dy;lastx=px;lasty=py;};stop=function(){unsynched("domomentum2d");if(timer)clearTimeout(timer);timer=0;lastscrollx=-1;lastscrolly=-1;};dosnapy=function(nx,ny){var snap=false;if(ny<0){ny=0;snap=true;}else if(ny>maxh){ny=maxh;snap=true;} if(nx<0){nx=0;snap=true;}else if(nx>maxw){nx=maxw;snap=true;} (snap)?doscrollpos(nx,ny,snapbackspeed):triggerscrollend();};domomentum=function(gp){var t=time();var l=(gp)?t+gp:lasttime;var sl=getscrollleft();var st=getscrolltop();var pageh=maxh;var pagew=maxw;speedx=(pagew>0)?min(60,speedx):0;speedy=(pageh>0)?min(60,speedy):0;var chk=l&&(t-l)<=60;if((st<0)||(st>pageh)||(sl<0)||(sl>pagew))chk=false;var sy=(speedy&&chk)?speedy:false;var sx=(speedx&&chk)?speedx:false;if(sy||sx){var tm=max(16,steptime);if(tm>50){var xm=tm/50;speedx*=xm;speedy*=xm;tm=50;} demulxy=0;lastscrollx=getscrollleft();chkx=lastscrollx;lastscrolly=getscrolltop();chky=lastscrolly;var nx=lastscrollx;var ny=lastscrolly;var onscroll=function(){var df=((time()-t)>600)?0.04:0.02;if(speedx){nx=floor(lastscrollx-(speedx*(demulxy)));lastscrollx=nx;if((nx<0)||(nx>pagew))df=0.10;} if(speedy){ny=floor(lastscrolly-(speedy*(demulxy)));lastscrolly=ny;if((ny<0)||(ny>pageh))df=0.10;} demulxy=min(1,demulxy+df);synched("domomentum2d",function(){if(speedx){var scx=getscrollleft();chkx=nx;setscrollleft(nx);} if(speedy){var scy=getscrolltop();chky=ny;setscrolltop(ny);} if(!timer){hidecursor();dosnapy(nx,ny);}});if(demulxy<1){timer=setTimeout(onscroll,tm);}else{stop();hidecursor();dosnapy(nx,ny);}};onscroll();}else{dosnapy(getscrollleft(),getscrolltop());}};};var _scrollTop=scrolltop;pageyoffset={get:function(elem,computed,extra){var nice=$.data(elem,'__nicescroll')||false;return(nice&&ishwscroll)?getscrolltop():call(elem);},set:function(elem,value){var nice=$.data(elem,'__nicescroll')||false;(nice&&ishwscroll)?setscrolltop(parseInt(value)):call(elem,value);return this;}};scrolltop=function(value){if(value===undefined){var nice=(this[0])?$.data(this[0],'__nicescroll')||false:false;return(nice&&ishwscroll)?getscrolltop():call(this);}else{return each(function(){var nice=$.data(this,'__nicescroll')||false;(nice&&ishwscroll)?setscrolltop(parseInt(value)):call($(this),value);});}};var _scrollLeft=scrollleft;$pagexoffset={get:function(elem,computed,extra){var nice=$.data(elem,'__nicescroll')||false;return(nice&&ishwscroll)?getscrollleft():call(elem);},set:function(elem,value){var nice=$.data(elem,'__nicescroll')||false;(nice&&ishwscroll)?setscrollleft(parseInt(value)):call(elem,value);return this;}};scrollleft=function(value){if(value===undefined){var nice=(this[0])?$.data(this[0],'__nicescroll')||false:false;return(nice&&ishwscroll)?getscrollleft():call(this);}else{return each(function(){var nice=$.data(this,'__nicescroll')||false;(nice&&ishwscroll)?setscrollleft(parseInt(value)):call($(this),value);});}};var NiceScrollArray=function(doms){var self=this;length=0;name="nicescrollarray";each=function(fn){$.each(self,fn);return self;};push=function(nice){self[length]=nice;length++;};eq=function(idx){return self[idx];};if(doms){for(var a=0;a