(function(a){function l(a){if(!a||typeof a!="string"&&typeof a!="number")throw new TypeError("Key name must be string or numeric");return!0}function k(){try{c.jStorage=f(b),d&&(d.setAttribute("jStorage",c.jStorage),d.save("jStorage")),e=c.jStorage?String(c.jStorage).length:0}catch(a){}}function j(){if(c.jStorage)try{b=g(String(c.jStorage))}catch(a){c.jStorage="{}"}else c.jStorage="{}";e=c.jStorage?String(c.jStorage).length:0}function i(){if("localStorage"in window)try{window.localStorage&&(c=window.localStorage,h="localStorage")}catch(a){}else if("globalStorage"in window)try{window.globalStorage&&(c=window.globalStorage[window.location.hostname],h="globalStorage")}catch(b){}else{d=document.createElement("link");if(!d.addBehavior){d=null;return}d.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(d),d.load("jStorage");var e="{}";try{e=d.getAttribute("jStorage")}catch(f){}c.jStorage=e,h="userDataBehavior"}j()}if(!a||!(a.toJSON||Object.toJSON||window.JSON))throw new Error("jQuery, MooTools or Prototype needs to be loaded before jStorage!");var b={},c={jStorage:"{}"},d=null,e=0,f=a.toJSON||Object.toJSON||window.JSON&&(JSON.encode||JSON.stringify),g=a.evalJSON||window.JSON&&(JSON.decode||JSON.parse)||function(a){return String(a).evalJSON()},h=!1;_XMLService={isXML:function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1},encode:function(a){if(!this.isXML(a))return!1;try{return(new XMLSerializer).serializeToString(a)}catch(b){try{return a.xml}catch(c){}}return!1},decode:function(a){var b="DOMParser"in window&&(new DOMParser).parseFromString||window.ActiveXObject&&function(a){var b=new ActiveXObject("Microsoft.XMLDOM");b.async="false",b.loadXML(a);return b},c;if(!b)return!1;c=b.call("DOMParser"in window&&new DOMParser||window,a,"text/xml");return this.isXML(c)?c:!1}},a.jStorage={version:"0.1.5.2",set:function(a,c){l(a),_XMLService.isXML(c)&&(c={_is_xml:!0,xml:_XMLService.encode(c)}),b[a]=c,k();return c},get:function(a,c){l(a);if(a in b)return b[a]&&typeof b[a]=="object"&&b[a]._is_xml&&b[a]._is_xml?_XMLService.decode(b[a].xml):b[a];return typeof c=="undefined"?null:c},deleteKey:function(a){l(a);if(a in b){delete b[a],k();return!0}return!1},flush:function(){b={},k();return!0},storageObj:function(){function a(){}a.prototype=b;return new a},index:function(){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a},storageSize:function(){return e},currentBackend:function(){return h},storageAvailable:function(){return!!h},reInit:function(){var a,b;if(d&&d.addBehavior){a=document.createElement("link"),d.parentNode.replaceChild(a,d),d=a,d.style.behavior="url(#default#userData)",document.getElementsByTagName("head")[0].appendChild(d),d.load("jStorage"),b="{}";try{b=d.getAttribute("jStorage")}catch(e){}c.jStorage=b,h="userDataBehavior"}j()}},i()})(window.jQuery||window.$)

