jQuery(document).ready(function() {
	jQuery('a[href*=#]').each(function() {
	    pos=this.href.split('#');
		if(pos.length==2 && pos[1]!='')	{
			var target=pos[1];	
			jQuery(this).click(function(event) {
				event.preventDefault();
				var targetOffset = jQuery('#'+target).offset().top;		    
				jQuery('html').animate({scrollTop: targetOffset}, 500, function() {
					location.hash = target;
				});
			});
		}
	});
});
