$(document).ready(function() {
	$('a[href*=#]').click(function() {
	   // make sure it's the same location      
	   if(location.pathname.replace(/^\//,'')==this.pathname.replace(/^\//,'') && location.hostname==this.hostname && this.hash.replace(/#/,''))
	   {
	      var hash=this.hash;
	      var target=$(hash).offset().top;
	      $("html:not(:animated),body:not(:animated)").animate({ scrollTop: target }, 500, function() { location.hash=hash; });
	      return false;
	   }
	});
});