// javascript document /* jquery.nicescroll 3.1.2 inuyaksa*2012 mit http://areaaperta.com/nicescroll */(function(e){var r=false,w=false,b=5e3,c=2e3,d=function(){var e=document.getelementsbytagname("script"),e=e[e.length-1].src.split("?")[0];return e.split("/").length>0?e.split("/").slice(0,-1).join("/")+"/":""}(),p=window.requestanimationframe||window.webkitrequestanimationframe||window.mozrequestanimationframe||window.orequestanimationframe||window.msrequestanimationframe||false,q=window.cancelrequestanimationframe||window.webkitcancelrequestanimationframe||window.mozcancelrequestanimationframe|| window.ocancelrequestanimationframe||window.mscancelrequestanimationframe||false,x=false,e=function(){if(x)return x;var e=document.createelement("div"),c={haspointerlock:"pointerlockelement"in document||"mozpointerlockelement"in document||"webkitpointerlockelement"in document};c.isopera="opera"in window;c.isopera12=c.isopera&&"getusermedia"in navigator;c.isie="all"in document&&"attachevent"in e&&!c.isopera;c.isieold=c.isie&&!("msinterpolationmode"in e.style);c.isie7=c.isie&&!c.isieold&&(!("documentmode"in document)||document.documentmode==7);c.isie8=c.isie&&"documentmode"in document&&document.documentmode==8;c.isie9=c.isie&&"performance"in window&&document.documentmode>=9;c.isie10=c.isie&&"performance"in window&&document.documentmode>=10;c.isie9mobile=/iemobile.9/i.test(navigator.useragent);if(c.isie9mobile)c.isie9=false;c.isie7mobile=!c.isie9mobile&&c.isie7&&/iemobile/i.test(navigator.useragent);c.ismozilla="mozappearance"in e.style;c.iswebkit="webkitappearance"in e.style;c.ischrome="chrome"in window; c.ischrome22=c.ischrome&&c.haspointerlock;c.cantouch="ontouchstart"in document.documentelement||"ontouchstart"in window;c.hasmstouch=window.navigator.mspointerenabled||false;c.ismac=/^mac$/i.test(navigator.platform);c.isios=c.cantouch&&/iphone|ipad|ipod/i.test(navigator.platform);c.isios4=c.isios&&!("seal"in object);c.isandroid=/android/i.test(navigator.useragent);c.trstyle=false;c.hastransform=false;c.hastranslate3d=false;c.transitionstyle=false;c.hastransition=false;c.transitionend=false;for(var h= ["transform","mstransform","webkittransform","moztransform","otransform"],i=0;ih&&!e.tt)b.delaylist[d]={last:h+g,tt:settimeout(function(){b.delaylist[d].tt=0;c.call()},g)};else if(!e||!e.tt)b.delaylist[d]={last:h,tt:0},settimeout(function(){c.call()},0)};this.synched=function(d,c){b.synclist[d]=c;(function(){if(!b.onsync)p(function(){b.onsync=false;for(d in b.synclist){var c=b.synclist[d];c&&c.call(b);b.synclist[d]=false}}),b.onsync=true})();return d};this.unsynched=function(d){b.synclist[d]&& (b.synclist[d]=false)};this.css=function(d,c){for(var g in c)b.saved.css.push([d,g,d.css(g)]),d.css(g,c[g])};this.scrolltop=function(d){return typeof d=="undefined"?b.getscrolltop():b.setscrolltop(d)};this.scrollleft=function(d){return typeof d=="undefined"?b.getscrollleft():b.setscrollleft(d)};bezierclass=function(b,c,g,f,e,h,i){this.st=b;this.ed=c;this.spd=g;this.p1=f||0;this.p2=e||1;this.p3=h||0;this.p4=i||1;this.ts=(new date).gettime();this.df=this.ed-this.st};bezierclass.prototype={b2:function(b){return 3* b*b*(1-b)},b3:function(b){return 3*b*(1-b)*(1-b)},b4:function(b){return(1-b)*(1-b)*(1-b)},getnow:function(){var b=1-((new date).gettime()-this.ts)/this.spd,c=this.b2(b)+this.b3(b)+this.b4(b);return b<0?this.ed:this.st+math.round(this.df*c)},update:function(b,c){this.st=this.getnow();this.ed=b;this.spd=c;this.ts=(new date).gettime();this.df=this.ed-this.st;return this}};if(this.ishwscroll){this.doc.translate={x:0,y:0,tx:"0px",ty:"0px"};f.hastranslate3d&&f.isios&&this.doc.css("-webkit-backface-visibility", "hidden");var m=function(){var d=b.doc.css(f.trstyle);return d&&d.substr(0,6)=="matrix"?d.replace(/^.*\((.*)\)$/g,"$1").replace(/px/g,"").split(/, +/):false};this.getscrolltop=function(d){if(!d){if(d=m())return d.length==16?-d[13]:-d[5];if(b.timerscroll&&b.timerscroll.bz)return b.timerscroll.bz.getnow()}return b.doc.translate.y};this.getscrollleft=function(d){if(!d){if(d=m())return d.length==16?-d[12]:-d[4];if(b.timerscroll&&b.timerscroll.bh)return b.timerscroll.bh.getnow()}return b.doc.translate.x}; this.notifyscrollevent=document.createevent?function(b){var c=document.createevent("uievents");c.inituievent("scroll",false,true,window,1);b.dispatchevent(c)}:document.fireevent?function(b){var c=document.createeventobject();b.fireevent("onscroll");c.cancelbubble=true}:function(){};f.hastranslate3d&&b.opt.enabletranslate3d?(this.setscrolltop=function(d,c){b.doc.translate.y=d;b.doc.translate.ty=d*-1+"px";b.doc.css(f.trstyle,"translate3d("+b.doc.translate.tx+","+b.doc.translate.ty+",0px)");c||b.notifyscrollevent(b.win[0])}, this.setscrollleft=function(d,c){b.doc.translate.x=d;b.doc.translate.tx=d*-1+"px";b.doc.css(f.trstyle,"translate3d("+b.doc.translate.tx+","+b.doc.translate.ty+",0px)");c||b.notifyscrollevent(b.win[0])}):(this.setscrolltop=function(d,c){b.doc.translate.y=d;b.doc.translate.ty=d*-1+"px";b.doc.css(f.trstyle,"translate("+b.doc.translate.tx+","+b.doc.translate.ty+")");c||b.notifyscrollevent(b.win[0])},this.setscrollleft=function(d,c){b.doc.translate.x=d;b.doc.translate.tx=d*-1+"px";b.doc.css(f.trstyle, "translate("+b.doc.translate.tx+","+b.doc.translate.ty+")");c||b.notifyscrollevent(b.win[0])})}else this.getscrolltop=function(){return b.docscroll.scrolltop()},this.setscrolltop=function(d){return b.docscroll.scrolltop(d)},this.getscrollleft=function(){return b.docscroll.scrollleft()},this.setscrollleft=function(d){return b.docscroll.scrollleft(d)};this.gettarget=function(b){return!b?false:b.target?b.target:b.srcelement?b.srcelement:false};this.hasparent=function(b,c){if(!b)return false;for(var g= b.target||b.srcelement||b||false;g&&g.id!=c;)g=g.parentnode||false;return g!==false};var o={thin:1,medium:3,thick:5};this.getoffset=function(){if(b.isfixed)return{top:parsefloat(b.win.css("top")),left:parsefloat(b.win.css("left"))};if(!b.viewport)return b.win.offset();var d=b.win.offset(),c=b.viewport.offset();return{top:d.top-c.top+b.viewport.scrolltop(),left:d.left-c.left+b.viewport.scrollleft()}};this.updatescrollbar=function(d){if(b.ishwscroll)b.rail.css({height:b.win.innerheight()}),b.railh&& b.railh.css({width:b.win.innerwidth()});else{var c=b.getoffset(),g=c.top,f=c.left;g+=h(b.win,"border-top-width",true);b.win.outerwidth();b.win.innerwidth();f+=b.rail.align?b.win.outerwidth()-h(b.win,"border-right-width")-b.rail.width:h(b.win,"border-left-width");var e=b.opt.railoffset;e&&(e.top&&(g+=e.top),b.rail.align&&e.left&&(f+=e.left));b.locked||b.rail.css({top:g,left:f,height:d?d.h:b.win.innerheight()});b.zoom&&b.zoom.css({top:g+1,left:b.rail.align==1?f-20:f+b.rail.width+4});if(b.railh&&!b.locked)g= c.top,f=c.left,d=b.railh.align?g+h(b.win,"border-top-width",true)+b.win.innerheight()-b.railh.height:g+h(b.win,"border-top-width",true),f+=h(b.win,"border-left-width"),b.railh.css({top:d,left:f,width:b.railh.width})}};this.dorailclick=function(d,c,g){var f;!(b.rail.drag&&b.rail.drag.pt!=1)&&!b.locked&&!b.rail.drag&&(b.cancelscroll(),b.cancelevent(d),c?(c=g?b.doscrollleft:b.doscrolltop,f=g?(d.pagex-b.railh.offset().left-b.cursorwidth/2)*b.scrollratio.x:(d.pagey-b.rail.offset().top-b.cursorheight/2)* b.scrollratio.y,c(f)):(c=g?b.doscrollleftby:b.doscrollby,f=g?b.scroll.x:b.scroll.y,d=g?d.pagex-b.railh.offset().left:d.pagey-b.rail.offset().top,g=g?b.view.w:b.view.h,f>=d?c(g):c(-g)))};b.hasanimationframe=p;b.hascancelanimationframe=q;b.hasanimationframe?b.hascancelanimationframe||(q=function(){b.cancelanimationframe=true}):(p=function(b){return settimeout(b,16)},q=clearinterval);this.init=function(){b.saved.css=[];if(f.isie7mobile)return true;f.hasmstouch&&b.css(b.ispage?e("html"):b.win,{"-ms-touch-action":"none"}); if(!b.ispage||!f.cantouch&&!f.isieold&&!f.isie9mobile){var d=b.docscroll;b.ispage&&(d=b.haswrapper?b.win:b.doc);f.isie9mobile||b.css(d,{"overflow-y":"hidden"});b.ispage&&f.isie7&&(b.doc[0].nodename=="body"?b.css(e("html"),{"overflow-y":"hidden"}):b.doc[0].nodename=="html"&&b.css(e("body"),{"overflow-y":"hidden"}));f.isios&&!b.ispage&&!b.haswrapper&&b.css(e("body"),{"-webkit-overflow-scrolling":"touch"});var c=e(document.createelement("div"));c.css({position:"relative",top:0,"float":"right",width:b.opt.cursorwidth, height:"0px","background-color":b.opt.cursorcolor,border:b.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":b.opt.cursorborderradius,"-moz-border-radius":b.opt.cursorborderradius,"border-radius":b.opt.cursorborderradius});c.hborder=parsefloat(c.outerheight()-c.innerheight());b.cursor=c;var g=e(document.createelement("div"));g.attr("id",b.id);var h,i,j=["left","right"],y;for(y in j)i=j[y],(h=b.opt.railpadding[i])?g.css("padding-"+i,h+"px"):b.opt.railpadding[i]=0;g.append(c); g.width=math.max(parsefloat(b.opt.cursorwidth),c.outerwidth())+b.opt.railpadding.left+b.opt.railpadding.right;g.css({width:g.width+"px",zindex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});g.visibility=true;g.scrollable=true;g.align=b.opt.railalign=="left"?0:1;b.rail=g;c=b.rail.drag=false;if(b.opt.boxzoom&&!b.ispage&&!f.isieold&&(c=document.createelement("div"),b.bind(c,"click",b.dozoom),b.zoom=e(c),b.zoom.css({cursor:"pointer","z-index":b.opt.zindex,backgroundimage:"url("+d+ "zoomico.png)",height:18,width:18,backgroundposition:"0px 0px"}),b.opt.dblclickzoom&&b.bind(b.win,"dblclick",b.dozoom),f.cantouch&&b.opt.gesturezoom))b.ongesturezoom=function(d){d.scale>1.5&&b.dozoomin(d);d.scale<0.8&&b.dozoomout(d);return b.cancelevent(d)},b.bind(b.win,"gestureend",b.ongesturezoom);b.railh=false;if(b.opt.horizrailenabled){b.css(d,{"overflow-x":"hidden"});c=e(document.createelement("div"));c.css({position:"relative",top:0,height:b.opt.cursorwidth,width:"0px","background-color":b.opt.cursorcolor, border:b.opt.cursorborder,"background-clip":"padding-box","-webkit-border-radius":b.opt.cursorborderradius,"-moz-border-radius":b.opt.cursorborderradius,"border-radius":b.opt.cursorborderradius});c.wborder=parsefloat(c.outerwidth()-c.innerwidth());b.cursorh=c;var k=e(document.createelement("div"));k.attr("id",b.id+"-hr");k.height=1+math.max(parsefloat(b.opt.cursorwidth),c.outerheight());k.css({height:k.height+"px",zindex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});k.append(c); k.visibility=true;k.scrollable=true;k.align=b.opt.railvalign=="top"?0:1;b.railh=k;b.railh.drag=false}if(b.ispage)g.css({position:"fixed",top:"0px",height:"100%"}),g.align?g.css({right:"0px"}):g.css({left:"0px"}),b.body.append(g),b.railh&&(k.css({position:"fixed",left:"0px",width:"100%"}),k.align?k.css({bottom:"0px"}):k.css({top:"0px"}),b.body.append(k));else{if(b.ishwscroll)b.win.css("position")=="static"&&b.css(b.win,{position:"relative"}),d=b.win[0].nodename=="html"?b.body:b.win,b.zoom&&(b.zoom.css({position:"absolute", top:1,right:0,"margin-right":g.width+4}),d.append(b.zoom)),g.css({position:"absolute",top:0}),g.align?g.css({right:0}):g.css({left:0}),d.append(g),k&&(k.css({position:"absolute",left:0,bottom:0}),k.align?k.css({bottom:0}):k.css({top:0}),d.append(k));else{b.isfixed=b.win.css("position")=="fixed";d=b.isfixed?"fixed":"absolute";if(!b.isfixed)b.viewport=b.getviewport(b.win[0]);if(b.viewport)b.body=b.viewport;g.css({position:d});b.zoom&&b.zoom.css({position:d});b.updatescrollbar();b.body.append(g);b.zoom&& b.body.append(b.zoom);b.railh&&(k.css({position:d}),b.body.append(k))}f.isios&&b.css(b.win,{"-webkit-tap-highlight-color":"rgba(0,0,0,0)","-webkit-touch-callout":"none"});f.isie&&b.opt.disableoutline&&b.win.attr("hidefocus","true");f.iswebkit&&b.opt.disableoutline&&b.win.css({outline:"none"})}if(b.opt.autohidemode===false)b.autohidedom=false,b.rail.css({opacity:b.opt.cursoropacitymax}),b.railh&&b.railh.css({opacity:b.opt.cursoropacitymax});else if(b.opt.autohidemode===true){if(b.autohidedom=e().add(b.rail), b.railh)b.autohidedom=b.autohidedom.add(b.railh)}else if(b.opt.autohidemode=="scroll"){if(b.autohidedom=e().add(b.rail),b.railh)b.autohidedom=b.autohidedom.add(b.railh)}else if(b.opt.autohidemode=="cursor"){if(b.autohidedom=e().add(b.cursor),b.railh)b.autohidedom=b.autohidedom.add(b.railh.cursor)}else if(b.opt.autohidemode=="hidden")b.autohidedom=false,b.hide(),b.locked=false;if(f.isie9mobile)b.scrollmom=new z(b),b.onmangotouch=function(){var d=b.getscrolltop(),c=b.getscrollleft();if(d==b.scrollmom.lastscrolly&& c==b.scrollmom.lastscrollx)return true;var g=d-b.mangotouch.sy,l=c-b.mangotouch.sx;if(math.round(math.sqrt(math.pow(l,2)+math.pow(g,2)))!=0){var f=g<0?-1:1,e=l<0?-1:1,h=+new date;b.mangotouch.lazy&&cleartimeout(b.mangotouch.lazy);if(h-b.mangotouch.tm>80||b.mangotouch.dry!=f||b.mangotouch.drx!=e)b.scrollmom.stop(),b.scrollmom.reset(c,d),b.mangotouch.sy=d,b.mangotouch.ly=d,b.mangotouch.sx=c,b.mangotouch.lx=c,b.mangotouch.dry=f,b.mangotouch.drx=e,b.mangotouch.tm=h;else if(b.scrollmom.stop(),b.scrollmom.update(b.mangotouch.sx- l,b.mangotouch.sy-g),b.mangotouch.tm=h,g=math.max(math.abs(b.mangotouch.ly-d),math.abs(b.mangotouch.lx-c)),b.mangotouch.ly=d,b.mangotouch.lx=c,g>2)b.mangotouch.lazy=settimeout(function(){b.mangotouch.lazy=false;b.mangotouch.dry=0;b.mangotouch.drx=0;b.mangotouch.tm=0;b.scrollmom.domomentum(30)},100)}},g=b.getscrolltop(),k=b.getscrollleft(),b.mangotouch={sy:g,ly:g,dry:0,sx:k,lx:k,drx:0,lazy:false,tm:0},b.bind(b.docscroll,"scroll",b.onmangotouch);else{if(f.cantouch||b.istouchcapable||b.opt.touchbehavior|| f.hasmstouch){b.scrollmom=new z(b);b.ontouchstart=function(d){if(d.pointertype&&d.pointertype!=2)return false;if(!b.locked){if(f.hasmstouch)for(var c=d.target?d.target:false;c;){var g=e(c).getnicescroll();if(g.length>0&&g[0].me==b.me)break;if(g.length>0)return false;if(c.nodename=="div"&&c.id==b.id)break;c=c.parentnode?c.parentnode:false}b.cancelscroll();if((c=b.gettarget(d))&&/input/i.test(c.nodename)&&/range/i.test(c.type))return b.stoppropagation(d);if(!("clientx"in d)&&"changedtouches"in d)d.clientx= d.changedtouches[0].clientx,d.clienty=d.changedtouches[0].clienty;if(b.forcescreen)g=d,d={original:d.original?d.original:d},d.clientx=g.screenx,d.clienty=g.screeny;b.rail.drag={x:d.clientx,y:d.clienty,sx:b.scroll.x,sy:b.scroll.y,st:b.getscrolltop(),sl:b.getscrollleft(),pt:2};b.opt.touchbehavior&&b.isiframe&&f.isie&&(g=b.win.position(),b.rail.drag.x+=g.left,b.rail.drag.y+=g.top);b.hasmoving=false;b.lastmouseup=false;b.scrollmom.reset(d.clientx,d.clienty);if(!f.cantouch&&!this.istouchcapable&&!f.hasmstouch){if(!c|| !/input|select|textarea/i.test(c.nodename))return!b.ispage&&f.hasmousecapture&&c.setcapture(),b.cancelevent(d);if(/submit|cancel|button/i.test(e(c).attr("type")))pc={tg:c,click:false},b.preventclick=pc}}};b.ontouchend=function(d){if(d.pointertype&&d.pointertype!=2)return false;if(b.rail.drag&&b.rail.drag.pt==2&&(b.scrollmom.domomentum(),b.rail.drag=false,b.hasmoving&&(b.hasmoving=false,b.lastmouseup=true,b.hidecursor(),f.hasmousecapture&&document.releasecapture(),!f.cantouch)))return b.cancelevent(d)}; var n=b.opt.touchbehavior&&b.isiframe&&!f.hasmousecapture;b.ontouchmove=function(d,c){if(d.pointertype&&d.pointertype!=2)return false;if(b.rail.drag&&b.rail.drag.pt==2){if(f.cantouch&&typeof d.original=="undefined")return true;b.hasmoving=true;if(b.preventclick&&!b.preventclick.click)b.preventclick.click=b.preventclick.tg.onclick||false,b.preventclick.tg.onclick=b.onpreventclick;d=e.extend({original:d},d);if("changedtouches"in d)d.clientx=d.changedtouches[0].clientx,d.clienty=d.changedtouches[0].clienty; if(b.forcescreen){var g=d,d={original:d.original?d.original:d};d.clientx=g.screenx;d.clienty=g.screeny}g=ofy=0;if(n&&!c){var l=b.win.position(),g=-l.left;ofy=-l.top}var h=d.clienty+ofy,i=b.rail.drag.st-(h-b.rail.drag.y);if(b.ishwscroll&&b.opt.bouncescroll)i<0?i=math.round(i/2):i>b.page.maxh&&(i=b.page.maxh+math.round((i-b.page.maxh)/2));else if(i<0&&(h=i=0),i>b.page.maxh)i=b.page.maxh,h=0;var s=d.clientx+g;if(b.railh&&b.railh.scrollable){var j=b.rail.drag.sl-(s-b.rail.drag.x);if(b.ishwscroll&&b.opt.bouncescroll)j< 0?j=math.round(j/2):j>b.page.maxw&&(j=b.page.maxw+math.round((j-b.page.maxw)/2));else if(j<0&&(s=j=0),j>b.page.maxw)j=b.page.maxw,s=0}b.synched("touchmove",function(){b.rail.drag&&b.rail.drag.pt==2&&(b.preparetransition&&b.preparetransition(0),b.rail.scrollable&&b.setscrolltop(i),b.scrollmom.update(s,h),b.railh&&b.railh.scrollable?(b.setscrollleft(j),b.showcursor(i,j)):b.showcursor(i),f.isie10&&document.selection.clear())});if(!f.ischrome&&!b.istouchcapable)return b.cancelevent(d)}}}f.cantouch||b.opt.touchbehavior? (b.onpreventclick=function(d){if(b.preventclick)return b.preventclick.tg.onclick=b.preventclick.click,b.preventclick=false,b.cancelevent(d)},b.onmousedown=b.ontouchstart,b.onmouseup=b.ontouchend,b.onclick=f.isios?false:function(d){return b.lastmouseup?(b.lastmouseup=false,b.cancelevent(d)):true},b.onmousemove=b.ontouchmove,f.cursorgrabvalue&&(b.css(b.ispage?b.doc:b.win,{cursor:f.cursorgrabvalue}),b.css(b.rail,{cursor:f.cursorgrabvalue}))):(b.onmousedown=function(d,c){if(!(b.rail.drag&&b.rail.drag.pt!= 1)){if(b.locked)return b.cancelevent(d);b.cancelscroll();b.rail.drag={x:d.clientx,y:d.clienty,sx:b.scroll.x,sy:b.scroll.y,pt:1,hr:!!c};var g=b.gettarget(d);!b.ispage&&f.hasmousecapture&&g.setcapture();if(b.isiframe&&!f.hasmousecapture)b.saved.csspointerevents=b.doc.css("pointer-events"),b.css(b.doc,{"pointer-events":"none"});return b.cancelevent(d)}},b.onmouseup=function(d){if(b.rail.drag&&(f.hasmousecapture&&document.releasecapture(),b.isiframe&&!f.hasmousecapture&&b.doc.css("pointer-events",b.saved.csspointerevents), b.rail.drag.pt==1))return b.rail.drag=false,b.cancelevent(d)},b.onmousemove=function(d){if(b.rail.drag){if(b.rail.drag.pt==1){if(f.ischrome&&d.which==0)return b.onmouseup(d);b.cursorfreezed=true;if(b.rail.drag.hr){b.scroll.x=b.rail.drag.sx+(d.clientx-b.rail.drag.x);if(b.scroll.x<0)b.scroll.x=0;var c=b.scrollvaluemaxw;if(b.scroll.x>c)b.scroll.x=c}else{b.scroll.y=b.rail.drag.sy+(d.clienty-b.rail.drag.y);if(b.scroll.y<0)b.scroll.y=0;c=b.scrollvaluemax;if(b.scroll.y>c)b.scroll.y=c}b.synched("mousemove", function(){b.rail.drag&&b.rail.drag.pt==1&&(b.showcursor(),b.rail.drag.hr?b.doscrollleft(math.round(b.scroll.x*b.scrollratio.x)):b.doscrolltop(math.round(b.scroll.y*b.scrollratio.y)))});return b.cancelevent(d)}}else b.checkarea=true});(f.cantouch||b.opt.touchbehavior)&&b.bind(b.win,"mousedown",b.onmousedown);f.hasmstouch&&(b.css(b.rail,{"-ms-touch-action":"none"}),b.css(b.cursor,{"-ms-touch-action":"none"}),b.bind(b.win,"mspointerdown",b.ontouchstart),b.bind(document,"mspointerup",b.ontouchend),b.bind(document, "mspointermove",b.ontouchmove),b.bind(b.cursor,"msgesturehold",function(b){b.preventdefault()}),b.bind(b.cursor,"contextmenu",function(b){b.preventdefault()}));this.istouchcapable&&(b.bind(b.win,"touchstart",b.ontouchstart),b.bind(document,"touchend",b.ontouchend),b.bind(document,"touchcancel",b.ontouchend),b.bind(document,"touchmove",b.ontouchmove));b.bind(b.cursor,"mousedown",b.onmousedown);b.bind(b.cursor,"mouseup",b.onmouseup);b.railh&&(b.bind(b.cursorh,"mousedown",function(d){b.onmousedown(d, true)}),b.bind(b.cursorh,"mouseup",function(d){if(!(b.rail.drag&&b.rail.drag.pt==2))return b.rail.drag=false,b.hasmoving=false,b.hidecursor(),f.hasmousecapture&&document.releasecapture(),b.cancelevent(d)}));b.bind(document,"mouseup",b.onmouseup);f.hasmousecapture&&b.bind(b.win,"mouseup",b.onmouseup);b.bind(document,"mousemove",b.onmousemove);b.onclick&&b.bind(document,"click",b.onclick);!f.cantouch&&!b.opt.touchbehavior&&(b.jqbind(b.rail,"mouseenter",function(){b.canshowonmouseevent&&b.showcursor(); b.rail.active=true}),b.jqbind(b.rail,"mouseleave",function(){b.rail.active=false;b.rail.drag||b.hidecursor()}),b.opt.sensitiverail&&(b.bind(b.rail,"click",function(d){b.dorailclick(d,false,false)}),b.bind(b.rail,"dblclick",function(d){b.dorailclick(d,true,false)}),b.bind(b.cursor,"click",function(d){b.cancelevent(d)}),b.bind(b.cursor,"dblclick",function(d){b.cancelevent(d)})),b.railh&&(b.jqbind(b.railh,"mouseenter",function(){b.canshowonmouseevent&&b.showcursor();b.rail.active=true}),b.jqbind(b.railh, "mouseleave",function(){b.rail.active=false;b.rail.drag||b.hidecursor()}),b.opt.sensitiverail&&(b.bind(b.railh,"click",function(d){b.dorailclick(d,false,true)}),b.bind(b.railh,"dblclick",function(d){b.dorailclick(d,true,true)}),b.bind(b.cursorh,"click",function(d){b.cancelevent(d)}),b.bind(b.cursorh,"dblclick",function(d){b.cancelevent(d)}))),b.zoom&&(b.jqbind(b.zoom,"mouseenter",function(){b.canshowonmouseevent&&b.showcursor();b.rail.active=true}),b.jqbind(b.zoom,"mouseleave",function(){b.rail.active= false;b.rail.drag||b.hidecursor()})));b.opt.enablemousewheel&&(b.isiframe||b.bind(f.isie&&b.ispage?document:b.docscroll,"mousewheel",b.onmousewheel),b.bind(b.rail,"mousewheel",b.onmousewheel),b.railh&&b.bind(b.railh,"mousewheel",b.onmousewheelhr));!b.ispage&&!f.cantouch&&!/html|body/.test(b.win[0].nodename)&&(b.win.attr("tabindex")||b.win.attr({tabindex:b++}),b.jqbind(b.win,"focus",function(d){r=b.gettarget(d).id||true;b.hasfocus=true;b.canshowonmouseevent&&b.noticecursor()}),b.jqbind(b.win,"blur", function(){r=false;b.hasfocus=false}),b.jqbind(b.win,"mouseenter",function(d){w=b.gettarget(d).id||true;b.hasmousefocus=true;b.canshowonmouseevent&&b.noticecursor()}),b.jqbind(b.win,"mouseleave",function(){w=false;b.hasmousefocus=false}))}b.onkeypress=function(d){if(b.locked&&b.page.maxh==0)return true;var d=d?d:window.e,c=b.gettarget(d);if(c&&/input|textarea|select|option/.test(c.nodename)&&(!c.getattribute("type")&&!c.type||!/submit|button|cancel/i.tp))return true;if(b.hasfocus||b.hasmousefocus&& !r||b.ispage&&!r&&!w){c=d.keycode;if(b.locked&&c!=27)return b.cancelevent(d);var g=d.ctrlkey||false,l=d.shiftkey||false,f=false;switch(c){case 38:case 63233:b.doscrollby(72);f=true;break;case 40:case 63235:b.doscrollby(-72);f=true;break;case 37:case 63232:b.railh&&(g?b.doscrollleft(0):b.doscrollleftby(72),f=true);break;case 39:case 63234:b.railh&&(g?b.doscrollleft(b.page.maxw):b.doscrollleftby(-72),f=true);break;case 33:case 63276:b.doscrollby(b.view.h);f=true;break;case 34:case 63277:b.doscrollby(-b.view.h); f=true;break;case 36:case 63273:b.railh&&g?b.doscrollpos(0,0):b.doscrollto(0);f=true;break;case 35:case 63275:b.railh&&g?b.doscrollpos(b.page.maxw,b.page.maxh):b.doscrollto(b.page.maxh);f=true;break;case 32:b.opt.spacebarenabled&&(l?b.doscrollby(b.view.h):b.doscrollby(-b.view.h),f=true);break;case 27:b.zoomactive&&(b.dozoom(),f=true)}if(f)return b.cancelevent(d)}};b.opt.enablekeyboard&&b.bind(document,f.isopera&&!f.isopera12?"keypress":"keydown",b.onkeypress);b.bind(window,"resize",b.resize);b.bind(window, "orientationchange",b.resize);b.bind(window,"load",b.resize);if(f.ischrome&&!b.ispage&&!b.haswrapper){var m=b.win.attr("style"),g=parsefloat(b.win.css("width"))+1;b.win.css("width",g);b.synched("chromefix",function(){b.win.attr("style",m)})}b.onattributechange=function(){b.lazyresize()};if(!b.ispage&&!b.haswrapper)"webkitmutationobserver"in window?(b.observer=new webkitmutationobserver(function(d){d.foreach(b.onattributechange)}),b.observer.observe(b.win[0],{attributes:true,subtree:false})):(b.bind(b.win, f.isie&&!f.isie9?"propertychange":"domattrmodified",b.onattributechange),f.isie9&&b.win[0].attachevent("onpropertychange",b.onattributechange));!b.ispage&&b.opt.boxzoom&&b.bind(window,"resize",b.resizezoom);b.istextarea&&b.bind(b.win,"mouseup",b.resize);b.resize()}if(this.doc[0].nodename=="iframe"){var a=function(){b.iframexd=false;try{var d="contentdocument"in this?this.contentdocument:this.contentwindow.document}catch(c){b.iframexd=true,d=false}if(b.iframexd)return"console"in window&&console.log("nicescroll error: policy restriced iframe"), true;b.forcescreen=true;if(b.isiframe)b.iframe={doc:e(d),html:b.doc.contents().find("html")[0],body:b.doc.contents().find("body")[0]},b.getcontentsize=function(){return{w:math.max(b.iframe.html.scrollwidth,b.iframe.body.scrollwidth),h:math.max(b.iframe.html.scrollheight,b.iframe.body.scrollheight)}},b.docscroll=e(b.iframe.body);if(!f.isios&&b.opt.iframeautoresize&&!b.isiframe){b.win.scrolltop(0);b.doc.height("");var g=math.max(d.getelementsbytagname("html")[0].scrollheight,d.body.scrollheight);b.doc.height(g)}b.resize(); f.isie7&&b.css(e(b.iframe.html),{"overflow-y":"hidden"});b.css(e(b.iframe.body),{"overflow-y":"hidden"});"contentwindow"in this?b.bind(this.contentwindow,"scroll",b.onscroll):b.bind(d,"scroll",b.onscroll);b.opt.enablemousewheel&&b.bind(d,"mousewheel",b.onmousewheel);b.opt.enablekeyboard&&b.bind(d,f.isopera?"keypress":"keydown",b.onkeypress);if(f.cantouch||b.opt.touchbehavior)b.bind(d,"mousedown",b.onmousedown),b.bind(d,"mousemove",function(d){b.onmousemove(d,true)}),f.cursorgrabvalue&&b.css(e(d.body), {cursor:f.cursorgrabvalue});b.bind(d,"mouseup",b.onmouseup);b.zoom&&(b.opt.dblclickzoom&&b.bind(d,"dblclick",b.dozoom),b.ongesturezoom&&b.bind(d,"gestureend",b.ongesturezoom))};this.doc[0].readystate&&this.doc[0].readystate=="complete"&&settimeout(function(){a.call(b.doc[0],false)},500);b.bind(this.doc,"load",a)}};this.showcursor=function(d,c){if(b.cursortimeout)cleartimeout(b.cursortimeout),b.cursortimeout=0;if(b.rail){if(b.autohidedom)b.autohidedom.stop().css({opacity:b.opt.cursoropacitymax}),b.cursoractive= true;if(typeof d!="undefined"&&d!==false)b.scroll.y=math.round(d*1/b.scrollratio.y);if(typeof c!="undefined")b.scroll.x=math.round(c*1/b.scrollratio.x);b.cursor.css({height:b.cursorheight,top:b.scroll.y});if(b.cursorh)!b.rail.align&&b.rail.visibility?b.cursorh.css({width:b.cursorwidth,left:b.scroll.x+b.rail.width}):b.cursorh.css({width:b.cursorwidth,left:b.scroll.x}),b.cursoractive=true;b.zoom&&b.zoom.stop().css({opacity:b.opt.cursoropacitymax})}};this.hidecursor=function(d){if(!b.cursortimeout&& b.rail&&b.autohidedom)b.cursortimeout=settimeout(function(){if(!b.rail.active||!b.showonmouseevent)b.autohidedom.stop().animate({opacity:b.opt.cursoropacitymin}),b.zoom&&b.zoom.stop().animate({opacity:b.opt.cursoropacitymin}),b.cursoractive=false;b.cursortimeout=0},d||400)};this.noticecursor=function(d,c,g){b.showcursor(c,g);b.rail.active||b.hidecursor(d)};this.getcontentsize=b.ispage?function(){return{w:math.max(document.body.scrollwidth,document.documentelement.scrollwidth),h:math.max(document.body.scrollheight, document.documentelement.scrollheight)}}:b.haswrapper?function(){return{w:b.doc.outerwidth()+parseint(b.win.css("paddingleft"))+parseint(b.win.css("paddingright")),h:b.doc.outerheight()+parseint(b.win.css("paddingtop"))+parseint(b.win.css("paddingbottom"))}}:function(){return{w:b.docscroll[0].scrollwidth,h:b.docscroll[0].scrollheight}};this.onresize=function(d,c){if(!b.win)return false;if(!b.haswrapper&&!b.ispage)if(b.win.css("display")=="none")return b.visibility&&b.hiderail().hiderailhr(),false; else!b.hidden&&!b.visibility&&b.showrail().showrailhr();var g=b.page.maxh,f=b.page.maxw,e=b.view.w;b.view={w:b.ispage?b.win.width():parseint(b.win[0].clientwidth),h:b.ispage?b.win.height():parseint(b.win[0].clientheight)};b.page=c?c:b.getcontentsize();b.page.maxh=math.max(0,b.page.h-b.view.h);b.page.maxw=math.max(0,b.page.w-b.view.w);if(b.page.maxh==g&&b.page.maxw==f&&b.view.w==e)if(b.ispage)return b;else{g=b.win.offset();if(b.lastposition&&(f=b.lastposition,f.top==g.top&&f.left==g.left))return b; b.lastposition=g}b.page.maxh==0?(b.hiderail(),b.scrollvaluemax=0,b.scroll.y=0,b.scrollratio.y=0,b.cursorheight=0,b.setscrolltop(0),b.rail.scrollable=false):b.rail.scrollable=true;b.page.maxw==0?(b.hiderailhr(),b.scrollvaluemaxw=0,b.scroll.x=0,b.scrollratio.x=0,b.cursorwidth=0,b.setscrollleft(0),b.railh.scrollable=false):b.railh.scrollable=true;b.locked=b.page.maxh==0&&b.page.maxw==0;if(b.locked)return b.ispage||b.updatescrollbar(b.view),false;!b.hidden&&!b.visibility?b.showrail().showrailhr():!b.hidden&& !b.railh.visibility&&b.showrailhr();b.istextarea&&b.win.css("resize")&&b.win.css("resize")!="none"&&(b.view.h-=20);b.ispage||b.updatescrollbar(b.view);b.cursorheight=math.min(b.view.h,math.round(b.view.h*(b.view.h/b.page.h)));b.cursorheight=b.opt.cursorfixedheight?b.opt.cursorfixedheight:math.max(b.opt.cursorminheight,b.cursorheight);b.cursorwidth=math.min(b.view.w,math.round(b.view.w*(b.view.w/b.page.w)));b.cursorwidth=b.opt.cursorfixedheight?b.opt.cursorfixedheight:math.max(b.opt.cursorminheight, b.cursorwidth);b.scrollvaluemax=b.view.h-b.cursorheight-b.cursor.hborder;if(b.railh)b.railh.width=b.page.maxh>0?b.view.w-b.rail.width:b.view.w,b.scrollvaluemaxw=b.railh.width-b.cursorwidth-b.cursorh.wborder;b.scrollratio={x:b.page.maxw/b.scrollvaluemaxw,y:b.page.maxh/b.scrollvaluemax};b.getscrolltop()>b.page.maxh?b.doscrolltop(b.page.maxh):(b.scroll.y=math.round(b.getscrolltop()*(1/b.scrollratio.y)),b.scroll.x=math.round(b.getscrollleft()*(1/b.scrollratio.x)),b.cursoractive&&b.noticecursor());b.scroll.y&& b.getscrolltop()==0&&b.doscrollto(math.floor(b.scroll.y*b.scrollratio.y));return b};this.resize=function(){b.delayed("resize",b.onresize,30);return b};this.lazyresize=function(){b.delayed("resize",b.resize,250)};this._bind=function(d,c,g,f){b.events.push({e:d,n:c,f:g,b:f,q:false});d.addeventlistener?d.addeventlistener(c,g,f||false):d.attachevent?d.attachevent("on"+c,g):d["on"+c]=g};this.jqbind=function(d,c,g){b.events.push({e:d,n:c,f:g,q:true});e(d).bind(c,g)};this.bind=function(d,c,g,e){var h="jquery"in d?d[0]:d;h.addeventlistener?(f.cantouch&&/mouseup|mousedown|mousemove/.test(c)&&b._bind(h,c=="mousedown"?"touchstart":c=="mouseup"?"touchend":"touchmove",function(b){if(b.touches){if(b.touches.length<2){var d=b.touches.length?b.touches[0]:b;d.original=b;g.call(this,d)}}else if(b.changedtouches)d=b.changedtouches[0],d.original=b,g.call(this,d)},e||false),b._bind(h,c,g,e||false),c=="mousewheel"&&b._bind(h,"dommousescroll",g,e||false),f.cantouch&&c=="mouseup"&&b._bind(h,"touchcancel",g,e||false)):b._bind(h, c,function(d){if((d=d||window.event||false)&&d.srcelement)d.target=d.srcelement;return g.call(h,d)===false||e===false?b.cancelevent(d):true})};this._unbind=function(b,c,g,f){b.removeeventlistener?b.removeeventlistener(c,g,f):b.detachevent?b.detachevent("on"+c,g):b["on"+c]=false};this.unbindall=function(){for(var d=0;d0)return c;b=b.parentnode?b.parentnode:false}return false};this.onmousewheel=function(d){if(b.locked)return true;if(!b.rail.scrollable)return b.railh&&b.railh.scrollable?b.onmousewheelhr(d):true;if(b.opt.preservenativescrolling&&b.checkarea)b.checkarea=false,b.nativescrollingarea=b.isscrollable(d);if(b.nativescrollingarea)return true;if(b.locked)return b.cancelevent(d);if(b.rail.drag)return b.cancelevent(d);i(d,false);return b.cancelevent(d)};this.onmousewheelhr= function(d){if(b.locked||!b.railh.scrollable)return true;if(b.opt.preservenativescrolling&&b.checkarea)b.checkarea=false,b.nativescrollingarea=b.isscrollable(d);if(b.nativescrollingarea)return true;if(b.locked)return b.cancelevent(d);if(b.rail.drag)return b.cancelevent(d);i(d,true);return b.cancelevent(d)};this.stop=function(){b.cancelscroll();b.scrollmon&&b.scrollmon.stop();b.cursorfreezed=false;b.scroll.y=math.round(b.getscrolltop()*(1/b.scrollratio.y));b.noticecursor();return b};this.gettransitionspeed= function(d){var c=math.round(b.opt.scrollspeed*10),d=math.min(c,math.round(d/20*b.opt.scrollspeed));return d>20?d:0};b.opt.smoothscroll?b.ishwscroll&&f.hastransition&&b.opt.usetransition?(this.preparetransition=function(d,c){var g=c?d>20?d:0:b.gettransitionspeed(d),e=g?f.prefixstyle+"transform "+g+"ms ease-out":"";if(!b.lasttransitionstyle||b.lasttransitionstyle!=e)b.lasttransitionstyle=e,b.doc.css(f.transitionstyle,e);return g},this.doscrollleft=function(d,c){var g=b.scrollrunning?b.newscrolly:b.getscrolltop(); b.doscrollpos(d,g,c)},this.doscrolltop=function(c,f){var g=b.scrollrunning?b.newscrollx:b.getscrollleft();b.doscrollpos(g,c,f)},this.doscrollpos=function(c,e,g){var h=b.getscrolltop(),i=b.getscrollleft();((b.newscrolly-h)*(e-h)<0||(b.newscrollx-i)*(c-i)<0)&&b.cancelscroll();if(b.opt.bouncescroll==false){if(e<0)e=0;else if(e>b.page.maxh)e=b.page.maxh;if(c<0)c=0;else if(c>b.page.maxw)c=b.page.maxw}if(c==b.newscrollx&&e==b.newscrolly)return false;b.newscrolly=e;b.newscrollx=c;b.newscrollspeed=g||false; if(b.timer)return false;b.timer=settimeout(function(){var g=b.getscrolltop(),h=b.getscrollleft(),i,j;i=c-h;j=e-g;i=math.round(math.sqrt(math.pow(i,2)+math.pow(j,2)));i=b.preparetransition(b.newscrollspeed?b.newscrollspeed:i);b.timerscroll&&b.timerscroll.tm&&clearinterval(b.timerscroll.tm);if(i>0){!b.scrollrunning&&b.onscrollstart&&b.onscrollstart.call(b,{type:"scrollstart",current:{x:h,y:g},request:{x:c,y:e},end:{x:b.newscrollx,y:b.newscrolly},speed:i});if(f.transitionend){if(!b.scrollendtrapped)b.scrollendtrapped= true,b.bind(b.doc,f.transitionend,b.onscrollend,false)}else b.scrollendtrapped&&cleartimeout(b.scrollendtrapped),b.scrollendtrapped=settimeout(b.onscrollend,i);b.timerscroll={bz:new bezierclass(g,b.newscrolly,i,0,0,0.58,1),bh:new bezierclass(h,b.newscrollx,i,0,0,0.58,1)};if(!b.cursorfreezed)b.timerscroll.tm=setinterval(function(){b.showcursor(b.getscrolltop(),b.getscrollleft())},60)}b.synched("doscroll-set",function(){b.timer=0;if(b.scrollendtrapped)b.scrollrunning=true;b.setscrolltop(b.newscrolly); b.setscrollleft(b.newscrollx);if(!b.scrollendtrapped)b.onscrollend()})},50)},this.cancelscroll=function(){if(!b.scrollendtrapped)return true;var c=b.getscrolltop(),e=b.getscrollleft();b.scrollrunning=false;f.transitionend||cleartimeout(f.transitionend);b.scrollendtrapped=false;b._unbind(b.doc,f.transitionend,b.onscrollend);b.preparetransition(0);b.setscrolltop(c);b.railh&&b.setscrollleft(e);b.timerscroll&&b.timerscroll.tm&&clearinterval(b.timerscroll.tm);b.timerscroll=false;b.cursorfreezed=false; b.showcursor(c,e);return b},this.onscrollend=function(){b.scrollendtrapped&&b._unbind(b.doc,f.transitionend,b.onscrollend);b.scrollendtrapped=false;b.preparetransition(0);b.timerscroll&&b.timerscroll.tm&&clearinterval(b.timerscroll.tm);b.timerscroll=false;var c=b.getscrolltop(),e=b.getscrollleft();b.setscrolltop(c);b.railh&&b.setscrollleft(e);b.noticecursor(false,c,e);b.cursorfreezed=false;if(c<0)c=0;else if(c>b.page.maxh)c=b.page.maxh;if(e<0)e=0;else if(e>b.page.maxw)e=b.page.maxw;if(c!=b.newscrolly|| e!=b.newscrollx)return b.doscrollpos(e,c,b.opt.snapbackspeed);b.onscrollend&&b.scrollrunning&&b.onscrollend.call(b,{type:"scrollend",current:{x:e,y:c},end:{x:b.newscrollx,y:b.newscrolly}});b.scrollrunning=false}):(this.doscrollleft=function(c){var f=b.scrollrunning?b.newscrolly:b.getscrolltop();b.doscrollpos(c,f)},this.doscrolltop=function(c){var f=b.scrollrunning?b.newscrollx:b.getscrollleft();b.doscrollpos(f,c)},this.doscrollpos=function(c,f){function g(){if(b.cancelanimationframe)return true;b.scrollrunning= true;if(n=1-n)return b.timer=p(g)||1;var c=0,d=sy=b.getscrolltop();if(b.dst.ay){var d=b.bzscroll?b.dst.py+b.bzscroll.getnow()*b.dst.ay:b.newscrolly,f=d-sy;if(f<0&&d0&&d>b.newscrolly)d=b.newscrolly;b.setscrolltop(d);d==b.newscrolly&&(c=1)}else c=1;var e=sx=b.getscrollleft();if(b.dst.ax){e=b.bzscroll?b.dst.px+b.bzscroll.getnow()*b.dst.ax:b.newscrollx;f=e-sx;if(f<0&&e0&&e>b.newscrollx)e=b.newscrollx;b.setscrollleft(e);e==b.newscrollx&&(c+=1)}else c+=1;if(c==2){b.timer= 0;b.cursorfreezed=false;b.bzscroll=false;b.scrollrunning=false;if(d<0)d=0;else if(d>b.page.maxh)d=b.page.maxh;if(e<0)e=0;else if(e>b.page.maxw)e=b.page.maxw;e!=b.newscrollx||d!=b.newscrolly?b.doscrollpos(e,d):b.onscrollend&&b.onscrollend.call(b,{type:"scrollend",current:{x:sx,y:sy},end:{x:b.newscrollx,y:b.newscrolly}})}else b.timer=p(g)||1}f=typeof f=="undefined"||f===false?b.getscrolltop(true):f;if(b.timer&&b.newscrolly==f&&b.newscrollx==c)return true;b.timer&&q(b.timer);b.timer=0;var e=b.getscrolltop(), h=b.getscrollleft();((b.newscrolly-e)*(f-e)<0||(b.newscrollx-h)*(c-h)<0)&&b.cancelscroll();b.newscrolly=f;b.newscrollx=c;if(!b.bouncescroll||!b.rail.visibility)if(b.newscrolly<0)b.newscrolly=0;else if(b.newscrolly>b.page.maxh)b.newscrolly=b.page.maxh;if(!b.bouncescroll||!b.railh.visibility)if(b.newscrollx<0)b.newscrollx=0;else if(b.newscrollx>b.page.maxw)b.newscrollx=b.page.maxw;b.dst={};b.dst.x=c-h;b.dst.y=f-e;b.dst.px=h;b.dst.py=e;var i=math.round(math.sqrt(math.pow(b.dst.x,2)+math.pow(b.dst.y, 2)));b.dst.ax=b.dst.x/i;b.dst.ay=b.dst.y/i;var j=0,k=i;if(b.dst.x==0)j=e,k=f,b.dst.ay=1,b.dst.py=0;else if(b.dst.y==0)j=h,k=c,b.dst.ax=1,b.dst.px=0;i=b.gettransitionspeed(i);b.bzscroll=i>0?b.bzscroll?b.bzscroll.update(k,i):new bezierclass(j,k,i,0,1,0,1):false;if(!b.timer){(e==b.page.maxh&&f>=b.page.maxh||h==b.page.maxw&&c>=b.page.maxw)&&b.checkcontentsize();var n=1;b.cancelanimationframe=false;b.timer=1;b.onscrollstart&&!b.scrollrunning&&b.onscrollstart.call(b,{type:"scrollstart",current:{x:h,y:e}, request:{x:c,y:f},end:{x:b.newscrollx,y:b.newscrolly},speed:i});g();(e==b.page.maxh&&f>=e||h==b.page.maxw&&c>=h)&&b.checkcontentsize();b.noticecursor()}},this.cancelscroll=function(){b.timer&&q(b.timer);b.timer=0;b.bzscroll=false;b.scrollrunning=false;return b}):(this.doscrollleft=function(c,f){var g=b.getscrolltop();b.doscrollpos(c,g,f)},this.doscrolltop=function(c,f){var g=b.getscrollleft();b.doscrollpos(g,c,f)},this.doscrollpos=function(c,f){var g=c>b.page.maxw?b.page.maxw:c;g<0&&(g=0);var e=f> b.page.maxh?b.page.maxh:f;e<0&&(e=0);b.synched("scroll",function(){b.setscrolltop(e);b.setscrollleft(g)})},this.cancelscroll=function(){});this.doscrollby=function(c,f){var g=0,g=f?math.floor((b.scroll.y-c)*b.scrollratio.y):(b.timer?b.newscrolly:b.getscrolltop(true))-c;if(b.bouncescroll){var e=math.round(b.view.h/2);g<-e?g=-e:g>b.page.maxh+e&&(g=b.page.maxh+e)}b.cursorfreezed=false;py=b.getscrolltop(true);if(g<0&&py<=0)return b.noticecursor();else if(g>b.page.maxh&&py>=b.page.maxh)return b.checkcontentsize(), b.noticecursor();b.doscrolltop(g)};this.doscrollleftby=function(c,f){var e=0,e=f?math.floor((b.scroll.x-c)*b.scrollratio.x):(b.timer?b.newscrollx:b.getscrollleft(true))-c;if(b.bouncescroll){var h=math.round(b.view.w/2);e<-h?e=-h:e>b.page.maxw+h&&(e=b.page.maxw+h)}b.cursorfreezed=false;px=b.getscrollleft(true);if(e<0&&px<=0)return b.noticecursor();else if(e>b.page.maxw&&px>=b.page.maxw)return b.noticecursor();b.doscrollleft(e)};this.doscrollto=function(c,e){e&&math.round(c*b.scrollratio.y);b.cursorfreezed= false;b.doscrolltop(c)};this.checkcontentsize=function(){var c=b.getcontentsize();(c.h!=b.page.h||c.w!=b.page.w)&&b.resize(false,c)};b.onscroll=function(){b.rail.drag||b.cursorfreezed||b.synched("scroll",function(){b.scroll.y=math.round(b.getscrolltop()*(1/b.scrollratio.y));if(b.railh)b.scroll.x=math.round(b.getscrollleft()*(1/b.scrollratio.x));b.noticecursor()})};b.bind(b.docscroll,"scroll",b.onscroll);this.dozoomin=function(c){if(!b.zoomactive){b.zoomactive=true;b.zoomrestore={style:{}};var h="position,top,left,zindex,backgroundcolor,margintop,marginbottom,marginleft,marginright".split(","), g=b.win[0].style,i;for(i in h){var j=h[i];b.zoomrestore.style[j]=typeof g[j]!="undefined"?g[j]:""}b.zoomrestore.style.width=b.win.css("width");b.zoomrestore.style.height=b.win.css("height");b.zoomrestore.padding={w:b.win.outerwidth()-b.win.width(),h:b.win.outerheight()-b.win.height()};if(f.isios4)b.zoomrestore.scrolltop=e(window).scrolltop(),e(window).scrolltop(0);b.win.css({position:f.isios4?"absolute":"fixed",top:0,left:0,"z-index":b.opt.zindex+100,margin:"0px"});h=b.win.css("backgroundcolor"); (h==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(h))&&b.win.css("backgroundcolor","#fff");b.rail.css({"z-index":b.opt.zindex+110});b.zoom.css({"z-index":b.opt.zindex+112});b.zoom.css("backgroundposition","0px -18px");b.resizezoom();b.onzoomin&&b.onzoomin.call(b);return b.cancelevent(c)}};this.dozoomout=function(c){if(b.zoomactive)return b.zoomactive=false,b.win.css("margin",""),b.win.css(b.zoomrestore.style),f.isios4&&e(window).scrolltop(b.zoomrestore.scrolltop),b.rail.css({"z-index":b.ispage? b.opt.zindex:b.opt.zindex+2}),b.zoom.css({"z-index":b.opt.zindex}),b.zoomrestore=false,b.zoom.css("backgroundposition","0px 0px"),b.onresize(),b.onzoomout&&b.onzoomout.call(b),b.cancelevent(c)};this.dozoom=function(c){return b.zoomactive?b.dozoomout(c):b.dozoomin(c)};this.resizezoom=function(){if(b.zoomactive){var c=b.getscrolltop();b.win.css({width:e(window).width()-b.zoomrestore.padding.w+"px",height:e(window).height()-b.zoomrestore.padding.h+"px"});b.onresize();console.log(c);b.setscrolltop(math.min(b.page.maxh, c))}};this.init();e.nicescroll.push(this)},z=function(e){var c=this;this.nc=e;this.steptime=this.lasttime=this.speedy=this.speedx=this.lasty=this.lastx=0;this.snapy=this.snapx=false;this.demuly=this.demulx=0;this.lastscrolly=this.lastscrollx=-1;this.timer=this.chky=this.chkx=0;this.time=function(){return+new date};this.reset=function(e,i){c.stop();var b=c.time();c.steptime=0;c.lasttime=b;c.speedx=0;c.speedy=0;c.lastx=e;c.lasty=i;c.lastscrollx=-1;c.lastscrolly=-1};this.update=function(e,i){var b=c.time(); c.steptime=b-c.lasttime;c.lasttime=b;var b=i-c.lasty,j=e-c.lastx,f=c.nc.getscrolltop(),m=c.nc.getscrollleft();f+=b;m+=j;c.snapx=m<0||m>c.nc.page.maxw;c.snapy=f<0||f>c.nc.page.maxh;c.speedx=j;c.speedy=b;c.lastx=e;c.lasty=i};this.stop=function(){c.nc.unsynched("domomentum2d");c.timer&&cleartimeout(c.timer);c.timer=0;c.lastscrollx=-1;c.lastscrolly=-1};this.dosnapy=function(e,i){var b=false;if(i<0)i=0,b=true;else if(i>c.nc.page.maxh)i=c.nc.page.maxh,b=true;if(e<0)e=0,b=true;else if(e>c.nc.page.maxw)e= c.nc.page.maxw,b=true;b&&c.nc.doscrollpos(e,i,c.nc.opt.snapbackspeed)};this.domomentum=function(e){var i=c.time(),b=e?i+e:c.lasttime,e=c.nc.getscrollleft(),j=c.nc.getscrolltop(),f=c.nc.page.maxh,m=c.nc.page.maxw;c.speedx=m>0?math.min(60,c.speedx):0;c.speedy=f>0?math.min(60,c.speedy):0;b=b&&i-b<=50;if(j<0||j>f||e<0||e>m)b=false;e=c.speedx&&b?c.speedx:false;if(c.speedy&&b&&c.speedy||e){var o=math.max(16,c.steptime);o>50&&(e=o/50,c.speedx*=e,c.speedy*=e,o=50);c.demulxy=0;c.lastscrollx=c.nc.getscrollleft(); c.chkx=c.lastscrollx;c.lastscrolly=c.nc.getscrolltop();c.chky=c.lastscrolly;var d=c.lastscrollx,l=c.lastscrolly,g=function(){var b=c.time()-i>600?0.04:0.02;if(c.speedx&&(d=math.floor(c.lastscrollx-c.speedx*(1-c.demulxy)),c.lastscrollx=d,d<0||d>m))b=0.1;if(c.speedy&&(l=math.floor(c.lastscrolly-c.speedy*(1-c.demulxy)),c.lastscrolly=l,l<0||l>f))b=0.1;c.demulxy=math.min(1,c.demulxy+b);c.nc.synched("domomentum2d",function(){if(c.speedx)c.nc.getscrollleft()!=c.chkx&&c.stop(),c.chkx=d,c.nc.setscrollleft(d); if(c.speedy)c.nc.getscrolltop()!=c.chky&&c.stop(),c.chky=l,c.nc.setscrolltop(l);c.timer||(c.nc.hidecursor(),c.dosnapy(d,l))});c.demulxy<1?c.timer=settimeout(g,o):(c.stop(),c.nc.hidecursor(),c.dosnapy(d,l))};g()}else c.dosnapy(c.nc.getscrollleft(),c.nc.getscrolltop())}},t=e.fn.scrolltop;e.csshooks.pageyoffset={get:function(j){var c=e.data(j,"__nicescroll")||false;return c&&c.ishwscroll?c.getscrolltop():t.call(j)},set:function(j,c){var h=e.data(j,"__nicescroll")||false;h&&h.ishwscroll?h.setscrolltop(parseint(c)): t.call(j,c);return this}};e.fn.scrolltop=function(j){if(typeof j=="undefined"){var c=this[0]?e.data(this[0],"__nicescroll")||false:false;return c&&c.ishwscroll?c.getscrolltop():t.call(this)}else return this.each(function(){var c=e.data(this,"__nicescroll")||false;c&&c.ishwscroll?c.setscrolltop(parseint(j)):t.call(e(this),j)})};var u=e.fn.scrollleft;e.csshooks.pagexoffset={get:function(j){var c=e.data(j,"__nicescroll")||false;return c&&c.ishwscroll?c.getscrollleft():u.call(j)},set:function(j,c){var h= e.data(j,"__nicescroll")||false;h&&h.ishwscroll?h.setscrollleft(parseint(c)):u.call(j,c);return this}};e.fn.scrollleft=function(j){if(typeof j=="undefined"){var c=this[0]?e.data(this[0],"__nicescroll")||false:false;return c&&c.ishwscroll?c.getscrollleft():u.call(this)}else return this.each(function(){var c=e.data(this,"__nicescroll")||false;c&&c.ishwscroll?c.setscrollleft(parseint(j)):u.call(e(this),j)})};var v=function(j){var c=this;this.length=0;this.name="nicescrollarray";this.each=function(e){for(var b= 0;b