Selaa lähdekoodia

2.6.5 - scroll + bounce + optimization

This release version 2.6.5 (recommended update for more stable experience) with optimizations on scroll feeling and new bounce scrolling, read changelog for a complete list:
-bounce effect with mouse wheel scrolling (bouncescroll)
-more fast scrolling at top/bottom with mouse wheel
-rail/cursor position/size optimization
Inuyaksa 13 vuotta sitten
vanhempi
commit
aae9619657
8 muutettua tiedostoa jossa 346 lisäystä ja 304 poistoa
  1. 3 2
      README
  2. 0 21
      changelog_2.6.0.txt
  3. 35 0
      changelog_2.6.5.txt
  4. 1 1
      demo/index.html
  5. 53 59
      demo/js/jquery.nicescroll.min.js
  6. 199 160
      jquery.nicescroll.js
  7. 53 59
      jquery.nicescroll.min.js
  8. 2 2
      package.json

+ 3 - 2
README

@@ -1,5 +1,5 @@
 jquery.nicescroll
-v. 2.6.0 12-15-2011
+v. 2.6.5 12-22-2011
 copyright 2011 InuYaksa*2011
 licensed under the MIT
 http://areaaperta.com/nicescroll
@@ -111,7 +111,7 @@ When you call "niceScroll" you can pass some parameters to custom visual aspects
 . cursorborderradius - border radius in pixel for cursor, default is "4px"
 . zindex - change z-index for scrollbar div, default value is 9999
 . scrollspeed - scrolling speed, default value is 60
-. mousescrollstep - scrolling speed with mouse wheel, default value is 48 (pixel)
+. mousescrollstep - scrolling speed with mouse wheel, default value is 40 (pixel)
 . touchbehavior - enable cursor-drag scrolling like touch devices in desktop computer, default is false
 . hwacceleration - use hardware accelerated scroll when supported, default is true
 . boxzoom - enable zoom for box content, default is false
@@ -124,6 +124,7 @@ When you call "niceScroll" you can pass some parameters to custom visual aspects
 . cursorminheight, set the minimum cursor height in pixel (default:20)
 . preservenativescrolling, you can scroll native scrollable areas with mouse, bubbling mouse wheel event (default:true)
 . railoffset, you can add offset top/left for rail position (default:false)
+. bouncescroll, enable scroll bouncing at the end of content as mobile-like (only hw accell) (default:false)
 
 * LICENSE
 

+ 0 - 21
changelog_2.6.0.txt

@@ -1,21 +0,0 @@
-Changelog nicescroll release 2.6.0
-http://areaaperta.com/nicescroll
-https://github.com/inuyaksa/jquery.nicescroll
-
-New options
-- preservenativescrolling, you can scroll native scrollable areas with mouse, bubbling mouse wheel event (default:true)
-- railoffset, you can add offset top/left for rail position (default:false)
-
-Changed features
-- optimized scroll event dispatcher for hwaccelerated scroll
-- optimized scroll momentum and bounce effect(scroll by touch)
-
-Fixes
-- detection of window object on bind function (addEventListener access error)
-- scrolling up with mouse wheel can stuck
-- scrollTop override (hw accelerated scroll)
-- iframe autoresize
-
-Other updates
-- mouseup/mousedown events changed bind from rail to cursor
-- crossdomain iframes detection

+ 35 - 0
changelog_2.6.5.txt

@@ -0,0 +1,35 @@
+Changelog nicescroll release 2.6.5
+http://areaaperta.com/nicescroll
+https://github.com/inuyaksa/jquery.nicescroll
+
+
+New features
+- bounce effect with mouse wheel scrolling (bouncescroll)
+
+
+New options
+- bouncescroll, enable scroll bouncing at the end of content as mobile-like (only hw accell) (default:false)
+
+
+Changed features
+- more fast scrolling at top/bottom with mouse wheel
+- (chrome) grab cursor doesn't appears (browser bug)
+- default hide timeout for cursor changed from 800ms to 400ms
+- mousescrollstep changed to 8*5 (recalibration after doScroll change)
+- rail/cursor some position/size optimization
+
+
+Warning, this changes can break compatibility
+- doScrollBy default changed to absolute pixels
+- doScrollTo default changed to absolute pixels
+
+
+Fixes
+- (hw scroll) added scrollTop animate hook
+- (mousewheel scrolling on page rail) "a.ownerDocument is null" error
+- mouseover of zoom icon
+- check scroll position on zoomin (scroll on bottom of the page)
+
+
+Other updates
+- Some internal optimizations

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

