$(function() {
	smoothLink();
});

function smoothLink() {
	$( 'a' ).each(function() {
		if( this.href.match( /(\#(\w+))/g ) ) {
			var id = RegExp.$2;
			if( document.getElementById( id ) ) {
				$( this ).click((function( ot ) {
					return function( evt ) {
						if( evt.preventDefault ) {
							evt.preventDefault();
						} else {
							evt.returnValue = false;
						}
						
						var st = document.body.scrollTop || document.documentElement.scrollTop;
						$e( window, [0,st], [0,ot] ).easing( 100 ).smoothScroll(function() {
							location.href = location.href.replace( /#.*/, '' ) + '#' + id;
						});
					}
				})( $( '#' + id ).offset().top ) );
			}
		}
	});
}

