var AJAXHistory=new Object();AJAXHistory.Methods={currentAnchor:null,isIE:Prototype.Browser.IE,listeners:new Array(),skipCount:0,init:function(initValue){if(this.isIE){this.createIE_History(initValue);}
this.checkAnchor();setInterval(this.checkAnchor.bindAsEventListener(this),300);},checkAnchor:function(){if(this.skipCount>0){this.skipCount--;return;}
var hash=document.location.hash;if(this.currentAnchor&&Prototype.Browser.IE&&this.historyIFrame!=null&&this.currentAnchor.replace("#","")!=this.getIframeHash()){hash=this.getIframeHash();window.location=window.location.toString().split("#")[0]+"#"+hash;}
if(this.currentAnchor!=hash){this.currentAnchor=document.location.hash;if(!this.currentAnchor.empty()&&Prototype.Browser.IE&&this.historyIFrame!=null){var ieHash=this.getIframeHash();if(hash.replace("#","")!=ieHash){this.addIE_History(hash.replace("#",""));}}
this.onAJAXHistoryChange(hash.replace("#",""));if(Prototype.Browser.IE)this.skipCount=7;}},onAJAXHistoryChange:function(value){for(var i=0;i<this.listeners.length;i++){this.listeners[i](value);}},addListener:function(listener){this.listeners.push(listener);},getIframeHash:function(){var doc=this.historyIFrame.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=="undefined"?null:hash;},createIE_History:function(){this.historyIFrame=new Element("iframe",{id:"history",src:"/blank.html?"+document.location.hash.replace("#",""),style:"width:1px;height:1px; position:absolute; left:-10000px"});$(document.body).insert(this.historyIFrame);},addIE_History:function(id){this.historyIFrame.src="/blank.html?"+id;}}
Object.extend(AJAXHistory,AJAXHistory.Methods);