window.dhtmlHistory={isIE:!1,isOpera:!1,isSafari:!1,isKonquerer:!1,isGecko:!1,isSupported:!1,isCreated:!1,create:function(a){a&&(this.blankPagePath=a.blankPagePath||"","/"!=this.blankPagePath.charAt(this.blankPagePath.length-1)&&(this.blankPagePath+="/"));var b=this,c=navigator.userAgent.toLowerCase();navigator.platform.toLowerCase();var d=navigator.vendor||"";"KDE"===d?(this.isKonqueror=!0,this.isSupported=!1):"undefined"!==typeof window.opera?this.isSupported=this.isOpera=!0:gx.util.browser.isIE()?
(this.isIE=9>=gx.util.browser.ieVersion(),this.isSupported=!0):-1<d.indexOf("Apple Computer, Inc.")?this.isSupported=this.isSafari=!0:-1!=c.indexOf("gecko")?this.isSupported=this.isGecko=!0:-1<c.indexOf("chrome")&&(this.isSupported=this.isSafari=!0);window.historyStorage.setup(a,this.isIE);this.isSafari?this.createSafari():this.isOpera&&this.createOpera();this.currentLocation=a=this.getCurrentLocation();this.isIE&&this.createIE(a);this.addEventListener(window,"unload",function(){b.firstLoad=null});
this.isIE?this.ignoreLocationChange=!0:historyStorage.hasKey(this.PAGELOADEDSTRING)?(this.ignoreLocationChange=!1,this.fireOnNewListener=!0):(this.firstLoad=this.ignoreLocationChange=!0,historyStorage.put(this.PAGELOADEDSTRING,!0));this.isCreated=!0;this.locationHandlerInterval=setInterval(function(){b.checkLocation()},10)},destroy:function(){this.locationHandlerInterval&&(this.isCreated=!1,delete this.fireOnNewListener,clearInterval(this.locationHandlerInterval),historyStorage.destroy())},initialize:function(){this.isIE&&
(historyStorage.hasKey(this.PAGELOADEDSTRING)?(this.fireOnNewListener=!0,this.firstLoad=!1):(this.fireOnNewListener=!1,this.firstLoad=!0,historyStorage.put(this.PAGELOADEDSTRING,!0)))},addListener:function(a){this.listener=a;this.fireOnNewListener&&(this.fireHistoryEvent(this.currentLocation),this.fireOnNewListener=!1)},addEventListener:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,function(){c(window.event)})},add:function(a,b){if(this.isSafari)a=
this.removeHash(a),historyStorage.put(a,b),this.currentLocation=a,window.location.hash=a,this.putSafariState(a);else{var c=this;window.setTimeout(function(){0<c.currentWaitTime&&(c.currentWaitTime-=c.waitTime);a=c.removeHash(a);if(document.getElementById(a)&&c.debugMode)throw Error("Exception: History locations can not have the same value as _any_ IDs that might be in the document, due to a bug in IE; please ask the developer to choose a history location that does not match any HTML IDs in this document. The following ID is already taken and cannot be a location: "+
a);historyStorage.put(a,b);c.ignoreLocationChange=!0;c.ieAtomicLocationChange=!0;c.currentLocation=a;window.location.hash=a;c.isIE&&(c.iframe.src=c.blankPagePath+"blank.html?"+a);c.ieAtomicLocationChange=!1},this.currentWaitTime);this.currentWaitTime+=this.waitTime}},isFirstLoad:function(){return this.firstLoad},getVersion:function(){return"0.6"},getCurrentLocation:function(){return this.getCurrentHash()},getCurrentHash:function(){var a=window.location.href,b=a.indexOf("#");return 0<=b?a.substr(b+
1):""},PAGELOADEDSTRING:"DhtmlHistory_pageLoaded",listener:null,waitTime:200,currentWaitTime:0,currentLocation:null,iframe:null,safariHistoryStartPoint:null,safariStack:null,safariLength:null,ignoreLocationChange:null,fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,createIE:function(a){this.waitTime=400;var b=document.createElement("iframe");b.setAttribute("id","rshHistoryFrame");b.style.border="0px";b.style.width="0px";b.style.height="0px";b.src=this.blankPagePath+"blank.html?"+
a;a=function(){this.iframe=document.body.appendChild(b)};if(document.body)a.call(this,b);else gx.evt.on_ready(this,a.closure(this,[b]))},createOpera:function(){this.waitTime=400;document.body.innerHTML+='<img src="javascript:location.href=\'javascript:dhtmlHistory.checkLocation();\';" style="'+historyStorage.hideStyles+'" />'},createSafari:function(){gx.evt.on_ready(this,function(){var a=historyStorage.debugMode?"width:800px;height:20px;border:1px solid black;margin:0;padding:0;":historyStorage.hideStyles,
a='<input type="text" style="'+a+'" id="rshSafariStack" value="[]"/><input type="text" style="'+a+'" id="rshSafariLength" value=""/>',b=document.createElement("div");b.innerHTML=a;document.forms[0].appendChild(b);this.safariStack=document.getElementById("rshSafariStack");this.safariLength=document.getElementById("rshSafariLength");historyStorage.hasKey(this.PAGELOADEDSTRING)?this.safariHistoryStartPoint=this.safariLength.value:(this.safariHistoryStartPoint=history.length,this.safariLength.value=this.safariHistoryStartPoint)}.closure(this,
[]))},getSafariStack:function(){return historyStorage.fromJSON(this.safariStack.value)},getSafariState:function(){return this.getSafariStack()[history.length-this.safariHistoryStartPoint-1]},putSafariState:function(a){var b=this.getSafariStack();b[history.length-this.safariHistoryStartPoint]=a;this.safariStack.value=historyStorage.toJSON(b)},fireHistoryEvent:function(a){var b=function(){var b=historyStorage.get(a);this.listener.call(null,a,b)};gx.spa.isNavigating()?gx.spa.addObserver("onnavigatecomplete",
this,b,{single:!0}):b.call(this)},checkLocation:function(){if(!this.isIE&&this.ignoreLocationChange)this.ignoreLocationChange=!1,this.currentLocation=this.getCurrentLocation();else if(this.isIE||!this.ieAtomicLocationChange){var a=this.getCurrentLocation();if(a!=this.currentLocation){this.ieAtomicLocationChange=!0;if(this.isIE&&this.getIframeHash()!=a)this.iframe.src=this.blankPagePath+"blank.html?"+a;else if(this.isIE)return;this.currentLocation=a;this.ieAtomicLocationChange=!1;this.fireHistoryEvent(a)}}},
getIframeHash:function(){var a=""+this.iframe.contentWindow.document.location.search;1==a.length&&"?"==a.charAt(0)?a="":2<=a.length&&"?"==a.charAt(0)&&(a=a.substring(1));return a},removeHash:function(a){return null===a||void 0===a?null:""===a?"":1==a.length&&"#"==a.charAt(0)?"":1<a.length&&"#"==a.charAt(0)?a.substring(1):a},iframeLoaded:function(a){this.ignoreLocationChange?this.ignoreLocationChange=!1:(a=""+a.search,1==a.length&&"?"==a.charAt(0)?a="":2<=a.length&&"?"==a.charAt(0)&&(a=a.substring(1)),
window.location.hash=a,this.fireHistoryEvent(a))}};
window.historyStorage={setup:function(a){if("undefined"!==typeof a&&(a.debugMode&&(this.debugMode=a.debugMode),a.toJSON&&(this.toJSON=a.toJSON),a.fromJSON))this.fromJSON=a.fromJSON;a=historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles;this.storageField=document.createElement("textarea");this.storageField.setAttribute("id","rshStorageField");this.storageField.setAttribute("style",a);this.storageField.setAttribute("title","Storage Field");this.storageField.style.visibility=
"hidden";this.storageFieldLabel=document.createElement("label");this.storageFieldLabel.setAttribute("for","rshStorageField");this.storageFieldLabel.innerHTML="Storage Field";this.storageFieldLabel.setAttribute("style",a);this.storageFieldLabel.style.visibility="hidden";a=function(a,c){document.forms[0].appendChild(c);document.forms[0].appendChild(a);"undefined"!==typeof window.opera&&c.focus()};if(document.forms[0])a(this.storageField,this.storageFieldLabel);else gx.evt.on_ready(this,a.closure(this,
[this.storageField,this.storageFieldLabel]))},put:function(a,b){this.assertValidKey(a);this.hasKey(a)&&this.remove(a);this.storageHash[a]=b;this.saveHashTable()},get:function(a){this.assertValidKey(a);this.loadHashTable();a=this.storageHash[a];void 0===a&&(a=null);return a},remove:function(a){this.assertValidKey(a);this.loadHashTable();delete this.storageHash[a];this.saveHashTable()},reset:function(){this.storageField.value="";this.storageHash={}},hasKey:function(a){this.assertValidKey(a);this.loadHashTable();
return"undefined"!==typeof this.storageHash[a]},isValidKey:function(a){return"string"===typeof a},showStyles:"border:0;margin:0;padding:0;",hideStyles:"left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;",debugMode:!1,storageHash:{},hashLoaded:!1,storageField:null,storageFieldLabel:null,assertValidKey:function(a){if(!this.isValidKey(a)&&this.debugMode)throw Error("Please provide a valid key for window.historyStorage. Invalid key = "+a+".");},loadHashTable:function(){if(!this.hashLoaded){var a=
this.storageField.value;""!==a&&null!==a&&(this.storageHash=this.fromJSON(a),this.hashLoaded=!0)}},saveHashTable:function(){this.loadHashTable();this.storageField.value=this.toJSON(this.storageHash)},toJSON:function(a){return a.toJSONString()},fromJSON:function(a){return a.parseJSON()},destroy:function(){var a=this.storageField.parentElement;a&&(a.removeChild(this.storageField),a.removeChild(this.storageFieldLabel));this.storageFieldLabel=this.storageField=null;this.storageHash={}}};
