window.dhtmlHistory={isIE:!1,isOpera:!1,isSafari:!1,isKonquerer:!1,isGecko:!1,isSupported:!1,create:function(a){var c=this;window.historyStorage.setup(a);if(a&&a.baseTitle){if(a.baseTitle.indexOf("@@@")<0&&historyStorage.debugMode)throw Error("Programmer error: options.baseTitle must contain the replacement parameter '@@@' to be useful.");this.baseTitle=a.baseTitle}var b=navigator.userAgent.toLowerCase(),d=navigator.platform.toLowerCase(),e=navigator.vendor||"";if(e==="KDE")this.isKonqueror=!0,this.isSupported=
!1;else if(typeof window.opera!=="undefined")this.isSupported=this.isOpera=!0;else if(typeof document.all!=="undefined")this.isSupported=this.isIE=!0;else if(e.indexOf("Apple Computer, Inc.")>-1)parseFloat(/version\/([0-9].[0-9])/.exec(b)[1])>=3?this.isSupported=this.isGecko=!0:(this.isSafari=!0,this.isSupported=d.indexOf("mac")>-1);else if(b.indexOf("gecko")!=-1)this.isSupported=this.isGecko=!0;this.isSafari?this.createSafari():this.isOpera&&this.createOpera();this.currentLocation=b=this.getCurrentLocation();
if(this.isIE){if(a&&a.blankURL)a=a.blankURL,this.blankURL=a.indexOf("?")!=a.length-1?a+"?":a;this.createIE(b)}this.addEventListener(window,"unload",function(){c.firstLoad=null});this.isIE?this.ignoreLocationChange=!0:historyStorage.hasKey(this.PAGELOADEDSTRING)?(this.firstLoad=this.ignoreLocationChange=!1,this.fireOnNewListener=!0):(this.firstLoad=this.ignoreLocationChange=!0,historyStorage.put(this.PAGELOADEDSTRING,!0));setInterval(function(){c.checkLocation()},100)},initialize:function(a){this.originalTitle=
document.title;if(this.isIE)historyStorage.hasKey(this.PAGELOADEDSTRING)?(this.fireOnNewListener=!0,this.firstLoad=!1):(this.fireOnNewListener=!1,this.firstLoad=!0,historyStorage.put(this.PAGELOADEDSTRING,!0));a&&this.addListener(a)},addListener:function(a){this.listener=a;if(this.fireOnNewListener)this.fireHistoryEvent(this.currentLocation),this.fireOnNewListener=!1},changeTitle:function(a){a=a&&a.newTitle?this.baseTitle.replace("@@@",a.newTitle):this.originalTitle;if(document.title!=a){document.title=
a;if(this.isIE)this.iframe.contentWindow.document.title=a;if(!this.isIE&&!this.isOpera&&(a=decodeURIComponent(document.location.hash),a!=""))a=encodeURIComponent(this.removeHash(a)),document.location.hash=a}},add:function(a,c){var b=this,d=encodeURIComponent(this.removeHash(a)),d=d.replace(/%2F/g,"/");this.isSafari?(historyStorage.put(a,c),this.currentLocation=d,window.location.hash=d,this.putSafariState(d),this.changeTitle(c)):(window.setTimeout(function(){b.currentWaitTime>0&&(b.currentWaitTime-=
b.waitTime);if(document.getElementById(d)&&b.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,c);b.ignoreLocationChange=!0;b.ieAtomicLocationChange=!0;b.currentLocation=d;window.location.hash=d;if(b.isIE)b.iframe.src=
b.blankURL+d;b.ieAtomicLocationChange=!1;b.changeTitle(c)},this.currentWaitTime),this.currentWaitTime+=this.waitTime)},isFirstLoad:function(){return this.firstLoad},getVersion:function(){return this.VERSIONNUMBER},PAGELOADEDSTRING:"DhtmlHistory_pageLoaded",VERSIONNUMBER:"0.8",baseTitle:"@@@",originalTitle:null,blankURL:"blank.html?",listener:null,waitTime:200,currentWaitTime:0,currentLocation:null,iframe:null,safariHistoryStartPoint:null,safariStack:null,safariLength:null,ignoreLocationChange:null,
fireOnNewListener:null,firstLoad:null,ieAtomicLocationChange:null,addEventListener:function(a,c,b){a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent&&a.attachEvent("on"+c,function(){b(window.event)})},createIE:function(a){this.waitTime=400;document.write('<iframe frameborder="0" id="rshHistoryFrame" style="'+(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles)+'" src="'+this.blankURL+a+'"></iframe>');this.iframe=document.getElementById("rshHistoryFrame")},
createOpera:function(){this.waitTime=400;document.write('<img src="javascript:location.href=\'javascript:dhtmlHistory.checkLocation();\';" style="'+historyStorage.hideStyles+'" />')},createSafari:function(){document.write('<form id="rshSafariForm" style="'+(historyStorage.debugMode?historyStorage.showStyles:historyStorage.hideStyles)+'"><textarea style="'+(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles)+'" id="rshSafariStack">[]</textarea><input type="text" style="'+
(historyStorage.debugMode?"width:800px;height:20px;border:1px solid black;margin:0;padding:0;":historyStorage.hideStyles)+'" id="rshSafariLength" value=""/></form>');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)},getCurrentLocation:function(){return this.isSafari?
this.getSafariState():this.getCurrentHash()},getCurrentHash:function(){var a=window.location.href,c=a.indexOf("#");return c>=0?a.substr(c+1):""},getSafariStack:function(){return historyStorage.fromJSON(this.safariStack.value)},getSafariState:function(){return this.getSafariStack()[history.length-this.safariHistoryStartPoint-1]},putSafariState:function(a){var c=this.getSafariStack();c[history.length-this.safariHistoryStartPoint]=a;this.safariStack.value=historyStorage.toJSON(c)},fireHistoryEvent:function(a){var a=
decodeURIComponent(a),c=historyStorage.get(a);this.changeTitle(c);this.listener.call(null,a,c)},checkLocation:function(){if(!this.isIE&&this.ignoreLocationChange)this.ignoreLocationChange=!1;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.blankURL+a;else if(this.isIE)return;this.currentLocation=a;this.ieAtomicLocationChange=!1;this.fireHistoryEvent(a)}}},
getIframeHash:function(){var a=String(this.iframe.contentWindow.document.location.search);a.length==1&&a.charAt(0)=="?"?a="":a.length>=2&&a.charAt(0)=="?"&&(a=a.substring(1));return a},removeHash:function(a){return a===null||a===void 0?null:a===""?"":a.length==1&&a.charAt(0)=="#"?"":a.length>1&&a.charAt(0)=="#"?a.substring(1):a},iframeLoaded:function(a){this.ignoreLocationChange?this.ignoreLocationChange=!1:(a=String(a.search),a.length==1&&a.charAt(0)=="?"?a="":a.length>=2&&a.charAt(0)=="?"&&(a=a.substring(1)),
window.location.hash=a,this.fireHistoryEvent(a))}};
window.historyStorage={setup:function(a){if(typeof a!=="undefined"){if(a.debugMode)this.debugMode=a.debugMode;if(a.toJSON)this.toJSON=a.toJSON;if(a.fromJSON)this.fromJSON=a.fromJSON}document.write('<form id="rshStorageForm" style="'+(this.debugMode?historyStorage.showStyles:historyStorage.hideStyles)+'"><textarea id="rshStorageField" style="'+(historyStorage.debugMode?"width: 800px;height:80px;border:1px solid black;":historyStorage.hideStyles)+'"></textarea></form>');this.storageField=document.getElementById("rshStorageField");
typeof window.opera!=="undefined"&&this.storageField.focus()},put:function(a,c){var b=encodeURIComponent(a);this.assertValidKey(b);this.hasKey(a)&&this.remove(a);this.storageHash[b]=c;this.saveHashTable()},get:function(a){a=encodeURIComponent(a);this.assertValidKey(a);this.loadHashTable();a=this.storageHash[a];a===void 0&&(a=null);return a},remove:function(a){a=encodeURIComponent(a);this.assertValidKey(a);this.loadHashTable();delete this.storageHash[a];this.saveHashTable()},reset:function(){this.storageField.value=
"";this.storageHash={}},hasKey:function(a){a=encodeURIComponent(a);this.assertValidKey(a);this.loadHashTable();return typeof this.storageHash[a]!=="undefined"},isValidKey:function(a){return typeof a==="string"},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,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;if(a!==""&&a!==null)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()}};
