function handler(event) {
var hash = typeof event === 'string' ? event : event.target.hash;
var headerHeight = $('.top').height();
if (!hash)
return
var tag = $(hash);
if (tag.length) {
var offset = tag.offset().top - headerHeight;
$('html, body').stop().animate({
scrollTop: offset
}, 2000);
}
}
$('.top-menu a').on("click", handler);
$(function() {
handler(location.hash);
});