Browse Source

2.2.0 trasition, detect resize, fix IE

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
Inuyaksa 13 years ago
parent
commit
7f2b7121db
7 changed files with 410 additions and 154 deletions
  1. 7 3
      README
  2. 0 20
      changelog_2.0.1.txt
  3. 41 0
      changelog_2.2.0.txt
  4. 1 1
      demo/index.html
  5. 39 30
      demo/js/jquery.nicescroll.min.js
  6. 283 70
      jquery.nicescroll.js
  7. 39 30
      jquery.nicescroll.min.js

+ 7 - 3
README

@@ -1,5 +1,5 @@
 jquery.nicescroll
-v. 2.0.1 11-07-2011
+v. 2.2.0 11-13-2011
 copyright 2011 InuYaksa*2011
 licensed under the MIT
 http://areaaperta.com/nicescroll
@@ -28,7 +28,7 @@ Warning for IE6 users (who uses IE6 yet? Please updgrade to a more stable and mo
 - on all browsers you can scroll: dragging the cursor, mouse wheel (speed customizable), keyboard navigation (cursor keys, pagup/down keys, home/end keys)
 - scroll is smooth (as modern tablet browsing), speed is customizable
 - zoom feature
-- hardware accelerated scroll (when available)
+- hardware accelerated scroll (where available)
 - tested for all major browsers desktop and mobile versiones
 - support for touch devices
 - compatible with many other browsers, including IE6, Safari on Mac and IE10 preview!
@@ -46,6 +46,8 @@ Put loading script tag after jquery script tag and loading the zoom image in the
 
 <script src="jquery.nicescroll.js"></script>
 
+Copy image "zoomico.png" in the same folder of jquery.nicescroll.js.
+
 
 * HOW TO USE
 
@@ -102,7 +104,9 @@ When you call "niceScroll" you can pass some parameters to custom visual aspects
 . boxzoom - enable zoom for box content, default is false
 . dblclickzoom - (only when boxzoom=true) zoom activated when double click on box, default is true
 . gesturezoom - (only when boxzoom=true and with touch devices) zoom activated when pinch out/in on box, default is true
-
+. 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 ""
 
 * LICENSE
 

+ 0 - 20
changelog_2.0.1.txt

@@ -1,20 +0,0 @@
-Changelog nicescroll release 2.0.1
-http://areaaperta.com/nicescroll
-https://github.com/inuyaksa/jquery.nicescroll
-
-
-New features
-none
-
-
-Changed features
-- cursorborderradius default value to "5px"
-
-
-Fixes
-- zoom preserve styles issue (i.e. zoom out on ipad doesn't work)
-- zoom in feature, it resets margins to zero for fullscreen content now
-
-
-Known issues
-- zoom on ios 4.x is unreliable

+ 41 - 0
changelog_2.2.0.txt

@@ -0,0 +1,41 @@
+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

+ 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.0.1</title>
+<title>jQuery NiceScroll Test 2.2.0</title>
 <style type="text/css">
 #boxscroll {
 	padding: 40px;

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

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.0.1
+-- versione 2.2.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -7,32 +7,41 @@
 -- https://github.com/inuyaksa/jquery.nicescroll
 --
 */
-(function(e){var i=false,j=false,k=function(){var c=document.getElementsByTagName("script"),c=c[c.length-1].src.split("?")[0];return c.split("/").length>0?c.split("/").slice(0,-1).join("/")+"/":""}(),l=function(c){var a=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,boxzoom:false,dblclickzoom:true,
-gesturezoom:true};if(c)for(var f in a.opt)c[f]!==void 0&&(a.opt[f]=c[f]);this.id=a.opt.doc[0].id||"";this.doc=a.opt.doc;this.ispage=a.doc[0].nodeName=="BODY"||a.doc[0].nodeName=="HTML";this.haswrapper=a.opt.win!==false;this.win=a.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.doc[0].nodeName=="IFRAME"&&this.doc.load(function(){var b="contentDocument"in this?this.contentDocument:
-this.contentWindow.document;if(a.isiframe)a.docscroll=e(b.body);a.onResize();e(b.body).css({"overflow-y":"hidden"});e(b).scroll(a.onscroll);e(b).mouseup(function(){a.rail.drag=false});a.bind(b,"mousewheel",a.onmousewheel);e(b).keydown(a.onkeypress);if(a.cantouch||a.opt.touchbehavior)a.bind(b,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(b,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(b,
-"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)});a.zoom&&(a.bind(b,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(b,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)}))});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;c=document.createElement("DIV");this.isieold=(this.isie=document.all&&!document.opera)&&!("msInterpolationMode"in c.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(a.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?
-"msTransform":c.style.webkitTransform!==void 0?"webkitTransform":c.style.MozTransform!==void 0?"MozTransform":false)&&c.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)c.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(c.style[this.trstyle]);this.transitionstyle=false;var g="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(",");for(f=0;f<g.length;f++)if(g[f]in c.style){this.transitionstyle=
-g[f];break}this.hastransition=this.transitionstyle}else this.hastransition=this.transitionstyle=this.hastransform=this.trstyle=false;this.ishwscroll=a.hastransform&&a.opt.hwacceleration&&a.haswrapper;this.scrollTop=function(b){return b===void 0?a.getScrollTop():a.setScrollTop(b)};this.ishwscroll?(a.doc.translate={x:0,y:0},this.getScrollTop=function(){return a.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(b){a.doc.css(a.trstyle,"translate3d(0px,"+b*-1+"px,0px)");a.doc.translate.y=
-b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}:function(b){a.doc.css(a.trstyle,"translate(0px,"+b*-1+"px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),
-b.cancelBubble=true)}):(this.getScrollTop=function(){return a.docscroll.scrollTop()},this.setScrollTop=function(b){return a.docscroll.scrollTop(b)});this.getTarget=function(a){return!a?false:a.target?a.target:a.srcElement?a.srcElement:false};this.hasParent=function(a,d){if(!a)return false;for(var h=a.target||a.srcElement||a||false;h&&h.id!=d;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(){if(a.ishwscroll)a.rail.css({height:a.win.innerHeight()});else{var b=a.win.offset();b.top+=
-2;b.left+=a.win.outerWidth()-a.rail.width-4;a.rail.css({position:"absolute",top:b.top,left:b.left,height:a.win.outerHeight()});a.zoom&&a.zoom.css({position:"absolute",top:b.top+1,left:b.left-18})}};this.init=function(){if(!a.ispage||!a.cantouch&&!this.isieold){a.ispage?a.doc.css({"overflow-y":"hidden"}):a.docscroll.css({"overflow-y":"hidden"});var b=e(document.createElement("div"));b.attr("id",a.id);b.width=4+parseFloat(a.opt.cursorwidth);b.css({"padding-left":"4px","padding-right":"1px",width:a.rail.width+
-"px","z-index":a.opt.zindex,opacity:a.cursoropacitymin});a.rail=b;var d=false;if(a.opt.boxzoom&&!a.ispage&&!a.isieold)d=document.createElement("div"),a.bind(d,"click",a.doZoom),a.zoom=e(d),a.zoom.css({cursor:"pointer","z-index":a.opt.zindex,backgroundImage:"url("+k+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),a.opt.dblclickzoom&&a.bind(a.win,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(a.win,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);
-return a.cancelEvent(b)});a.ispage?(b.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),a.doc.append(b)):a.ishwscroll?(a.win.css("position")=="static"&&a.win.css("position","relative"),a.zoom&&(a.zoom.css({position:"absolute",top:1,right:0,"margin-right":b.width+2}),a.win.append(a.zoom)),b.css({position:"absolute",top:0,right:0}),a.win.append(b)):(a.updateScrollBar(),e("body").append(b),a.zoom&&e("body").append(a.zoom));b=e(document.createElement("div"));b.css({position:"relative",top:0,
-left:0,width:a.opt.cursorwidth,height:"0px","background-color":a.opt.cursorcolor,border:a.opt.cursorborder,"-webkit-border-radius":a.opt.cursorborderradius,"-moz-border-radius":a.opt.cursorborderradius,"border-radius":a.opt.cursorborderradius});a.cursor=b;a.rail.append(b);a.win.resize(a.onResize);a.doc.resize(a.onResize);!a.ispage&&a.opt.boxzoom&&e(window).resize(a.resizeZoom);a.onResize();a.cantouch||a.opt.touchbehavior?(a.bind(a.win,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,
-sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.win,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)})):
-(a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.screenX,y:b.screenY,sx:a.scroll.x,sy:a.scroll.y};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;a.hideCursor();return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag){a.scroll.y=a.rail.drag.sy+(b.screenY-a.rail.drag.y);if(a.scroll.y<0)a.scroll.y=0;var d=a.scrollvaluemax;if(a.scroll.y>d)a.scroll.y=d;a.showCursor();a.cursorfreezed=true;a.doScroll(Math.round(a.scroll.y*a.scrollratio.y));
-return a.cancelEvent(b)}}));a.bind(document,"mouseup",function(){a.rail.drag=false;a.hideCursor()});a.cantouch||(a.rail.mouseenter(function(){a.showCursor();a.rail.active=true}),a.rail.mouseleave(function(){a.rail.active=false;a.rail.drag||a.hideCursor()}),a.isiframe||a.bind(a.isie&&a.ispage?document:a.docscroll,"mousewheel",a.onmousewheel),a.bind(a.rail,"mousewheel",a.onmousewheel));!a.ispage&&!a.cantouch&&(a.win.attr("tabindex")||a.win.attr({tabindex:(new Date).getTime()}),a.win.focus(function(b){i=
-a.getTarget(b).id||true;a.hasfocus=true;a.noticeCursor()}),a.win.blur(function(){i=false;a.hasfocus=false}),a.win.mouseenter(function(b){j=a.getTarget(b).id||true;a.hasmousefocus=true;a.noticeCursor()}),a.win.mouseleave(function(){j=false;a.hasmousefocus=false}));a.onkeypress=function(b){var b=b?b:window.e,d=a.getTarget(b);if(!d||!/(INPUT|TEXTAREA|SELECT)/.test(d.nodeName))if(a.hasfocus||a.hasmousefocus&&!i||a.ispage&&!i&&!j){d=true;switch(b.keyCode){case 38:case 63233:a.doScrollBy(12);d=false;break;
-case 40:case 63235:a.doScrollBy(-12);d=false;break;case 33:case 63276:a.doScrollBy(a.view.h,true);d=false;break;case 34:case 63277:a.doScrollBy(-a.view.h,true);d=false;break;case 36:case 63273:a.doScrollTo(0,true);d=false;break;case 35:case 63275:a.doScrollTo(a.page.h,true);d=false;break;case 27:a.zoomactive&&(a.doZoom(),d=false)}if(!d)return a.cancelEvent(b)}};a.bind(document,"keydown",a.onkeypress)}};this.showCursor=function(){if(a.cursortimeout)clearTimeout(a.cursortimeout),a.cursortimeout=0;a.rail&&
-(a.rail.stop().css({opacity:a.opt.cursoropacitymax}),a.cursor.css({height:a.cursorheight,top:a.scroll.y}),a.zoom&&a.zoom.stop().css({opacity:a.opt.cursoropacitymax}))};this.hideCursor=function(b){if(!a.cursortimeout&&a.rail)a.cursortimeout=setTimeout(function(){a.rail.active||(e(a.rail).stop().animate({opacity:a.opt.cursoropacitymin}),a.zoom&&a.zoom.stop().animate({opacity:a.opt.cursoropacitymin}));a.cursortimeout=0},b||800)};this.noticeCursor=function(b){a.showCursor();a.hideCursor(b)};this.getContentSize=
-function(){var b=a.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:a.haswrapper?{w:a.doc.outerWidth()+parseInt(a.win.css("paddingLeft"))+parseInt(a.win.css("paddingRight")),h:a.doc.outerHeight()+parseInt(a.win.css("paddingTop"))+parseInt(a.win.css("paddingBottom"))}:{w:a.docscroll[0].scrollWidth,h:a.docscroll[0].scrollHeight};b.w-=1;b.h-=1;return b};this.onResize=function(){a.ispage||a.updateScrollBar();
-a.view={w:a.ispage?a.win.width():a.win.innerWidth(),h:a.ispage?a.win.height():a.win.innerHeight()};a.page=a.getContentSize();a.cursorheight=Math.min(a.view.h,Math.round(a.view.h*(a.view.h/a.page.h)));a.scrollvaluemax=a.view.h-a.cursorheight-2;a.scrollratio={x:0,y:(a.page.h-a.view.h)/a.scrollvaluemax};a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()};this.bind=function(b,d,c,e){var f=b.length?b[0]:b;f.addEventListener?(a.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&
-f.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(a){if(a.touches.length<2){var b=a.touches.length>0?a.touches[0]:a;b.original=a;c.call(this,b)}},e||false),f.addEventListener(d,c,e||false),d=="mousewheel"&&f.addEventListener("DOMMouseScroll",c,e||false)):f.attachEvent?f.attachEvent("on"+d,function(b){if(!c.call(f,b)||!e)return a.cancelEvent(b)}):f["on"+d]=function(b){if(!c.call(f,b)||!e)return a.cancelEvent(b)}};this.cancelEvent=function(b){b=a.cantouch?b?
-b.original:false:b?b:window.event||false;if(!b)return false;b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b.cancelBubble=true;b.cancel=true;return b.returnValue=false};this.onmousewheel=function(b){b=b?b:window.event;if(a.rail.drag)return a.cancelEvent(b);var d=0;(d=b.detail?b.detail*-1:b.wheelDelta/40)&&a.doScrollBy(d*a.opt.mousescrollstep,true);return a.cancelEvent(b)};this.stop=function(){a.timer&&clearInterval(a.timer);a.timer=0;a.cursorfreezed=false;a.scroll.y=Math.round(a.getScrollTop()*
-(1/a.scrollratio.y));a.noticeCursor()};this.doScroll=function(b){a.newscrolly=b;if(!a.timer)a.timer=setInterval(function(){var b=a.newscrolly-a.getScrollTop(),b=b>0?Math.ceil(b/4):Math.floor(b/4),b=a.getScrollTop()+b;a.setScrollTop(b);if(b==a.newscrolly)clearInterval(a.timer),a.timer=0,a.cursorfreezed=false},a.opt.scrollspeed),a.noticeCursor()};this.doScrollBy=function(b,d){d&&(b=Math.round(b*1/a.scrollratio.y));var c=a.scroll.y-b;c<0&&(c=0);var e=a.scrollvaluemax;c>e&&(c=e);a.cursorfreezed=false;
-a.doScroll(Math.floor(c*a.scrollratio.y))};this.doScrollTo=function(b,d){d&&(b=Math.round(b*1/a.scrollratio.y));ny=b;ny<0&&(ny=0);var c=a.scrollvaluemax;ny>c&&(ny=c);a.cursorfreezed=false;a.doScroll(Math.floor(ny*a.scrollratio.y))};a.onscroll=function(){var b=(new Date).getTime();if(!a.lastcontentcheck||a.lastcontentcheck<b)if(a.lastcontentcheck=b+500,a.getContentSize().h!=a.page.h)a.onResize();if(!a.rail.drag){if(!a.cursorfreezed)a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()}};
-a.docscroll.scroll(function(b){a.onscroll(b)});this.doZoomIn=function(b){if(!a.zoomactive){a.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,width,height,marginTop,marginBottom,marginLeft,marginRight".split(","),c;for(c in d){var e=d[c];a.zoomrestore.style[e]=a.win.css(e)||""}a.zoomrestore.padding={w:a.win.outerWidth()-a.win.width(),h:a.win.outerHeight()-a.win.height()};a.win.css({position:"fixed",top:0,left:0,"z-index":a.opt.zindex+100,margin:"0px"});d=a.win.css("backgroundColor");
-(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&a.win.css("backgroundColor","#fff");a.rail.css({"z-index":a.opt.zindex+110});a.zoom.css({"z-index":a.opt.zindex+112});a.zoomactive=true;a.zoom.css("backgroundPosition","0px -18px");a.resizeZoom();return a.cancelEvent(b)}};this.doZoomOut=function(b){if(a.zoomactive)return a.win.css("margin",""),a.win.css(a.zoomrestore.style),a.rail.css({"z-index":a.opt.zindex}),a.zoom.css({"z-index":a.opt.zindex}),a.zoomactive=false,a.zoomrestore=false,
-a.zoom.css("backgroundPosition","0px 0px"),a.win.resize(),a.cancelEvent(b)};this.doZoom=function(b){return a.zoomactive?a.doZoomOut(b):a.doZoomIn(b)};this.resizeZoom=function(){if(a.zoomactive){var b=a.getScrollTop();a.win.css({width:e(window).width()-a.zoomrestore.padding.w+"px",height:e(window).height()-a.zoomrestore.padding.h+"px"});a.setScrollTop(b);a.win.resize()}};this.init()};e.fn.niceScroll=function(c,a){typeof c=="object"&&typeof a=="undefined"&&(a=c,c=false);var f=[];typeof a=="undefined"&&
-(a={});if(c)a.doc=e(c),a.win=e(this);var g=!("doc"in a);this.each(function(){a.doc=g?e(this):a.doc;f.push(new l(a))});return f.length==1?f[0]:f}})(jQuery);
+(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);

