
function AnchorJump (target, history) {
	
	if (history == undefined) history = true;
	
	/* Jump to anchor if it exists */
	if (window.location.hash) {
		var hash = window.location.hash.split("#").pop();
		var anchorItem = (document.anchors[hash] == undefined) ? document.getElementById(hash) : document.anchors[hash];
		
		if (anchorItem && !this.hasJumped) {
			if (history) {
				window.location.hash = (target != undefined) ? target : window.location.hash;
			} else {
				window.location.replace((target != undefined) ? window.location.pathname + window.location.search + "#" + target : window.location.hash);
			}
			
			this.hasJumped = true;
		}
	}
	
}

Class(AnchorJump);

AnchorJump.prototype.hasJumped = false;