(function($) {
	$(function() {
		$('a[href]').not('a[href^="#"]').each(function() {
			var path = this.getAttribute('href');
			if (path.indexOf('#') >= 0) {
				var absPath = (function() {
					var e = document.createElement('span');
					e.innerHTML = '<a href="' + path + '" />';
					return e.firstChild.href;
				})();
				absPath = absPath.substr(0, absPath.lastIndexOf('#'));
				var locationPath = location.href;
				if (locationPath.indexOf('#') >= 0) {
					locationPath = locationPath.substr(0, locationPath.lastIndexOf('#'));
				}
				if (absPath == locationPath) {
					var fragment = path.substr(path.lastIndexOf('#'));
					this.setAttribute('href', fragment);
				}
			}
		});
	});
})(jQuery);


