function Timer(){
this.obj = (arguments.length)?arguments[0]:window;
return this;
}
Timer.prototype.setInterval = function(func, msec){
var i = Timer.getNew();
var t = Timer.buildCall(this.obj, i, arguments);
Timer.set[i].timer = window.setInterval(t,msec);
return i;
}
Timer.prototype.setTimeout = function(func, msec){
var i = Timer.getNew();
Timer.buildCall(this.obj, i, arguments);
Timer.set[i].timer = window.setTimeout("Timer.callOnce("+i+");",msec);
return i;
}
Timer.prototype.clearInterval = function(i){
if(!Timer.set[i]) return;
window.clearInterval(Timer.set[i].timer);
Timer.set[i] = null;
}
Timer.prototype.clearTimeout = function(i){
if(!Timer.set[i]) return;
window.clearTimeout(Timer.set[i].timer);
Timer.set[i] = null;
}
Timer.set = new Array();
Timer.buildCall = function(obj, i, args){
var t = "";
Timer.set[i] = new Array();
if(obj != window){
Timer.set[i].obj = obj;
t = "Timer.set["+i+"].obj.";
}
t += args[0]+"(";
if(args.length > 2){
Timer.set[i][0] = args[2];
t += "Timer.set["+i+"][0]";
for(var j=1; (j+2)<args.length; j++){
Timer.set[i][j] = args[j+2];
t += ", Timer.set["+i+"]["+j+"]";
}}
t += ");";
Timer.set[i].call = t;
return t;
}
Timer.callOnce = function(i){
if(!Timer.set[i]) return;
eval(Timer.set[i].call);
Timer.set[i] = null;
}
Timer.getNew = function(){
var i = 0;
while(Timer.set[i]) i++;
return i;
}
function AjaxUrlFixer(){
this.timer = new Timer(this);
this.timer.setInterval("checkWhetherChanged", 1000);
this.getStoredHash = getStoredHash;
this.storeHash = storeHash;
this.setHash = setHash;
this.getHash = getHash;
this.checkWhetherChanged = checkWhetherChanged;
this.storeHash(this.getHash());
return this;
}
function getStoredHash(){
return this.stored_hash;
}

function storeHash(hash){
this.stored_hash = hash;
}

function setHash(hash){
if(hash != ""){
this.storeHash(hash);
window.location.hash = "#"+hash;
}
}
function getHash() {
var hash = window.location.hash;
var separator_position = hash.lastIndexOf("#");
if(separator_position != -1)
hash = hash.substr(separator_position+1);

return hash;
}
function checkWhetherChanged(){
if(this.getHash() != this.getStoredHash()) {
autoLoadPage(getHash());
//alert(getHash() +"-"+ getStoredHash());
}
}

