(function($){function History(){this._curHash="";
this._callback=function(hash){}
}$.history=new History();
$.extend(History.prototype,{init:function(callback){this._callback=function(hash){callback(hash)
};
this._curHash=location.hash;
if($.browser.msie){if(this._curHash===""){this._curHash="#"
}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');
var iframe=$("#jQuery_history")[0].contentWindow.document;
iframe.open();
iframe.close();
iframe.location.hash=this._curHash
}else{if($.browser.safari){this._historyBackStack=[];
this._historyBackStack.length=history.length;
this._historyForwardStack=[];
this._isFirst=true;
this._dontCheck=false
}}if(this._curHash!="#"){this._callback(C4.Util.hashFromUrl(this._curHash,true))
}setInterval(this._check,100)
},add:function(hash){this._historyBackStack.push(hash);
this._historyForwardStack.length=0;
this._isFirst=true
},_check:function(){if($.browser.msie){var ihistory=$("#jQuery_history")[0];
var iframe=ihistory.contentDocument||ihistory.contentWindow.document;
var current_hash=iframe.location.hash;
if(current_hash!=$.history._curHash){location.hash=current_hash;
$.history._curHash=current_hash;
$.history._callback(C4.Util.hashFromUrl(current_hash,true))
}}else{if($.browser.safari){if(!$.history._dontCheck){var historyDelta=history.length-$.history._historyBackStack.length;
if(historyDelta){$.history._isFirst=false;
if(historyDelta<0){for(var i=0;
i<Math.abs(historyDelta);
i++){$.history._historyForwardStack.unshift($.history._historyBackStack.pop())
}}else{for(i=0;
i<historyDelta;
i++){$.history._historyBackStack.push($.history._historyForwardStack.shift())
}}var cachedHash=$.history._historyBackStack[$.history._historyBackStack.length-1];
if(cachedHash!==undefined){$.history._curHash=location.hash;
$.history._callback(cachedHash)
}}else{if($.history._historyBackStack[$.history._historyBackStack.length-1]===undefined&&!$.history._isFirst){if(document.URL.indexOf("#")>=0){$.history._callback(C4.Util.hashFromUrl(document.URL,true))
}else{$.history._callback("")
}$.history._isFirst=true
}}}}else{current_hash=location.hash;
if(current_hash!=$.history._curHash){$.history._curHash=current_hash;
$.history._callback(C4.Util.hashFromUrl(current_hash,true))
}}}},load:function(hash){var newhash;
if($.browser.safari){newhash=hash
}else{if($.browser.msie){newhash="#"+hash;
location.hash=newhash
}else{newhash="#"+hash;
location.hash=newhash
}}this._curHash=newhash;
if($.browser.msie){var ihistory=$("#jQuery_history")[0];
var iframe=ihistory.contentWindow.document;
iframe.open();
iframe.close();
iframe.location.hash=newhash
}else{if($.browser.safari){this._dontCheck=true;
this.add(hash);
var fn=function(){$.history._dontCheck=false
};
window.setTimeout(fn,200);
location.hash=newhash
}else{}}}})
})(jQuery);