+ 53 - 59
demo/js/jquery.nicescroll.min.js

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

+ 199 - 160
jquery.nicescroll.js

@@ -1,5 +1,5 @@
 /* jquery.nicescroll
--- version 2.6.0
+-- version 2.6.5
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
@@ -30,7 +30,7 @@
 
     var self = this;
 
-    this.version = '2.6.0';
+    this.version = '2.6.5';
     this.name = 'nicescroll';
     
     this.me = me;
@@ -46,7 +46,7 @@
       cursorborder:"1px solid #fff",
       cursorborderradius:"5px",
       scrollspeed:60,
-      mousescrollstep:8*6,
+      mousescrollstep:8*5,
       touchbehavior:false,
       hwacceleration:true,
       usetransition:true,
@@ -59,7 +59,8 @@
       iframeautoresize:true,
       cursorminheight:20,
       preservenativescrolling:true,
-      railoffset:false
+      railoffset:false,
+      bouncescroll:false
     };
     
     if (myopt||false) {
@@ -86,6 +87,7 @@
     this.onmousemove = false;
     this.onmousewheel = false;
     this.onkeypress = false;
+    this.ongesturezoom = false;
     
     
 // Let's start!  
@@ -133,20 +135,16 @@
     this.isie9 = this.isie&&("performance" in window)&&(document.documentMode>=9);
     
     this.ismozilla = ("MozAppearance" in domtest.style);
+    this.ischrome = ("chrome" in window);
     
     this.cantouch = ("ontouchstart" in document.documentElement);
 
-    if (this.cantouch && /iphone|ipad|ipod/i.test(navigator.platform)) {
-      this.isios = true;
-      this.isios4 = !("seal" in Object);
-    } else {
-      this.isios = false;
-      this.isios4 = false;
-    }
+    this.isios = (this.cantouch && /iphone|ipad|ipod/i.test(navigator.platform));
+    this.isios4 = ((this.isios)&&!("seal" in Object));
     
     if (self.opt.hwacceleration) {  // if you dont need dont bother to look for
       this.trstyle = (window.opera) ? 'OTransform' : (document.all) ? 'msTransform' : (domtest.style.webkitTransform!==undefined) ? 'webkitTransform' : (domtest.style.MozTransform!==undefined) ? 'MozTransform' : false;
-      if (this.trstyle && domtest.style[this.trstyle] === undefined) this.trstyle = false;
+      if (this.trstyle && typeof domtest.style[this.trstyle] == "undefined") this.trstyle = false;
       this.hastransform = (this.trstyle != false);
       if (this.hastransform) {
         domtest.style[this.trstyle] = "translate3d(1px,2px,3px)";
@@ -182,7 +180,7 @@
     
     if (self.opt.grabcursorenabled&&self.opt.touchbehavior) {  // check grab cursor support
       function detectCursorGrab() {
-        if (!self.isie||self.isie9) {  // some old IE return false positive
+        if (!self.ischrome&&(!self.isie||self.isie9)) {  // some old IE return false positive + chrome cursor bug
           var lst = ['grab','-moz-grab','-webkit-grab'];
           for(var a=0;a<lst.length;a++) {
             var p = lst[a];
@@ -190,22 +188,30 @@
             if (domtest.style['cursor']==p) return p;
           }
         }
-        return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';
+        return 'url(http://www.google.com/intl/en_ALL/mapfiles/openhand.cur),n-resize';  // thank you google!
       }
       this.cursorgrabvalue = detectCursorGrab();
     }
 
-    domtest = null;
+    domtest = null;  //memory released
     
     this.ishwscroll = (self.hastransform)&&(self.opt.hwacceleration)&&(self.haswrapper);
     
+    this.css = function(el,pars) {  // save & set
+      for(var n in pars) {
+        self.saved.css.push([el,n,el.css(n)]);
+        el.css(n,pars[n]);
+      }
+    }
+    
     this.scrollTop = function(val) {
-      return (val === undefined) ? self.getScrollTop() : self.setScrollTop(val);
+      return (typeof val == "undefined") ? self.getScrollTop() : self.setScrollTop(val);
     };
     
-    if (this.ishwscroll) {
-      // hw accelerated scroll
+    if (this.ishwscroll) {  
+    // hw accelerated scroll
       self.doc.translate = {x:0,y:0};
+      
       this.getScrollTop = function() {
         return self.doc.translate.y;
       };
@@ -242,7 +248,7 @@
         };
       }
     } else {
-      // native scroll
+    // native scroll
       this.getScrollTop = function() {
         return self.docscroll.scrollTop();
       };
@@ -274,7 +280,7 @@
         var pos = self.win.offset();
         pos.top+=2;
         var brd = (self.win.outerWidth() - self.win.innerWidth())/2;
-        pos.left+= self.win.innerWidth() + brd - self.rail.width - 1;
+        pos.left+= self.win.innerWidth() + brd - self.rail.width -1;
         
         var off = self.opt.railoffset;
         if (off) {
@@ -282,8 +288,8 @@
           if (off.left) pos.left+=off.left;
         }
         
-        self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
-        if (self.zoom) self.zoom.css({position:"absolute",top:pos.top+1,left:pos.left-20});
+        self.rail.css({top:pos.top,left:pos.left,height:(len)?len.h:self.win.innerHeight()});
+        if (self.zoom) self.zoom.css({top:pos.top+1,left:pos.left-20});
       }
     };
     
@@ -317,15 +323,12 @@
     this.init = function() {
 
       self.saved.css = [];
-      if (self.ispage) self.saved.css.push([self.doc,'overflow-y',self.doc.css('overflow-y')]);
-      if (!self.ispage) self.saved.css.push([self.docscroll,'overflow-y',self.docscroll.css('overflow-y')]);
-      if (self.ispage&&self.isie7) self.saved.css.push([$("html"),'overflow-y',$("html").css('overflow-y')]);
       
       if (!self.ispage || (!self.cantouch && !self.isieold)) {
 
-        (self.ispage)?self.doc.css({'overflow-y':'hidden'}):self.docscroll.css({'overflow-y':'hidden'});
+        (self.ispage)?self.css(self.doc,{'overflow-y':'hidden'}):self.css(self.docscroll,{'overflow-y':'hidden'});
       
-        if (self.ispage&&self.isie7) $("html").css({'overflow-y':'hidden'});  //IE7 double scrollbar issue
+        if (self.ispage&&self.isie7&&self.win[0].nodeName=='BODY') self.css($("html"),{'overflow-y':'hidden'});  //IE7 double scrollbar issue
         
         var cursor = $(document.createElement('div'));
         cursor.css({
@@ -343,7 +346,7 @@
         
         var rail = $(document.createElement('div'));
         rail.attr('id',self.id);
-        rail.width = 3+Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth());
+        rail.width = 1+Math.max(parseFloat(self.opt.cursorwidth),cursor.outerWidth());
         rail.css({"padding-left":"0px","padding-right":"1px",width:rail.width+"px",'zIndex':(self.ispage)?self.opt.zindex:self.opt.zindex+2,"background":self.opt.background});
         
         rail.append(cursor);
@@ -358,27 +361,30 @@
           self.zoom.css({"cursor":"pointer",'z-index':self.opt.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
           if (self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
           if (self.cantouch&&self.opt.gesturezoom) {
-            self.bind(self.win,"gestureend",function(e) {
+            self.ongesturezoom = function(e) {
               if (e.scale>1.5) self.doZoomIn(e);
               if (e.scale<0.8) self.doZoomOut(e);
               return self.cancelEvent(e);
-            });             
+            };
+            self.bind(self.win,"gestureend",self.ongesturezoom);             
           }
         }
         
         if (self.ispage) {
           rail.css({position:"fixed",top:"0px",right:"0px",height:"100%"});
-          self.doc.append(rail);          
+          $("body").append(rail);          
         } else {
           if (self.ishwscroll) {
-            if (self.win.css('position')=='static') self.win.css('position','relative');
+            if (self.win.css('position')=='static') self.css(self.win,{'position':'relative'});
             if (self.zoom) {
               self.zoom.css({position:"absolute",top:1,right:0,"margin-right":rail.width+4});
               self.win.append(self.zoom);
             }
             rail.css({position:"absolute",top:0,right:0});
-            self.win.append(rail);          
+            self.win.append(rail);
           } else {
+            rail.css({position:"absolute"});
+            if (self.zoom) self.zoom.css({position:"absolute"});
             self.updateScrollBar();
             $("body").append(rail);           
             if (self.zoom) $("body").append(self.zoom);
@@ -414,7 +420,7 @@
           self.onmousedown = function(e) {
             if (!self.locked) {
               self.cancelScroll();
-              self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};//,st:self.getScrollTop(),lx:e.pageX,ly:e.pageY,nx:e.pageX,ny:e.pageY,tt:(new Date()).getTime(),lt:(new Date()).getTime()};
+              self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
               self.hasmoving = false;
               self.scrollmom.y.reset(e.screenY);
               if (!self.cantouch) return self.cancelEvent(e);
@@ -422,7 +428,6 @@
           };
           self.onmouseup = function(e) {
             if (self.rail.drag) {            
-//              self.doScrollMomentum(self.rail.drag);
               self.scrollmom.y.doMomentum();
               self.rail.drag = false;
               if (self.hasmoving) {
@@ -465,8 +470,8 @@
           };
           
           if (self.cursorgrabvalue) {
-            self.saved.css.push([self.win,'cursor',self.win.css('cursor')]);
-            self.win.css({'cursor':self.cursorgrabvalue});
+            self.css(self.win,{'cursor':self.cursorgrabvalue});            
+            self.css(self.rail,{'cursor':self.cursorgrabvalue});
           }
         } else {
           self.onmousedown = function(e) {
@@ -520,11 +525,21 @@
             self.rail.active = false;
             if (!self.rail.drag) self.hideCursor();
           });
-        
           if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
           self.bind(self.rail,"mousewheel",self.onmousewheel);
         }
 
+        if (self.zoom) {
+          self.zoom.mouseenter(function() {
+            self.showCursor();
+            self.rail.active = true;
+          });          
+          self.zoom.mouseleave(function() { 
+            self.rail.active = false;
+            if (!self.rail.drag) self.hideCursor();
+          });
+        }
+        
         if (!self.ispage&&!self.cantouch) {
           if (!self.win.attr("tabindex")) self.win.attr({"tabindex":tabindexcounter++});
           self.win.focus(function(e) {
@@ -561,46 +576,46 @@
             
             if (self.locked&&key!=27) return self.cancelEvent(e);
             
-            var ret = true;
+            var ret = false;
             switch (key) {
               case 38:
               case 63233: //safari
-                self.doScrollBy(24*3,true);
-                ret = false;
+                self.doScrollBy(24*3);
+                ret = true;
                 break;
               case 40:
               case 63235: //safari
-                self.doScrollBy(-24*3,true);
-                ret = false;
+                self.doScrollBy(-24*3);
+                ret = true;
                 break;
               case 33:
               case 63276: // safari
-                self.doScrollBy(self.view.h,true);
-                ret = false;
+                self.doScrollBy(self.view.h);
+                ret = true;
                 break;
               case 34:
               case 63277: // safari
-                self.doScrollBy(-self.view.h,true);
-                ret = false;
+                self.doScrollBy(-self.view.h);
+                ret = true;
                 break;
               case 36:
               case 63273: // safari
-                self.doScrollTo(0,true);
-                ret = false;
+                self.doScrollTo(0);
+                ret = true;
                 break;
               case 35:
               case 63275: // safari
-                self.doScrollTo(self.page.maxh,true);
-                ret = false;
+                self.doScrollTo(self.page.maxh);
+                ret = true;
                 break;
               case 27: // ESC
                 if (self.zoomactive) {
                   self.doZoom();
-                  ret = false;
+                  ret = true;
                 }
                 break;
             }
-            if (!ret) return self.cancelEvent(e);
+            if (ret) return self.cancelEvent(e);
           }
         };
         
@@ -628,18 +643,13 @@
           if (self.opt.iframeautoresize&&!self.isiframe) {
             self.win.scrollTop(0); // reset position
             self.doc.height("");  //reset height to fix browser bug
-//            var cc=self.doc.contents();
-//            var hh=Math.max(cc.find('html').attr('scrollHeight'),cc.find('body').attr('scrollHeight'));
-            var hh=Math.max(self.win.height(),doc.body.scrollHeight);
+            var hh=Math.max(doc.getElementsByTagName('html')[0].scrollHeight,doc.body.scrollHeight);
             self.doc.height(hh);          
           }
           self.onResize();
           
-          if (self.isie7) self.saved.css.push([$(doc).find('html'),'overflow-y',$(doc).find('html').css('overflow-y')]);
-          self.saved.css.push([$(doc.body),'overflow-y',$(doc.body).css('overflow-y')]);
-          
-          if (self.isie7) $(doc).find('html').css({'overflow-y':'hidden'});
-          $(doc.body).css({'overflow-y':'hidden'});
+          if (self.isie7) self.css($(doc).find('html'),{'overflow-y':'hidden'});
+          self.css($(doc.body),{'overflow-y':'hidden'});
           if ('contentWindow' in this) {
             self.bind(this.contentWindow,"scroll",self.onscroll);  //IE8 & minor
           } else {          
@@ -650,30 +660,21 @@
           self.bind(doc,(self.isopera)?"keypress":"keydown",self.onkeypress);          
           if (self.cantouch||self.opt.touchbehavior) {
             self.bind(doc,"mousedown",self.onmousedown);
-            if (self.cursorgrabvalue) {
-              self.saved.css.push([$(doc),'cursor',$(doc).css('cursor')]);
-              $(doc).css({'cursor':self.cursorgrabvalue});
-            }
+            if (self.cursorgrabvalue) self.css($(doc),{'cursor':self.cursorgrabvalue});
           }
           
           self.bind(doc,"mousemove",self.onmousemove);
           
           if (self.zoom) {
             if (self.opt.dblclickzoom) self.bind(doc,'dblclick',self.doZoom);
-            if (self.cantouch&&self.opt.gesturezoom) {
-              self.bind(doc,"gesturechange",function(e) {
-                if (e.scale>1.5) self.doZoomIn(e);
-                if (e.scale<0.8) self.doZoomOut(e);
-                return self.cancelEvent(e);
-              });             
-            }          
+            if (self.ongesturezoom) self.bind(doc,"gestureend",self.ongesturezoom);             
           }
         };
         
         if (this.doc[0].readyState&&this.doc[0].readyState=="complete"){
           setTimeout(function(){oniframeload.call(self.doc[0],false)},500);
         }
-        this.doc.load(oniframeload);
+        self.bind(this.doc,"load",oniframeload);
         
       }
       
@@ -705,7 +706,7 @@
            if (self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
          }
          self.cursortimeout = 0;
-      },tm||800);
+      },tm||400);
     };
     
     this.noticeCursor = function(tm) {
@@ -736,8 +737,8 @@
           h:self.docscroll[0].scrollHeight
         };
         
-      pg.w-=1;
-      pg.h-=1;
+//      pg.w-=1;
+//      pg.h-=1;
 
       return pg;
     };
@@ -771,9 +772,9 @@
       
       self.page = self.getContentSize();
       
-      self.page.maxh = self.page.h - self.view.h;
+      self.page.maxh = Math.max(0,self.page.h - self.view.h);
       
-      if (self.view.h>=self.page.h) {
+      if (self.page.maxh==0) {
         self.hide();        
         self.scrollvaluemax = 0;
         self.scroll.y = 0;
@@ -793,11 +794,11 @@
       self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
       self.cursorheight = Math.max(self.opt.cursorminheight,self.cursorheight);
       
-      self.scrollvaluemax = self.view.h-self.cursorheight-self.cursor.hborder-2;
+      self.scrollvaluemax = self.view.h-self.cursorheight-self.cursor.hborder;
       
       self.scrollratio = {
         x:0,
-        y:((self.page.h - self.view.h)/self.scrollvaluemax)
+        y:(self.page.maxh/self.scrollvaluemax)
       };
      
       self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
@@ -823,7 +824,7 @@
     };
    
     this.bind = function(dom,name,fn,bubble) {  // touch-oriented & fixing jquery bind
-      var el = (dom.length&&("selector" in dom)) ? dom[0] : dom;
+      var el = ("jquery" in dom) ? dom[0] : dom;
       if (el.addEventListener) {
         if (self.cantouch && /mouseup|mousedown|mousemove/.test(name)) {  // touch device support
           var tt = (name=='mousedown')?'touchstart':(name=='mouseup')?'touchend':'touchmove';
@@ -837,9 +838,13 @@
       }
       else {
         self._bind(el,name,function(e) {
-          if (e&&!("pageY" in e)&&("screenY" in e)) {
-            e.pageX = e.screenX;
-            e.pageY = e.screenY;
+          e = e||window.event||false;
+          if (e) {
+            if (e.srcElement) e.target=e.srcElement;
+            if ("screenY" in e) {
+              e.pageX = e.screenX;
+              e.pageY = e.screenY;
+            }
           }
           return ((fn.call(el,e)===false)||bubble===false) ? self.cancelEvent(e) : true;
         });
@@ -910,9 +915,9 @@
       return self;
     };
     
-    this.isScrollable = function(e) {
+    this.isScrollable = function(e) {      
       var dom = (e.target) ? e.target : e;
-      while (dom&&dom.nodeName&&dom.nodeName!='BODY') {
+      while (dom&&dom.nodeName&&!(/BODY|HTML/.test(dom.nodeName))) {
         var dd = $(dom);
         var ov = dd.css('overflowY')||dd.css('overflow')||'';        
         if (/scroll|auto/.test(ov)) return (dom.clientHeight!=dom.scrollHeight);
@@ -928,13 +933,12 @@
       }
       if (self.nativescrollingarea) return true; // it's not my business
       if (self.locked) return self.cancelEvent(e);
-      e = e ? e : window.event;
       if (self.rail.drag) return self.cancelEvent(e);
       var delta = 0;      
       var delta = e.detail ? e.detail * -1 : e.wheelDelta / 40;
       if (delta) {
         if (self.scrollmom) self.scrollmom.y.stop();
-        self.doScrollBy(delta*self.opt.mousescrollstep,true);
+        self.doScrollBy(delta*self.opt.mousescrollstep);
       }
       return self.cancelEvent(e);
     };
@@ -958,56 +962,101 @@
           self.doc.css(self.transitionstyle,trans);
         }
       };
-      this.doScroll = function(y) {
+      this.doScroll = function(y) {       
+        var sy = self.getScrollTop();
+        if (y<0&&sy<=0) return self.noticeCursor();
+        else if (y>self.page.maxh&&sy>=self.page.maxh) return self.noticeCursor();
+        
         self.newscrolly = y;
+        
         if (self.timer) return false;
         
+        if (!self.scrollendtrapped) {
+          self.scrollendtrapped = true;
+          self.bind(self.doc,self.transitionend,self.onScrollEnd,false); //I have got to do something usefull!!
+        }
+        
         self.timer = setTimeout(function(){        
           var top = self.getScrollTop();
           var dif = Math.abs(top-self.newscrolly);
-          self.prepareTransition(dif)
+          self.prepareTransition(dif);
           self.timer = setTimeout(function(){
-            self.setScrollTop(self.newscrolly);
-            self.timer = 0;
+            if (self.newscrolly<0&&!self.opt.bouncescroll) self.newscrolly = 0
+            else if (self.newscrolly>self.page.maxh&&!self.opt.bouncescroll) self.newscrolly = self.page.maxh;          
+            if (self.newscrolly==self.getScrollTop()) {
+              self.timer = 0;
+              self.onScrollEnd();
+            } else {
+              self.setScrollTop(self.newscrolly);
+              self.timer = 0;
+            }
           },15);
         },self.opt.scrollspeed);
         self.noticeCursor();
       };
-      this.cancelScroll = function() {
+      this.cancelScroll = function() {        
+        self.scrollendtrapped = false;
+        self._unbind(self.doc,self.transitionend,self.onScrollEnd);
         var py = self.getScrollTop();
-        self.prepareTransition(0);
+        self.prepareTransition(0);        
         self.setScrollTop(py);
+//        self.scrollstart = false;
         self.noticeCursor();
         return self;
       };
-      
-//      self.bind(self.doc,'transitionend',function(e){console.log(e)},false); TEST!! Later or soon I use it! (I hope so)
+      this.onScrollEnd = function() {
+        self.scrollendtrapped = false;
+        self._unbind(self.doc,self.transitionend,self.onScrollEnd);
+        var py = self.getScrollTop();
+        if (py<0) self.doScroll(0)
+        else if (py>self.page.maxh) self.doScroll(self.page.maxh);
+      };
 
     } else {
       this.doScroll = function(y) {
+        var py = self.getScrollTop();
         self.newscrolly = y;
-        var df = y-self.getScrollTop();
-        if ((df*df)>100) {
+        var df = y-py;
+        self.newspeedy = {
+          x:y-Math.round(df/4),
+          v:Math.round(df/12)
+        };
+        if (Math.abs(self.newspeedy.v)<5) {
           self.newspeedy = {
-            x:y-Math.round(df/6),
-            v:Math.round((df/6*5/8)+0.5)
+            x:y-Math.round(df/4),
+            v:Math.round((df/4)*3)
           };
-        } else {
-          self.newspeedy = false;
         }
+        if (self.newspeedy.v==0) self.newspeedy = false;
+        
+        if (!self.bouncescroll) {
+          if (self.newscrolly<0) {
+            if (self.newspeedy) self.newspeedy.x = 0;
+            self.newscrolly = 0;
+          }
+          else if (self.newscrolly>self.page.maxh) {
+            if (self.newspeedy) self.newspeedy.x = self.page.maxh;
+            self.newscrolly = self.page.maxh;
+          }
+        }
+        
         if (self.timer) return;
         var rt = 1/4;      
         var sync = 0;
         var lastsync = 0;
+        var tick = self.opt.scrollspeed/2;
+        
         function scrolling() {
           if (self.cancelAnimationFrame) return true;
           sync=(new Date()).getTime();
           if (sync<lastsync) return (self.timer = setAnimationFrame(scrolling)||1);
-          lastsync = Math.floor((new Date()).getTime()+self.opt.scrollspeed/2);
+          lastsync = Math.floor(sync+tick);
           sync=0;
           var sy = self.getScrollTop();
+          var dr=0;
           if (self.newspeedy) {
             var sc = sy + self.newspeedy.v;
+            dr = self.newspeedy.v;           
             if (self.newspeedy.v>0) {
               if (sc>=self.newspeedy.x) self.newspeedy = false;
             } else {
@@ -1016,13 +1065,17 @@
           } else {
             var gp = self.newscrolly - self.getScrollTop();
             var df = (gp>0) ? Math.ceil(gp*rt) : Math.floor(gp*rt);
-            var sc = (df) ? self.getScrollTop()+df : self.newscrolly;
-          }
+            var sc = (df) ? self.getScrollTop()+df : self.newscrolly;                        
+            dr = df;            
+          }                    
+          if ((dr<0&&sc<self.newscrolly)||(dr>0&&sc>self.newscrolly)) sc = self.newscrolly;
           self.setScrollTop(sc);
-          if (sc == self.newscrolly) {            
+          if (sc == self.newscrolly) {
 //            clearAnimationFrame(self.timer);
             self.timer = 0;        
             self.cursorfreezed = false;
+            if (sc<0) self.doScroll(0);
+            else if (sc>self.page.maxh) self.doScroll(self.page.maxh);
           } else {
             self.timer = setAnimationFrame(scrolling)||1;
           }
@@ -1039,25 +1092,28 @@
       };
     }
     
-    this.doScrollBy = function(stp,absolute) {
+    this.doScrollBy = function(stp,relative) {
       var ny = 0;
-      if (absolute) {
-        if (self.timer) {
-          ny = self.newscrolly-stp;
-        } else {
-          ny = self.getScrollTop()-stp;  
-        }          
-      } else {
+      if (relative) {
         ny = Math.floor((self.scroll.y-stp)*self.scrollratio.y)
+      } else {        
+        var sy = (self.timer) ? self.newscrolly : self.getScrollTop();        
+        ny = sy-stp;
       }
-      if (ny<0) ny=0
-      else if (ny>self.page.maxh) ny = self.page.maxh;
-      self.cursorfreezed = false;
+      if (self.bouncescroll) {
+        var haf = Math.round(self.view.h/2);
+        if (ny<-haf) ny=-haf
+        else if (ny>(self.page.maxh+haf)) ny = (self.page.maxh+haf);
+      } /*else {
+        if (ny<0) ny=0
+        else if (ny>self.page.maxh) ny=self.page.maxh;
+      }*/
+      self.cursorfreezed = false;      
       self.doScroll(ny);
     };
     
