var 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")).hide();this.iframe.name=this.iframe.id="DhtmlHistoryFrame";this.iframe.src="javascript:false;";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(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(this.addImpl.bind(this,_2,_3),this.currentWaitTime);this.currentWaitTime+=this.WAIT_TIME;},getCurrentLocation:function(){return this.removeHash(unescape(location.hash));},addImpl:function(_4,_5){if(this.currentWaitTime){this.currentWaitTime-=this.WAIT_TIME;}if($("newLoc")){return;}var _4=this.removeHash(_4);historyStorage.put(_4,_5);this.ignoreLocationChange=this.ieAtomicLocationChange=true;this.currentLocation=_4;location.hash=escape(_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;}location.hash=escape(_9);this.fireHistoryEvent(_9);},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();}};var historyStorage={put:function(_c,_d){this.loadHashTable();this.storageHash[_c]=_d;this.saveHashTable();},get:function(_e){this.loadHashTable();var _f=this.storageHash[_e];return(_f==undefined)?null:_f;},remove:function(key){this.loadHashTable();delete this.storageHash[key];this.saveHashTable();},reset:function(){this.storageField.value="";this.storageHash=$H();},hasKey:function(key){this.loadHashTable();return!(typeof this.storageHash[key]==undefined);},init:function(){var _12=$(document.createElement("FORM")).hide();document.body.appendChild(_12);var ta=$(document.createElement("TEXTAREA"));ta.id="historyStorageField";_12.appendChild(ta);this.storageField=$("historyStorageField");},loadHashTable:function(){if(!this.storageHash){this.storageHash=(this.storageField.value)?this.storageField.value.evalJSON():$H();}},saveHashTable:function(){this.loadHashTable();this.storageField.value=Object.toJSON(this.storageHash);}};