var selfLocation="/js/dhtml_history";window.dhtmlHistory={initialize:function(){if(this.isInternetExplorer()==false){return }if(historyStorage.hasKey("DhtmlHistory_pageLoaded")==false){this.fireOnNewListener=false;this.firstLoad=true;historyStorage.put("DhtmlHistory_pageLoaded",true)}else{this.fireOnNewListener=true;this.firstLoad=false}},addListener:function(A){this.listener=A;if(this.fireOnNewListener==true){this.fireHistoryEvent(this.currentLocation);this.fireOnNewListener=false}},add:function(C,D){var A=this;var B=function(){if(A.currentWaitTime>0){A.currentWaitTime=A.currentWaitTime-A.WAIT_TIME}C=A.removeHash(C);var F=document.getElementById(C);if(F!=undefined||F!=null){var E="Exception: History locations can not have the same value as _any_ id's that might be in the document, due to a bug in Internet Explorer; please ask the developer to choose a history location that does not match any HTML id's in this document. The following ID is already taken and can not be a location: "+C;throw E}historyStorage.put(C,D);A.ignoreLocationChange=true;this.ieAtomicLocationChange=true;A.currentLocation=C;window.location.hash=C;if(A.isInternetExplorer()){A.iframe.src=selfLocation+"/blank.html?"+C}this.ieAtomicLocationChange=false};window.setTimeout(B,this.currentWaitTime);this.currentWaitTime=this.currentWaitTime+this.WAIT_TIME},isFirstLoad:function(){if(this.firstLoad==true){return true}else{return false}},isInternational:function(){return false},getVersion:function(){return"0.05"},getCurrentLocation:function(){var A=this.removeHash(window.location.hash);return A},currentLocation:null,listener:null,iframe:null,ignoreLocationChange:null,WAIT_TIME:200,currentWaitTime:0,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,create:function(){var A=this.getCurrentLocation();this.currentLocation=A;if(this.isInternetExplorer()){document.write("<iframe style='border: 0px; width: 1px; height: 1px; position: absolute; bottom: 0px; right: 0px; visibility: visible;' name='DhtmlHistoryFrame' id='DhtmlHistoryFrame' src='"+selfLocation+"/blank.html?"+A+"'></iframe>");this.WAIT_TIME=400}var B=this;window.onunload=function(){B.firstLoad=null};if(this.isInternetExplorer()==false){if(historyStorage.hasKey("DhtmlHistory_pageLoaded")==false){this.ignoreLocationChange=true;this.firstLoad=true;historyStorage.put("DhtmlHistory_pageLoaded",true)}else{this.ignoreLocationChange=false;this.fireOnNewListener=true}}else{this.ignoreLocationChange=true}if(this.isInternetExplorer()){this.iframe=document.getElementById("DhtmlHistoryFrame")}var B=this;var C=function(){B.checkLocation()};setInterval(C,100)},fireHistoryEvent:function(A){var B=historyStorage.get(A);this.listener.call(null,A,B)},checkLocation:function(){if(this.isInternetExplorer()==false&&this.ignoreLocationChange==true){this.ignoreLocationChange=false;return }if(this.isInternetExplorer()==false&&this.ieAtomicLocationChange==true){return }var A=this.getCurrentLocation();if(A==this.currentLocation){return }this.currentLocation=A;this.ieAtomicLocationChange=true;if(this.isInternetExplorer()&&this.getIFrameHash()!=A){this.iframe.src=selfLocation+"/blank.html?"+A}else{if(this.isInternetExplorer()){return }}this.ieAtomicLocationChange=false;this.fireHistoryEvent(A)},getIFrameHash:function(){var A=document.getElementById("DhtmlHistoryFrame");var C=A.contentWindow.document;var B=new String(C.location.search);if(B.length==1&&B.charAt(0)=="?"){B=""}else{if(B.length>=2&&B.charAt(0)=="?"){B=B.substring(1)}}return B},removeHash:function(A){if(A==null||A==undefined){return null}else{if(A==""){return""}else{if(A.length==1&&A.charAt(0)=="#"){return""}else{if(A.length>1&&A.charAt(0)=="#"){return A.substring(1)}else{return A}}}}},iframeLoaded:function(A){if(this.ignoreLocationChange==true){this.ignoreLocationChange=false;return }var B=new String(A.search);if(B.length==1&&B.charAt(0)=="?"){B=""}else{if(B.length>=2&&B.charAt(0)=="?"){B=B.substring(1)}}if(this.pageLoadEvent!=true){window.location.hash=B}this.fireHistoryEvent(B)},isInternetExplorer:function(){var A=navigator.userAgent.toLowerCase();if(document.all&&A.indexOf("msie")!=-1){return true}else{return false}}};window.historyStorage={debugging:false,storageHash:new Object(),hashLoaded:false,put:function(A,B){this.assertValidKey(A);if(this.hasKey(A)){this.remove(A)}this.storageHash[A]=B;this.saveHashTable()},get:function(A){this.assertValidKey(A);this.loadHashTable();var B=this.storageHash[A];if(B==undefined){return null}else{return B}},remove:function(A){this.assertValidKey(A);this.loadHashTable();delete this.storageHash[A];this.saveHashTable()},reset:function(){this.storageField.value="";this.storageHash=new Object()},hasKey:function(A){this.assertValidKey(A);this.loadHashTable();if(typeof this.storageHash[A]=="undefined"){return false}else{return true}},isValidKey:function(A){return(typeof A=="string")},storageField:null,init:function(){var B="width: 0px; height: 0px";if(this.debugging==true){B="width: 30em; height: 30em;"}var A="<form id='historyStorageForm' method='GET' style='"+B+"'><textarea id='historyStorageField' style='"+B+"'left: -1000px;' name='historyStorageField'></textarea></form>";document.write(A);this.storageField=document.getElementById("historyStorageField")},assertValidKey:function(A){if(this.isValidKey(A)==false){throw"Please provide a valid key for window.historyStorage, key= "+A}},loadHashTable:function(){if(this.hashLoaded==false){var serializedHashTable=this.storageField.value;if(serializedHashTable!=""&&serializedHashTable!=null){this.storageHash=eval("("+serializedHashTable+")")}this.hashLoaded=true}},saveHashTable:function(){this.loadHashTable();var A=JSON.stringify(this.storageHash);this.storageField.value=A}};var JSON;(function(){JSON={stringify:function(arg){switch(typeof arg){case"string":return'"'+encodeString(arg)+'"';case"number":return String(arg);case"object":if(arg){var out=[];if(arg instanceof Array){for(var i=0;i<arg.length;i++){var json=this.stringify(arg[i]);if(json!=null){out[out.length]=json}}return"["+out.join(",")+"]"}else{for(var p in arg){var json=this.stringify(arg[p]);if(json!=null){out[out.length]='"'+encodeString(p)+'":'+json}}return"{"+out.join(",")+"}"}}return"null";case"boolean":return String(arg)}},parse:function(text){try{return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g,"")))&&eval("("+text+")")}catch(e){return false}}};var JS13=("1".replace(/1/,function(){return""})=="");var CHARS={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\",'"':'\\"'};for(var i=0;i<32;i++){var c=String.fromCharCode(i);if(!CHARS[c]){CHARS[c]=((i<16)?"\\u000":"\\u00")+i.toString(16)}}function encodeString(str){if(!/[\x00-\x1f\\"]/.test(str)){return str}else{if(JS13){return str.replace(/([\x00-\x1f\\"])/g,function($0,$1){return CHARS[$1]})}else{var out=new Array(str.length);for(var i=0;i<str.length;i++){var c=str.charAt(i);out[i]=CHARS[c]||c}return out.join("")}}}})();window.historyStorage.init();window.dhtmlHistory.create();
