/*
 * jQuery history plugin
 *
 * Copyright (c) 2006 Taku Sano (Mikage Sawatari)
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization
 * for msie when no initial hash supplied.
 * API rewrite by Lauris Bukšis-Haberkorns
 */
(function(a){function b(){this._curHash="";this._callback=function(a){}}a.extend(b.prototype,{init:function(b){this._callback=b;this._curHash=location.hash;if(a.browser.msie){if(this._curHash==""){this._curHash="#"}a("body").prepend('<iframe id="jQuery_history" style="display: none;" src="javascript:void(0);"></iframe>');var c=a("#jQuery_history")[0].contentWindow.document;c.open();c.close();c.location.hash=this._curHash}else if(a.browser.safari){this._historyBackStack=[];this._historyBackStack.length=history.length;this._historyForwardStack=[];this._isFirst=true;this._dontCheck=false}this._callback(this._curHash.replace(/^#/,""));setInterval(this._check,100)},add:function(a){this._historyBackStack.push(a);this._historyForwardStack.length=0;this._isFirst=true},_check:function(){if(a.browser.msie){var b=a("#jQuery_history")[0];var c=b.contentDocument||b.contentWindow.document;var d=c.location.hash;if(d!=a.history._curHash){location.hash=d;a.history._curHash=d;a.history._callback(d.replace(/^#/,""))}}else if(a.browser.safari){if(!a.history._dontCheck){var e=history.length-a.history._historyBackStack.length;if(e){a.history._isFirst=false;if(e<0){for(var f=0;f<Math.abs(e);f++)a.history._historyForwardStack.unshift(a.history._historyBackStack.pop())}else{for(var f=0;f<e;f++)a.history._historyBackStack.push(a.history._historyForwardStack.shift())}var g=a.history._historyBackStack[a.history._historyBackStack.length-1];if(g!=undefined){a.history._curHash=location.hash;a.history._callback(g)}}else if(a.history._historyBackStack[a.history._historyBackStack.length-1]==undefined&&!a.history._isFirst){if(location.hash.indexOf("#")>=0){a.history._callback(location.hash.split("#")[1])}else{a.history._callback("")}a.history._isFirst=true}}}else{var d=location.hash;if(d!=a.history._curHash){a.history._curHash=d;a.history._callback(d.replace(/^#/,""))}}},isKonqueror:function(){return/KHTML|Konqueror/.test(navigator.userAgent)},load:function(b){var c;if(a.browser.safari){c=b}else{c=(this.isKonqueror()?"":"#")+b;location.hash=c}this._curHash=c;if(a.browser.msie){var d=a("#jQuery_history")[0];var e=d.contentWindow.document;e.open();e.close();e.location.hash=c;this._callback(b)}else if(a.browser.safari){this._dontCheck=true;this.add(b);var f=function(){a.history._dontCheck=false};window.setTimeout(f,200);this._callback(b);location.hash=c}else{this._callback(b)}}});a(document).ready(function(){a.history=new b})})(jQuery)

 
