function filterPath(string) { 
	return string
    	.replace(/^\//,'')
        .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
        .replace(/\/$/,'');
}

$(document).ready(function() {
	$("a[href*=#], area[href*=#]").each(function() {
		caller = $(this).attr("href");												 
		if (caller.indexOf("#tabs-") == -1){
			var locationPath = filterPath(location.pathname);
			var thisPath = filterPath(this.pathname) || locationPath;
        	if (locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,"") ) {
				$target = null;
       	      	$(this).click(function(event) {
					if ($("[name="+this.hash.substr(1)+"]").length != 0)
						var $target = $("[name="+this.hash.substr(1)+"]");
					else if ($("[id="+this.hash.substr(1)+"]").length != 0)
						var $target = $("[id="+this.hash.substr(1)+"]");
		            if ($target) {
            	    	event.preventDefault();
						$("html, body").animate({scrollTop: $target.offset().top-100}, 1000, function() {});
					}
            	});
    		}
		}
	 });
});
						   
