/*
 * jQuery history plugin
 * 
 * The MIT License
 * 
 * Copyright (c) 2006-2009 Taku Sano (Mikage Sawatari)
 * Copyright (c) 2010 Takayuki Miwa
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */(function(a){function d(c){function e(b){var c=new RegExp(a.map(b,encodeURIComponent).join("|"),"ig");return function(a){return a.replace(c,decodeURIComponent)}}function d(a){return a===!0?function(a){return a}:typeof a=="string"&&(a=e(a.split("")))||typeof a=="function"?function(b){return a(encodeURIComponent(b))}:encodeURIComponent}c=a.extend({unescape:!1},c||{}),b.encoder=d(c.unescape)}var b={put:function(a,b){(b||window).location.hash=this.encoder(a)},get:function(b){var c=(b||window).location.hash.replace(/^#/,"");try{return a.browser.mozilla?c:decodeURIComponent(c)}catch(d){return c}},encoder:encodeURIComponent},c={id:"__jQuery_history",init:function(){var b='<iframe id="'+this.id+'" style="display:none" src="javascript:false;" />';a("body").prepend(b);return this},_document:function(){return a("#"+this.id)[0].contentWindow.document},put:function(a){var c=this._document();c.open(),c.close(),b.put(a,c)},get:function(){return b.get(this._document())}},e={};e.base={callback:undefined,type:undefined,check:function(){},load:function(a){},init:function(a,b){d(b),f.callback=a,f._options=b,f._init()},_init:function(){},_options:{}},e.timer={_appState:undefined,_init:function(){var a=b.get();f._appState=a,f.callback(a),setInterval(f.check,100)},check:function(){var a=b.get();a!=f._appState&&(f._appState=a,f.callback(a))},load:function(a){a!=f._appState&&(b.put(a),f._appState=a,f.callback(a))}},e.iframeTimer={_appState:undefined,_init:function(){var a=b.get();f._appState=a,c.init().put(a),f.callback(a),setInterval(f.check,100)},check:function(){var a=c.get(),d=b.get();d!=a&&(d==f._appState?(f._appState=a,b.put(a),f.callback(a)):(f._appState=d,c.put(d),f.callback(d)))},load:function(a){a!=f._appState&&(b.put(a),c.put(a),f._appState=a,f.callback(a))}},e.hashchangeEvent={_init:function(){f.callback(b.get()),a(window).bind("hashchange",f.check)},check:function(){f.callback(b.get())},load:function(a){b.put(a)}};var f=a.extend({},e.base);a.browser.msie&&(a.browser.version<8||document.documentMode<8)?f.type="iframeTimer":"onhashchange"in window?f.type="hashchangeEvent":f.type="timer",a.extend(f,e[f.type]),a.history=f})(jQuery)
