﻿jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyIframeSrc:undefined,historyInit:function(a,b){jQuery.historyCallback=a;if(b)jQuery.historyIframeSrc=b;var c=location.hash.replace(/\?.*$/,'');jQuery.historyCurrentHash=c;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==''){jQuery.historyCurrentHash='#'}jQuery("body").prepend('<iframe id="jQuery_history" style="display: none;"'+(jQuery.historyIframeSrc?' src="'+jQuery.historyIframeSrc+'"':'')+'></iframe>');var d=jQuery("#jQuery_history")[0];var e=d.contentWindow.document;e.open();e.close();e.location.hash=c}else if(jQuery.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.lastHistoryLength=history.length;jQuery.isFirst=true}if(c)jQuery.historyCallback(c.replace(/^#/,''))},historyAddHistory:function(a){jQuery.historyBackStack.push(a);jQuery.historyForwardStack.length=0;this.isFirst=true},historyCheck:function(){if(jQuery.browser.msie){var a=jQuery("#jQuery_history")[0];var b=a.contentDocument||a.contentWindow.document;var c=b.location.hash.replace(/\?.*$/,'');if(c!=jQuery.historyCurrentHash){location.hash=c;jQuery.historyCurrentHash=c;jQuery.historyCallback(c.replace(/^#/,''))}}else if(jQuery.browser.safari){if(jQuery.lastHistoryLength==history.length&&jQuery.historyBackStack.length>jQuery.lastHistoryLength){jQuery.historyBackStack.shift()}if(!jQuery.dontCheck){var d=history.length-jQuery.historyBackStack.length;jQuery.lastHistoryLength=history.length;if(d){jQuery.isFirst=false;if(d<0){for(var i=0;i<Math.abs(d);i++)jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop())}else{for(var i=0;i<d;i++)jQuery.historyBackStack.push(jQuery.historyForwardStack.shift())}var e=jQuery.historyBackStack[jQuery.historyBackStack.length-1];if(e!=undefined){jQuery.historyCurrentHash=location.hash.replace(/\?.*$/,'');jQuery.historyCallback(e)}}else if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(location.hash){var c=location.hash;jQuery.historyCallback(location.hash.replace(/^#/,''))}else{var c='';jQuery.historyCallback('')}jQuery.isFirst=true}}}else{var c=location.hash.replace(/\?.*$/,'');if(c!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=c;jQuery.historyCallback(c.replace(/^#/,''))}}},historyLoad:function(a){var b;a=decodeURIComponent(a.replace(/\?.*$/,''));if(jQuery.browser.safari){b=a}else{b='#'+a;location.hash=b}jQuery.historyCurrentHash=b;if(jQuery.browser.msie){var c=jQuery("#jQuery_history")[0];var d=c.contentWindow.document;d.open();d.close();d.location.hash=b;jQuery.lastHistoryLength=history.length;jQuery.historyCallback(a)}else if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(a);var e=function(){jQuery.dontCheck=false};window.setTimeout(e,200);jQuery.historyCallback(a);location.hash=b}else{jQuery.historyCallback(a)}}});