+ 283 - 70
jquery.nicescroll.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.0.1
+-- versione 2.2.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -10,6 +10,7 @@
 
 (function($){
 
+  // globals
   var domfocus = false;
   var mousefocus = false;
   var zoomactive = false;
@@ -18,10 +19,11 @@
   function getScriptPath() {
     var scripts= document.getElementsByTagName('script');
     var path= scripts[scripts.length-1].src.split('?')[0];
-    return (path.split('/').length>0) ? path.split('/').slice(0, -1).join('/')+'/' : '';
+    return (path.split('/').length>0) ? path.split('/').slice(0,-1).join('/')+'/' : '';
   }
   var scriptpath = getScriptPath();
 
+  
   var NiceScrollClass = function(myopt) {
 
     var self = this;
@@ -40,9 +42,13 @@
       mousescrollstep:8*6,
       touchbehavior:false,
       hwacceleration:true,
+      usetransition:true,
       boxzoom:false,
       dblclickzoom:true,
-      gesturezoom:true
+      gesturezoom:true,
+      grabcursorenabled:true,
+      autohidemode:true,
+      background:""
     };
     
     if (myopt||false) {
@@ -59,9 +65,11 @@
     this.docscroll = this.ispage?$(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') {
-      this.doc.load(function() {        
+      function oniframeload(e) {        
         var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
         if (self.isiframe) self.docscroll = $(doc.body);
         self.onResize();
@@ -71,6 +79,7 @@
         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);
@@ -96,7 +105,14 @@
             });             
           }          
         }
-      });
+      };
+      
+      if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
+        setTimeout(function(){oniframeload.call(self.doc[0],false)},1000);
+      } else {
+        this.doc.load(oniframeload);
+      }
+      
     }
     
     this.view = false;
