dhtmlHistory={WAIT_TIME:200,currentWaitTime:0,initialize:function(){
if(Prototype.Browser.WebKit){
return false;
}
historyStorage.init();
this.currentLocation=this.getCurrentLocation();
if(Prototype.Browser.IE){
this.iframe=$(document.createElement("IFRAME"));
this.iframe.name=this.iframe.id="DhtmlHistoryFrame";
this.iframe.src="javascript:false;";
this.iframe.hide();
document.body.appendChild(this.iframe);
this.writeIframe(this.currentLocation);
this.WAIT_TIME=400;
this.ignoreLocationChange=true;
}
Event.observe(window,"unload",function(){
this.firstLoad=false;
}.bind(this));
this.isFirstLoad();
setInterval(function(){
this.checkLocation();
}.bind(this),100);
return true;
},addListener:function(_1){
this.listener=_1;
if(this.fireOnNewListener){
this.fireHistoryEvent(this.currentLocation);
this.fireOnNewListener=false;
}
},add:function(_2,_3){
if(Prototype.Browser.WebKit){
return;
}
setTimeout(function(){
this.addImpl(_2,_3);
}.bind(this),this.currentWaitTime);
this.currentWaitTime+=this.WAIT_TIME;
},getCurrentLocation:function(){
return this.removeHash(location.hash);
},addImpl:function(_4,_5){
if(this.currentWaitTime){
this.currentWaitTime-=this.WAIT_TIME;
}
var _4=this.removeHash(_4);
if($("newLoc")){
return;
}
historyStorage.put(_4,_5);
this.ignoreLocationChange=true;
this.ieAtomicLocationChange=true;
this.currentLocation=location.hash=_4;
if(Prototype.Browser.IE){
this.writeIframe(_4);
}
this.ieAtomicLocationChange=false;
},isFirstLoad:function(){
if(historyStorage.hasKey("DhtmlHistory_pageLoaded")==false){
if(Prototype.Browser.IE){
this.fireOnNewListener=false;
}else{
this.ignoreLocationChange=true;
}
this.firstLoad=true;
historyStorage.put("DhtmlHistory_pageLoaded",true);
}else{
if(Prototype.Browser.IE){
this.firstLoad=false;
}else{
this.ignoreLocationChange=false;
}
this.fireOnNewListener=true;
}
},fireHistoryEvent:function(_6){
this.listener.call(null,_6,historyStorage.get(_6));
},checkLocation:function(){
if(!Prototype.Browser.IE){
if(this.ignoreLocationChange){
this.ignoreLocationChange=false;
return;
}
}else{
if(this.ieAtomicLocationChange){
return;
}
}
var _7=this.getCurrentLocation();
if(_7==this.currentLocation){
return;
}
this.ieAtomicLocationChange=true;
if(Prototype.Browser.IE){
if(this.iframe.contentWindow.l==_7){
return;
}
this.writeIframe(_7);
}
this.currentLocation=_7;
this.ieAtomicLocationChange=false;
this.fireHistoryEvent(_7);
},removeHash:function(h){
if(h==null||h==undefined){
return null;
}else{
if(h.length&&h.charAt(0)=="#"){
if(h.length==1){
return "";
}else{
return h.substring(1);
}
}
}
return h;
},iframeLoaded:function(_9){
if(this.ignoreLocationChange){
this.ignoreLocationChange=false;
return;
}
var _a=location.hash=_9;
this.fireHistoryEvent(_a);
},writeIframe:function(l){
var d=this.iframe.contentWindow.document;
d.open();
d.write("<html><script type=\"text/javascript\">var l=\""+l+"\";function pageLoaded(){window.parent.dhtmlHistory.iframeLoaded(l);}</script><body onload=\"pageLoaded()\"></body></html>");
d.close();
}};
historyStorage={put:function(_d,_e){
if(this.hasKey(_d)){
this.remove(_d);
}
this.storageHash[_d]=_e;
this.saveHashTable();
},get:function(_f){
this.loadHashTable();
var _10=this.storageHash[_f];
return (_10==undefined)?null:_10;
},remove:function(key){
this.loadHashTable();
delete this.storageHash[key];
this.saveHashTable();
},reset:function(){
this.storageField.value="";
this.storageHash={};
},hasKey:function(key){
this.loadHashTable();
return !(typeof this.storageHash[key]=="undefined");
},init:function(){
var _13=$(document.createElement("FORM"));
_13.hide();
document.body.appendChild(_13);
var ta=$(document.createElement("TEXTAREA"));
ta.id="historyStorageField";
_13.appendChild(ta);
this.storageField=$("historyStorageField");
},loadHashTable:function(){
if(!this.storageHash){
this.storageHash=(this.storageField.value)?this.storageField.value.evalJSON():{};
}
},saveHashTable:function(){
this.loadHashTable();
this.storageField.value=Object.toJSON(this.storageHash);
}};
