﻿jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(a){jQuery.historyCallback=a;var b=location.hash;jQuery.historyCurrentHash=b;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==''){jQuery.historyCurrentHash='#'}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var c=$("#jQuery_history")[0];var d=c.contentWindow.document;d.open();d.close();d.location.hash=b}else if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}jQuery.historyCallback(b.replace(/^#/,''));setInterval(jQuery.historyCheck,100)},historyAddHistory:function(a){jQuery.historyBackStack.push(a);jQuery.historyForwardStack.length=0;this.isFirst=true},historyCheck:function(){if(jQuery.browser.msie){var a=$("#jQuery_history")[0];var b=a.contentDocument||a.contentWindow.document;var c=b.location.hash;if(c!=jQuery.historyCurrentHash){location.hash=c;jQuery.historyCurrentHash=c;jQuery.historyCallback(c.replace(/^#/,''))}}else if($.browser.safari){if(!jQuery.dontCheck){var d=history.length-jQuery.historyBackStack.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;jQuery.historyCallback(e)}}else if(jQuery.historyBackStack[jQuery.historyBackStack.length-1]==undefined&&!jQuery.isFirst){if(document.URL.indexOf('#')>=0){jQuery.historyCallback(document.URL.split('#')[1])}else{var c=location.hash;jQuery.historyCallback('')}jQuery.isFirst=true}}}else{var c=location.hash;if(c!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=c;jQuery.historyCallback(c.replace(/^#/,''))}}},historyLoad:function(a){var b;if(jQuery.browser.safari){b=a}else{b='#'+a;location.hash=b}jQuery.historyCurrentHash=b;if(jQuery.browser.msie){var c=$("#jQuery_history")[0];var d=c.contentWindow.document;d.open();d.close();d.location.hash=b;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)}}});