Scroll to top of element using jQuery
Takes the distance between the top of the browser window and the element in question, then scrolls upwards. I subtract 100 so it doesn't quite scroll to the top.
var offset = $('#nameofsection').offset();
$("html").animate({scrollTop:offset.top - 100},900);