	function UrlChangeDetector(url){
		this.location = url;
		this.timer = new Timer(this);
		this.checkChanges();
  	}
	
	UrlChangeDetector.prototype.registerChange = function(l) {
		//alert('registering change: ' + l);
		this.location = l;
	}
	
/*	UrlChangeDetector.prototype.checkChanges = function (l1, l2) {
		if(l1 != l2) {
			alert("change detected: " + l1 + "!=" + l2);
			this.location = l2;
			if(document.iframesfix) {
				window.location.href = l2;
			}
			loadByUrl('', l2);
		}
		if(document.iframesfix) {
			checkHash = document.frames['ajaxnav'].getHash();
			checkUrl = appendHashToCurrentUrl(checkHash);
			alert('checking page: ' + checkUrl);
			this.timer.setTimeout("checkChanges", 5000, this.location, checkUrl);
		} else{
			this.timer.setTimeout("checkChanges", 300, this.location, window.location.href);
		}
	}
*/
	UrlChangeDetector.prototype.getCheckUrl = function() {
		var checkUrl='';
		if(document.iframesfix) {
			checkHash = document.frames['ajaxnav'].getHash();
			checkUrl = appendHashToCurrentUrl(checkHash);
		} else{
			checkUrl = window.location.href;
		}
		return checkUrl;
	}

	UrlChangeDetector.prototype.checkChanges = function() {
		var checkUrl=this.getCheckUrl();
		//alert("checking: " + this.location + "!=" + checkUrl);
		if(this.location != checkUrl) {
			this.location = checkUrl;
			loadByUrl('', checkUrl);
		}
		this.timer.setTimeout("checkChanges", 200);
	}

	function appendHashToCurrentUrl(newHash) {
		var newUrl = '';
		var currUrlNoHash = '';
		if(-1 != window.location.href.indexOf('#')) {
			currUrlNoHash = window.location.href.substr(0, window.location.href.indexOf('#')); 
		} else {
			currUrlNoHash = window.location.href;
		}
		if('' == newHash || '#' == newHash) {
			newUrl = currUrlNoHash; 
		} else {
			newUrl = currUrlNoHash + newHash;
		}

		return newUrl;
	}
	
	function getHashFromUrl(url) {
		if(-1 == url.indexOf('#')){
			return '';
		} else {
			return url.substr(url.indexOf('#'), url.length-1);
		}
	}

