/**
* -------------------------------------------------------------------------------
* Classe Storage 1.0 (jQuery)
* 	Visa a organização dos dados. Baseada nas seguintes classes:
*	  - 'generic' de David Walsh (http://davidwalsh.name/php-generic-objects-organize-code-class/)
*	  - 'MixedCollection' da biblioteca ExtJS 2.0
* -------------------------------------------------------------------------------
* Criado em....: 29/02/2008
* Alterado em..: -
* -------------------------------------------------------------------------------
* Changelog
* -------------------------------------------------------------------------------
*/

var Storage =  function(hMyItems){
	return {Store: {
		
		$items: hMyItems,
		
		clear: function(){
			return $items = {};
		},
		
		contains: function(sMyValue){
			var aValues = [];
			$.each(this.$items, function(sKey, sValue){ aValues.push(sValue); });
			
			return -1 < $.inArray(sMyValue, aValues);
		},
		
		containsKey: function(sMyKey){
			var aKeys = [];
			$.each(this.$items, function(sKey, sValue){ aKeys.push(sKey); });
			
			return -1 < $.inArray(sMyKey, aKeys);
		},
		
		get: function(sKey){
			return this.$items[sKey];
		},
		
		getAll: function(){
			return this.$items;
		},
		
		getCount: function(){
			var aKeys = [];
			$.each(this.$items, function(sKey, sValue){ aKeys.push(sKey); });
			
			return aKeys.length;
		},
		
		load: function(hVars){
			return $.extend(this.$items, hVars);
		},
		
		replace: function(sKey, sValue){
			this.$items[sKey] = sValue;
			return sValue;
		},
		
		set: function(sKey, sValue, bReplaceIfExists){
			if(this.containsKey(sKey) && !bReplaceIfExists)
				return false;
			
			return this.replace(sKey, sValue);
		},
		
		unset: function(sKey){
			var sValue = this.get(sKey);
			delete this.$items[sKey];
			
			return sValue;
		}
		
	}};
};