(function(A){A.ajaxHistory=new function(){var J="historyReset";var C=location.hash;var I=null;var G;this.update=function(){};var F=function(){var L=A(".remote-output");if(L.children().size()>0){L.empty()}};A(document).bind(J,F);if(A.browser.msie){var H;A(function(){H=A('<iframe style="display: none;"></iframe>').appendTo(document.body).get(0);var L=H.contentWindow.document;L.open();L.close();L.location.hash=C.replace("#","")});this.update=function(M){C=M;var L=H.contentWindow.document;L.open();L.close();L.location.hash=M.replace("#","")};G=function(){var M=H.contentWindow.document;var L=M.location.hash;if(L!=C){C=L;if(L!="#"){A('a[href$="'+L+'"]').click();location.hash=L}else{location.hash="";A(document).trigger(J)}}}}else{if(A.browser.mozilla||A.browser.opera){this.update=function(L){C=L};G=function(){if(location.hash){if(C!=location.hash){C=location.hash;A('a[href$="'+C+'"]').click()}}else{if(C){C="";A(document).trigger(J)}}}}else{if(A.browser.safari){var K,B,E;A(function(){K=[];K.length=history.length;B=[]});var D=false;E=function(L){K.push(L);B.length=0;D=false};this.update=function(L){C=L;E(C)};G=function(){var L=history.length-K.length;if(L){D=false;if(L<0){for(var M=0;M<Math.abs(L);M++){B.unshift(K.pop())}}else{for(var M=0;M<L;M++){K.push(B.shift())}}var N=K[K.length-1];A('a[href$="'+N+'"]').click();C=location.hash}else{if(K[K.length-1]==undefined&&!D){if(document.URL.indexOf("#")>=0){A('a[href$="#'+document.URL.split("#")[1]+'"]').click()}else{A(document).trigger(J)}D=true}}}}}}this.initialize=function(L){if(typeof L=="function"){A(document).unbind(J,F).bind(J,L)}if(location.hash&&typeof E=="undefined"){A('a.remote[href$="'+location.hash+'"]').click()}if(G&&I==null){I=setInterval(G,200)}}};A.fn.remote=function(B){var C=A(B).size()&&A(B)||A("<div></div>").appendTo("body");C.addClass("remote-output");return this.each(function(E){var D=this.href;var F="#remote-"+ ++E;this.href=F;A(this).click(function(H){var G=H.clientX;C.load(D,function(){if(G){A.ajaxHistory.update(F)}})})})};A.fn.history=function(){return this.click(function(C){var B=C.clientX;if(B){A.ajaxHistory.update(this.hash)}})}})(jQuery)