$('.scroll-to').click(function(e) {
var thisHref = $(this).attr("href");
var thisPos = $(thisHref).offset().top;
var thisAttrScrollOffset = $(this).attr('data-scrolloffset');
var thisOffset;
if (typeof thisAttrScrollOffset !== typeof undefined && thisAttrScrollOffset !== false) {
thisOffset = +$(this).attr('data-scrolloffset');
} else {
thisOffset = 0;
}
var thisScroll = thisPos - thisOffset;
if ( thisHref === "" ) {
alert( "ATTENTION: This link has a scroll-to class. You need to add a href attribute value for this scroll-to link to function correctly. Make sure the href attribute value starts with a '#'" );
} else {
$("html, body").animate( { scrollTop: Math.ceil( thisScroll ) }, 800 );
}
e.preventDefault();
});