/** * zudolab jqTinyscrolling * * @version 1 (updated: 2008/12/16) * @author Takeshi Takatsudo (http://zudolab.net/) * @license MIT (http://www.opensource.org/licenses/mit-license.php) * original idea by Marco Rosella (http://lab.centralscrutinizer.it/the-tiny-scrollings/) */ (function(g){var f;var b;var a;var h;var c;var e;var d;var k;jqTinyscrolling=function(m){this.speed=m&&m.speed?m.speed:20;this.maxStep=m&&m.maxStep?m.maxStep:200;this.maxStepWhenLongDoc=m&&m.maxStepWhenLongDoc?m.maxStepWhenLongDoc:1000;this.brakeK=m&&m.brakeK?m.brakeK:3;this.addHash=m&&m.addHash===false?false:true;this.anchors=[];var l=this;g(function(){l.setup()})};jqTinyscrolling.prototype.setup=function(){this.prepareAnchors();if(!this.anchors){return}this.setEvents()};jqTinyscrolling.prototype.prepareAnchors=function(){var l=g("a[href^=#]");for(var n=0,m;m=l[n];n++){if(g(m).hasClass("avoidScroll")){continue}this.anchors.push(m)}};jqTinyscrolling.prototype.setEvents=function(){var l=this;for(var o=0,m;m=this.anchors[o];o++){g(m).click(function(){if(d){j()}if(n(this)){i()}return false})}function n(p){var q=g(p);var s=q.attr("href").replace("#","");var r=document.getElementById(s);if(!r){return false}c=r;e=s;d=g(r).offset().top;f=l.speed;b=(g(document).height()>2500)?l.maxStepWhenLongDoc:l.maxStep;a=l.brakeK;h=l.addHash;return true}};function i(){var m=g(document).scrollTop();if(d>m){var l=Math.round((g(document).height()-(m+g(window).height()))/a);l=Math.min(Math.round((d-m)/a),l);var n=Math.max(2,Math.min(l,b));if(Math.round((d-m)/a)<10){n=2}}else{var n=-Math.min(Math.abs(Math.round((d-m)/a)),b)}window.scrollTo(0,m+n);if(Math.abs(m-d)<=1||g(document).scrollTop()==m){window.scrollTo(0,d);if(h&&(!document.all||window.opera)){location.hash=e}j()}else{k=setTimeout(i,f)}}function j(){f=null;b=null;a=null;h=null;c=null;e=null;d=null;clearTimeout(k);k=null}(function(){if(!g.browser.opera||g.browser.version<9.5){return}g.each(["Height","Width"],function(m,l){var n=l.toLowerCase();var o=g.fn[n];g.fn[n]=function(p){return this[0]==window?document.documentElement["client"+l]:o.call(this,p)}})})()})(jQuery); new jqTinyscrolling;