瀏覽代碼

2.3.0

scrollbar will hide when div has hidden
requestAnimationFrame
event fix for IE
Inuyaksa 13 年之前
父節點
當前提交
f10ab1707f
共有 7 個文件被更改,包括 371 次插入268 次删除
  1. 3 1
      README
  2. 0 41
      changelog_2.2.0.txt
  3. 35 0
      changelog_2.3.0.txt
  4. 1 1
      demo/index.html
  5. 43 39
      demo/js/jquery.nicescroll.min.js
  6. 246 147
      jquery.nicescroll.js
  7. 43 39
      jquery.nicescroll.min.js

+ 3 - 1
README

@@ -1,5 +1,5 @@
 jquery.nicescroll
-v. 2.2.0 11-13-2011
+v. 2.3.0 11-23-2011
 copyright 2011 InuYaksa*2011
 licensed under the MIT
 http://areaaperta.com/nicescroll
@@ -107,6 +107,8 @@ When you call "niceScroll" you can pass some parameters to custom visual aspects
 . grabcursorenabled, display "grab" icon for div with touchbehavior = true, default is true
 . autohidemode, how hide the scrollbar works, true=default / "cursor" = only cursor hidden / false = do not hide
 . background, change css for rail background, default is ""
+. iframeautoresize, autoresize iframe on load event (default:true)
+. autohidemode, when true the scrollbars has hidden if there is no scroll on page/div (default:true)
 
 * LICENSE
 

+ 0 - 41
changelog_2.2.0.txt

