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