@@ -125,10 +141,17 @@
     
     var domtest = document.createElement('DIV');
     
-    this.isie = (document.all && !document.opera);
-    this.isieold = (this.isie && !('msInterpolationMode' in domtest.style));
+    this.isopera = ("opera" in window);
+    
+    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.isie8 = this.isie&&("documentMode" in document)&&(document.documentMode==8);
+    this.isie9 = this.isie&&("performance" in window)&&(document.documentMode>=9);
     
-    this.cantouch = ('ontouchstart' in document.documentElement);
+    this.ismozilla = ("MozAppearance" in domtest.style);
+    
+    this.cantouch = ("ontouchstart" in document.documentElement);
 
     if (this.cantouch && /iphone|ipad|ipod/i.test(navigator.platform)) {
       this.isios = true;
@@ -148,10 +171,16 @@
       }
       
       this.transitionstyle = false;
+      this.prefixstyle = '';
+      this.transitionend = false;
       var check = ['transition','webkitTransition','MozTransition','OTransition','msTransition','KhtmlTransition'];
+      var prefix = ['','-webkit-','-moz-','-o-','-ms-','-khtml-'];
+      var evs = ['transitionEnd','webkitTransitionEnd','transitionend','oTransitionEnd','msTransitionEnd','KhtmlTransitionEnd'];
       for(var a=0;a<check.length;a++) {
         if (check[a] in domtest.style) {
           this.transitionstyle = check[a];
+          this.prefixstyle = prefix[a];
+          this.transitionend = evs[a];
           break;
         }
       }
