SO fiddle
Test Fiddle mainly for SO Questions
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/overcast/jquery-ui.css">
<div id="categories">
<a href="#A">Section A</a>
<a href="#B">Section B</a>
<a href="#C">Section C</a>
<a href="#D">Section D</a>
</div>
<h3 id="A">Section A</h3>
<div>
Image1-Image2 etc<br />
<a href="#categories" class="backToTop">Back to Top</a>
</div>
<h3 id="B">Section B</h3>
<div>
Image1-Image2 etc<br />
<a href="#categories" class="backToTop">Back to Top</a>
</div>
<h3 id="C">Section C</h3>
<div>
Image1-Image2 etc<br />
<a href="#categories" class="backToTop">Back to Top</a>
</div>
<h3 id="D">Section D</h3>
<div>
Image1-Image2 etc<br />
<a href="#categories" class="backToTop">Back to Top</a>
</div>
CSS
#categories { height: 50px; }
div { height: 400px; border: solid 1px #ddd; }
JavaScript
$("#categories a, a.backToTop").click(function(e) {
e.preventDefault();
$('html, body').animate({ scrollTop: $(this.hash).offset().top });
});