/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.storage.BehaviorStorageProvider"],["require","dojox.storage.Provider"],["require","dojox.storage.manager"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.storage.BehaviorStorageProvider"]){_4._hasResource["dojox.storage.BehaviorStorageProvider"]=true;_4.provide("dojox.storage.BehaviorStorageProvider");_4.require("dojox.storage.Provider");_4.require("dojox.storage.manager");_4.declare("dojox.storage.BehaviorStorageProvider",[_6.storage.Provider],{store:null,storeName:"__dojox_BehaviorStorage",keys:[],initialize:function(){try{this.store=this._createStore();this.store.load(this.storeName);}catch(e){throw new Error("Store is not available: "+e);}var _7=this.get("keys","dojoxSystemNS");this.keys=_7||[];this.initialized=true;_6.storage.manager.loaded();},isAvailable:function(){return _4.isIE&&_4.isIE>=5;},_createStore:function(){var _8=_4.create("link",{id:this.storeName+"Node",style:{"display":"none"}},_4.query("head")[0]);_8.addBehavior("#default#userdata");return _8;},put:function(_9,_a,_b,_c){this._assertIsValidKey(_9);_c=_c||this.DEFAULT_NAMESPACE;this._assertIsValidNamespace(_c);var _d=this.getFullKey(_9,_c);_a=_4.toJson(_a);this.store.setAttribute(_d,_a);this.store.save(this.storeName);var _e=this.store.getAttribute(_d)===_a;if(_e){this._addKey(_d);this.store.setAttribute("__dojoxSystemNS_keys",_4.toJson(this.keys));this.store.save(this.storeName);}if(_b){_b(_e?this.SUCCESS:this.FAILED,_9,null,_c);}},get:function(_f,_10){this._assertIsValidKey(_f);_10=_10||this.DEFAULT_NAMESPACE;this._assertIsValidNamespace(_10);_f=this.getFullKey(_f,_10);return _4.fromJson(this.store.getAttribute(_f));},getKeys:function(_11){_11=_11||this.DEFAULT_NAMESPACE;this._assertIsValidNamespace(_11);_11="__"+_11+"_";var _12=[];for(var i=0;i<this.keys.length;i++){var _13=this.keys[i];if(this._beginsWith(_13,_11)){_13=_13.substring(_11.length);_12.push(_13);}}return _12;},clear:function(_14){_14=_14||this.DEFAULT_NAMESPACE;this._assertIsValidNamespace(_14);_14="__"+_14+"_";var _15=[];for(var i=0;i<this.keys.length;i++){var _16=this.keys[i];if(this._beginsWith(_16,_14)){_15.push(_16);}}_4.forEach(_15,function(key){this.store.removeAttribute(key);this._removeKey(key);},this);this.put("keys",this.keys,null,"dojoxSystemNS");this.store.save(this.storeName);},remove:function(key,_17){this._assertIsValidKey(key);_17=_17||this.DEFAULT_NAMESPACE;this._assertIsValidNamespace(_17);key=this.getFullKey(key,_17);this.store.removeAttribute(key);this._removeKey(key);this.put("keys",this.keys,null,"dojoxSystemNS");this.store.save(this.storeName);},getNamespaces:function(){var _18=[this.DEFAULT_NAMESPACE];var _19={};_19[this.DEFAULT_NAMESPACE]=true;var _1a=/^__([^_]*)_/;for(var i=0;i<this.keys.length;i++){var _1b=this.keys[i];if(_1a.test(_1b)==true){var _1c=_1b.match(_1a)[1];if(typeof _19[_1c]=="undefined"){_19[_1c]=true;_18.push(_1c);}}}return _18;},isPermanent:function(){return true;},getMaximumSize:function(){return 64;},hasSettingsUI:function(){return false;},isValidKey:function(_1d){if(_1d===null||_1d===undefined){return false;}return /^[0-9A-Za-z_-]*$/.test(_1d);},isValidNamespace:function(_1e){if(_1e===null||_1e===undefined){return false;}return /^[0-9A-Za-z-]*$/.test(_1e);},getFullKey:function(key,_1f){return "__"+_1f+"_"+key;},_beginsWith:function(_20,_21){if(_21.length>_20.length){return false;}return _20.substring(0,_21.length)===_21;},_assertIsValidNamespace:function(_22){if(this.isValidNamespace(_22)===false){throw new Error("Invalid namespace given: "+_22);}},_assertIsValidKey:function(key){if(this.isValidKey(key)===false){throw new Error("Invalid key given: "+key);}},_addKey:function(key){this._removeKey(key);this.keys.push(key);},_removeKey:function(key){this.keys=_4.filter(this.keys,function(_23){return _23!==key;},this);}});_6.storage.manager.register("dojox.storage.BehaviorStorageProvider",new _6.storage.BehaviorStorageProvider());}}};});