(function(){function b(a){a&&a.storage&&(this.storage=a.storage);this.async.set=g(this.async.set,this);this.async.get=g(this.async.get,this)}var c=this,g=function(a,d){return function(){return a.apply(d,arguments)}};b.prototype.VERSION="0.3.2";var j=b.prototype,k;try{c.localStorage.setItem("___locache___","___locache___"),c.localStorage.getItem("___locache___"),c.localStorage.removeItem("___locache___"),k=!0}catch(q){k=!1}var o=j.supportsLocalStorage=k,j=b.prototype,h;try{c.sessionStorage.setItem("___locache___", "___locache___"),c.sessionStorage.getItem("___locache___"),c.sessionStorage.removeItem("___locache___"),h=!0}catch(r){h=!1}var p=j.supportsSessionStorage=h,m=b.prototype.supportsNativeJSON=!!c.JSON;b.prototype.supportsPostMessage=!!window.postMessage;h=b.prototype;var i=function(a){this.fn=a},l=[],f;c.addEventListener?f=c.addEventListener:c.attachEvent&&(f=c.attachEvent);f("message",function(a){if(!(a.source!==c||a.data!=="function-defer-message")){a.stopPropagation();if(l.length!==0){l.shift()(); return false}}},!0);i.prototype.defer=function(){this.resultValue=this.fn();this.hasOwnProperty("finishedFunction")&&this.finishedFunction(this.resultValue)};i.prototype.hasFinished=function(){return this.hasOwnProperty("resultValue")};i.prototype.finished=function(a){this.finishedFunction=a;this.hasFinished()&&this.finishedFunction(this.resultValue);return this};var n=h._defer=function(a){a=new i(a);l.push(g(a.defer,a));c.postMessage("function-defer-message","*");return a};b.prototype.cachePrefix= "___locache___";b.prototype.expirePrefix="___locacheExpire___";b.prototype.backends={local:{set:function(a,d){return c.localStorage.setItem(a,d)},get:function(a){return c.localStorage.getItem(a)},remove:function(a){return c.localStorage.removeItem(a)},length:function(){return c.localStorage.length},key:function(a){if(!(a<0||a>=this.length()))return c.localStorage.key(a)},enabled:function(){return m&&o}},session:{set:function(a,d){return c.sessionStorage.setItem(a,d)},get:function(a){return c.sessionStorage.getItem(a)}, remove:function(a){return c.sessionStorage.removeItem(a)},length:function(){return c.sessionStorage.length},key:function(a){if(!(a<0||a>=this.length()))return c.sessionStorage.key(a)},enabled:function(){return m&&p}}};b.prototype.storage=b.prototype.backends.local;b.prototype.key=function(a){return this.cachePrefix+a};b.prototype.expirekey=function(a){return this.expirePrefix+a};b.prototype.hasExpired=function(a){a=this.expirekey(a);return(a=parseInt(this.storage.get(a),10))&&a<(new Date).getTime()? true:false};b.prototype.set=function(a,d,b){if(this.storage.enabled()&&a){var c=this.expirekey(a),a=this.key(a);b&&this.storage.set(c,(new Date).getTime()+b*1E3);d=JSON.stringify(d);return this.storage.set(a,d)}};b.prototype.get=function(a){if(!this.storage.enabled()||!a)return null;if(this.hasExpired(a)){this.remove(this.key(a));return null}a=this.key(a);if(a=this.storage.get(a))try{return JSON.parse(a)}catch(d){return null}return a};b.prototype.async={set:function(a,d,b){return n(g(function(){return this.set(a, d,b)},this))},get:function(a){return n(g(function(){return this.get(a)},this))}};b.prototype.remove=function(a){if(this.storage.enabled()){var d=this.expirekey(a),a=this.key(a);this.storage.remove(d);this.storage.remove(a)}};b.prototype.incr=function(a){if(this.storage.enabled()){var d=parseInt(this.get(a),10);d||(d=0);d++;this.set(a,d);return d}};b.prototype.decr=function(a){if(this.storage.enabled()){var d=parseInt(this.get(a),10);d||(d=0);d--;this.set(a,d);return d}};b.prototype.setMany=function(a, d){if(this.storage.enabled())for(var b in a)a.hasOwnProperty(b)&&this.set(b,a[b],d)};b.prototype.getMany=function(a){for(var d={},b=0;b=0;a--){var c=this.storage.key(a);c&&c.indexOf(b)===0&&this.storage.remove(c)}};b.prototype.length=function(){if(!this.storage.enabled())return 0;for(var a=0,b=this.storage.length(),c=this.cachePrefix,e=0;e