/*
 * 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.
 */
jQuery.extend({historyCurrentHash:undefined,historyCallback:undefined,historyInit:function(D){jQuery.historyCallback=D;var C=location.hash;jQuery.historyCurrentHash=C;if(jQuery.browser.msie){if(jQuery.historyCurrentHash==""){jQuery.historyCurrentHash="#"}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var A=$("#jQuery_history")[0];var B=A.contentWindow.document;B.open();B.close();B.location.hash=C}else{if($.browser.safari){jQuery.historyBackStack=[];jQuery.historyBackStack.length=history.length;jQuery.historyForwardStack=[];jQuery.isFirst=true}}jQuery.historyCallback(C.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 D=A.contentDocument||A.contentWindow.document;var F=D.location.hash;if(F!=jQuery.historyCurrentHash){location.hash=F;jQuery.historyCurrentHash=F;jQuery.historyCallback(F.replace(/^#/,""))}}else{if($.browser.safari){if(!jQuery.dontCheck){var B=history.length-jQuery.historyBackStack.length;if(B){jQuery.isFirst=false;if(B<0){for(var C=0;C<Math.abs(B);C++){jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop())}}else{for(var C=0;C<B;C++){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 F=location.hash;jQuery.historyCallback("")}jQuery.isFirst=true}}}}else{var F=location.hash;if(F!=jQuery.historyCurrentHash){jQuery.historyCurrentHash=F;jQuery.historyCallback(F.replace(/^#/,""))}}}},historyLoad:function(D){var E;if(jQuery.browser.safari){E=D}else{E="#"+D;location.hash=E}jQuery.historyCurrentHash=E;if(jQuery.browser.msie){var A=$("#jQuery_history")[0];var C=A.contentWindow.document;C.open();C.close();C.location.hash=E;jQuery.historyCallback(D)}else{if(jQuery.browser.safari){jQuery.dontCheck=true;this.historyAddHistory(D);var B=function(){jQuery.dontCheck=false};window.setTimeout(B,200);jQuery.historyCallback(D);location.hash=E}else{jQuery.historyCallback(D)}}}});