window.dhtmlHistory = {
addListener: function(callback) {
this.listener = callback;
},
getCurrentLocation: function() {
return this.removeHash(window.location.hash);
},
currentLocation: null,
listener: null,
create: function() {
this.currentLocation = this.getCurrentLocation();
var self = this;
var locationHandler = function() {
	self.checkLocation();
	};
setInterval(locationHandler, 100);
},
checkLocation: function() {
var hash = this.getCurrentLocation();
if (hash != this.currentLocation){
this.currentLocation = hash;
this.listener.call(null, hash, '');
}},  
removeHash: function(hashValue) {
if (hashValue == null || hashValue == undefined)
	return null;
else if (hashValue == "")
	return "";
else if (hashValue.length == 1 && hashValue.charAt(0) == "#")
	return "";
else if (hashValue.length > 1 && hashValue.charAt(0) == "#")
	return hashValue.substring(1);
else
	return hashValue;  
}
}
window.dhtmlHistory.create();