﻿window.onload=function(){tinyScrolling.init()};var tinyScrolling={speed:50,maxStep:150,brakeK:3,hash:null,currentBlock:null,requestedY:0,init:function(){var c=document.getElementsByTagName("a");for(var b=0,a;a=c[b];b++)if(a.href&&a.href.indexOf("#")!=-1&&(a.pathname==location.pathname||"/"+a.pathname==location.pathname)&&a.search==location.search)a.onclick=tinyScrolling.initScroll},getElementYpos:function(a){var b=0;while(a.offsetParent){b+=a.offsetTop;a=a.offsetParent}return b},getScrollTop:function(){if(document.all)return document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;else return window.pageYOffset},getWindowHeight:function(){if(window.innerHeight)return window.innerHeight;if(document.documentElement&&document.documentElement.clientHeight)return document.documentElement.clientHeight},getDocumentHeight:function(){if(document.height)return document.height;if(document.body.offsetHeight)return document.body.offsetHeight},initScroll:function(b){var a;if(!b)var b=window.event;if(b.target)a=b.target;else if(b.srcElement)a=b.srcElement;tinyScrolling.hash=a.href.substr(a.href.indexOf("#")+1,a.href.length);tinyScrolling.currentBlock=document.getElementById(tinyScrolling.hash);if(!tinyScrolling.currentBlock)return;tinyScrolling.requestedY=tinyScrolling.getElementYpos(tinyScrolling.currentBlock);tinyScrolling.scroll();return false},scroll:function(){var a=tinyScrolling.getScrollTop();if(tinyScrolling.requestedY>a){var b=Math.round((tinyScrolling.getDocumentHeight()-(a+tinyScrolling.getWindowHeight()))/tinyScrolling.brakeK);b=Math.min(Math.round((tinyScrolling.requestedY-a)/tinyScrolling.brakeK),b);var c=Math.max(2,Math.min(b,tinyScrolling.maxStep))}else var c=-Math.min(Math.abs(Math.round((tinyScrolling.requestedY-a)/tinyScrolling.brakeK)),tinyScrolling.maxStep);window.scrollTo(0,a+c);if(Math.abs(a-tinyScrolling.requestedY)<=1||tinyScrolling.getScrollTop()==a){window.scrollTo(0,tinyScrolling.requestedY);if(!document.all||window.opera)location.hash=tinyScrolling.hash;tinyScrolling.hash=null}else setTimeout(tinyScrolling.scroll,tinyScrolling.speed)}}
