(function ($) {
	$.fn.ScrollTo = function(speed, callback) {
		var top = $(this).offset().top;

		if ('BODY' == $(this).attr('tagName')) {
			top = 0;
		}

		var selector = 'html';

		if ($.browser.safari) {
			selector = 'body';
		}
		else if ($.browser.msie) {
			if ('undefined' != typeof document.documentElement.style.msInterpolationMode) {
				// IE7 later
			}
			else {
				selector = 'body';// IE6
			}
		}

		$(selector).animate({scrollTop: top}, speed, 'swing', callback);
	};
}) (jQuery);

$(document).ready(function() {
	$('a[href^=#]:not([href=#])').each(function() {
		$(this).click(function() {
			var id = $(this.hash);

			if (id.size()) {
				id.ScrollTo(800);
				return false;
			}
		});
	});
});
