/**
 * History/Remote 0.2 - jQuery plugin for enabling history and bookmarking in Ajax driven
 *                      applications in an unobtrusive and accessible manner ("Hijax").
 *
 * http://stilbuero.de/jquery/history/
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
(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);
