/*
 * Taken from http://snipplr.com/view/12510/smooth-scrolling-with-jquery-and-internal-page-links/
 *
 * Fixed by http://snipt.net/Jonic/jquery-smooth-scrolling-on-internal-links/
 *
 * Modified with ideas from http://eddcouchman.com/notebook/smooth-scrolling-links/
 * and with ideas from http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links/
 *
 */
$(document).ready(function() {
	$('a[href^=#]:not([href=#])').each(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[id=' + this.hash.slice(1) + ']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$(this).click(function() {
					$('html, body').animate({scrollTop: targetOffset}, 400);
					return false;
				});
			}
		}
	});
});