@@ -1,41 +0,0 @@
-Changelog nicescroll release 2.2.0
-http://areaaperta.com/nicescroll
-https://github.com/inuyaksa/jquery.nicescroll
-
-
-New features
-- scrolling with css transition (for full hw speed)
-- cssHook-ed scrollTop property, hw-scroll can be controlled by jQuery and you can use animation
-- override jQuery scrollTop function, hw-scroll can be controlled by jQuery and you can use animation
-- nicescroll object linked with jQuery DOM, using $.data named "__nicescroll"
-- jQuery function's getNiceScroll, to get the nicescroll object using $ selectors
-- only one instance for div, it checks if nicescroll already exists on the div
-- "grab" icon on div with touchbehavior = true
-
-New options
-- grabcursorenabled, display "grab" icon for div with touchbehavior = true, default is true
-- autohidemode, how hide the scrollbar works, true=default / "cursor" = only cursor hidden / false = do not hide
-- background, change css for rail background, default is ""
-
-Changed features
-- zIndex for scrollbar of document is the default value and for others is default+2
-- using css "background-clip" with value "padding-box" for a better cursor display. (see http://css-tricks.com/7423-transparent-borders-with-background-clip/)
-
-Fixes
-- zoom on iOS4, not fully visible
-- textarea resize bug, scrollbar didn't update
-- IE7, page scrollbar not hidden 
-- IE7-IE8, touchbehavior (grab-to-scroll) doesnt' work
-- IE8, workaround for IFRAME onload bug
-- Opera, key repetitions not working
-- scrollball don't update position when div has resized (no wrapper div), only for IE/Firefox/Opera
-
-
-Known issues
-- textarea on Firefox7, native scrollbars can't be hidden (firefox bug?)
-- chrome, -webkit-grab value accepted but cursor remain as pointer (possible browser bug)
-- chrome/safari, can't detect div resize (browser limitation)
-
-
-Thanks for nice feeback to:
-butchewing, replete, pathetix and mkmcdonald

+ 35 - 0
changelog_2.3.0.txt

@@ -0,0 +1,35 @@
+Changelog nicescroll release 2.3.0
+http://areaaperta.com/nicescroll
+https://github.com/inuyaksa/jquery.nicescroll
+
+
+New features
+- show/hide scrollbar functions
+- scrollbar will hide when div has hidden
+- show scrollbar only when it needs (page/div with scroll)
+- detect orientationchange event (when available)
+- requestAnimationFrame (most of modern browsers) implementation for a smoother scrolling and CPU power saving (only native scrolling)
+- added variable with version of library
+
+New options
+- iframeautoresize, autoresize iframe on load event (default:true)
+- autohidemode, when true the scrollbars has hidden if there is no scroll on page/div (default:true)
+
+Changed features
+- more precise scrolling when key has pressed
+- more consistent iframe support
+- internal reorganization of event functions
+- added touchcancel event
+
+Fixes
+- x-position of cursor and rail width on simple div
+- prevent default for gesture event
+- Opera, keypress on iframe
+- IE7 detection routine
+- IE8 IE7, keypress on form fields
+- better event manager for IE8-
+- IE8 & older, fix iframe scrolling detection
+
+Known issues
+- chrome/safari can't detect dom attribute change, on div attr change you need to recall onResize() function
+

+ 1 - 1
demo/index.html

@@ -2,7 +2,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>jQuery NiceScroll Test 2.2.0</title>
+<title>jQuery NiceScroll Test 2.3.0</title>
 <style type="text/css">
 #boxscroll {
 	padding: 40px;

+ 43 - 39
demo/js/jquery.nicescroll.min.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.2.0
+-- version 2.3.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -7,41 +7,45 @@
 -- https://github.com/inuyaksa/jquery.nicescroll
 --
 */
-(function(e){var k=false,l=false,n=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("/")+"/":""}(),m=function(f){var b=this;this.opt={doc:e("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,hwacceleration:true,usetransition:true,boxzoom:false,
-dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:""};if(f)for(var g in b.opt)f[g]!==void 0&&(b.opt[g]=f[g]);this.id=b.opt.doc[0].id||"";this.doc=b.opt.doc;this.ispage=b.doc[0].nodeName=="BODY"||b.doc[0].nodeName=="HTML";this.haswrapper=b.opt.win!==false;this.win=b.opt.win||(this.ispage?e(window):this.doc);this.docscroll=this.ispage?e(window):this.win;this.isiframe=this.doc[0].nodeName=="IFRAME"&&this.win[0].nodeName=="IFRAME";this.istextarea=this.win[0].nodeName==
-"TEXTAREA";if(this.doc[0].nodeName=="IFRAME"){var j=function(){var c="contentDocument"in this?this.contentDocument:this.contentWindow.document;if(b.isiframe)b.docscroll=e(c.body);b.onResize();e(c.body).css({"overflow-y":"hidden"});e(c).scroll(b.onscroll);e(c).mouseup(function(){b.rail.drag=false});b.bind(c,"mousewheel",b.onmousewheel);e(c).keydown(b.onkeypress);if(b.cantouch||b.opt.touchbehavior)b.cursorgrabvalue&&e(c).css({cursor:b.cursorgrabvalue}),b.bind(c,"mousedown",function(c){b.rail.drag={x:c.pageX,
-y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop()};return b.cancelEvent(c)}),b.bind(c,"mouseup",function(c){b.rail.drag=false;return b.cancelEvent(c)}),b.bind(c,"mousemove",function(c){if(b.rail.drag)return b.doScrollTo(b.rail.drag.st-(c.pageY-b.rail.drag.y),true),b.cancelEvent(c)});b.zoom&&(b.bind(c,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(c,"gesturechange",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)}))};this.doc[0].readyState&&
-this.doc[0].readyState=="complete"?setTimeout(function(){j.call(b.doc[0],false)},1E3):this.doc.load(j)}this.page=this.view=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));this.locked=this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;var i=document.createElement("DIV");this.isopera="opera"in window;this.isieold=
-(this.isie="all"in document&&"attachEvent"in i&&!this.isopera)&&!("msInterpolationMode"in i.style);this.isie7=this.isie&&(!("documentMode"in document)||document.documentMode==7);this.isie8=this.isie&&"documentMode"in document&&document.documentMode==8;this.isie9=this.isie&&"performance"in window&&document.documentMode>=9;this.ismozilla="MozAppearance"in i.style;(this.cantouch="ontouchstart"in document.documentElement)&&/iphone|ipad|ipod/i.test(navigator.platform)?(this.isios=true,this.isios4=!("seal"in
-Object)):this.isios4=this.isios=false;if(b.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":i.style.webkitTransform!==void 0?"webkitTransform":i.style.MozTransform!==void 0?"MozTransform":false)&&i.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)i.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(i.style[this.trstyle]);this.transitionstyle=false;this.prefixstyle="";this.transitionend=
-false;var f="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(","),m=",-webkit-,-moz-,-o-,-ms-,-khtml-".split(","),o="transitionEnd,webkitTransitionEnd,transitionend,oTransitionEnd,msTransitionEnd,KhtmlTransitionEnd".split(",");for(g=0;g<f.length;g++)if(f[g]in i.style){this.transitionstyle=f[g];this.prefixstyle=m[g];this.transitionend=o[g];break}this.hastransition=this.transitionstyle}else this.hastransition=this.transitionstyle=this.hastransform=this.trstyle=
-false;this.cursorgrabvalue="";if(b.opt.grabcursorenabled&&b.opt.touchbehavior)this.cursorgrabvalue=function(){if(!b.isie||b.isie9)for(var c=["grab","-moz-grab","-webkit-grab"],d=0;d<c.length;d++){var h=c[d];i.style.cursor=h;if(i.style.cursor==h)return h}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}();i=null;this.ishwscroll=b.hastransform&&b.opt.hwacceleration&&b.haswrapper;this.scrollTop=function(c){return c===void 0?b.getScrollTop():b.setScrollTop(c)};this.ishwscroll?
-(b.doc.translate={x:0,y:0},this.getScrollTop=function(){return b.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(c,d){b.doc.css(b.trstyle,"translate3d(0px,"+c*-1+"px,0px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var h=document.createEvent("UIEvents");h.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(h)}else h=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),h.cancelBubble=true}:function(c,d){b.doc.css(b.trstyle,"translate(0px,"+c*
--1+"px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var h=document.createEvent("UIEvents");h.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(h)}else h=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),h.cancelBubble=true}):(this.getScrollTop=function(){return b.docscroll.scrollTop()},this.setScrollTop=function(c){return b.docscroll.scrollTop(c)});this.getTarget=function(b){return!b?false:b.target?b.target:b.srcElement?b.srcElement:false};this.hasParent=
-function(b,d){if(!b)return false;for(var h=b.target||b.srcElement||b||false;h&&h.id!=d;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(c){if(b.ishwscroll)b.rail.css({height:b.win.innerHeight()});else{var d=b.win.offset();d.top+=2;d.left+=b.win.outerWidth()-b.rail.width-4;b.rail.css({position:"absolute",top:d.top,left:d.left,height:c?c.h:b.win.outerHeight()});b.zoom&&b.zoom.css({position:"absolute",top:d.top+1,left:d.left-18})}};this.init=function(){if(!b.ispage||!b.cantouch&&
-!b.isieold){b.ispage?b.doc.css({"overflow-y":"hidden"}):b.docscroll.css({"overflow-y":"hidden"});b.ispage&&b.isie7&&e("html").css({"overflow-y":"hidden"});var c=e(document.createElement("div"));c.attr("id",b.id);c.width=4+parseFloat(b.opt.cursorwidth);c.css({"padding-left":"2px","padding-right":"1px",width:b.rail.width+"px",zIndex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});b.rail=c;var d=false;if(b.opt.boxzoom&&!b.ispage&&!b.isieold)d=document.createElement("div"),b.bind(d,
-"click",b.doZoom),b.zoom=e(d),b.zoom.css({cursor:"pointer","z-index":b.opt.zindex,backgroundImage:"url("+n+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),b.opt.dblclickzoom&&b.bind(b.win,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(b.win,"gesturechange",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)});b.ispage?(c.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),b.doc.append(c)):b.ishwscroll?(b.win.css("position")==
-"static"&&b.win.css("position","relative"),b.zoom&&(b.zoom.css({position:"absolute",top:1,right:0,"margin-right":c.width+2}),b.win.append(b.zoom)),c.css({position:"absolute",top:0,right:0}),b.win.append(c)):(b.updateScrollBar(),e("body").append(c),b.zoom&&e("body").append(b.zoom));c=e(document.createElement("div"));c.css({position:"relative",top:0,left:0,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});b.cursor=c;b.rail.append(c);if(b.opt.autohidemode===false)b.autohidedom=false;else if(b.opt.autohidemode===true)b.autohidedom=b.rail;else if(b.opt.autohidemode=="cursor")b.autohidedom=b.cursor;e(window).resize(b.onResize);!b.ispage&&!b.haswrapper&&b.bind(b.win,b.isie&&!b.isie9?"propertychange":"DOMAttrModified",b.onAttributeChange);!b.ispage&&b.opt.boxzoom&&e(window).resize(b.resizeZoom);b.istextarea&&b.win.mouseup(b.onResize);
-b.onResize();b.cantouch||b.opt.touchbehavior?(b.bind(b.win,"mousedown",function(c){b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)}),b.bind(b.win,"mouseup",function(c){b.doScrollMomentum(b.rail.drag);b.rail.drag=false;return b.cancelEvent(c)}),b.bind(b.rail,"mousedown",function(c){b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),
-lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)}),b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;return b.cancelEvent(c)}),b.bind(document,"mousemove",function(c){if(b.rail.drag){var d=c.pageY-b.rail.drag.y;b.rail.drag.ly=b.rail.drag.ny;b.rail.drag.ny=c.pageY;b.rail.drag.lt=(new Date).getTime();b.scroll.y=Math.round((b.rail.drag.st-d)*(1/b.scrollratio.y));if(b.scroll.y<0)b.scroll.y=0;if(b.scroll.y>b.scrollvaluemax)b.scroll.y=
-b.scrollvaluemax;b.showCursor();b.doScrollTo(b.rail.drag.st-d,true);return b.cancelEvent(c)}}),b.cursorgrabvalue&&b.win.css({cursor:b.cursorgrabvalue})):(b.bind(b.rail,"mousedown",function(c){b.rail.drag={x:c.screenX,y:c.screenY,sx:b.scroll.x,sy:b.scroll.y};return b.cancelEvent(c)}),b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;b.hideCursor();return b.cancelEvent(c)}),b.bind(document,"mousemove",function(c){if(b.rail.drag){b.scroll.y=b.rail.drag.sy+(c.screenY-b.rail.drag.y);if(b.scroll.y<
-0)b.scroll.y=0;var d=b.scrollvaluemax;if(b.scroll.y>d)b.scroll.y=d;b.showCursor();b.cursorfreezed=true;b.doScroll(Math.round(b.scroll.y*b.scrollratio.y));return b.cancelEvent(c)}}));b.bind(document,"mouseup",function(){b.rail.drag=false;b.hideCursor()});b.cantouch||(b.rail.mouseenter(function(){b.showCursor();b.rail.active=true}),b.rail.mouseleave(function(){b.rail.active=false;b.rail.drag||b.hideCursor()}),b.isiframe||b.bind(b.isie&&b.ispage?document:b.docscroll,"mousewheel",b.onmousewheel),b.bind(b.rail,
-"mousewheel",b.onmousewheel));!b.ispage&&!b.cantouch&&(b.win.attr("tabindex")||b.win.attr({tabindex:(new Date).getTime()}),b.win.focus(function(c){k=b.getTarget(c).id||true;b.hasfocus=true;b.noticeCursor()}),b.win.blur(function(){k=false;b.hasfocus=false}),b.win.mouseenter(function(c){l=b.getTarget(c).id||true;b.hasmousefocus=true;b.noticeCursor()}),b.win.mouseleave(function(){l=false;b.hasmousefocus=false}));b.onkeypress=function(c){var c=c?c:window.e,d=b.getTarget(c);if(!d||!/(INPUT|TEXTAREA|SELECT)/.test(d.nodeName))if(b.hasfocus||
-b.hasmousefocus&&!k||b.ispage&&!k&&!l){d=true;switch(c.keyCode){case 38:case 63233:b.doScrollBy(12);d=false;break;case 40:case 63235:b.doScrollBy(-12);d=false;break;case 33:case 63276:b.doScrollBy(b.view.h,true);d=false;break;case 34:case 63277:b.doScrollBy(-b.view.h,true);d=false;break;case 36:case 63273:b.doScrollTo(0,true);d=false;break;case 35:case 63275:b.doScrollTo(b.page.h,true);d=false;break;case 27:b.zoomactive&&(b.doZoom(),d=false)}if(!d)return b.cancelEvent(c)}};b.bind(document,b.isopera?
-"keypress":"keydown",b.onkeypress)}};this.showCursor=function(){if(b.cursortimeout)clearTimeout(b.cursortimeout),b.cursortimeout=0;b.rail&&b.autohidedom&&(b.autohidedom.stop().css({opacity:b.opt.cursoropacitymax}),b.cursor.css({height:b.cursorheight,top:b.scroll.y}),b.zoom&&b.zoom.stop().css({opacity:b.opt.cursoropacitymax}))};this.hideCursor=function(c){if(!b.cursortimeout&&b.rail&&b.autohidedom)b.cursortimeout=setTimeout(function(){b.rail.active||(b.autohidedom.stop().animate({opacity:b.opt.cursoropacitymin}),
-b.zoom&&b.zoom.stop().animate({opacity:b.opt.cursoropacitymin}));b.cursortimeout=0},c||800)};this.noticeCursor=function(c){b.showCursor();b.hideCursor(c)};this.getContentSize=function(){var c=b.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:b.haswrapper?{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"))}:{w:b.docscroll[0].scrollWidth,h:b.docscroll[0].scrollHeight};c.w-=1;c.h-=1;return c};this.onAttributeChange=function(c){if(c&&c.target){if(c.target!==b.win[0])return true;if(c.target!==b.doc[0])return true;if((c="attrChange"in c?c.attrName:"propertyName"in c?c.propertyName:false)&&/width|height|style/i.test(c)){if(b.lastattributechange)b.lastattributechange=clearTimeout(b.lastattributechange);b.lastattributechange=setTimeout(function(){b.lastattributechange=0;
-b.onResize()},60)}}};this.onResize=function(){b.view={w:b.ispage?b.win.width():b.win.innerWidth(),h:b.ispage?b.win.height():b.win.innerHeight()};b.istextarea&&b.win.css("resize")&&b.win.css("resize")!="none"&&(b.view.h-=20);b.ispage||b.updateScrollBar(b.view);b.page=b.getContentSize();b.cursorheight=Math.min(b.view.h,Math.round(b.view.h*(b.view.h/b.page.h)));b.scrollvaluemax=b.view.h-b.cursorheight-2;b.scrollratio={x:0,y:(b.page.h-b.view.h)/b.scrollvaluemax};b.scroll.y=Math.round(b.getScrollTop()*
-(1/b.scrollratio.y));b.noticeCursor()};this.bind=function(c,d,e,f){var g=c.length?c[0]:c;g.addEventListener?(b.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&g.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(b){if(b.touches.length<2){var c=b.touches.length>0?b.touches[0]:b;c.original=b;e.call(this,c)}},f||false),g.addEventListener(d,e,f||false),d=="mousewheel"&&g.addEventListener("DOMMouseScroll",e,f||false)):g.attachEvent?g.attachEvent("on"+d,function(c){if(c&&
-!("pageY"in c)&&"screenY"in c)c.pageX=c.screenX,c.pageY=c.screenY;if(!e.call(g,c)||!f)return b.cancelEvent(c)}):g["on"+d]=function(c){if(!e.call(g,c)||!f)return b.cancelEvent(c)}};this.cancelEvent=function(c){c=b.cantouch?c?c.original:false:c?c:window.event||false;if(!c)return false;c.stopPropagation&&c.stopPropagation();c.preventDefault&&c.preventDefault();c.cancelBubble=true;c.cancel=true;return c.returnValue=false};this.onmousewheel=function(c){c=c?c:window.event;if(b.rail.drag)return b.cancelEvent(c);
-var d=0;(d=c.detail?c.detail*-1:c.wheelDelta/40)&&b.doScrollBy(d*b.opt.mousescrollstep,true);return b.cancelEvent(c)};this.stop=function(){b.timer&&clearInterval(b.timer);b.timer=0;b.cursorfreezed=false;b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};b.ishwscroll&&b.hastransition&&b.opt.usetransition?(this.prepareTransition=function(c){var d=Math.round(b.opt.scrollspeed*10),c=Math.min(d,Math.round(c/20*b.opt.scrollspeed)),c=c>20?b.prefixstyle+"transform "+c+"ms ease-out 0s":
-"";if(!b.lasttransitionstyle||b.lasttransitionstyle!=c)b.lasttransitionstyle=c,b.doc.css(b.transitionstyle,c)},this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setTimeout(function(){var c=b.getScrollTop();b.prepareTransition(c>b.newscrolly?c-b.newscrolly:b.newscrolly-c);b.setScrollTop(b.newscrolly);b.timer=0},b.opt.scrollspeed),b.noticeCursor()}):this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setInterval(function(){var c=b.newscrolly-b.getScrollTop(),c=c>0?Math.ceil(c/4):
-Math.floor(c/4),c=b.getScrollTop()+c;b.setScrollTop(c);if(c==b.newscrolly)clearInterval(b.timer),b.timer=0,b.cursorfreezed=false},b.opt.scrollspeed),b.noticeCursor()};this.doScrollBy=function(c,d){d&&(c=Math.round(c*1/b.scrollratio.y));var e=b.scroll.y-c;e<0&&(e=0);var f=b.scrollvaluemax;e>f&&(e=f);b.cursorfreezed=false;b.doScroll(Math.floor(e*b.scrollratio.y))};this.doScrollTo=function(c,d){ny=d?Math.round(c*1/b.scrollratio.y):c;ny<0&&(c=0);var e=b.scrollvaluemax;ny>e&&(c=d?Math.round(e*b.scrollratio.y):
-e);b.cursorfreezed=false;b.doScroll(d?c:Math.round(c*b.scrollratio.y))};this.doScrollMomentum=function(c){var d=c.ly-c.ny,c=(new Date).getTime()-c.lt;Math.abs(d)>1&&c<601&&b.doScrollBy(d,true)};b.onscroll=function(){var c=(new Date).getTime();if(!b.lastcontentcheck||b.lastcontentcheck<c)if(b.lastcontentcheck=c+500,b.getContentSize().h!=b.page.h)b.onResize();if(!b.rail.drag){if(!b.cursorfreezed)b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()}};b.docscroll.scroll(function(c){b.onscroll(c)});
-this.doZoomIn=function(c){if(!b.zoomactive){b.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,marginTop,marginBottom,marginLeft,marginRight".split(","),f=b.win[0].style,g;for(g in d){var i=d[g];b.zoomrestore.style[i]=typeof f[i]!="undefined"?f[i]:""}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(b.isios4)b.zoomrestore.scrollTop=e(window).scrollTop(),
-e(window).scrollTop(0);b.win.css({position:b.isios4?"absolute":"fixed",top:0,left:0,"z-index":b.opt.zindex+100,margin:"0px"});d=b.win.css("backgroundColor");(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&b.win.css("backgroundColor","#fff");b.rail.css({"z-index":b.opt.zindex+110});b.zoom.css({"z-index":b.opt.zindex+112});b.zoomactive=true;b.zoom.css("backgroundPosition","0px -18px");b.resizeZoom();return b.cancelEvent(c)}};this.doZoomOut=function(c){if(b.zoomactive)return b.win.css("margin",
-""),b.win.css(b.zoomrestore.style),b.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.zoomactive=false,b.zoomrestore=false,b.zoom.css("backgroundPosition","0px 0px"),b.win.resize(),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.setScrollTop(c);b.win.resize()}};this.init()};e.fn.niceScroll=function(f,b){typeof f=="object"&&typeof b=="undefined"&&(b=f,f=false);var g=[];typeof b=="undefined"&&(b={});if(f)b.doc=e(f),b.win=e(this);var j=!("doc"in b);this.each(function(){var f=e(this).data("__nicescroll")||false;if(!f)b.doc=j?e(this):b.doc,f=new m(b),e(this).data("__nicescroll",f);g.push(f)});return g.length==1?g[0]:g};var j=jQuery.fn.scrollTop;e.cssHooks.scrollTop=
-{get:function(f){var b=e.data(f,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(f)},set:function(f,b){var g=e.data(f,"__nicescroll")||false;g&&g.ishwscroll?g.setScrollTop(parseInt(b)):j.call(f,b);return this}};jQuery.fn.scrollTop=function(f){if(typeof f=="undefined"){var b=e.data(this,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(this)}else return this.each(function(){var b=e.data(this,"__nicescroll")||false;b&&b.ishwscroll?b.setScrollTop(parseInt(f)):
-j.call(e(this),f)})};jQuery.fn.getNiceScroll=function(f){if(typeof f=="undefined"){for(a=0;a<this.length;a++)if(f=e.data(this[a],"__nicescroll")||false)return f;return false}else return f=e.data(this[f],"__nicescroll")||false}})(jQuery);
+(function(g){var l=false,m=false,o=function(){var f=document.getElementsByTagName("script"),f=f[f.length-1].src.split("?")[0];return f.split("/").length>0?f.split("/").slice(0,-1).join("/")+"/":""}(),q=function(f){var b=this;this.version="2.3.0";this.name="nicescroll";this.opt={doc:g("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,
+hwacceleration:true,usetransition:true,boxzoom:false,dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:"",iframeautoresize:true};if(f)for(var h in b.opt)f[h]!==void 0&&(b.opt[h]=f[h]);this.id=b.opt.doc[0].id||"";this.doc=b.opt.doc;this.ispage=b.doc[0].nodeName=="BODY"||b.doc[0].nodeName=="HTML";this.haswrapper=b.opt.win!==false;this.win=b.opt.win||(this.ispage?g(window):this.doc);this.docscroll=this.ispage?g(window):this.win;this.iframe=false;this.isiframe=this.doc[0].nodeName==
+"IFRAME"&&this.win[0].nodeName=="IFRAME";this.istextarea=this.win[0].nodeName=="TEXTAREA";this.page=this.view=this.onkeypress=this.onmousewheel=this.onmousemove=this.onmouseup=this.onmousedown=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;this.visibility=
+true;this.locked=false;var i=document.createElement("DIV");this.isopera="opera"in window;this.isieold=(this.isie="all"in document&&"attachEvent"in i&&!this.isopera)&&!("msInterpolationMode"in i.style);this.isie7=this.isie&&!this.isieold&&(!("documentMode"in document)||document.documentMode==7);this.isie8=this.isie&&"documentMode"in document&&document.documentMode==8;this.isie9=this.isie&&"performance"in window&&document.documentMode>=9;this.ismozilla="MozAppearance"in i.style;(this.cantouch="ontouchstart"in
+document.documentElement)&&/iphone|ipad|ipod/i.test(navigator.platform)?(this.isios=true,this.isios4=!("seal"in Object)):this.isios4=this.isios=false;if(b.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":i.style.webkitTransform!==void 0?"webkitTransform":i.style.MozTransform!==void 0?"MozTransform":false)&&i.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)i.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=
+/translate3d/.test(i.style[this.trstyle]);this.transitionstyle=false;this.prefixstyle="";this.transitionend=false;var f="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(","),p=",-webkit-,-moz-,-o-,-ms-,-khtml-".split(","),j="transitionEnd,webkitTransitionEnd,transitionend,oTransitionEnd,msTransitionEnd,KhtmlTransitionEnd".split(",");for(h=0;h<f.length;h++)if(f[h]in i.style){this.transitionstyle=f[h];this.prefixstyle=p[h];this.transitionend=j[h];break}this.hastransition=
+this.transitionstyle}else this.transitionend=this.hastransition=this.transitionstyle=this.hastranslate3d=this.hastransform=this.trstyle=false;this.cursorgrabvalue="";if(b.opt.grabcursorenabled&&b.opt.touchbehavior)this.cursorgrabvalue=function(){if(!b.isie||b.isie9)for(var c=["grab","-moz-grab","-webkit-grab"],d=0;d<c.length;d++){var e=c[d];i.style.cursor=e;if(i.style.cursor==e)return e}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}();i=null;this.ishwscroll=b.hastransform&&
+b.opt.hwacceleration&&b.haswrapper;this.scrollTop=function(c){return c===void 0?b.getScrollTop():b.setScrollTop(c)};this.ishwscroll?(b.doc.translate={x:0,y:0},this.getScrollTop=function(){return b.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(c,d){b.doc.css(b.trstyle,"translate3d(0px,"+c*-1+"px,0px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var e=document.createEvent("UIEvents");e.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(e)}else e=document.createEventObject(),
+b.docscroll[0].fireEvent("onscroll"),e.cancelBubble=true}:function(c,d){b.doc.css(b.trstyle,"translate(0px,"+c*-1+"px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var e=document.createEvent("UIEvents");e.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(e)}else e=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),e.cancelBubble=true}):(this.getScrollTop=function(){return b.docscroll.scrollTop()},this.setScrollTop=function(c){return b.docscroll.scrollTop(c)});
+this.getTarget=function(b){return!b?false:b.target?b.target:b.srcElement?b.srcElement:false};this.hasParent=function(b,d){if(!b)return false;for(var e=b.target||b.srcElement||b||false;e&&e.id!=d;)e=e.parentNode||false;return e!==false};this.updateScrollBar=function(c){if(b.ishwscroll)b.rail.css({height:b.win.innerHeight()});else{var d=b.win.offset();d.top+=2;var e=(b.win.outerWidth()-b.win.innerWidth())/2;d.left+=b.win.innerWidth()+e-b.rail.width-1;b.rail.css({position:"absolute",top:d.top,left:d.left,
+height:c?c.h:b.win.innerHeight()});b.zoom&&b.zoom.css({position:"absolute",top:d.top+1,left:d.left-18})}};var k=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||false,n=window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||false;b.hasanimationframe=k;
+b.hascancelanimationframe=n;b.hasanimationframe||(k=function(b){return setTimeout(b,1E3/60)});b.hascancelanimationframe||(n=clearInterval);this.init=function(){if(!b.ispage||!b.cantouch&&!b.isieold){b.ispage?b.doc.css({"overflow-y":"hidden"}):b.docscroll.css({"overflow-y":"hidden"});b.ispage&&b.isie7&&g("html").css({"overflow-y":"hidden"});var c=g(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 d=g(document.createElement("div"));d.attr("id",b.id);d.width=3+Math.max(parseFloat(b.opt.cursorwidth),c.outerWidth());d.css({"padding-left":"0px","padding-right":"1px",width:d.width+"px",zIndex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});
+d.append(c);b.rail=d;c=false;if(b.opt.boxzoom&&!b.ispage&&!b.isieold)c=document.createElement("div"),b.bind(c,"click",b.doZoom),b.zoom=g(c),b.zoom.css({cursor:"pointer","z-index":b.opt.zindex,backgroundImage:"url("+o+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),b.opt.dblclickzoom&&b.bind(b.win,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(b.win,"gestureend",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)});b.ispage?(d.css({position:"fixed",
+top:"0px",right:"0px",height:"100%"}),b.doc.append(d)):b.ishwscroll?(b.win.css("position")=="static"&&b.win.css("position","relative"),b.zoom&&(b.zoom.css({position:"absolute",top:1,right:0,"margin-right":d.width+2}),b.win.append(b.zoom)),d.css({position:"absolute",top:0,right:0}),b.win.append(d)):(b.updateScrollBar(),g("body").append(d),b.zoom&&g("body").append(b.zoom));if(b.opt.autohidemode===false)b.autohidedom=false;else if(b.opt.autohidemode===true)b.autohidedom=b.rail;else if(b.opt.autohidemode==
+"cursor")b.autohidedom=b.cursor;b.bind(window,"resize",b.onResize);b.bind(window,"orientationchange",b.onResize);!b.ispage&&!b.haswrapper&&b.bind(b.win,b.isie&&!b.isie9?"propertychange":"DOMAttrModified",b.onAttributeChange);!b.ispage&&b.opt.boxzoom&&g(window).resize(b.resizeZoom);b.istextarea&&b.win.mouseup(b.onResize);b.onResize();b.cantouch||b.opt.touchbehavior?(b.onmousedown=function(c){if(b.locked)return b.cancelEvent(c);b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),
+lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)},b.onmouseup=function(c){if(b.rail.drag)return b.doScrollMomentum(b.rail.drag),b.rail.drag=false,b.cancelEvent(c)},b.onmousemove=function(c){if(b.rail.drag){var d=c.pageY-b.rail.drag.y;b.rail.drag.ly=b.rail.drag.ny;b.rail.drag.ny=c.pageY;b.rail.drag.lt=(new Date).getTime();b.scroll.y=Math.round((b.rail.drag.st-d)*(1/b.scrollratio.y));if(b.scroll.y<0)b.scroll.y=0;if(b.scroll.y>b.scrollvaluemax)b.scroll.y=
+b.scrollvaluemax;b.showCursor();b.doScrollTo(b.rail.drag.st-d,true);return b.cancelEvent(c)}},b.cursorgrabvalue&&b.win.css({cursor:b.cursorgrabvalue})):(b.onmousedown=function(c){if(b.locked)return b.cancelEvent(c);b.rail.drag={x:c.screenX,y:c.screenY,sx:b.scroll.x,sy:b.scroll.y};return b.cancelEvent(c)},b.onmouseup=function(c){if(b.rail.drag)return b.rail.drag=false,b.cancelEvent(c)},b.onmousemove=function(c){if(b.rail.drag){b.scroll.y=b.rail.drag.sy+(c.screenY-b.rail.drag.y);if(b.scroll.y<0)b.scroll.y=
+0;var d=b.scrollvaluemax;if(b.scroll.y>d)b.scroll.y=d;b.showCursor();b.cursorfreezed=true;b.doScroll(Math.round(b.scroll.y*b.scrollratio.y));return b.cancelEvent(c)}});(b.cantouch||b.opt.touchbehavior)&&b.bind(b.win,"mousedown",b.onmousedown);b.bind(b.win,"mouseup",b.onmouseup);b.bind(b.rail,"mousedown",b.onmousedown);b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;b.hideCursor();return b.cancelEvent(c)});b.bind(document,"mouseup",b.onmouseup);b.bind(document,"mousemove",b.onmousemove);b.cantouch||
+(b.rail.mouseenter(function(){b.showCursor();b.rail.active=true}),b.rail.mouseleave(function(){b.rail.active=false;b.rail.drag||b.hideCursor()}),b.isiframe||b.bind(b.isie&&b.ispage?document:b.docscroll,"mousewheel",b.onmousewheel),b.bind(b.rail,"mousewheel",b.onmousewheel));!b.ispage&&!b.cantouch&&(b.win.attr("tabindex")||b.win.attr({tabindex:(new Date).getTime()}),b.win.focus(function(c){l=b.getTarget(c).id||true;b.hasfocus=true;b.noticeCursor()}),b.win.blur(function(){l=false;b.hasfocus=false}),
+b.win.mouseenter(function(c){m=b.getTarget(c).id||true;b.hasmousefocus=true;b.noticeCursor()}),b.win.mouseleave(function(){m=false;b.hasmousefocus=false}));b.onkeypress=function(c){var c=c?c:window.e,d=b.getTarget(c);if(d&&/INPUT|TEXTAREA|SELECT/.test(d.nodeName)&&(!d.getAttribute("type")&&!d.type||!/submit|button|cancel/i.tp))return true;if(b.hasfocus||b.hasmousefocus&&!l||b.ispage&&!l&&!m){d=c.keyCode;if(b.locked&&d!=27)return b.cancelEvent(c);var e=true;switch(d){case 38:case 63233:b.doScrollBy(72,
+true);e=false;break;case 40:case 63235:b.doScrollBy(-72,true);e=false;break;case 33:case 63276:b.doScrollBy(b.view.h,true);e=false;break;case 34:case 63277:b.doScrollBy(-b.view.h,true);e=false;break;case 36:case 63273:b.doScrollTo(0,true);e=false;break;case 35:case 63275:b.doScrollTo(b.page.h,true);e=false;break;case 27:b.zoomactive&&(b.doZoom(),e=false)}if(!e)return b.cancelEvent(c)}};b.bind(document,b.isopera?"keypress":"keydown",b.onkeypress)}if(this.doc[0].nodeName=="IFRAME"){var e=function(){var c=
+"contentDocument"in this?this.contentDocument:this.contentWindow.document;if(b.isiframe)b.docscroll=g(c),b.iframe={html:b.doc.contents().find("html")[0],body:b.doc.contents().find("body")[0]};if(b.opt.iframeautoresize&&!b.isiframe){b.win.scrollTop(0);b.doc.height("");var d=b.doc.contents(),d=Math.max(d.find("html").attr("scrollHeight"),d.find("body").attr("scrollHeight"));b.doc.height(d)}b.onResize();b.isie7&&g(c).find("html").css({"overflow-y":"hidden"});g(c.body).css({"overflow-y":"hidden"});"contentWindow"in
+this?b.bind(this.contentWindow,"scroll",b.onscroll):b.bind(c,"scroll",b.onscroll);b.bind(c,"mouseup",b.onmouseup);b.bind(c,"mousewheel",b.onmousewheel);b.bind(c,b.isopera?"keypress":"keydown",b.onkeypress);if(b.cantouch||b.opt.touchbehavior)b.bind(c,"mousedown",b.onmousedown),b.cursorgrabvalue&&g(c).css({cursor:b.cursorgrabvalue});b.bind(c,"mousemove",b.onmousemove);b.zoom&&(b.opt.dblclickzoom&&b.bind(c,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(c,"gesturechange",function(c){c.scale>
+1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)}))};this.doc[0].readyState&&this.doc[0].readyState=="complete"&&setTimeout(function(){e.call(b.doc[0],false)},500);this.doc.load(e)}};this.showCursor=function(){if(b.cursortimeout)clearTimeout(b.cursortimeout),b.cursortimeout=0;b.rail&&(b.autohidedom&&b.autohidedom.stop().css({opacity:b.opt.cursoropacitymax}),b.cursor.css({height:b.cursorheight,top:b.scroll.y}),b.zoom&&b.zoom.stop().css({opacity:b.opt.cursoropacitymax}))};this.hideCursor=
+function(c){if(!b.cursortimeout&&b.rail&&b.autohidedom)b.cursortimeout=setTimeout(function(){b.rail.active||(b.autohidedom.stop().animate({opacity:b.opt.cursoropacitymin}),b.zoom&&b.zoom.stop().animate({opacity:b.opt.cursoropacitymin}));b.cursortimeout=0},c||800)};this.noticeCursor=function(c){b.showCursor();b.hideCursor(c)};this.getContentSize=function(){var c=b.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:
+b.haswrapper?{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"))}:b.iframe?{w:Math.max(b.iframe.html.scrollWidth,b.iframe.body.scrollWidth),h:Math.max(b.iframe.html.scrollHeight,b.iframe.body.scrollHeight)}:{w:b.docscroll[0].scrollWidth,h:b.docscroll[0].scrollHeight};c.w-=1;c.h-=1;return c};this.onAttributeChange=function(c){if(c&&c.target){if(c.target!==b.win[0]&&
+c.target!==b.doc[0])return true;if((c="attrChange"in c?c.attrName:"propertyName"in c?c.propertyName:false)&&/width|height|style|block/i.test(c)){if(b.lastattributechange)b.lastattributechange=clearTimeout(b.lastattributechange);b.lastattributechange=setTimeout(function(){b.lastattributechange=0;b.onResize()},60)}}};this.onResize=function(){if(!b.haswrapper&&!b.ispage){var c=b.win.css("display")!="none";c&&!b.visibility&&b.show();!c&&b.visibility&&b.hide();if(!b.visibility)return false}b.view={w:b.ispage?
+b.win.width():b.win.innerWidth(),h:b.ispage?b.win.height():b.win.innerHeight()};b.page=b.getContentSize();if(b.view.h>=b.page.h)return b.hide(),b.scrollvaluemax=0,b.scroll.y=0,b.scrollratio={x:0,y:0},b.cursorheight=0,b.locked=true,b.setScrollTop(0),false;else b.visibility||b.show();b.locked=false;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.scrollvaluemax=
+b.view.h-b.cursorheight-b.cursor.hborder-2;b.scrollratio={x:0,y:(b.page.h-b.view.h)/b.scrollvaluemax};b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};this.bind=function(c,d,e,f){var g=c.length?c[0]:c;g.addEventListener?(b.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&g.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(b){if(b.touches.length<2){var c=b.touches.length>0?b.touches[0]:b;c.original=b;e.call(this,c)}},f||false),g.addEventListener(d,
+e,f||false),d=="mousewheel"&&g.addEventListener("DOMMouseScroll",e,f||false),b.cantouch&&d=="mouseup"&&g.addEventListener("touchcancel",e,f||false)):g.attachEvent?g.attachEvent("on"+d,function(c){if(c&&!("pageY"in c)&&"screenY"in c)c.pageX=c.screenX,c.pageY=c.screenY;return e.call(g,c)===false||f===false?b.cancelEvent(c):true}):g["on"+d]=function(c){return e.call(g,c)===false||f===false?b.cancelEvent(c):true}};this.cancelEvent=function(c){c=b.cantouch?c.original?c.original:c||false:c?c:window.event||
+false;if(!c)return false;c.stopPropagation&&c.stopPropagation();c.preventDefault&&c.preventDefault();c.cancelBubble=true;c.cancel=true;return c.returnValue=false};this.show=function(){b.visibility=true;b.rail.css("display","block")};this.hide=function(){b.visibility=false;b.rail.css("display","none")};this.onmousewheel=function(c){if(b.locked)return b.cancelEvent(c);c=c?c:window.event;if(b.rail.drag)return b.cancelEvent(c);var d=0;(d=c.detail?c.detail*-1:c.wheelDelta/40)&&b.doScrollBy(d*b.opt.mousescrollstep,
+true);return b.cancelEvent(c)};this.stop=function(){b.timer&&n(b.timer);b.timer=0;b.cursorfreezed=false;b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};b.ishwscroll&&b.hastransition&&b.opt.usetransition?(this.prepareTransition=function(c){var d=Math.round(b.opt.scrollspeed*10),c=Math.min(d,Math.round(c/20*b.opt.scrollspeed)),c=c>20?b.prefixstyle+"transform "+c+"ms ease-out 0s":"";if(!b.lasttransitionstyle||b.lasttransitionstyle!=c)b.lasttransitionstyle=c,b.doc.css(b.transitionstyle,
+c)},this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setTimeout(function(){var c=b.getScrollTop();b.prepareTransition(c>b.newscrolly?c-b.newscrolly:b.newscrolly-c);b.setScrollTop(b.newscrolly);b.timer=0},b.opt.scrollspeed),b.noticeCursor()}):this.doScroll=function(c){function d(){g=(new Date).getTime();if(g<f)return b.timer=k(d);f=(new Date).getTime()+b.opt.scrollspeed;g=0;var c=b.newscrolly-b.getScrollTop(),c=c>0?Math.ceil(c*e):Math.floor(c*e),c=b.getScrollTop()+c;b.setScrollTop(c);c==
+b.newscrolly?(b.timer=0,b.cursorfreezed=false):b.timer=k(d)}b.newscrolly=c;if(!b.timer){var e=0.25,g=0,f=0;b.timer=k(d);b.noticeCursor()}};this.doScrollBy=function(c,d){d&&(c=Math.round(c*1/b.scrollratio.y));var e=b.scroll.y-c;e<0&&(e=0);var g=b.scrollvaluemax;e>g&&(e=g);b.cursorfreezed=false;b.doScroll(Math.floor(e*b.scrollratio.y))};this.doScrollTo=function(c,d){ny=d?Math.round(c*1/b.scrollratio.y):c;ny<0&&(c=0);var e=b.scrollvaluemax;ny>e&&(c=d?Math.round(e*b.scrollratio.y):e);b.cursorfreezed=
+false;b.doScroll(d?c:Math.round(c*b.scrollratio.y))};this.doScrollMomentum=function(c){var d=c.ly-c.ny,c=(new Date).getTime()-c.lt;(d=Math.floor(d*3/((c+1)*0.2)))&&b.doScrollBy(d,true)};b.onscroll=function(){var c=(new Date).getTime();if(!b.lastcontentcheck||b.lastcontentcheck<c)if(b.lastcontentcheck=c+500,b.getContentSize().h!=b.page.h)b.onResize();if(!b.rail.drag){if(!b.cursorfreezed)b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()}};b.docscroll.scroll(function(c){b.onscroll(c)});
+this.doZoomIn=function(c){if(!b.zoomactive){b.zoomactive=true;b.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,marginTop,marginBottom,marginLeft,marginRight".split(","),e=b.win[0].style,f;for(f in d){var h=d[f];b.zoomrestore.style[h]=typeof e[h]!="undefined"?e[h]:""}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(b.isios4)b.zoomrestore.scrollTop=
+g(window).scrollTop(),g(window).scrollTop(0);b.win.css({position:b.isios4?"absolute":"fixed",top:0,left:0,"z-index":b.opt.zindex+100,margin:"0px"});d=b.win.css("backgroundColor");(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&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();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),b.isios4&&g(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.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:g(window).width()-b.zoomrestore.padding.w+
+"px",height:g(window).height()-b.zoomrestore.padding.h+"px"});b.setScrollTop(c);b.onResize()}};this.init()};g.fn.niceScroll=function(f,b){typeof f=="object"&&typeof b=="undefined"&&(b=f,f=false);var h=[];typeof b=="undefined"&&(b={});if(f)b.doc=g(f),b.win=g(this);var i=!("doc"in b);this.each(function(){var f=g(this).data("__nicescroll")||false;if(!f)b.doc=i?g(this):b.doc,f=new q(b),g(this).data("__nicescroll",f);h.push(f)});return h.length==1?h[0]:h};var j=jQuery.fn.scrollTop;g.cssHooks.scrollTop=
+{get:function(f){var b=g.data(f,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(f)},set:function(f,b){var h=g.data(f,"__nicescroll")||false;h&&h.ishwscroll?h.setScrollTop(parseInt(b)):j.call(f,b);return this}};jQuery.fn.scrollTop=function(f){if(typeof f=="undefined"){var b=g.data(this,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(this)}else return this.each(function(){var b=g.data(this,"__nicescroll")||false;b&&b.ishwscroll?b.setScrollTop(parseInt(f)):
+j.call(g(this),f)})};jQuery.fn.getNiceScroll=function(f){if(typeof f=="undefined"){for(a=0;a<this.length;a++)if(f=g.data(this[a],"__nicescroll")||false)return f;return false}else return f=g.data(this[f],"__nicescroll")||false}})(jQuery);

+ 246 - 147
jquery.nicescroll.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.2.0
+-- version 2.3.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -27,6 +27,9 @@
   var NiceScrollClass = function(myopt) {
 
     var self = this;
+
+    this.version = '2.3.0';
+    this.name = 'nicescroll';
     
     this.opt = {
       doc:$("body"),
@@ -48,7 +51,8 @@
       gesturezoom:true,
       grabcursorenabled:true,
       autohidemode:true,
-      background:""
+      background:"",
+      iframeautoresize:true
     };
     
     if (myopt||false) {
@@ -64,57 +68,20 @@
     this.win = self.opt.win||(this.ispage?$(window):this.doc);
     this.docscroll = this.ispage?$(window):this.win;
 
+    this.iframe = false;
     this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME'));
     
     this.istextarea = (this.win[0].nodeName == 'TEXTAREA');
 
-    if (this.doc[0].nodeName == 'IFRAME') {
-      function oniframeload(e) {        
-        var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
-        if (self.isiframe) self.docscroll = $(doc.body);
-        self.onResize();
-        $(doc.body).css({'overflow-y':'hidden'});
-        $(doc).scroll(self.onscroll);
-        $(doc).mouseup(function(){self.rail.drag = false;});
-        self.bind(doc,"mousewheel",self.onmousewheel);
-        $(doc).keydown(self.onkeypress);        
-        if (self.cantouch||self.opt.touchbehavior) {
-          if (self.cursorgrabvalue) $(doc).css({'cursor':self.cursorgrabvalue});
-          self.bind(doc,"mousedown",function(e) {            
-            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
-            return self.cancelEvent(e);
-          });
-          self.bind(doc,"mouseup",function(e) {
-            self.rail.drag = false;
-            return self.cancelEvent(e);
-          });
-          self.bind(doc,"mousemove",function(e) {
-            if (self.rail.drag) {
-              self.doScrollTo(self.rail.drag.st - (e.pageY-self.rail.drag.y),true);
-              return self.cancelEvent(e);
-            }
-          });
-        }      
-        if (self.zoom) {
-          self.bind(doc,'dblclick',self.doZoom);
-          if (self.cantouch&&self.opt.gesturezoom) {
-            self.bind(doc,"gesturechange",function(e) {
-              if (e.scale>1.5) self.doZoomIn(e);
-              if (e.scale<0.8) self.doZoomOut(e);
-              return self.cancelEvent(e);
-            });             
-          }          
-        }
-      };
-      
-      if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
-        setTimeout(function(){oniframeload.call(self.doc[0],false)},1000);
-      } else {
-        this.doc.load(oniframeload);
-      }
-      
-    }
+// Events jump table    
+    this.onmousedown = false;
+    this.onmouseup = false;
+    this.onmousemove = false;
+    this.onmousewheel = false;
+    this.onkeypress = false;
+    
     
+// Let's start!  
     this.view = false;
     this.page = false;
     
@@ -137,6 +104,7 @@
     this.hasfocus = false;
     this.hasmousefocus = false;
     
+    this.visibility = true;
     this.locked = false;
     
     var domtest = document.createElement('DIV');
@@ -145,7 +113,7 @@
     
     this.isie = (("all" in document) && ("attachEvent" in domtest) && !this.isopera);
     this.isieold = (this.isie && !("msInterpolationMode" in domtest.style));  // IE6 and older
-    this.isie7 = this.isie&&(!("documentMode" in document)||(document.documentMode==7));
+    this.isie7 = this.isie&&!this.isieold&&(!("documentMode" in document)||(document.documentMode==7));
     this.isie8 = this.isie&&("documentMode" in document)&&(document.documentMode==8);
     this.isie9 = this.isie&&("performance" in window)&&(document.documentMode>=9);
     
@@ -189,8 +157,10 @@
     } else {
       this.trstyle = false;
       this.hastransform = false;
+      this.hastranslate3d = false;
       this.transitionstyle = false;
       this.hastransition = false;
+      this.transitionend = false;
     }
     
     this.cursorgrabvalue = '';
@@ -289,12 +259,37 @@
       } else {
         var pos = self.win.offset();
         pos.top+=2;
-        pos.left+=self.win.outerWidth()-self.rail.width-4;
-        self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:(len)?len.h:self.win.outerHeight()});
+        var brd = (self.win.outerWidth() - self.win.innerWidth())/2;
+        pos.left+= self.win.innerWidth() + brd - self.rail.width - 1;
+        self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
         if (self.zoom) self.zoom.css({position:"absolute",top:pos.top+1,left:pos.left-18});
       }
     };
     