@@ -163,7 +192,26 @@
       this.transitionstyle = false;
       this.hastransition = false;
     }
+    
+    this.cursorgrabvalue = '';
+    
+    if (self.opt.grabcursorenabled&&self.opt.touchbehavior) {  // check grab cursor support
+      function detectCursorGrab() {
+        if (!self.isie||self.isie9) {  // some old IE return false positive
+          var lst = ['grab','-moz-grab','-webkit-grab'];
+          for(var a=0;a<lst.length;a++) {
+            var p = lst[a];
+            domtest.style['cursor']=p;
+            if (domtest.style['cursor']==p) return p;
+          }
+        }
+        return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';
+      }
+      this.cursorgrabvalue = detectCursorGrab();
+    }
 
+    domtest = null;
+    
     this.ishwscroll = (self.hastransform)&&(self.opt.hwacceleration)&&(self.haswrapper);
     
     this.scrollTop = function(val) {
@@ -177,31 +225,35 @@
         return self.doc.translate.y;
       };
       if (this.hastranslate3d) {
-        this.setScrollTop = function(val) {
+        this.setScrollTop = function(val,silent) {
           self.doc.css(self.trstyle,"translate3d(0px,"+(val*-1)+"px,0px)");
           self.doc.translate.y = val;
-          if (document.createEvent) {
-            var e = document.createEvent("UIEvents");
-            e.initUIEvent("scroll", false, true, window, 1);
-            self.docscroll[0].dispatchEvent(e);
-          } else {
-            var e = document.createEventObject();
-            self.docscroll[0].fireEvent("onscroll");
-            e.cancelBubble = true; 
+          if (!silent) {
+            if (document.createEvent) {
+              var e = document.createEvent("UIEvents");
+              e.initUIEvent("scroll", false, true, window, 1);
+              self.docscroll[0].dispatchEvent(e);
+            } else {
+              var e = document.createEventObject();
+              self.docscroll[0].fireEvent("onscroll");
+              e.cancelBubble = true; 
+            }
           }
         };
       } else {
-        this.setScrollTop = function(val) {
+        this.setScrollTop = function(val,silent) {
           self.doc.css(self.trstyle,"translate(0px,"+(val*-1)+"px)");
           self.doc.translate.y = val;
-          if (document.createEvent) {
-            var e = document.createEvent("UIEvents");
-            e.initUIEvent("scroll", false, true, window, 1);
-            self.docscroll[0].dispatchEvent(e);
-          } else {
-            var e = document.createEventObject();
-            self.docscroll[0].fireEvent("onscroll");
-            e.cancelBubble = true; 
+          if (!silent) {
+            if (document.createEvent) {
+              var e = document.createEvent("UIEvents");
+              e.initUIEvent("scroll", false, true, window, 1);
+              self.docscroll[0].dispatchEvent(e);
+            } else {
+              var e = document.createEventObject();
+              self.docscroll[0].fireEvent("onscroll");
+              e.cancelBubble = true; 
+            }
           }
         };
       }
@@ -231,27 +283,30 @@
       return (el!==false);
     };
     
-    this.updateScrollBar = function() {
+    this.updateScrollBar = function(len) {
       if (self.ishwscroll) {
         self.rail.css({height:self.win.innerHeight()});
       } 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:self.win.outerHeight()});
+        self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:(len)?len.h:self.win.outerHeight()});
         if (self.zoom) self.zoom.css({position:"absolute",top:pos.top+1,left:pos.left-18});
       }
     };
     
     this.init = function() {
     
-      if (!self.ispage || (!self.cantouch && !this.isieold)) {
+      if (!self.ispage || (!self.cantouch && !self.isieold)) {
 
         (self.ispage)?self.doc.css({'overflow-y':'hidden'}):self.docscroll.css({'overflow-y':'hidden'});
+        
+        if (self.ispage&&self.isie7) $("html").css({'overflow-y':'hidden'});  //IE7 double scrollbar issue
+        
         var rail = $(document.createElement('div'));
         rail.attr('id',self.id);
         rail.width = 4+parseFloat(self.opt.cursorwidth);
-        rail.css({"padding-left":"4px","padding-right":"1px",width:self.rail.width+"px",'z-index':self.opt.zindex,opacity:self.cursoropacitymin});
+        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});
         self.rail = rail;
         
         var zoom = false;
@@ -284,7 +339,7 @@
             self.win.append(rail);
           } else {
             self.updateScrollBar();
-            $("body").append(rail);
+            $("body").append(rail);           
             if (self.zoom) $("body").append(self.zoom);
           }
         }
@@ -294,6 +349,7 @@
           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
@@ -301,22 +357,37 @@
         self.cursor = cursor;
         self.rail.append(cursor);
         
