var View_smoothScroll = function(speed)
{ this.speed = speed; this.timer; this.offsetTop_current = 0; this.myConstruct = function()
{ var pointY; var ancA = document.getElementsByTagName('a'); var locate; var myThis = this; var ancs = document.getElementsByTagName('*'); for(var y = 0; y < ancA.length; y++)
{ locate = ancA[y]; if
( locate.href &&
locate.href.indexOf('#') != -1 &&
locate.href.match(/[#]$/) != "#" &&
( (locate.pathname ==location.pathname) || ('/' + locate.pathname ==location.pathname)
)
)
{ this.add(locate, this.del); locate.onclick = function()
{ locate = this.hash.substr(1); for(var i = 0; i < ancs.length; i++)
{ if(locate == ancs[i].name || locate == ancs[i].id)
{ pointY = myThis.get_y_anc(ancs[i]); clearInterval(this.timer); myThis.timer = setInterval( 'o_view.scroll(' + pointY + ')', 10 );}
}
}
}
}
}
this.add = function(locate, fnc)
{ if(locate.addEventListener)
{ locate.addEventListener('click', fnc, false);}
else if(locate.attachEvent)
{ locate.attachEvent('onclick', fnc);}
}
this.del = function(element)
{ if(window.event)
{ window.event.cancelBubble = true; window.event.returnValue = false;}
else if(element.preventDefault && element.stopPropagation)
{ element.preventDefault(); element.stopPropagation();}
}
this.get_y_anc = function(anc)
{ var y = anc.offsetTop; if(anc.offsetParent)
{ while(anc = anc.offsetParent)
{ y+= anc.offsetTop;}
}
return y;}
this.scroll = function(yMoving)
{ var yNow = this.get_y_now(); if(yMoving > yNow)
{ yNow+= Math.ceil( (yMoving - yNow) / this.speed );}
else
{ yNow+= (yMoving - yNow) / this.speed;}
window.scrollTo(0, yNow); if(yNow == yMoving || this.offsetTop_current == yNow)
{ clearInterval(this.timer);}
this.offsetTop_current = yNow;}
this.get_y_now = function()
{ var body= document.body; var d = document.documentElement; if(body && body.scrollTop) return body.scrollTop; if(d && d.scrollTop) return d.scrollTop; if(window.pageYOffset) return window.pageYOffset; return 0;}
this.myConstruct();}
if(window.addEventListener)
{ window.addEventListener
( 'load', function()
{ eval( 'o_view = new View_smoothScroll(10);' );}, false );}
else if(window.attachEvent)
{ window.attachEvent
( 'onload', function()
{ eval( 'o_view = new View_smoothScroll(10);' );} );}

