/********************************************************
	Clase: Dictionary
	Programador: Fran
	Fecha: 12/01/2006
	Modificado: 26/01/2006
	Descripción: Simula un objeto Dictionary o array
				 asociativo
 ********************************************************/
 
// Constructor
function Dictionary(content){
	if(!content) 
		this._content = {};
	else{
		if(typeof(content) == 'object')
			this._content = content;
		else
			throw new Error("Tipo de dato erróneo");
	}
}

// Métodos
Dictionary.prototype = {
	Add: function(key, value){
		this._content[key] = value;
	},
	
	AddDictionary: function(dict){
		if(dict instanceof Dictionary){
			var content = dict.getContent();
			for(var key in content)
				this.Add(key, content[key]);
		}
		else
			throw new Error("Tipo de dato erróneo");
	},
	
	Remove: function(key, value){
		delete this._content[key];
	},
	
	Exist: function(key){
		if(this._content[key] != null)
			return true;
		else
			return false;
	},
	
	Value: function(key){
		if(this.Exist(key))
			return this._content[key];
	},
	
	getKeys: function(){
		var keys = [];
		for(key in this._content)
			keys[keys.length] = key;
		
		return keys;
	},
	
	getValues: function(){
		var values = [];
		for(key in this._content)
			values[values.length] = this._content[key];
		
		return values;
	},
	
	Length: function(){
		var keys = 	this.getKeys();
		return keys.length;
	},
	
	Index: function(key){
		var index = 0;
		for(k in this._content){
			if(k == key)
				return index;
			else
				index++;
		}
		
		return -1;
	},
	
	getContent: function(){
		return this._content;	
	}
}