-        self.win.resize(self.onResize);
-        self.doc.resize(self.onResize);
+        if (self.opt.autohidemode===false) {
+          self.autohidedom = false;
+        }
+        else if (self.opt.autohidemode===true) {
+          self.autohidedom = self.rail;
+        }
+        else if (self.opt.autohidemode=="cursor") {
+          self.autohidedom = self.cursor;
+        }        
+        
+        $(window).resize(self.onResize)
+        if (!self.ispage&&!self.haswrapper) {
+          self.bind(self.win,(self.isie&&!self.isie9)?"propertychange":"DOMAttrModified",self.onAttributeChange);
+        }
+
         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) {
+        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()};
+            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) {
-            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
+            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) {
@@ -325,10 +396,21 @@
           });
           self.bind(document,"mousemove",function(e) {
             if (self.rail.drag) {
-              self.doScrollTo(self.rail.drag.st - (e.pageY-self.rail.drag.y),true);
+              var my = (e.pageY-self.rail.drag.y);
+              self.rail.drag.ly = self.rail.drag.ny;
+              self.rail.drag.ny = e.pageY;
+              self.rail.drag.lt = (new Date()).getTime();
+              
+              self.scroll.y = Math.round((self.rail.drag.st-my) * (1/self.scrollratio.y));
+              if (self.scroll.y<0) self.scroll.y=0;
+              if (self.scroll.y>self.scrollvaluemax) self.scroll.y=self.scrollvaluemax;
+              self.showCursor();
+              
+              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.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y};
@@ -443,7 +525,7 @@
             if (!ret) return self.cancelEvent(e);
           }
         };
-        self.bind(document,"keydown",self.onkeypress);
+        self.bind(document,(self.isopera)?"keypress":"keydown",self.onkeypress);
         
       }
       
@@ -455,7 +537,8 @@
         self.cursortimeout = 0;
       }
       if (!self.rail) return;
-      self.rail.stop().css({opacity:self.opt.cursoropacitymax});
+      if (!self.autohidedom) return;
+      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});
     };
