(function(a){a.ajaxHistory=new function(){var k="historyReset";var c=location.hash;var j=null;var h;this.update=function(){};var g=function(){a(".remote-output").empty()};a(document).bind(k,g);if(a.browser.msie){var i,d=false;a(function(){i=a('<iframe style="display: none;"></iframe>').appendTo(document.body).get(0);var m=i.contentWindow.document;m.open();m.close();if(c&&c!="#"){m.location.hash=c.replace("#","")}});this.update=function(n){c=n;var m=i.contentWindow.document;m.open();m.close();m.location.hash=n.replace("#","")};h=function(){var n=i.contentWindow.document;var m=n.location.hash;if(m!=c){c=m;if(m&&m!="#"){a('a[href$="'+m+'"]').click();location.hash=m}else{if(d){location.hash="";a(document).trigger(k)}}}d=true}}else{if(a.browser.mozilla||a.browser.opera){this.update=function(m){c=m};h=function(){if(location.hash){if(c!=location.hash){c=location.hash;a('a[href$="'+c+'"]').click()}}else{if(c){c="";a(document).trigger(k)}}}}else{if(a.browser.safari){var l,b,f;a(function(){l=[];l.length=history.length;b=[]});var e=false,d=false;f=function(m){l.push(m);b.length=0;e=false};this.update=function(m){c=m;f(c)};h=function(){var m=history.length-l.length;if(m){e=false;if(m<0){for(var n=0;n<Math.abs(m);n++){b.unshift(l.pop())}}else{for(var n=0;n<m;n++){l.push(b.shift())}}var o=l[l.length-1];a('a[href$="'+o+'"]').click();c=location.hash}else{if(l[l.length-1]==undefined&&!e){if(document.URL.indexOf("#")>=0){a('a[href$="#'+document.URL.split("#")[1]+'"]').click()}else{if(d){a(document).trigger(k)}}e=true}}d=true}}}}this.initialize=function(m){if(typeof m=="function"){a(document).unbind(k,g).bind(k,m)}if(location.hash&&typeof f=="undefined"){a('a[href$="'+location.hash+'"]').trigger("click")}if(h&&j==null){j=setInterval(h,200)}}};a.fn.remote=function(b,c,e){e=e||function(){};if(typeof c=="function"){e=c}c=a.extend({hashPrefix:"remote-"},c||{});var d=a(b).size()&&a(b)||a("<div></div>").appendTo("body");d.addClass("remote-output");return this.each(function(h){var g=this.href,j="#"+(this.title&&this.title.replace(/\s/g,"_")||c.hashPrefix+(h+1)),f=this;this.href=j;a(this).click(function(i){if(!d.locked){if(i.clientX){a.ajaxHistory.update(j)}d.load(g,function(){d.locked=null;e.apply(f)})}})})};a.fn.history=function(b){return this.click(function(c){if(c.clientX){if(this.hash==location.hash){return false}a.ajaxHistory.update(this.hash)}if(typeof b=="function"){b.call(this)}})}})(jQuery);