var wasload = 0; window.AjHistory = { isIE: false, isOpera: false, isSafari: false, isKonquerer: false, isGecko: false, isSupported: false, hideStyles: 'left:-1000px;top:-1000px;width:1px;height:1px;border:0;position:absolute;', create: function() { var that = this; var UA = navigator.userAgent.toLowerCase(); var platform = navigator.platform.toLowerCase(); var vendor = navigator.vendor || ""; if (vendor === "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 (vendor.indexOf("Apple Computer, Inc.") > -1) { this.isSafari = true; this.isSupported = (platform.indexOf("mac") > -1);} else if (UA.indexOf("gecko") != -1) { this.isGecko = true; this.isSupported = true;}
if (this.isSafari) { this.createSafari();} else if (this.isOpera) { this.createOpera();}
var initialHash = this.getCurrentLocation(); this.currentLocation = initialHash; if (this.isIE) { this.createIE(initialHash);}
var unloadHandler = function() { }; this.addEventListener(window,'unload',unloadHandler); if (this.isIE) { this.ignoreLocationChange = true;} else { if (!wasload) { this.ignoreLocationChange = true; wasload = 1;} else { this.ignoreLocationChange = false; this.fireOnNewListener = true;}
}
var locationHandler = function() { that.checkLocation();}; setInterval(locationHandler, 100);}, initialize: function() { if (this.isIE) { if (!wasload) { this.fireOnNewListener = false; wasload = 1;}
else { this.fireOnNewListener = true;}
}
}, addListener: function(listener) { this.listener = listener; if (this.fireOnNewListener) { this.fireHistoryEvent(this.currentLocation); this.fireOnNewListener = false;}
}, addEventListener: function(o,e,l) { if (o.addEventListener) { o.addEventListener(e,l,false);} else if (o.attachEvent) { o.attachEvent('on'+e,function() { l(window.event);});}
}, add: function(newLocation) { if (this.isSafari) { newLocation = this.removeHash(newLocation); this.currentLocation = newLocation; window.location.hash = newLocation; this.putSafariState(newLocation);}
else { var that = this; var addImpl = function() { if (that.currentWaitTime > 0) { that.currentWaitTime = that.currentWaitTime - that.waitTime;}
newLocation = that.removeHash(newLocation); that.ignoreLocationChange = true; that.ieAtomicLocationChange = true; that.currentLocation = newLocation; window.location.hash = newLocation; if (that.isIE) { that.iframe.src = "/aj/blank.html?" + newLocation;}
that.ieAtomicLocationChange = false;}; window.setTimeout(addImpl, this.currentWaitTime); this.currentWaitTime = this.currentWaitTime + this.waitTime;}
}, getCurrentLocation: function() { var r = (this.isSafari
? this.getSafariState()
: this.getCurrentHash() ); return r;}, getCurrentHash: function() { var r = window.location.href; var i = r.indexOf("#"); return (i >= 0
? r.substr(i+1)
: "" );}, listener: null, waitTime: 200, currentWaitTime: 0, currentLocation: null, iframe: null, safariHistoryStartPoint: null, safariStack: null, safariLength: null, ignoreLocationChange: null, fireOnNewListener: null, ieAtomicLocationChange: null, createIE: function(initialHash) { this.waitTime = 400; var styles = this.hideStyles; var iframeID = "rshHistoryFrame"; var iframeHTML = '<iframe frameborder="0" id="' + iframeID + '" style="' + styles + '" src="/aj/blank.html?' + initialHash + '"></iframe>'; document.write(iframeHTML); this.iframe = document.getElementById(iframeID);}, createOpera: function() { this.waitTime = 400; var imgHTML = '<img src="javascript:location.href=\'javascript:AjHistory.checkLocation();\';" style="' + this.hideStyles + '" />'; document.write(imgHTML);}, createSafari: function() { var formID = "rshSafariForm"; var stackID = "rshSafariStack"; var lengthID = "rshSafariLength"; var formStyles = this.hideStyles; var inputStyles = this.hideStyles; var safariHTML = '<form id="' + formID + '" style="' + formStyles + '">' + '<input type="text" style="' + inputStyles + '" id="' + stackID + '" value="[]"/>' + '<input type="text" style="' + inputStyles + '" id="' + lengthID + '" value=""/>' + '</form>'; document.write(safariHTML); this.safariStack = document.getElementById(stackID); this.safariLength = document.getElementById(lengthID); if (!wasload) { this.safariHistoryStartPoint = history.length; this.safariLength.value = this.safariHistoryStartPoint;} else { this.safariHistoryStartPoint = this.safariLength.value;}
}, getSafariStack: function() { var r = this.safariStack.value; return r;}, getSafariState: function() { var stack = this.getSafariStack(); var state = stack[history.length - this.safariHistoryStartPoint - 1]; return state;}, putSafariState: function(newLocation) { var stack = this.getSafariStack(); stack[history.length - this.safariHistoryStartPoint] = newLocation; this.safariStack.value = stack;}, fireHistoryEvent: function(newHash) { this.listener.call(null, newHash);}, checkLocation: function() { if (!this.isIE && this.ignoreLocationChange) { this.ignoreLocationChange = false; return;}
if (!this.isIE && this.ieAtomicLocationChange) { return;}
var hash = this.getCurrentLocation(); if (hash == this.currentLocation) { return;}
this.ieAtomicLocationChange = true; if (this.isIE && this.getIframeHash() != hash) { this.iframe.src = "/aj/blank.html?" + hash;}
else if (this.isIE) return; this.currentLocation = hash; this.ieAtomicLocationChange = false; this.fireHistoryEvent(hash);}, getIframeHash: function() { var doc = this.iframe.contentWindow.document; var hash = String(doc.location.search); if (hash.length == 1 && hash.charAt(0) == "?") { hash = "";}
else if (hash.length >= 2 && hash.charAt(0) == "?") { hash = hash.substring(1);}
return hash;}, removeHash: function(hashValue) { var r; if (hashValue === null || hashValue === undefined) { r = null;}
else if (hashValue === "") { r = "";}
else if (hashValue.length == 1 && hashValue.charAt(0) == "#") { r = "";}
else if (hashValue.length > 1 && hashValue.charAt(0) == "#") { r = hashValue.substring(1);}
else { r = hashValue;}
return r;}, iframeLoaded: function(newLocation) { if (this.ignoreLocationChange) { this.ignoreLocationChange = false; return;}
var hash = String(newLocation.search); if (hash.length == 1 && hash.charAt(0) == "?") { hash = "";}
else if (hash.length >= 2 && hash.charAt(0) == "?") { hash = hash.substring(1);}
window.location.hash = hash; this.fireHistoryEvent(hash);}
}; window.AjHistory.create(); 