-    this.doScrollTo = function(pos,absolute) {
-      var ny = (absolute) ? pos : Math.round(pos*self.scrollratio.y);
+    this.doScrollTo = function(pos,relative) {
+      var ny = (relative) ? Math.round(pos*self.scrollratio.y) : pos;
       if (ny<0) ny=0
       else if (ny>self.page.maxh) ny = self.page.maxh;
       self.cursorfreezed = false;
@@ -1151,9 +1207,8 @@
         width:$(window).width()-self.zoomrestore.padding.w+"px",
         height:$(window).height()-self.zoomrestore.padding.h+"px"
       });
-      self.setScrollTop(py);
-      
       self.onResize();
+      self.setScrollTop(Math.min(self.page.maxh,py));
     };
    
     this.init();
@@ -1263,11 +1318,16 @@
       return (nice&&nice.ishwscroll) ? nice.getScrollTop() : _scrollTop.call(elem);
     },
     set: function(elem,value) {
-      var nice = $.data(elem,'__nicescroll')||false;      
+      var nice = $.data(elem,'__nicescroll')||false;    
       (nice&&nice.ishwscroll) ? nice.setScrollTop(parseInt(value)) : _scrollTop.call(elem,value);
       return this;
     }
   };
+  
+  $.fx.step["scrollTop"] = function(fx){
+    if (fx.start=='') fx.start=$.cssHooks.scrollTop.get(fx.elem);
+    $.cssHooks.scrollTop.set(fx.elem,fx.now+fx.unit);
+  };  
  
   jQuery.fn.scrollTop = function(value) {    
     if (typeof value == "undefined") {
@@ -1290,42 +1350,6 @@
       for(var a=0;a<self.length;a++) fn.call(self[a]);
       return self;
     };
-
-    this.show = function() {
-      return self.each(function(){
-        this.show();
-      });
-    };
-
-    this.hide = function() {
-      return self.each(function(){
-        this.hide();
-      });
-    };
-
-    this.onResize = function() {  // OBSOLETE - for compatibilty
-      return self.each(function(){
-        this.onResize();
-      });
-    };
-
-    this.resize = function() {
-      return self.each(function(){
-        this.resize();
-      });
-    };
-    
-    this.remove = function() {
-      return self.each(function(){
-        this.remove();
-      });
-    };
-    
-    this.stop = function() {
-      return self.each(function(){
-        this.stop();
-      });
-    };
     
     this.push = function(nice) {
       self[self.length]=nice;
@@ -1349,6 +1373,21 @@
     return this;
   };
   
+  function mplex(el,lst,fn) {
+    for(var a=0;a<lst.length;a++) fn(el,lst[a]);
+  };  
+  mplex(
+    NiceScrollArray.prototype,
+    ['show','hide','onResize','resize','remove','stop'],
+    function(e,n) {
+      e[n] = function(){
+        return this.each(function(){
+          this[n].call();
+        });
+      };
+    }
+  );  
+  
   jQuery.fn.getNiceScroll = function(index) {
     if (typeof index == "undefined") {
       return new NiceScrollArray(this);
@@ -1359,8 +1398,8 @@
   };
   
   jQuery.extend(jQuery.expr[':'], {
-    nicescroll: function(a) { 
-      return ($.data(a,'__nicescroll')||false);
+    nicescroll: function(a) {
+      return ($.data(a,'__nicescroll'))?true:false;
     }
   });  
   

+ 53 - 59
jquery.nicescroll.min.js

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

+ 2 - 2
package.json

@@ -1,6 +1,6 @@
 {
     "name": "nicescroll",
-    "version": "2.6.0",
+    "version": "2.6.5",
     "title": "jQuery.NiceScroll",
     "author": {
         "name": "InuYaksa",
@@ -13,7 +13,7 @@
         }
     ],
     "dependencies": {
-        "jquery": ">=1.4.2"
+        "jquery": ">=1.4.3"
     },
     "description": "Nicescroll (as nice scroll for browsers) is a jquery (since 1.5) plugin, for nice scrollbars with a very similar ios/mobile style. It supports DIVs, IFrames and document page (body) scrollbars. Compatible with Firefox 4+, Chrome 5+, Safari 4+ (win/mac), Opera 10+, IE 6+ (all A-grade browsers). Compatible with iOS devices as iPad.",
     "keywords": [