<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<script type="text/javascript" src="http://yandex.st/jquery/1.4.4/jquery.min.js"></script>
</head>
<body>
<ul style="padding-bottom:400px;">
<li><a href="#one">One</a></li>
<li><a href="#two">Two</a></li>
<li><a href="#three">Three</a></li>
<li><a href="#four">Four</a></li>
<li><a href="#five">Five</a></li>
<li><a href="#six">four</a></li>
</ul>
<h2 id="one">One</h2>
<h2 id="two">Two</h2>
<h2 id="three">Three</h2>
<h2 id="four">Four</h2>
<h2 id="five">Five</h2>
<h2 id="six" style="padding-bottom:1000px;">Six</h2>
.....
<style>
h2[id].active,
a.active {
color:red;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
function setcookie(f,e,h){if(h){var g=new Date();g.setDate(g.getDate()+h)}if(f&&e){document.cookie=f+"="+encodeURIComponent(e)+";path=/"+(h?"; expires="+g.toUTCString():"")}else return false;}
function getcookie(e){var d=new RegExp(e+"=([^;]){1,}");var f=d.exec(document.cookie);if(f){f=f[0].split("=")}else{return false}return f[1]?decodeURIComponent(f[1]):false}
var blkLink = $('a[href="#one"]').parents('ul:first').find('a');
blkLink.click(function(e){
e.preventDefault();
blkLink.removeClass('active');
$('h2[id]').removeClass('active');
var hash = $(this).addClass('active').attr('href')
setcookie('blkLink',hash,30);
thScroll = $(hash).addClass('active').offset().top;
$('html, body').stop().animate({'scrollTop': thScroll},time,'swing', function () {
window.location.hash = hash;
});
});
var time=0;
var Lnk= getcookie('blkLink');
if(Lnk) blkLink.parents('ul:first').find('a[href="'+Lnk+'"]').click();
time=900;
});
</script>
</body>
</html>