@@ -463,9 +546,10 @@
     this.hideCursor = function(tm) {
       if (self.cursortimeout) return;
       if (!self.rail) return;
+      if (!self.autohidedom) return;
       self.cursortimeout = setTimeout(function() {
          if (!self.rail.active) {
-           $(self.rail).stop().animate({opacity:self.opt.cursoropacitymin});
+           self.autohidedom.stop().animate({opacity:self.opt.cursoropacitymin});
            if (self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
          }
          self.cursortimeout = 0;
@@ -501,13 +585,30 @@
       return pg;
     };
     
-    this.onResize = function() {
-      if (!self.ispage) self.updateScrollBar();
-
+    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 (self.lastattributechange) self.lastattributechange=clearTimeout(self.lastattributechange);
+          self.lastattributechange = setTimeout(function(){
+            self.lastattributechange = 0;
+            self.onResize();            
+          },60);
+        }
+      }
+    };
+    
+    this.onResize = function() {      
       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();
       
       self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
@@ -524,7 +625,7 @@
       self.noticeCursor();
     };
    
-    this.bind = function(dom,name,fn,bubble) {  // fixing jquery bind & touch-oriented
+    this.bind = function(dom,name,fn,bubble) {  // touch-oriented & fixing jquery bind
       var el = (dom.length) ? dom[0] : dom;
       if (el.addEventListener) {
         if (self.cantouch && /mouseup|mousedown|mousemove/.test(name)) {  // touch device support
@@ -538,6 +639,10 @@
       } 
       else if (el.attachEvent) {
         el.attachEvent("on"+name,function(e) {
+          if (e&&!("pageY" in e)&&("screenY" in e)) {
+            e.pageX = e.screenX;
+            e.pageY = e.screenY;
+          }
           if (!fn.call(el,e)||!bubble) return self.cancelEvent(e);
         });
       } 
@@ -584,22 +689,47 @@
       self.noticeCursor();      
     };
     
-    this.doScroll = function(y) {
-      self.newscrolly = y;
-      if (self.timer) return;
-      self.timer = setInterval(function() {
-        var gp = self.newscrolly - self.getScrollTop();
-        var df = (gp>0) ? Math.ceil(gp/4) : Math.floor(gp/4);
-        var sc = self.getScrollTop()+df;
-        self.setScrollTop(sc);     
-        if (sc == self.newscrolly) {
-          clearInterval(self.timer);
-          self.timer = 0;        
-          self.cursorfreezed = false;
+    if (self.ishwscroll&&self.hastransition&&self.opt.usetransition) {
+      this.prepareTransition = function(dif,trend) {
+        var sp = Math.round(self.opt.scrollspeed*10);
+        var ex = Math.min(sp,Math.round((dif / 20) * self.opt.scrollspeed));
+        var trans = (ex>20) ? self.prefixstyle+'transform '+ex+'ms ease-out 0s' : '';
+        if (!self.lasttransitionstyle||self.lasttransitionstyle!=trans) {
+          self.lasttransitionstyle = trans;
+          self.doc.css(self.transitionstyle,trans);
         }
-      },self.opt.scrollspeed);
-      self.noticeCursor();
-    };
+      };
+      this.doScroll = function(y) {
+        self.newscrolly = y;
+        if (self.timer) return;
+        self.timer = setTimeout(function() {
+          var top = self.getScrollTop();
+          var dif = (top>self.newscrolly) ? top-self.newscrolly : self.newscrolly-top;
+          self.prepareTransition(dif)
+          self.setScrollTop(self.newscrolly);
+          self.timer = 0;
+        },self.opt.scrollspeed);
+        self.noticeCursor();
+      };
+//      self.bind(self.doc,'transitionend',function(e){console.log(e)},false); TEST!!
+    } else {
+      this.doScroll = function(y) {
+        self.newscrolly = y;
+        if (self.timer) return;
+        self.timer = setInterval(function() {
+          var gp = self.newscrolly - self.getScrollTop();
+          var df = (gp>0) ? Math.ceil(gp/4) : Math.floor(gp/4);
+          var sc = self.getScrollTop()+df;
+          self.setScrollTop(sc);     
+          if (sc == self.newscrolly) {
+            clearInterval(self.timer);
+            self.timer = 0;        
+            self.cursorfreezed = false;
+          }
+        },self.opt.scrollspeed);
+        self.noticeCursor();
+      };
+    }
     
     this.doScrollBy = function(stp,absolute) {
       if (absolute) stp = Math.round(stp * 1/self.scrollratio.y);
@@ -611,14 +741,36 @@
       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) {
-      if (absolute) pos = Math.round(pos * 1/self.scrollratio.y);
-      ny=pos;
-      if (ny<0) ny=0;
+      ny=(absolute)?Math.round(pos * 1/self.scrollratio.y):pos;
+      if (ny<0) pos=0;
       var my = self.scrollvaluemax;
-      if (ny>my) ny=my;
+      if (ny>my) pos=(absolute)?Math.round(my*self.scrollratio.y):my;
       self.cursorfreezed = false;
-      self.doScroll(Math.floor(ny*self.scrollratio.y));
+      self.doScroll((absolute)?pos:Math.round(pos*self.scrollratio.y));
+    };
+    
+    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);
+      }
     };
     
     self.onscroll = function(e) {    
@@ -642,17 +794,28 @@
       self.zoomrestore = {
         style:{}
       };
-      var lst = ['position','top','left','zIndex','backgroundColor','width','height','marginTop','marginBottom','marginLeft','marginRight'];
+      var lst = ['position','top','left','zIndex','backgroundColor','marginTop','marginBottom','marginLeft','marginRight'];
+      var win = self.win[0].style;
       for(var a in lst) {
         var pp = lst[a];
-        self.zoomrestore.style[pp] = self.win.css(pp)||'';
+        self.zoomrestore.style[pp] = (typeof win[pp]!='undefined') ? win[pp] : '';
       }
+      
+      self.zoomrestore.style.width = self.win.css('width');
+      self.zoomrestore.style.height = self.win.css('height');
+      
       self.zoomrestore.padding = {
         w:self.win.outerWidth()-self.win.width(),
         h:self.win.outerHeight()-self.win.height()
       };
+      
+      if (self.isios4) {
+        self.zoomrestore.scrollTop = $(window).scrollTop();
+        $(window).scrollTop(0);
+      }
+      
       self.win.css({
-        "position":"fixed",
+        "position":(self.isios4)?"absolute":"fixed",
         "top":0,
         "left":0,
         "z-index":self.opt.zindex+100,
@@ -674,7 +837,11 @@
       self.win.css("margin","");
       self.win.css(self.zoomrestore.style);
       
-      self.rail.css({"z-index":self.opt.zindex});
+      if (self.isios4) {
+        $(window).scrollTop(self.zoomrestore.scrollTop);
+      }
+      
+      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;
@@ -717,11 +884,57 @@
     }    
     var docundef = !("doc" in opt);    
     this.each(function() {      
-      opt.doc = (docundef) ? $(this) : opt.doc;
-      ret.push(new NiceScrollClass(opt));
+      var nice = $(this).data('__nicescroll')||false;
+      if (!nice) {
+        opt.doc = (docundef) ? $(this) : opt.doc;
+        nice = new NiceScrollClass(opt);
+        $(this).data('__nicescroll',nice);
+      }
+      ret.push(nice);
     });
     return (ret.length==1) ? ret[0] : ret;
   };
+
+// override jQuery scrollTop
+ 
+   var _scrollTop = jQuery.fn.scrollTop; // preserve original function
+   
+  $.cssHooks.scrollTop = {
+    get: function(elem,computed,extra) {
+      var nice = $.data(elem,'__nicescroll')||false;
+      return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(elem);
+    },
+    set: function(elem,value) {
+      var nice = $.data(elem,'__nicescroll')||false;      
+      (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call(elem,value);
+      return this;
+    }
+  };
+ 
+  jQuery.fn.scrollTop = function(value) {    
+    if (typeof value == "undefined") {
+      var nice = $.data(this,'__nicescroll')||false;
+      return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(this);
+    } else {
+      return this.each(function() {     
+        var nice = $.data(this,'__nicescroll')||false;
+        (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call($(this),value);
+      });
+    }
+  }
+
+  jQuery.fn.getNiceScroll = function(index) {
+    if (typeof index == "undefined") {
+      for(a=0;a<this.length;a++) {
+        var nice = $.data(this[a],'__nicescroll')||false;
+        if (nice) return nice;
+      };
+      return false;
+    } else {
+      var nice = $.data(this[index],'__nicescroll')||false;
+      return nice;
+    }
+  }
   
 })( jQuery );
   

+ 39 - 30
jquery.nicescroll.min.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- versione 2.0.1
+-- versione 2.2.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -7,32 +7,41 @@
 -- https://github.com/inuyaksa/jquery.nicescroll
 --
 */
-(function(e){var i=false,j=false,k=function(){var c=document.getElementsByTagName("script"),c=c[c.length-1].src.split("?")[0];return c.split("/").length>0?c.split("/").slice(0,-1).join("/")+"/":""}(),l=function(c){var a=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,boxzoom:false,dblclickzoom:true,
-gesturezoom:true};if(c)for(var f in a.opt)c[f]!==void 0&&(a.opt[f]=c[f]);this.id=a.opt.doc[0].id||"";this.doc=a.opt.doc;this.ispage=a.doc[0].nodeName=="BODY"||a.doc[0].nodeName=="HTML";this.haswrapper=a.opt.win!==false;this.win=a.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.doc[0].nodeName=="IFRAME"&&this.doc.load(function(){var b="contentDocument"in this?this.contentDocument:
-this.contentWindow.document;if(a.isiframe)a.docscroll=e(b.body);a.onResize();e(b.body).css({"overflow-y":"hidden"});e(b).scroll(a.onscroll);e(b).mouseup(function(){a.rail.drag=false});a.bind(b,"mousewheel",a.onmousewheel);e(b).keydown(a.onkeypress);if(a.cantouch||a.opt.touchbehavior)a.bind(b,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(b,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(b,
-"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)});a.zoom&&(a.bind(b,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(b,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)}))});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;c=document.createElement("DIV");this.isieold=(this.isie=document.all&&!document.opera)&&!("msInterpolationMode"in c.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(a.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?
-"msTransform":c.style.webkitTransform!==void 0?"webkitTransform":c.style.MozTransform!==void 0?"MozTransform":false)&&c.style[this.trstyle]===void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)c.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(c.style[this.trstyle]);this.transitionstyle=false;var g="transition,webkitTransition,MozTransition,OTransition,msTransition,KhtmlTransition".split(",");for(f=0;f<g.length;f++)if(g[f]in c.style){this.transitionstyle=
-g[f];break}this.hastransition=this.transitionstyle}else this.hastransition=this.transitionstyle=this.hastransform=this.trstyle=false;this.ishwscroll=a.hastransform&&a.opt.hwacceleration&&a.haswrapper;this.scrollTop=function(b){return b===void 0?a.getScrollTop():a.setScrollTop(b)};this.ishwscroll?(a.doc.translate={x:0,y:0},this.getScrollTop=function(){return a.doc.translate.y},this.setScrollTop=this.hastranslate3d?function(b){a.doc.css(a.trstyle,"translate3d(0px,"+b*-1+"px,0px)");a.doc.translate.y=
-b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}:function(b){a.doc.css(a.trstyle,"translate(0px,"+b*-1+"px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),
-b.cancelBubble=true)}):(this.getScrollTop=function(){return a.docscroll.scrollTop()},this.setScrollTop=function(b){return a.docscroll.scrollTop(b)});this.getTarget=function(a){return!a?false:a.target?a.target:a.srcElement?a.srcElement:false};this.hasParent=function(a,d){if(!a)return false;for(var h=a.target||a.srcElement||a||false;h&&h.id!=d;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(){if(a.ishwscroll)a.rail.css({height:a.win.innerHeight()});else{var b=a.win.offset();b.top+=
-2;b.left+=a.win.outerWidth()-a.rail.width-4;a.rail.css({position:"absolute",top:b.top,left:b.left,height:a.win.outerHeight()});a.zoom&&a.zoom.css({position:"absolute",top:b.top+1,left:b.left-18})}};this.init=function(){if(!a.ispage||!a.cantouch&&!this.isieold){a.ispage?a.doc.css({"overflow-y":"hidden"}):a.docscroll.css({"overflow-y":"hidden"});var b=e(document.createElement("div"));b.attr("id",a.id);b.width=4+parseFloat(a.opt.cursorwidth);b.css({"padding-left":"4px","padding-right":"1px",width:a.rail.width+
-"px","z-index":a.opt.zindex,opacity:a.cursoropacitymin});a.rail=b;var d=false;if(a.opt.boxzoom&&!a.ispage&&!a.isieold)d=document.createElement("div"),a.bind(d,"click",a.doZoom),a.zoom=e(d),a.zoom.css({cursor:"pointer","z-index":a.opt.zindex,backgroundImage:"url("+k+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),a.opt.dblclickzoom&&a.bind(a.win,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(a.win,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);
-return a.cancelEvent(b)});a.ispage?(b.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),a.doc.append(b)):a.ishwscroll?(a.win.css("position")=="static"&&a.win.css("position","relative"),a.zoom&&(a.zoom.css({position:"absolute",top:1,right:0,"margin-right":b.width+2}),a.win.append(a.zoom)),b.css({position:"absolute",top:0,right:0}),a.win.append(b)):(a.updateScrollBar(),e("body").append(b),a.zoom&&e("body").append(a.zoom));b=e(document.createElement("div"));b.css({position:"relative",top:0,
-left:0,width:a.opt.cursorwidth,height:"0px","background-color":a.opt.cursorcolor,border:a.opt.cursorborder,"-webkit-border-radius":a.opt.cursorborderradius,"-moz-border-radius":a.opt.cursorborderradius,"border-radius":a.opt.cursorborderradius});a.cursor=b;a.rail.append(b);a.win.resize(a.onResize);a.doc.resize(a.onResize);!a.ispage&&a.opt.boxzoom&&e(window).resize(a.resizeZoom);a.onResize();a.cantouch||a.opt.touchbehavior?(a.bind(a.win,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,
-sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.win,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)})):
-(a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.screenX,y:b.screenY,sx:a.scroll.x,sy:a.scroll.y};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;a.hideCursor();return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag){a.scroll.y=a.rail.drag.sy+(b.screenY-a.rail.drag.y);if(a.scroll.y<0)a.scroll.y=0;var d=a.scrollvaluemax;if(a.scroll.y>d)a.scroll.y=d;a.showCursor();a.cursorfreezed=true;a.doScroll(Math.round(a.scroll.y*a.scrollratio.y));
-return a.cancelEvent(b)}}));a.bind(document,"mouseup",function(){a.rail.drag=false;a.hideCursor()});a.cantouch||(a.rail.mouseenter(function(){a.showCursor();a.rail.active=true}),a.rail.mouseleave(function(){a.rail.active=false;a.rail.drag||a.hideCursor()}),a.isiframe||a.bind(a.isie&&a.ispage?document:a.docscroll,"mousewheel",a.onmousewheel),a.bind(a.rail,"mousewheel",a.onmousewheel));!a.ispage&&!a.cantouch&&(a.win.attr("tabindex")||a.win.attr({tabindex:(new Date).getTime()}),a.win.focus(function(b){i=
-a.getTarget(b).id||true;a.hasfocus=true;a.noticeCursor()}),a.win.blur(function(){i=false;a.hasfocus=false}),a.win.mouseenter(function(b){j=a.getTarget(b).id||true;a.hasmousefocus=true;a.noticeCursor()}),a.win.mouseleave(function(){j=false;a.hasmousefocus=false}));a.onkeypress=function(b){var b=b?b:window.e,d=a.getTarget(b);if(!d||!/(INPUT|TEXTAREA|SELECT)/.test(d.nodeName))if(a.hasfocus||a.hasmousefocus&&!i||a.ispage&&!i&&!j){d=true;switch(b.keyCode){case 38:case 63233:a.doScrollBy(12);d=false;break;
-case 40:case 63235:a.doScrollBy(-12);d=false;break;case 33:case 63276:a.doScrollBy(a.view.h,true);d=false;break;case 34:case 63277:a.doScrollBy(-a.view.h,true);d=false;break;case 36:case 63273:a.doScrollTo(0,true);d=false;break;case 35:case 63275:a.doScrollTo(a.page.h,true);d=false;break;case 27:a.zoomactive&&(a.doZoom(),d=false)}if(!d)return a.cancelEvent(b)}};a.bind(document,"keydown",a.onkeypress)}};this.showCursor=function(){if(a.cursortimeout)clearTimeout(a.cursortimeout),a.cursortimeout=0;a.rail&&
-(a.rail.stop().css({opacity:a.opt.cursoropacitymax}),a.cursor.css({height:a.cursorheight,top:a.scroll.y}),a.zoom&&a.zoom.stop().css({opacity:a.opt.cursoropacitymax}))};this.hideCursor=function(b){if(!a.cursortimeout&&a.rail)a.cursortimeout=setTimeout(function(){a.rail.active||(e(a.rail).stop().animate({opacity:a.opt.cursoropacitymin}),a.zoom&&a.zoom.stop().animate({opacity:a.opt.cursoropacitymin}));a.cursortimeout=0},b||800)};this.noticeCursor=function(b){a.showCursor();a.hideCursor(b)};this.getContentSize=
-function(){var b=a.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:a.haswrapper?{w:a.doc.outerWidth()+parseInt(a.win.css("paddingLeft"))+parseInt(a.win.css("paddingRight")),h:a.doc.outerHeight()+parseInt(a.win.css("paddingTop"))+parseInt(a.win.css("paddingBottom"))}:{w:a.docscroll[0].scrollWidth,h:a.docscroll[0].scrollHeight};b.w-=1;b.h-=1;return b};this.onResize=function(){a.ispage||a.updateScrollBar();
-a.view={w:a.ispage?a.win.width():a.win.innerWidth(),h:a.ispage?a.win.height():a.win.innerHeight()};a.page=a.getContentSize();a.cursorheight=Math.min(a.view.h,Math.round(a.view.h*(a.view.h/a.page.h)));a.scrollvaluemax=a.view.h-a.cursorheight-2;a.scrollratio={x:0,y:(a.page.h-a.view.h)/a.scrollvaluemax};a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()};this.bind=function(b,d,c,e){var f=b.length?b[0]:b;f.addEventListener?(a.cantouch&&/mouseup|mousedown|mousemove/.test(d)&&
-f.addEventListener(d=="mousedown"?"touchstart":d=="mouseup"?"touchend":"touchmove",function(a){if(a.touches.length<2){var b=a.touches.length>0?a.touches[0]:a;b.original=a;c.call(this,b)}},e||false),f.addEventListener(d,c,e||false),d=="mousewheel"&&f.addEventListener("DOMMouseScroll",c,e||false)):f.attachEvent?f.attachEvent("on"+d,function(b){if(!c.call(f,b)||!e)return a.cancelEvent(b)}):f["on"+d]=function(b){if(!c.call(f,b)||!e)return a.cancelEvent(b)}};this.cancelEvent=function(b){b=a.cantouch?b?
-b.original:false:b?b:window.event||false;if(!b)return false;b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b.cancelBubble=true;b.cancel=true;return b.returnValue=false};this.onmousewheel=function(b){b=b?b:window.event;if(a.rail.drag)return a.cancelEvent(b);var d=0;(d=b.detail?b.detail*-1:b.wheelDelta/40)&&a.doScrollBy(d*a.opt.mousescrollstep,true);return a.cancelEvent(b)};this.stop=function(){a.timer&&clearInterval(a.timer);a.timer=0;a.cursorfreezed=false;a.scroll.y=Math.round(a.getScrollTop()*
-(1/a.scrollratio.y));a.noticeCursor()};this.doScroll=function(b){a.newscrolly=b;if(!a.timer)a.timer=setInterval(function(){var b=a.newscrolly-a.getScrollTop(),b=b>0?Math.ceil(b/4):Math.floor(b/4),b=a.getScrollTop()+b;a.setScrollTop(b);if(b==a.newscrolly)clearInterval(a.timer),a.timer=0,a.cursorfreezed=false},a.opt.scrollspeed),a.noticeCursor()};this.doScrollBy=function(b,d){d&&(b=Math.round(b*1/a.scrollratio.y));var c=a.scroll.y-b;c<0&&(c=0);var e=a.scrollvaluemax;c>e&&(c=e);a.cursorfreezed=false;
-a.doScroll(Math.floor(c*a.scrollratio.y))};this.doScrollTo=function(b,d){d&&(b=Math.round(b*1/a.scrollratio.y));ny=b;ny<0&&(ny=0);var c=a.scrollvaluemax;ny>c&&(ny=c);a.cursorfreezed=false;a.doScroll(Math.floor(ny*a.scrollratio.y))};a.onscroll=function(){var b=(new Date).getTime();if(!a.lastcontentcheck||a.lastcontentcheck<b)if(a.lastcontentcheck=b+500,a.getContentSize().h!=a.page.h)a.onResize();if(!a.rail.drag){if(!a.cursorfreezed)a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()}};
-a.docscroll.scroll(function(b){a.onscroll(b)});this.doZoomIn=function(b){if(!a.zoomactive){a.zoomrestore={style:{}};var d="position,top,left,zIndex,backgroundColor,width,height,marginTop,marginBottom,marginLeft,marginRight".split(","),c;for(c in d){var e=d[c];a.zoomrestore.style[e]=a.win.css(e)||""}a.zoomrestore.padding={w:a.win.outerWidth()-a.win.width(),h:a.win.outerHeight()-a.win.height()};a.win.css({position:"fixed",top:0,left:0,"z-index":a.opt.zindex+100,margin:"0px"});d=a.win.css("backgroundColor");
-(d==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(d))&&a.win.css("backgroundColor","#fff");a.rail.css({"z-index":a.opt.zindex+110});a.zoom.css({"z-index":a.opt.zindex+112});a.zoomactive=true;a.zoom.css("backgroundPosition","0px -18px");a.resizeZoom();return a.cancelEvent(b)}};this.doZoomOut=function(b){if(a.zoomactive)return a.win.css("margin",""),a.win.css(a.zoomrestore.style),a.rail.css({"z-index":a.opt.zindex}),a.zoom.css({"z-index":a.opt.zindex}),a.zoomactive=false,a.zoomrestore=false,
-a.zoom.css("backgroundPosition","0px 0px"),a.win.resize(),a.cancelEvent(b)};this.doZoom=function(b){return a.zoomactive?a.doZoomOut(b):a.doZoomIn(b)};this.resizeZoom=function(){if(a.zoomactive){var b=a.getScrollTop();a.win.css({width:e(window).width()-a.zoomrestore.padding.w+"px",height:e(window).height()-a.zoomrestore.padding.h+"px"});a.setScrollTop(b);a.win.resize()}};this.init()};e.fn.niceScroll=function(c,a){typeof c=="object"&&typeof a=="undefined"&&(a=c,c=false);var f=[];typeof a=="undefined"&&
-(a={});if(c)a.doc=e(c),a.win=e(this);var g=!("doc"in a);this.each(function(){a.doc=g?e(this):a.doc;f.push(new l(a))});return f.length==1?f[0]:f}})(jQuery);
+(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);