А если такой?
$(function() {
//инициализация меню
var lastId, //текущий выбранный
topMenu = $("#menu"), //селектор меню
topMenuHeight = topMenu.outerHeight()+1, //высота меню + коррекция при необходимости
menuItems = topMenu.find("a"), //коллекция ссылок меню
scrollItems = menuItems.map(function() { //якоря
var item = $($(this).attr("href"));
if(item.length) return item;
});
//прокрутка к выбранному в меню
menuItems.click(function(e) {
var href = $(this).attr("href"),
offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+15; //прокручиваем якорь за минусом высоты меню плюс коррекция при необходимости
$('body,html').stop().animate({
scrollTop: offsetTop
}, 1500, 'easeOutExpo', function() {
history.pushState(null, null, href); //изменили адресную строку
});
e.preventDefault();
});
//слежение меню за прокруткой страницы
$(window).scroll(function(){
var fromTop = $(this).scrollTop()+topMenuHeight;
var cur = scrollItems.map(function() {
if($(this).offset().top < fromTop) return this;
});
//изменение стиля элементов меню при скролле
cur = cur[cur.length-1];
var id = cur && cur.length ? cur[0].id : "";
if(/\d/g.exec(id)) id = id.split('-',1)[0];
if(lastId !== id) {
lastId = id;
menuItems.parent()
.removeClass("current")
.end()
.filter("[href=#"+id+"]")
.parent()
.addClass("current");
}
});
});