+// derived by http://blog.joelambert.co.uk/2011/06/01/a-better-settimeoutsetinterval/
+    var setAnimationFrame = (function(){
+      return  window.requestAnimationFrame       || 
+              window.webkitRequestAnimationFrame || 
+              window.mozRequestAnimationFrame    || 
+              window.oRequestAnimationFrame      || 
+              window.msRequestAnimationFrame     || 
+              false;
+    })();
+    var clearAnimationFrame = (function(){
+      return  window.cancelRequestAnimationFrame       || 
+              window.webkitCancelRequestAnimationFrame || 
+              window.mozCancelRequestAnimationFrame    || 
+              window.oCancelRequestAnimationFrame      || 
+              window.msCancelRequestAnimationFrame     || 
+              false;
+    })();
+    
+    self.hasanimationframe = (setAnimationFrame);
+    self.hascancelanimationframe = (clearAnimationFrame);
+    
+    if (!self.hasanimationframe) setAnimationFrame=function(fn){return setTimeout(fn,1000/60)};
+    if (!self.hascancelanimationframe) clearAnimationFrame=clearInterval;
+    
     this.init = function() {
     
       if (!self.ispage || (!self.cantouch && !self.isieold)) {
@@ -303,10 +298,26 @@
         
         if (self.ispage&&self.isie7) $("html").css({'overflow-y':'hidden'});  //IE7 double scrollbar issue
         
+        var cursor = $(document.createElement('div'));
+        cursor.css({
+          position:"relative",top:0,"float":"right",width:self.opt.cursorwidth,height:"0px",
+          'background-color':self.opt.cursorcolor,
+          border:self.opt.cursorborder,
+          'background-clip':'padding-box',
+          '-webkit-border-radius':self.opt.cursorborderradius,
+          '-moz-border-radius':self.opt.cursorborderradius,
+          'border-radius':self.opt.cursorborderradius
+        });        
+        cursor.hborder = parseFloat(cursor.outerHeight() - cursor.innerHeight());        
+        self.cursor = cursor;        
+        
         var rail = $(document.createElement('div'));
         rail.attr('id',self.id);
-        rail.width = 4+parseFloat(self.opt.cursorwidth);
-        rail.css({"padding-left":"2px","padding-right":"1px",width:self.rail.width+"px",'zIndex':(self.ispage)?self.opt.zindex:self.opt.zindex+2,"background":self.opt.background});
+        rail.width = 3+Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth());
+        rail.css({"padding-left":"0px","padding-right":"1px",width:rail.width+"px",'zIndex':(self.ispage)?self.opt.zindex:self.opt.zindex+2,"background":self.opt.background});
+        
+        rail.append(cursor);
+        
         self.rail = rail;
         
         var zoom = false;
@@ -317,7 +328,7 @@
           self.zoom.css({"cursor":"pointer",'z-index':self.opt.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
           if (self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
           if (self.cantouch&&self.opt.gesturezoom) {
-            self.bind(self.win,"gesturechange",function(e) {
+            self.bind(self.win,"gestureend",function(e) {
               if (e.scale>1.5) self.doZoomIn(e);
               if (e.scale<0.8) self.doZoomOut(e);
               return self.cancelEvent(e);
@@ -344,19 +355,6 @@
           }
         }
         
-        var cursor = $(document.createElement('div'));
-        cursor.css({
-          position:"relative",top:0,left:0,width:self.opt.cursorwidth,height:"0px",
-          'background-color':self.opt.cursorcolor,
-          border:self.opt.cursorborder,
-          'background-clip':'padding-box',
-          '-webkit-border-radius':self.opt.cursorborderradius,
-          '-moz-border-radius':self.opt.cursorborderradius,
-          'border-radius':self.opt.cursorborderradius
-        });
-        self.cursor = cursor;
-        self.rail.append(cursor);
-        
         if (self.opt.autohidemode===false) {
           self.autohidedom = false;
         }
@@ -367,7 +365,9 @@
           self.autohidedom = self.cursor;
         }        
         
-        $(window).resize(self.onResize)
+        self.bind(window,'resize',self.onResize);
+        self.bind(window,'orientationchange',self.onResize);
+        
         if (!self.ispage&&!self.haswrapper) {
           self.bind(self.win,(self.isie&&!self.isie9)?"propertychange":"DOMAttrModified",self.onAttributeChange);
         }
@@ -375,26 +375,21 @@
         if (!self.ispage&&self.opt.boxzoom) $(window).resize(self.resizeZoom);
         if (self.istextarea) self.win.mouseup(self.onResize);
         self.onResize();
-
-        if (self.cantouch||self.opt.touchbehavior) {          
-          self.bind(self.win,"mousedown",function(e) {
-            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop(),lx:e.pageX,ly:e.pageY,nx:e.pageX,ny:e.pageY,tt:(new Date()).getTime(),lt:(new Date()).getTime()};
-            return self.cancelEvent(e);
-          });
-          self.bind(self.win,"mouseup",function(e) {
-            self.doScrollMomentum(self.rail.drag);
-            self.rail.drag = false;
-            return self.cancelEvent(e);
-          });
-          self.bind(self.rail,"mousedown",function(e) {
+        
+        if (self.cantouch||self.opt.touchbehavior) {
+          self.onmousedown = function(e) {
+            if (self.locked) return self.cancelEvent(e);
             self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop(),lx:e.pageX,ly:e.pageY,nx:e.pageX,ny:e.pageY,tt:(new Date()).getTime(),lt:(new Date()).getTime()};
             return self.cancelEvent(e);
-          });
-          self.bind(self.rail,"mouseup",function(e) {
-            self.rail.drag = false;
-            return self.cancelEvent(e);
-          });
-          self.bind(document,"mousemove",function(e) {
+          };
+          self.onmouseup = function(e) {
+            if (self.rail.drag) {
+              self.doScrollMomentum(self.rail.drag);
+              self.rail.drag = false;
+              return self.cancelEvent(e);
+            }
+          };
+          self.onmousemove = function(e) {
             if (self.rail.drag) {
               var my = (e.pageY-self.rail.drag.y);
               self.rail.drag.ly = self.rail.drag.ny;
@@ -409,19 +404,22 @@
               self.doScrollTo(self.rail.drag.st-my,true);
               return self.cancelEvent(e);
             }
-          });
+          };
+          
           if (self.cursorgrabvalue) self.win.css({'cursor':self.cursorgrabvalue});
         } else {
-          self.bind(self.rail,"mousedown",function(e) {
+          self.onmousedown = function(e) {
+            if (self.locked) return self.cancelEvent(e);
             self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y};
             return self.cancelEvent(e);
-          });
-          self.bind(self.rail,"mouseup",function(e) {
-            self.rail.drag = false;
-            self.hideCursor();
-            return self.cancelEvent(e);
-          });
-          self.bind(document,"mousemove",function(e) {
+          };
+          self.onmouseup = function(e) {
+            if (self.rail.drag) {
+              self.rail.drag = false;
+              return self.cancelEvent(e);
+            }
+          };        
+          self.onmousemove = function(e) {
             if (self.rail.drag) {
               self.scroll.y = self.rail.drag.sy + (e.screenY-self.rail.drag.y);
               if (self.scroll.y<0) self.scroll.y=0;
@@ -432,14 +430,22 @@
               self.doScroll(Math.round(self.scroll.y*self.scrollratio.y));          
               return self.cancelEvent(e);
             }
-          });
+          };
         }
 
-        self.bind(document,"mouseup",function(e) {
-          self.rail.drag = false;      
+        if (self.cantouch||self.opt.touchbehavior) self.bind(self.win,"mousedown",self.onmousedown);
+        self.bind(self.win,"mouseup",self.onmouseup);
+        
+        self.bind(self.rail,"mousedown",self.onmousedown);          
+        self.bind(self.rail,"mouseup",function(e) {
+          self.rail.drag = false;
           self.hideCursor();
+          return self.cancelEvent(e);
         });
         
+        self.bind(document,"mouseup",self.onmouseup);
+        self.bind(document,"mousemove",self.onmousemove);
+        
         if (!self.cantouch) {
           self.rail.mouseenter(function() {
             self.showCursor();
@@ -479,20 +485,27 @@
         //Thanks to http://www.quirksmode.org !!
         self.onkeypress = function(e) {
           e = (e) ? e : window.e;
-          var tg = self.getTarget(e);
-          if (tg&&/(INPUT|TEXTAREA|SELECT)/.test(tg.nodeName)) return;
+          var tg = self.getTarget(e);          
+          if (tg&&/INPUT|TEXTAREA|SELECT/.test(tg.nodeName)) {
+            var tp = tg.getAttribute('type')||tg.type||false;            
+            if ((!tp)||!(/submit|button|cancel/i.tp)) return true;
+          }
+          
           if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
-            var key = e.keyCode;     
+            var key = e.keyCode;
+            
+            if (self.locked&&key!=27) return self.cancelEvent(e);
+            
             var ret = true;
             switch (key) {
               case 38:
               case 63233: //safari
-                self.doScrollBy(12);
+                self.doScrollBy(24*3,true);
                 ret = false;
                 break;
               case 40:
               case 63235: //safari
-                self.doScrollBy(-12);
+                self.doScrollBy(-24*3,true);
                 ret = false;
                 break;
               case 33:
@@ -525,10 +538,65 @@
             if (!ret) return self.cancelEvent(e);
           }
         };
+        
         self.bind(document,(self.isopera)?"keypress":"keydown",self.onkeypress);
         
       }
       
+      if (this.doc[0].nodeName == 'IFRAME') {
+        function oniframeload(e) {
+          var doc = 'contentDocument' in this ? this.contentDocument : this.contentWindow.document;
+          if (self.isiframe) {
+            self.docscroll = $(doc);        
+            self.iframe = {
+              html:self.doc.contents().find('html')[0],
+              body:self.doc.contents().find('body')[0]
+            };
+          }
+          if (self.opt.iframeautoresize&&!self.isiframe) {
+            self.win.scrollTop(0); // reset position
+            self.doc.height("");  //reset height to fix browser bug
+            var cc=self.doc.contents();
+            var hh=Math.max(cc.find('html').attr('scrollHeight'),cc.find('body').attr('scrollHeight'));
+            self.doc.height(hh);          
+          }
+          self.onResize();
+          if (self.isie7) $(doc).find('html').css({'overflow-y':'hidden'});
+          $(doc.body).css({'overflow-y':'hidden'});          
+          if ('contentWindow' in this) {
+            self.bind(this.contentWindow,"scroll",self.onscroll);  //IE8 & minor
+          } else {          
+            self.bind(doc,"scroll",self.onscroll);
+          }          
+          self.bind(doc,"mouseup",self.onmouseup);
+          self.bind(doc,"mousewheel",self.onmousewheel);
+          self.bind(doc,(self.isopera)?"keypress":"keydown",self.onkeypress);          
+          if (self.cantouch||self.opt.touchbehavior) {
+            self.bind(doc,"mousedown",self.onmousedown);
+            if (self.cursorgrabvalue) $(doc).css({'cursor':self.cursorgrabvalue});
+          }
+          
+          self.bind(doc,"mousemove",self.onmousemove);
+          
+          if (self.zoom) {
+            if (self.opt.dblclickzoom) self.bind(doc,'dblclick',self.doZoom);
+            if (self.cantouch&&self.opt.gesturezoom) {
+              self.bind(doc,"gesturechange",function(e) {
+                if (e.scale>1.5) self.doZoomIn(e);
+                if (e.scale<0.8) self.doZoomOut(e);
+                return self.cancelEvent(e);
+              });             
+            }          
+          }
+        };
+        
+        if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
+          setTimeout(function(){oniframeload.call(self.doc[0],false)},500);
+        }
+        this.doc.load(oniframeload);
+        
+      }
+      
     };
     
     this.showCursor = function() {
@@ -537,8 +605,7 @@
         self.cursortimeout = 0;
       }
       if (!self.rail) return;
-      if (!self.autohidedom) return;
-      self.autohidedom.stop().css({opacity:self.opt.cursoropacitymax});
+      if (self.autohidedom) self.autohidedom.stop().css({opacity:self.opt.cursoropacitymax});
       self.cursor.css({height:self.cursorheight,top:self.scroll.y});
       if (self.zoom) self.zoom.stop().css({opacity:self.opt.cursoropacitymax});
     };
@@ -573,6 +640,11 @@
           w:self.doc.outerWidth()+parseInt(self.win.css('paddingLeft'))+parseInt(self.win.css('paddingRight')),
           h:self.doc.outerHeight()+parseInt(self.win.css('paddingTop'))+parseInt(self.win.css('paddingBottom'))
         } 
+        : (self.iframe) ?
+        {
+          w:Math.max(self.iframe.html.scrollWidth,self.iframe.body.scrollWidth),
+          h:Math.max(self.iframe.html.scrollHeight,self.iframe.body.scrollHeight)
+        }        
         :
         {
           w:self.docscroll[0].scrollWidth,
@@ -587,10 +659,9 @@
     
     this.onAttributeChange = function(e) {      
       if (e&&e.target) {
-        if (e.target !== self.win[0]) return true;
-        if (e.target !== self.doc[0]) return true;
-        var attr = ("attrChange" in e)?e.attrName:("propertyName" in e)?e.propertyName:false;      
-        if (attr&&/width|height|style/i.test(attr)) {
+        if ((e.target !== self.win[0])&&(e.target!==self.doc[0])) return true;
+        var attr = ("attrChange" in e)?e.attrName:("propertyName" in e)?e.propertyName:false;
+        if (attr&&/width|height|style|block/i.test(attr)) {
           if (self.lastattributechange) self.lastattributechange=clearTimeout(self.lastattributechange);
           self.lastattributechange = setTimeout(function(){
             self.lastattributechange = 0;
@@ -600,20 +671,41 @@
       }
     };
     
-    this.onResize = function() {      
+    this.onResize = function() {
+      if (!self.haswrapper&&!self.ispage) {        
+        var vis = (self.win.css('display')!='none');      
+        if (vis&&!self.visibility) self.show();
+        if (!vis&&self.visibility) self.hide();      
+        if (!self.visibility) return false;
+      }
+    
       self.view = {
         w:(self.ispage) ? self.win.width() : self.win.innerWidth(),
         h:(self.ispage) ? self.win.height() : self.win.innerHeight()
       };
-      if (self.istextarea&&self.win.css('resize')&&self.win.css('resize')!='none') self.view.h-=20;
-      
-      if (!self.ispage) self.updateScrollBar(self.view);
       
       self.page = self.getContentSize();
+
+      if (self.view.h>=self.page.h) {
+        self.hide();        
+        self.scrollvaluemax = 0;
+        self.scroll.y = 0;
+        self.scrollratio = {x:0,y:0};
+        self.cursorheight = 0;
+        self.locked = true;
+        self.setScrollTop(0);
+        return false;
+      } 
+      else if (!self.visibility) self.show();     
       
+      self.locked = false;
+      
+      if (self.istextarea&&self.win.css('resize')&&self.win.css('resize')!='none') self.view.h-=20;      
+      if (!self.ispage) self.updateScrollBar(self.view);
+
       self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
       
-      self.scrollvaluemax = self.view.h-self.cursorheight-2;
+      self.scrollvaluemax = self.view.h-self.cursorheight-self.cursor.hborder-2;
       
       self.scrollratio = {
         x:0,
@@ -636,6 +728,7 @@
         }
         el.addEventListener(name,fn,bubble||false);
         if (name=='mousewheel') el.addEventListener("DOMMouseScroll",fn,bubble||false);
+        if (self.cantouch && name=="mouseup") el.addEventListener("touchcancel",fn,bubble||false);
       } 
       else if (el.attachEvent) {
         el.attachEvent("on"+name,function(e) {
@@ -643,13 +736,13 @@
             e.pageX = e.screenX;
             e.pageY = e.screenY;
           }
-          if (!fn.call(el,e)||!bubble) return self.cancelEvent(e);
+          return ((fn.call(el,e)===false)||bubble===false) ? self.cancelEvent(e) : true;
         });
       } 
       else {
         el["on"+name] = function(e) {
           var rt=fn.call(el,e);          
-          if (!rt||!bubble) return self.cancelEvent(e);          
+          return (rt===false||bubble===false) ? self.cancelEvent(e) : true;
         };
       }
     };
@@ -657,7 +750,7 @@
     // Thanks to http://www.switchonthecode.com !!
     this.cancelEvent = function(e) {
       if (self.cantouch) {
-        e = e ? e.original : false;
+        e = e.original ? e.original : e||false;
       } else {
         e = e ? e : window.event||false;
       }
@@ -669,8 +762,19 @@
       e.returnValue = false;
       return false;
     };
-   
+
+    this.show = function() {
+      self.visibility = true;
+      self.rail.css('display','block');
+    };
+
+    this.hide = function() {
+      self.visibility = false;
+      self.rail.css('display','none');
+    };
+    
     this.onmousewheel = function(e) {
+      if (self.locked) return self.cancelEvent(e);
       e = e ? e : window.event;
       if (self.rail.drag) return self.cancelEvent(e);
       var delta = 0;      
@@ -682,7 +786,7 @@
     };
     
     this.stop = function() {
-      if (self.timer) clearInterval(self.timer);
+      if (self.timer) clearAnimationFrame(self.timer);
       self.timer = 0;
       self.cursorfreezed = false;
       self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));      
@@ -711,22 +815,33 @@
         },self.opt.scrollspeed);
         self.noticeCursor();
       };
-//      self.bind(self.doc,'transitionend',function(e){console.log(e)},false); TEST!!
+//      self.bind(self.doc,'transitionend',function(e){console.log(e)},false); TEST!! Later or soon I use it! (I hope so)
     } else {
       this.doScroll = function(y) {
         self.newscrolly = y;
         if (self.timer) return;
-        self.timer = setInterval(function() {
+        var rt = 1/4; //*(60/self.opt.scrollspeed));        
+        var sync = 0;
+        var lastsync = 0;
+        function scrolling() {
+          sync=(new Date()).getTime();
+          if (sync<lastsync) return (self.timer = setAnimationFrame(scrolling));
+          lastsync = (new Date()).getTime()+self.opt.scrollspeed;
+          sync=0;
           var gp = self.newscrolly - self.getScrollTop();
-          var df = (gp>0) ? Math.ceil(gp/4) : Math.floor(gp/4);
+          var df = (gp>0) ? Math.ceil(gp*rt) : Math.floor(gp*rt);
           var sc = self.getScrollTop()+df;
           self.setScrollTop(sc);     
           if (sc == self.newscrolly) {
-            clearInterval(self.timer);
+//            clearAnimationFrame(self.timer);
             self.timer = 0;        
             self.cursorfreezed = false;
+          } else {
+            self.timer = setAnimationFrame(scrolling);
           }
-        },self.opt.scrollspeed);
+        };        
+        self.timer = setAnimationFrame(scrolling);
+        
         self.noticeCursor();
       };
     }
@@ -740,18 +855,6 @@
       self.cursorfreezed = false;
       self.doScroll(Math.floor(ny*self.scrollratio.y));
     };
-
-    /*
-    this.doScrollBy = function(stp,absolute) {
-      var ny = (absolute)?self.scroll.y-Math.round(stp * 1/self.scrollratio.y):self.scroll.y-stp;
-      if (ny<0) stp=0;
-      var my = self.scrollvaluemax;
-      if (ny>my) stp=(absolute)?Math.round(my*self.scrollratio.y):my;
-      self.cursorfreezed = false;
-      console.log((absolute)?stp:Math.round(stp*self.scrollratio.y));
-      self.doScroll((absolute)?stp:Math.round(stp*self.scrollratio.y));
-    };
-    */
     
     this.doScrollTo = function(pos,absolute) {
       ny=(absolute)?Math.round(pos * 1/self.scrollratio.y):pos;
@@ -765,12 +868,8 @@
     this.doScrollMomentum = function(mom) {
       var dy = mom.ly-mom.ny;
       var tt = ((new Date()).getTime()-mom.lt);
-      if ((Math.abs(dy)>1)&&(tt<601)) {        
-        var my = dy;
-//        if (dy<0) my=-my;
-//        console.log(my+' '+tt);
-        self.doScrollBy(my,true);
-      }
+      var my = Math.floor((dy*3)/((tt+1)*0.2));
+      if (my) self.doScrollBy(my,true);
     };
     
     self.onscroll = function(e) {    
@@ -790,6 +889,7 @@
     
     this.doZoomIn = function(e) {
       if (self.zoomactive) return;
+      self.zoomactive = true;
       
       self.zoomrestore = {
         style:{}
@@ -824,8 +924,7 @@
       var bkg = self.win.css("backgroundColor");      
       if (bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor","#fff");
       self.rail.css({"z-index":self.opt.zindex+110});
-      self.zoom.css({"z-index":self.opt.zindex+112});
-      self.zoomactive = true;
+      self.zoom.css({"z-index":self.opt.zindex+112});      
       self.zoom.css('backgroundPosition','0px -18px');
       self.resizeZoom();                
       return self.cancelEvent(e);
@@ -833,6 +932,7 @@
 
     this.doZoomOut = function(e) {
       if (!self.zoomactive) return;
+      self.zoomactive = false;
       
       self.win.css("margin","");
       self.win.css(self.zoomrestore.style);
@@ -843,10 +943,9 @@
       
       self.rail.css({"z-index":(self.ispage)?self.opt.zindex:self.opt.zindex+2});
       self.zoom.css({"z-index":self.opt.zindex});
-      self.zoomactive = false;
       self.zoomrestore = false;
       self.zoom.css('backgroundPosition','0px 0px');
-      self.win.resize();
+      self.onResize();
       return self.cancelEvent(e);
     };
     
@@ -864,7 +963,7 @@
       });
       self.setScrollTop(py);
       
-      self.win.resize();
+      self.onResize();
     };
    
     this.init();

+ 43 - 39
jquery.nicescroll.min.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.2.0
+-- version 2.3.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -7,41 +7,45 @@
 -- https://github.com/inuyaksa/jquery.nicescroll
 --
 */
-(function(e){var k=false,l=false,n=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("/")+"/":""}(),m=function(f){var b=this;this.opt={doc:e("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,hwacceleration:true,usetransition:true,boxzoom:false,
-dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:""};if(f)for(var g in b.opt)f[g]!==void 0&&(b.opt[g]=f[g]);this.id=b.opt.doc[0].id||"";this.doc=b.opt.doc;this.ispage=b.doc[0].nodeName=="BODY"||b.doc[0].nodeName=="HTML";this.haswrapper=b.opt.win!==false;this.win=b.opt.win||(this.ispage?e(window):this.doc);this.docscroll=this.ispage?e(window):this.win;this.isiframe=this.doc[0].nodeName=="IFRAME"&&this.win[0].nodeName=="IFRAME";this.istextarea=this.win[0].nodeName==
-"TEXTAREA";if(this.doc[0].nodeName=="IFRAME"){var j=function(){var c="contentDocument"in this?this.contentDocument:this.contentWindow.document;if(b.isiframe)b.docscroll=e(c.body);b.onResize();e(c.body).css({"overflow-y":"hidden"});e(c).scroll(b.onscroll);e(c).mouseup(function(){b.rail.drag=false});b.bind(c,"mousewheel",b.onmousewheel);e(c).keydown(b.onkeypress);if(b.cantouch||b.opt.touchbehavior)b.cursorgrabvalue&&e(c).css({cursor:b.cursorgrabvalue}),b.bind(c,"mousedown",function(c){b.rail.drag={x:c.pageX,
-y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop()};return b.cancelEvent(c)}),b.bind(c,"mouseup",function(c){b.rail.drag=false;return b.cancelEvent(c)}),b.bind(c,"mousemove",function(c){if(b.rail.drag)return b.doScrollTo(b.rail.drag.st-(c.pageY-b.rail.drag.y),true),b.cancelEvent(c)});b.zoom&&(b.bind(c,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(c,"gesturechange",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)}))};this.doc[0].readyState&&
-this.doc[0].readyState=="complete"?setTimeout(function(){j.call(b.doc[0],false)},1E3):this.doc.load(j)}this.page=this.view=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));this.locked=this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;var i=document.createElement("DIV");this.isopera="opera"in window;this.isieold=
-(this.isie="all"in document&&"attachEvent"in i&&!this.isopera)&&!("msInterpolationMode"in i.style);this.isie7=this.isie&&(!("documentMode"in document)||document.documentMode==7);this.isie8=this.isie&&"documentMode"in document&&document.documentMode==8;this.isie9=this.isie&&"performance"in window&&document.documentMode>=9;this.ismozilla="MozAppearance"in i.style;(this.cantouch="ontouchstart"in document.documentElement)&&/iphone|ipad|ipod/i.test(navigator.platform)?(this.isios=true,this.isios4=!("seal"in
-Object)):this.isios4=this.isios=false;if(b.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":i.style.webkitTransform!==void 0?"webkitTransform":i.style.MozTransform!==void 0?"MozTransform":false)&&i.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)i.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(i.style[this.trstyle]);this.transitionstyle=false;this.prefixstyle="";this.transitionend=
-false;var f="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(","),m=",-webkit-,-moz-,-o-,-ms-,-khtml-".split(","),o="transitionEnd,webkitTransitionEnd,transitionend,oTransitionEnd,msTransitionEnd,KhtmlTransitionEnd".split(",");for(g=0;g<f.length;g++)if(f[g]in i.style){this.transitionstyle=f[g];this.prefixstyle=m[g];this.transitionend=o[g];break}this.hastransition=this.transitionstyle}else this.hastransition=this.transitionstyle=this.hastransform=this.trstyle=
-false;this.cursorgrabvalue="";if(b.opt.grabcursorenabled&&b.opt.touchbehavior)this.cursorgrabvalue=function(){if(!b.isie||b.isie9)for(var c=["grab","-moz-grab","-webkit-grab"],d=0;d<c.length;d++){var h=c[d];i.style.cursor=h;if(i.style.cursor==h)return h}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}();i=null;this.ishwscroll=b.hastransform&&b.opt.hwacceleration&&b.haswrapper;this.scrollTop=function(c){return c===void 0?b.getScrollTop():b.setScrollTop(c)};this.ishwscroll?
-(b.doc.translate={x:0,y:0},this.getScrollTop=function(){return b.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(c,d){b.doc.css(b.trstyle,"translate3d(0px,"+c*-1+"px,0px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var h=document.createEvent("UIEvents");h.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(h)}else h=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),h.cancelBubble=true}:function(c,d){b.doc.css(b.trstyle,"translate(0px,"+c*
--1+"px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var h=document.createEvent("UIEvents");h.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(h)}else h=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),h.cancelBubble=true}):(this.getScrollTop=function(){return b.docscroll.scrollTop()},this.setScrollTop=function(c){return b.docscroll.scrollTop(c)});this.getTarget=function(b){return!b?false:b.target?b.target:b.srcElement?b.srcElement:false};this.hasParent=
-function(b,d){if(!b)return false;for(var h=b.target||b.srcElement||b||false;h&&h.id!=d;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(c){if(b.ishwscroll)b.rail.css({height:b.win.innerHeight()});else{var d=b.win.offset();d.top+=2;d.left+=b.win.outerWidth()-b.rail.width-4;b.rail.css({position:"absolute",top:d.top,left:d.left,height:c?c.h:b.win.outerHeight()});b.zoom&&b.zoom.css({position:"absolute",top:d.top+1,left:d.left-18})}};this.init=function(){if(!b.ispage||!b.cantouch&&
-!b.isieold){b.ispage?b.doc.css({"overflow-y":"hidden"}):b.docscroll.css({"overflow-y":"hidden"});b.ispage&&b.isie7&&e("html").css({"overflow-y":"hidden"});var c=e(document.createElement("div"));c.attr("id",b.id);c.width=4+parseFloat(b.opt.cursorwidth);c.css({"padding-left":"2px","padding-right":"1px",width:b.rail.width+"px",zIndex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});b.rail=c;var d=false;if(b.opt.boxzoom&&!b.ispage&&!b.isieold)d=document.createElement("div"),b.bind(d,
-"click",b.doZoom),b.zoom=e(d),b.zoom.css({cursor:"pointer","z-index":b.opt.zindex,backgroundImage:"url("+n+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),b.opt.dblclickzoom&&b.bind(b.win,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(b.win,"gesturechange",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)});b.ispage?(c.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),b.doc.append(c)):b.ishwscroll?(b.win.css("position")==
-"static"&&b.win.css("position","relative"),b.zoom&&(b.zoom.css({position:"absolute",top:1,right:0,"margin-right":c.width+2}),b.win.append(b.zoom)),c.css({position:"absolute",top:0,right:0}),b.win.append(c)):(b.updateScrollBar(),e("body").append(c),b.zoom&&e("body").append(b.zoom));c=e(document.createElement("div"));c.css({position:"relative",top:0,left:0,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});b.cursor=c;b.rail.append(c);if(b.opt.autohidemode===false)b.autohidedom=false;else if(b.opt.autohidemode===true)b.autohidedom=b.rail;else if(b.opt.autohidemode=="cursor")b.autohidedom=b.cursor;e(window).resize(b.onResize);!b.ispage&&!b.haswrapper&&b.bind(b.win,b.isie&&!b.isie9?"propertychange":"DOMAttrModified",b.onAttributeChange);!b.ispage&&b.opt.boxzoom&&e(window).resize(b.resizeZoom);b.istextarea&&b.win.mouseup(b.onResize);
-b.onResize();b.cantouch||b.opt.touchbehavior?(b.bind(b.win,"mousedown",function(c){b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)}),b.bind(b.win,"mouseup",function(c){b.doScrollMomentum(b.rail.drag);b.rail.drag=false;return b.cancelEvent(c)}),b.bind(b.rail,"mousedown",function(c){b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),
-lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)}),b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;return b.cancelEvent(c)}),b.bind(document,"mousemove",function(c){if(b.rail.drag){var d=c.pageY-b.rail.drag.y;b.rail.drag.ly=b.rail.drag.ny;b.rail.drag.ny=c.pageY;b.rail.drag.lt=(new Date).getTime();b.scroll.y=Math.round((b.rail.drag.st-d)*(1/b.scrollratio.y));if(b.scroll.y<0)b.scroll.y=0;if(b.scroll.y>b.scrollvaluemax)b.scroll.y=
-b.scrollvaluemax;b.showCursor();b.doScrollTo(b.rail.drag.st-d,true);return b.cancelEvent(c)}}),b.cursorgrabvalue&&b.win.css({cursor:b.cursorgrabvalue})):(b.bind(b.rail,"mousedown",function(c){b.rail.drag={x:c.screenX,y:c.screenY,sx:b.scroll.x,sy:b.scroll.y};return b.cancelEvent(c)}),b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;b.hideCursor();return b.cancelEvent(c)}),b.bind(document,"mousemove",function(c){if(b.rail.drag){b.scroll.y=b.rail.drag.sy+(c.screenY-b.rail.drag.y);if(b.scroll.y<
-0)b.scroll.y=0;var d=b.scrollvaluemax;if(b.scroll.y>d)b.scroll.y=d;b.showCursor();b.cursorfreezed=true;b.doScroll(Math.round(b.scroll.y*b.scrollratio.y));return b.cancelEvent(c)}}));b.bind(document,"mouseup",function(){b.rail.drag=false;b.hideCursor()});b.cantouch||(b.rail.mouseenter(function(){b.showCursor();b.rail.active=true}),b.rail.mouseleave(function(){b.rail.active=false;b.rail.drag||b.hideCursor()}),b.isiframe||b.bind(b.isie&&b.ispage?document:b.docscroll,"mousewheel",b.onmousewheel),b.bind(b.rail,
-"mousewheel",b.onmousewheel));!b.ispage&&!b.cantouch&&(b.win.attr("tabindex")||b.win.attr({tabindex:(new Date).getTime()}),b.win.focus(function(c){k=b.getTarget(c).id||true;b.hasfocus=true;b.noticeCursor()}),b.win.blur(function(){k=false;b.hasfocus=false}),b.win.mouseenter(function(c){l=b.getTarget(c).id||true;b.hasmousefocus=true;b.noticeCursor()}),b.win.mouseleave(function(){l=false;b.hasmousefocus=false}));b.onkeypress=function(c){var c=c?c:window.e,d=b.getTarget(c);if(!d||!/(INPUT|TEXTAREA|SELECT)/.test(d.nodeName))if(b.hasfocus||
-b.hasmousefocus&&!k||b.ispage&&!k&&!l){d=true;switch(c.keyCode){case 38:case 63233:b.doScrollBy(12);d=false;break;case 40:case 63235:b.doScrollBy(-12);d=false;break;case 33:case 63276:b.doScrollBy(b.view.h,true);d=false;break;case 34:case 63277:b.doScrollBy(-b.view.h,true);d=false;break;case 36:case 63273:b.doScrollTo(0,true);d=false;break;case 35:case 63275:b.doScrollTo(b.page.h,true);d=false;break;case 27:b.zoomactive&&(b.doZoom(),d=false)}if(!d)return b.cancelEvent(c)}};b.bind(document,b.isopera?
-"keypress":"keydown",b.onkeypress)}};this.showCursor=function(){if(b.cursortimeout)clearTimeout(b.cursortimeout),b.cursortimeout=0;b.rail&&b.autohidedom&&(b.autohidedom.stop().css({opacity:b.opt.cursoropacitymax}),b.cursor.css({height:b.cursorheight,top:b.scroll.y}),b.zoom&&b.zoom.stop().css({opacity:b.opt.cursoropacitymax}))};this.hideCursor=function(c){if(!b.cursortimeout&&b.rail&&b.autohidedom)b.cursortimeout=setTimeout(function(){b.rail.active||(b.autohidedom.stop().animate({opacity:b.opt.cursoropacitymin}),
-b.zoom&&b.zoom.stop().animate({opacity:b.opt.cursoropacitymin}));b.cursortimeout=0},c||800)};this.noticeCursor=function(c){b.showCursor();b.hideCursor(c)};this.getContentSize=function(){var c=b.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:b.haswrapper?{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"))}:{w:b.docscroll[0].scrollWidth,h:b.docscroll[0].scrollHeight};c.w-=1;c.h-=1;return c};this.onAttributeChange=function(c){if(c&&c.target){if(c.target!==b.win[0])return true;if(c.target!==b.doc[0])return true;if((c="attrChange"in c?c.attrName:"propertyName"in c?c.propertyName:false)&&/width|height|style/i.test(c)){if(b.lastattributechange)b.lastattributechange=clearTimeout(b.lastattributechange);b.lastattributechange=setTimeout(function(){b.lastattributechange=0;
-b.onResize()},60)}}};this.onResize=function(){b.view={w:b.ispage?b.win.width():b.win.innerWidth(),h:b.ispage?b.win.height():b.win.innerHeight()};b.istextarea&&b.win.css("resize")&&b.win.css("resize")!="none"&&(b.view.h-=20);b.ispage||b.updateScrollBar(b.view);b.page=b.getContentSize();b.cursorheight=Math.min(b.view.h,Math.round(b.view.h*(b.view.h/b.page.h)));b.scrollvaluemax=b.view.h-b.cursorheight-2;b.scrollratio={x:0,y:(b.page.h-b.view.h)/b.scrollvaluemax};b.scroll.y=Math.round(b.getScrollTop()*
-(1/b.scrollratio.y));b.noticeCursor()};this.bind=function(c,d,e,f){var g=c.length?c[0]:c;g.addEventListener?(b.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&g.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(b){if(b.touches.length<2){var c=b.touches.length>0?b.touches[0]:b;c.original=b;e.call(this,c)}},f||false),g.addEventListener(d,e,f||false),d=="mousewheel"&&g.addEventListener("DOMMouseScroll",e,f||false)):g.attachEvent?g.attachEvent("on"+d,function(c){if(c&&
-!("pageY"in c)&&"screenY"in c)c.pageX=c.screenX,c.pageY=c.screenY;if(!e.call(g,c)||!f)return b.cancelEvent(c)}):g["on"+d]=function(c){if(!e.call(g,c)||!f)return b.cancelEvent(c)}};this.cancelEvent=function(c){c=b.cantouch?c?c.original:false:c?c:window.event||false;if(!c)return false;c.stopPropagation&&c.stopPropagation();c.preventDefault&&c.preventDefault();c.cancelBubble=true;c.cancel=true;return c.returnValue=false};this.onmousewheel=function(c){c=c?c:window.event;if(b.rail.drag)return b.cancelEvent(c);
-var d=0;(d=c.detail?c.detail*-1:c.wheelDelta/40)&&b.doScrollBy(d*b.opt.mousescrollstep,true);return b.cancelEvent(c)};this.stop=function(){b.timer&&clearInterval(b.timer);b.timer=0;b.cursorfreezed=false;b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};b.ishwscroll&&b.hastransition&&b.opt.usetransition?(this.prepareTransition=function(c){var d=Math.round(b.opt.scrollspeed*10),c=Math.min(d,Math.round(c/20*b.opt.scrollspeed)),c=c>20?b.prefixstyle+"transform "+c+"ms ease-out 0s":
-"";if(!b.lasttransitionstyle||b.lasttransitionstyle!=c)b.lasttransitionstyle=c,b.doc.css(b.transitionstyle,c)},this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setTimeout(function(){var c=b.getScrollTop();b.prepareTransition(c>b.newscrolly?c-b.newscrolly:b.newscrolly-c);b.setScrollTop(b.newscrolly);b.timer=0},b.opt.scrollspeed),b.noticeCursor()}):this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setInterval(function(){var c=b.newscrolly-b.getScrollTop(),c=c>0?Math.ceil(c/4):
-Math.floor(c/4),c=b.getScrollTop()+c;b.setScrollTop(c);if(c==b.newscrolly)clearInterval(b.timer),b.timer=0,b.cursorfreezed=false},b.opt.scrollspeed),b.noticeCursor()};this.doScrollBy=function(c,d){d&&(c=Math.round(c*1/b.scrollratio.y));var e=b.scroll.y-c;e<0&&(e=0);var f=b.scrollvaluemax;e>f&&(e=f);b.cursorfreezed=false;b.doScroll(Math.floor(e*b.scrollratio.y))};this.doScrollTo=function(c,d){ny=d?Math.round(c*1/b.scrollratio.y):c;ny<0&&(c=0);var e=b.scrollvaluemax;ny>e&&(c=d?Math.round(e*b.scrollratio.y):
-e);b.cursorfreezed=false;b.doScroll(d?c:Math.round(c*b.scrollratio.y))};this.doScrollMomentum=function(c){var d=c.ly-c.ny,c=(new Date).getTime()-c.lt;Math.abs(d)>1&&c<601&&b.doScrollBy(d,true)};b.onscroll=function(){var c=(new Date).getTime();if(!b.lastcontentcheck||b.lastcontentcheck<c)if(b.lastcontentcheck=c+500,b.getContentSize().h!=b.page.h)b.onResize();if(!b.rail.drag){if(!b.cursorfreezed)b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()}};b.docscroll.scroll(function(c){b.onscroll(c)});
-this.doZoomIn=function(c){if(!b.zoomactive){b.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,marginTop,marginBottom,marginLeft,marginRight".split(","),f=b.win[0].style,g;for(g in d){var i=d[g];b.zoomrestore.style[i]=typeof f[i]!="undefined"?f[i]:""}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(b.isios4)b.zoomrestore.scrollTop=e(window).scrollTop(),
-e(window).scrollTop(0);b.win.css({position:b.isios4?"absolute":"fixed",top:0,left:0,"z-index":b.opt.zindex+100,margin:"0px"});d=b.win.css("backgroundColor");(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&b.win.css("backgroundColor","#fff");b.rail.css({"z-index":b.opt.zindex+110});b.zoom.css({"z-index":b.opt.zindex+112});b.zoomactive=true;b.zoom.css("backgroundPosition","0px -18px");b.resizeZoom();return b.cancelEvent(c)}};this.doZoomOut=function(c){if(b.zoomactive)return b.win.css("margin",
-""),b.win.css(b.zoomrestore.style),b.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.zoomactive=false,b.zoomrestore=false,b.zoom.css("backgroundPosition","0px 0px"),b.win.resize(),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.setScrollTop(c);b.win.resize()}};this.init()};e.fn.niceScroll=function(f,b){typeof f=="object"&&typeof b=="undefined"&&(b=f,f=false);var g=[];typeof b=="undefined"&&(b={});if(f)b.doc=e(f),b.win=e(this);var j=!("doc"in b);this.each(function(){var f=e(this).data("__nicescroll")||false;if(!f)b.doc=j?e(this):b.doc,f=new m(b),e(this).data("__nicescroll",f);g.push(f)});return g.length==1?g[0]:g};var j=jQuery.fn.scrollTop;e.cssHooks.scrollTop=
-{get:function(f){var b=e.data(f,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(f)},set:function(f,b){var g=e.data(f,"__nicescroll")||false;g&&g.ishwscroll?g.setScrollTop(parseInt(b)):j.call(f,b);return this}};jQuery.fn.scrollTop=function(f){if(typeof f=="undefined"){var b=e.data(this,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(this)}else return this.each(function(){var b=e.data(this,"__nicescroll")||false;b&&b.ishwscroll?b.setScrollTop(parseInt(f)):
-j.call(e(this),f)})};jQuery.fn.getNiceScroll=function(f){if(typeof f=="undefined"){for(a=0;a<this.length;a++)if(f=e.data(this[a],"__nicescroll")||false)return f;return false}else return f=e.data(this[f],"__nicescroll")||false}})(jQuery);
+(function(g){var l=false,m=false,o=function(){var f=document.getElementsByTagName("script"),f=f[f.length-1].src.split("?")[0];return f.split("/").length>0?f.split("/").slice(0,-1).join("/")+"/":""}(),q=function(f){var b=this;this.version="2.3.0";this.name="nicescroll";this.opt={doc:g("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"5px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,
+hwacceleration:true,usetransition:true,boxzoom:false,dblclickzoom:true,gesturezoom:true,grabcursorenabled:true,autohidemode:true,background:"",iframeautoresize:true};if(f)for(var h in b.opt)f[h]!==void 0&&(b.opt[h]=f[h]);this.id=b.opt.doc[0].id||"";this.doc=b.opt.doc;this.ispage=b.doc[0].nodeName=="BODY"||b.doc[0].nodeName=="HTML";this.haswrapper=b.opt.win!==false;this.win=b.opt.win||(this.ispage?g(window):this.doc);this.docscroll=this.ispage?g(window):this.win;this.iframe=false;this.isiframe=this.doc[0].nodeName==
+"IFRAME"&&this.win[0].nodeName=="IFRAME";this.istextarea=this.win[0].nodeName=="TEXTAREA";this.page=this.view=this.onkeypress=this.onmousewheel=this.onmousemove=this.onmouseup=this.onmousedown=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;this.visibility=
+true;this.locked=false;var i=document.createElement("DIV");this.isopera="opera"in window;this.isieold=(this.isie="all"in document&&"attachEvent"in i&&!this.isopera)&&!("msInterpolationMode"in i.style);this.isie7=this.isie&&!this.isieold&&(!("documentMode"in document)||document.documentMode==7);this.isie8=this.isie&&"documentMode"in document&&document.documentMode==8;this.isie9=this.isie&&"performance"in window&&document.documentMode>=9;this.ismozilla="MozAppearance"in i.style;(this.cantouch="ontouchstart"in
+document.documentElement)&&/iphone|ipad|ipod/i.test(navigator.platform)?(this.isios=true,this.isios4=!("seal"in Object)):this.isios4=this.isios=false;if(b.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":i.style.webkitTransform!==void 0?"webkitTransform":i.style.MozTransform!==void 0?"MozTransform":false)&&i.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)i.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=
+/translate3d/.test(i.style[this.trstyle]);this.transitionstyle=false;this.prefixstyle="";this.transitionend=false;var f="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(","),p=",-webkit-,-moz-,-o-,-ms-,-khtml-".split(","),j="transitionEnd,webkitTransitionEnd,transitionend,oTransitionEnd,msTransitionEnd,KhtmlTransitionEnd".split(",");for(h=0;h<f.length;h++)if(f[h]in i.style){this.transitionstyle=f[h];this.prefixstyle=p[h];this.transitionend=j[h];break}this.hastransition=
+this.transitionstyle}else this.transitionend=this.hastransition=this.transitionstyle=this.hastranslate3d=this.hastransform=this.trstyle=false;this.cursorgrabvalue="";if(b.opt.grabcursorenabled&&b.opt.touchbehavior)this.cursorgrabvalue=function(){if(!b.isie||b.isie9)for(var c=["grab","-moz-grab","-webkit-grab"],d=0;d<c.length;d++){var e=c[d];i.style.cursor=e;if(i.style.cursor==e)return e}return"url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize"}();i=null;this.ishwscroll=b.hastransform&&
+b.opt.hwacceleration&&b.haswrapper;this.scrollTop=function(c){return c===void 0?b.getScrollTop():b.setScrollTop(c)};this.ishwscroll?(b.doc.translate={x:0,y:0},this.getScrollTop=function(){return b.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(c,d){b.doc.css(b.trstyle,"translate3d(0px,"+c*-1+"px,0px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var e=document.createEvent("UIEvents");e.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(e)}else e=document.createEventObject(),
+b.docscroll[0].fireEvent("onscroll"),e.cancelBubble=true}:function(c,d){b.doc.css(b.trstyle,"translate(0px,"+c*-1+"px)");b.doc.translate.y=c;if(!d)if(document.createEvent){var e=document.createEvent("UIEvents");e.initUIEvent("scroll",false,true,window,1);b.docscroll[0].dispatchEvent(e)}else e=document.createEventObject(),b.docscroll[0].fireEvent("onscroll"),e.cancelBubble=true}):(this.getScrollTop=function(){return b.docscroll.scrollTop()},this.setScrollTop=function(c){return b.docscroll.scrollTop(c)});
+this.getTarget=function(b){return!b?false:b.target?b.target:b.srcElement?b.srcElement:false};this.hasParent=function(b,d){if(!b)return false;for(var e=b.target||b.srcElement||b||false;e&&e.id!=d;)e=e.parentNode||false;return e!==false};this.updateScrollBar=function(c){if(b.ishwscroll)b.rail.css({height:b.win.innerHeight()});else{var d=b.win.offset();d.top+=2;var e=(b.win.outerWidth()-b.win.innerWidth())/2;d.left+=b.win.innerWidth()+e-b.rail.width-1;b.rail.css({position:"absolute",top:d.top,left:d.left,
+height:c?c.h:b.win.innerHeight()});b.zoom&&b.zoom.css({position:"absolute",top:d.top+1,left:d.left-18})}};var k=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||false,n=window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||false;b.hasanimationframe=k;
+b.hascancelanimationframe=n;b.hasanimationframe||(k=function(b){return setTimeout(b,1E3/60)});b.hascancelanimationframe||(n=clearInterval);this.init=function(){if(!b.ispage||!b.cantouch&&!b.isieold){b.ispage?b.doc.css({"overflow-y":"hidden"}):b.docscroll.css({"overflow-y":"hidden"});b.ispage&&b.isie7&&g("html").css({"overflow-y":"hidden"});var c=g(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 d=g(document.createElement("div"));d.attr("id",b.id);d.width=3+Math.max(parseFloat(b.opt.cursorwidth),c.outerWidth());d.css({"padding-left":"0px","padding-right":"1px",width:d.width+"px",zIndex:b.ispage?b.opt.zindex:b.opt.zindex+2,background:b.opt.background});
+d.append(c);b.rail=d;c=false;if(b.opt.boxzoom&&!b.ispage&&!b.isieold)c=document.createElement("div"),b.bind(c,"click",b.doZoom),b.zoom=g(c),b.zoom.css({cursor:"pointer","z-index":b.opt.zindex,backgroundImage:"url("+o+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),b.opt.dblclickzoom&&b.bind(b.win,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(b.win,"gestureend",function(c){c.scale>1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)});b.ispage?(d.css({position:"fixed",
+top:"0px",right:"0px",height:"100%"}),b.doc.append(d)):b.ishwscroll?(b.win.css("position")=="static"&&b.win.css("position","relative"),b.zoom&&(b.zoom.css({position:"absolute",top:1,right:0,"margin-right":d.width+2}),b.win.append(b.zoom)),d.css({position:"absolute",top:0,right:0}),b.win.append(d)):(b.updateScrollBar(),g("body").append(d),b.zoom&&g("body").append(b.zoom));if(b.opt.autohidemode===false)b.autohidedom=false;else if(b.opt.autohidemode===true)b.autohidedom=b.rail;else if(b.opt.autohidemode==
+"cursor")b.autohidedom=b.cursor;b.bind(window,"resize",b.onResize);b.bind(window,"orientationchange",b.onResize);!b.ispage&&!b.haswrapper&&b.bind(b.win,b.isie&&!b.isie9?"propertychange":"DOMAttrModified",b.onAttributeChange);!b.ispage&&b.opt.boxzoom&&g(window).resize(b.resizeZoom);b.istextarea&&b.win.mouseup(b.onResize);b.onResize();b.cantouch||b.opt.touchbehavior?(b.onmousedown=function(c){if(b.locked)return b.cancelEvent(c);b.rail.drag={x:c.pageX,y:c.pageY,sx:b.scroll.x,sy:b.scroll.y,st:b.getScrollTop(),
+lx:c.pageX,ly:c.pageY,nx:c.pageX,ny:c.pageY,tt:(new Date).getTime(),lt:(new Date).getTime()};return b.cancelEvent(c)},b.onmouseup=function(c){if(b.rail.drag)return b.doScrollMomentum(b.rail.drag),b.rail.drag=false,b.cancelEvent(c)},b.onmousemove=function(c){if(b.rail.drag){var d=c.pageY-b.rail.drag.y;b.rail.drag.ly=b.rail.drag.ny;b.rail.drag.ny=c.pageY;b.rail.drag.lt=(new Date).getTime();b.scroll.y=Math.round((b.rail.drag.st-d)*(1/b.scrollratio.y));if(b.scroll.y<0)b.scroll.y=0;if(b.scroll.y>b.scrollvaluemax)b.scroll.y=
+b.scrollvaluemax;b.showCursor();b.doScrollTo(b.rail.drag.st-d,true);return b.cancelEvent(c)}},b.cursorgrabvalue&&b.win.css({cursor:b.cursorgrabvalue})):(b.onmousedown=function(c){if(b.locked)return b.cancelEvent(c);b.rail.drag={x:c.screenX,y:c.screenY,sx:b.scroll.x,sy:b.scroll.y};return b.cancelEvent(c)},b.onmouseup=function(c){if(b.rail.drag)return b.rail.drag=false,b.cancelEvent(c)},b.onmousemove=function(c){if(b.rail.drag){b.scroll.y=b.rail.drag.sy+(c.screenY-b.rail.drag.y);if(b.scroll.y<0)b.scroll.y=
+0;var d=b.scrollvaluemax;if(b.scroll.y>d)b.scroll.y=d;b.showCursor();b.cursorfreezed=true;b.doScroll(Math.round(b.scroll.y*b.scrollratio.y));return b.cancelEvent(c)}});(b.cantouch||b.opt.touchbehavior)&&b.bind(b.win,"mousedown",b.onmousedown);b.bind(b.win,"mouseup",b.onmouseup);b.bind(b.rail,"mousedown",b.onmousedown);b.bind(b.rail,"mouseup",function(c){b.rail.drag=false;b.hideCursor();return b.cancelEvent(c)});b.bind(document,"mouseup",b.onmouseup);b.bind(document,"mousemove",b.onmousemove);b.cantouch||
+(b.rail.mouseenter(function(){b.showCursor();b.rail.active=true}),b.rail.mouseleave(function(){b.rail.active=false;b.rail.drag||b.hideCursor()}),b.isiframe||b.bind(b.isie&&b.ispage?document:b.docscroll,"mousewheel",b.onmousewheel),b.bind(b.rail,"mousewheel",b.onmousewheel));!b.ispage&&!b.cantouch&&(b.win.attr("tabindex")||b.win.attr({tabindex:(new Date).getTime()}),b.win.focus(function(c){l=b.getTarget(c).id||true;b.hasfocus=true;b.noticeCursor()}),b.win.blur(function(){l=false;b.hasfocus=false}),
+b.win.mouseenter(function(c){m=b.getTarget(c).id||true;b.hasmousefocus=true;b.noticeCursor()}),b.win.mouseleave(function(){m=false;b.hasmousefocus=false}));b.onkeypress=function(c){var c=c?c:window.e,d=b.getTarget(c);if(d&&/INPUT|TEXTAREA|SELECT/.test(d.nodeName)&&(!d.getAttribute("type")&&!d.type||!/submit|button|cancel/i.tp))return true;if(b.hasfocus||b.hasmousefocus&&!l||b.ispage&&!l&&!m){d=c.keyCode;if(b.locked&&d!=27)return b.cancelEvent(c);var e=true;switch(d){case 38:case 63233:b.doScrollBy(72,
+true);e=false;break;case 40:case 63235:b.doScrollBy(-72,true);e=false;break;case 33:case 63276:b.doScrollBy(b.view.h,true);e=false;break;case 34:case 63277:b.doScrollBy(-b.view.h,true);e=false;break;case 36:case 63273:b.doScrollTo(0,true);e=false;break;case 35:case 63275:b.doScrollTo(b.page.h,true);e=false;break;case 27:b.zoomactive&&(b.doZoom(),e=false)}if(!e)return b.cancelEvent(c)}};b.bind(document,b.isopera?"keypress":"keydown",b.onkeypress)}if(this.doc[0].nodeName=="IFRAME"){var e=function(){var c=
+"contentDocument"in this?this.contentDocument:this.contentWindow.document;if(b.isiframe)b.docscroll=g(c),b.iframe={html:b.doc.contents().find("html")[0],body:b.doc.contents().find("body")[0]};if(b.opt.iframeautoresize&&!b.isiframe){b.win.scrollTop(0);b.doc.height("");var d=b.doc.contents(),d=Math.max(d.find("html").attr("scrollHeight"),d.find("body").attr("scrollHeight"));b.doc.height(d)}b.onResize();b.isie7&&g(c).find("html").css({"overflow-y":"hidden"});g(c.body).css({"overflow-y":"hidden"});"contentWindow"in
+this?b.bind(this.contentWindow,"scroll",b.onscroll):b.bind(c,"scroll",b.onscroll);b.bind(c,"mouseup",b.onmouseup);b.bind(c,"mousewheel",b.onmousewheel);b.bind(c,b.isopera?"keypress":"keydown",b.onkeypress);if(b.cantouch||b.opt.touchbehavior)b.bind(c,"mousedown",b.onmousedown),b.cursorgrabvalue&&g(c).css({cursor:b.cursorgrabvalue});b.bind(c,"mousemove",b.onmousemove);b.zoom&&(b.opt.dblclickzoom&&b.bind(c,"dblclick",b.doZoom),b.cantouch&&b.opt.gesturezoom&&b.bind(c,"gesturechange",function(c){c.scale>
+1.5&&b.doZoomIn(c);c.scale<0.8&&b.doZoomOut(c);return b.cancelEvent(c)}))};this.doc[0].readyState&&this.doc[0].readyState=="complete"&&setTimeout(function(){e.call(b.doc[0],false)},500);this.doc.load(e)}};this.showCursor=function(){if(b.cursortimeout)clearTimeout(b.cursortimeout),b.cursortimeout=0;b.rail&&(b.autohidedom&&b.autohidedom.stop().css({opacity:b.opt.cursoropacitymax}),b.cursor.css({height:b.cursorheight,top:b.scroll.y}),b.zoom&&b.zoom.stop().css({opacity:b.opt.cursoropacitymax}))};this.hideCursor=
+function(c){if(!b.cursortimeout&&b.rail&&b.autohidedom)b.cursortimeout=setTimeout(function(){b.rail.active||(b.autohidedom.stop().animate({opacity:b.opt.cursoropacitymin}),b.zoom&&b.zoom.stop().animate({opacity:b.opt.cursoropacitymin}));b.cursortimeout=0},c||800)};this.noticeCursor=function(c){b.showCursor();b.hideCursor(c)};this.getContentSize=function(){var c=b.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:
+b.haswrapper?{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"))}:b.iframe?{w:Math.max(b.iframe.html.scrollWidth,b.iframe.body.scrollWidth),h:Math.max(b.iframe.html.scrollHeight,b.iframe.body.scrollHeight)}:{w:b.docscroll[0].scrollWidth,h:b.docscroll[0].scrollHeight};c.w-=1;c.h-=1;return c};this.onAttributeChange=function(c){if(c&&c.target){if(c.target!==b.win[0]&&
+c.target!==b.doc[0])return true;if((c="attrChange"in c?c.attrName:"propertyName"in c?c.propertyName:false)&&/width|height|style|block/i.test(c)){if(b.lastattributechange)b.lastattributechange=clearTimeout(b.lastattributechange);b.lastattributechange=setTimeout(function(){b.lastattributechange=0;b.onResize()},60)}}};this.onResize=function(){if(!b.haswrapper&&!b.ispage){var c=b.win.css("display")!="none";c&&!b.visibility&&b.show();!c&&b.visibility&&b.hide();if(!b.visibility)return false}b.view={w:b.ispage?
+b.win.width():b.win.innerWidth(),h:b.ispage?b.win.height():b.win.innerHeight()};b.page=b.getContentSize();if(b.view.h>=b.page.h)return b.hide(),b.scrollvaluemax=0,b.scroll.y=0,b.scrollratio={x:0,y:0},b.cursorheight=0,b.locked=true,b.setScrollTop(0),false;else b.visibility||b.show();b.locked=false;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.scrollvaluemax=
+b.view.h-b.cursorheight-b.cursor.hborder-2;b.scrollratio={x:0,y:(b.page.h-b.view.h)/b.scrollvaluemax};b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};this.bind=function(c,d,e,f){var g=c.length?c[0]:c;g.addEventListener?(b.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&g.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(b){if(b.touches.length<2){var c=b.touches.length>0?b.touches[0]:b;c.original=b;e.call(this,c)}},f||false),g.addEventListener(d,
+e,f||false),d=="mousewheel"&&g.addEventListener("DOMMouseScroll",e,f||false),b.cantouch&&d=="mouseup"&&g.addEventListener("touchcancel",e,f||false)):g.attachEvent?g.attachEvent("on"+d,function(c){if(c&&!("pageY"in c)&&"screenY"in c)c.pageX=c.screenX,c.pageY=c.screenY;return e.call(g,c)===false||f===false?b.cancelEvent(c):true}):g["on"+d]=function(c){return e.call(g,c)===false||f===false?b.cancelEvent(c):true}};this.cancelEvent=function(c){c=b.cantouch?c.original?c.original:c||false:c?c:window.event||
+false;if(!c)return false;c.stopPropagation&&c.stopPropagation();c.preventDefault&&c.preventDefault();c.cancelBubble=true;c.cancel=true;return c.returnValue=false};this.show=function(){b.visibility=true;b.rail.css("display","block")};this.hide=function(){b.visibility=false;b.rail.css("display","none")};this.onmousewheel=function(c){if(b.locked)return b.cancelEvent(c);c=c?c:window.event;if(b.rail.drag)return b.cancelEvent(c);var d=0;(d=c.detail?c.detail*-1:c.wheelDelta/40)&&b.doScrollBy(d*b.opt.mousescrollstep,
+true);return b.cancelEvent(c)};this.stop=function(){b.timer&&n(b.timer);b.timer=0;b.cursorfreezed=false;b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()};b.ishwscroll&&b.hastransition&&b.opt.usetransition?(this.prepareTransition=function(c){var d=Math.round(b.opt.scrollspeed*10),c=Math.min(d,Math.round(c/20*b.opt.scrollspeed)),c=c>20?b.prefixstyle+"transform "+c+"ms ease-out 0s":"";if(!b.lasttransitionstyle||b.lasttransitionstyle!=c)b.lasttransitionstyle=c,b.doc.css(b.transitionstyle,
+c)},this.doScroll=function(c){b.newscrolly=c;if(!b.timer)b.timer=setTimeout(function(){var c=b.getScrollTop();b.prepareTransition(c>b.newscrolly?c-b.newscrolly:b.newscrolly-c);b.setScrollTop(b.newscrolly);b.timer=0},b.opt.scrollspeed),b.noticeCursor()}):this.doScroll=function(c){function d(){g=(new Date).getTime();if(g<f)return b.timer=k(d);f=(new Date).getTime()+b.opt.scrollspeed;g=0;var c=b.newscrolly-b.getScrollTop(),c=c>0?Math.ceil(c*e):Math.floor(c*e),c=b.getScrollTop()+c;b.setScrollTop(c);c==
+b.newscrolly?(b.timer=0,b.cursorfreezed=false):b.timer=k(d)}b.newscrolly=c;if(!b.timer){var e=0.25,g=0,f=0;b.timer=k(d);b.noticeCursor()}};this.doScrollBy=function(c,d){d&&(c=Math.round(c*1/b.scrollratio.y));var e=b.scroll.y-c;e<0&&(e=0);var g=b.scrollvaluemax;e>g&&(e=g);b.cursorfreezed=false;b.doScroll(Math.floor(e*b.scrollratio.y))};this.doScrollTo=function(c,d){ny=d?Math.round(c*1/b.scrollratio.y):c;ny<0&&(c=0);var e=b.scrollvaluemax;ny>e&&(c=d?Math.round(e*b.scrollratio.y):e);b.cursorfreezed=
+false;b.doScroll(d?c:Math.round(c*b.scrollratio.y))};this.doScrollMomentum=function(c){var d=c.ly-c.ny,c=(new Date).getTime()-c.lt;(d=Math.floor(d*3/((c+1)*0.2)))&&b.doScrollBy(d,true)};b.onscroll=function(){var c=(new Date).getTime();if(!b.lastcontentcheck||b.lastcontentcheck<c)if(b.lastcontentcheck=c+500,b.getContentSize().h!=b.page.h)b.onResize();if(!b.rail.drag){if(!b.cursorfreezed)b.scroll.y=Math.round(b.getScrollTop()*(1/b.scrollratio.y));b.noticeCursor()}};b.docscroll.scroll(function(c){b.onscroll(c)});
+this.doZoomIn=function(c){if(!b.zoomactive){b.zoomactive=true;b.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,marginTop,marginBottom,marginLeft,marginRight".split(","),e=b.win[0].style,f;for(f in d){var h=d[f];b.zoomrestore.style[h]=typeof e[h]!="undefined"?e[h]:""}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(b.isios4)b.zoomrestore.scrollTop=
+g(window).scrollTop(),g(window).scrollTop(0);b.win.css({position:b.isios4?"absolute":"fixed",top:0,left:0,"z-index":b.opt.zindex+100,margin:"0px"});d=b.win.css("backgroundColor");(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&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();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),b.isios4&&g(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.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:g(window).width()-b.zoomrestore.padding.w+
+"px",height:g(window).height()-b.zoomrestore.padding.h+"px"});b.setScrollTop(c);b.onResize()}};this.init()};g.fn.niceScroll=function(f,b){typeof f=="object"&&typeof b=="undefined"&&(b=f,f=false);var h=[];typeof b=="undefined"&&(b={});if(f)b.doc=g(f),b.win=g(this);var i=!("doc"in b);this.each(function(){var f=g(this).data("__nicescroll")||false;if(!f)b.doc=i?g(this):b.doc,f=new q(b),g(this).data("__nicescroll",f);h.push(f)});return h.length==1?h[0]:h};var j=jQuery.fn.scrollTop;g.cssHooks.scrollTop=
+{get:function(f){var b=g.data(f,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(f)},set:function(f,b){var h=g.data(f,"__nicescroll")||false;h&&h.ishwscroll?h.setScrollTop(parseInt(b)):j.call(f,b);return this}};jQuery.fn.scrollTop=function(f){if(typeof f=="undefined"){var b=g.data(this,"__nicescroll")||false;return b&&b.ishwscroll?b.getScrollTop():j.call(this)}else return this.each(function(){var b=g.data(this,"__nicescroll")||false;b&&b.ishwscroll?b.setScrollTop(parseInt(f)):
+j.call(g(this),f)})};jQuery.fn.getNiceScroll=function(f){if(typeof f=="undefined"){for(a=0;a<this.length;a++)if(f=g.data(this[a],"__nicescroll")||false)return f;return false}else return f=g.data(this[f],"__nicescroll")||false}})(jQuery);