Web.Components.Lists = function () {
	this.Objetos 	= Web.Library.Instances.create('Objects');
	this.Documents 	= Web.Components.Instances.create('Documents');
	this.fl_retorno = 1;
	this.iCount 	= 0;
	this.obj_Iproperty = {};
	this.obj_Ievents   = {};
	this.str_name      = "";
	
	this.create = function (strObj,criarEm) {
		var objObj, criar, nome, LEvents;
		nome     = this.Objetos.getNonEmpty(this.getName(), strObj);
		objObj   = this.Objetos.getObj(strObj, 'UL');
		criar    = (typeof objObj == 'string') ? true : false;
		criarEm  = (criarEm != null && typeof this.Objetos.getObj(criarEm) == 'object') ? this.Objetos.getObj(criarEm) : criarEm;
		criarEm  = (criarEm != null) ? criarEm : this.Objetos.getBody();
		LEvents  = this.getLEvents();
		
		if (criar) {
			objObj = this.Documents.newList(strObj, null, null);
			
			objObj.setAttribute('id', nome);
			objObj.setAttribute('name', nome);

			criarEm.appendChild(objObj);
		}
		
		objObj['objObj'] = this;
		
		if (typeof LEvents == 'object') {
			for (x in LEvents) {
				if (LEvents[x] == '______array' || LEvents[x] == '') continue;
				this.Objetos.register(objObj, LEvents[x][0], LEvents[x][1]);
			}
		}
		
		this.setInput(objObj);
		this.setInputID(strObj);
		this.setCreateAT(criarEm);
		
		return (this.getRetorno() == 2) ? this : objObj;
	}
	
	this.Fill = function (objArray) {
		for (x in objArray) {
			if (objArray[x] == '______array') continue;
			this.Add(objArray[x]);
		}
	}
	
	this.RemoveAll = function () {
		var objList = this.getObjObj();
		var Items   = objList.getElementsByTagName('LI');
		
		for (var i = 0; i < Items.length; i++) {
			objList.removeChild(Items[x]);
		}
	}
	
	this.Add = function (texto) {
		var objList     = this.getObjObj();
		var Ultimo		= this.iCount;
		var newListItem = this.Documents.newListItem(this.getInputID() +'_'+ Ultimo, ((typeof texto == 'object') ? texto[1] : null), null);
		var Properties  = this.getIProperty();
		var Eventos     = this.getIEvents();
		newListItem.innerHTML = (texto != null) ? texto : newListItem.innerHTML;
		
		if (Properties[Ultimo] != null) {
			this.Objetos.setAttributes(newListItem, Properties[Ultimo]);
		}
		
		if (typeof Eventos[Ultimo] == 'object') {
			for (x in Eventos[Ultimo]) {
				if (Eventos[Ultimo][x] == '______array' || Eventos[Ultimo][x] == "") continue;
				this.Objetos.register(newListItem, Eventos[Ultimo][x][0], Eventos[Ultimo][x][1]);
			}
		}
		
		objList.appendChild(newListItem);
		this.iCount++;
	}
	
	this.Remove = function (indice) {
		var objList = this.getObjObj();
		var Items   = objList.getElementsByTagName('LI');
		
		indice = (indice != null) ? indice : Math.abs(Items.length-1);
		for (var x = 0; x < Items.length; x++) {
			if (Items[x].id != this.getInputID()+'_'+indice) continue;
			
			objList.removeChild(Items[x]);
			return true;
		}
	}
	
	this.AddEvent = function (strEvent, strFunc) {
		this.Objetos.register(this.getObjObj(), strEvent, strFunc);
	}
	
	this.RemoveEvent = function (strEvent, strFunc) {
		this.Objetos.unregister(this.getObjObj(), strEvent, strFunc);
	}
	
	this.AddItemEvent = function (indice, strEvent, strFunc) {
		this.Objetos.register(this.getItem(indice), strEvent, strFunc);
	}
	
	this.RemoveItemEvent = function (indice, strEvent, strFunc) {
		this.Objetos.unregister(this.getItem(indice), strEvent, strFunc);
	}
	
	this.setAttributes = function (argumentos) {
		this.Objetos.setAttributes(this.getObjObj(), argumentos);
	}
	
	this.setItemAttributes = function (indice, argumentos) {
		this.Objetos.setAttributes(this.getItem(indice), argumentos);
	}
	
	this.getItem = function (indice) {
		var objList = this.getObjObj();
		var Items   = objList.getElementsByTagName('LI');
		
		indice = (indice != null) ? indice : Math.abs(Items.length-1);
		for (var x = 0; x < Items.length; x++) {
			if (Items[x].id == this.getInputID()+'_'+indice) {
				return Items[x];
			}
		}
	}
	
	this.getObjObj = function () { return this.obj_input; }
	this.setObjObj = function (valor) { this.obj_input = valor; }
	
	this.getName = function () { return this.str_name; }
	this.setName = function (valor) { this.str_name = valor; }
	
	this.getInput = function () { return this.obj_input; }
	this.setInput = function (valor) { this.obj_input = valor; }
	
	this.getInputID = function () { return this.input_id; }
	this.setInputID = function (valor) { this.input_id = valor; }
	
	this.getCreateAT = function () { return this.create_at; }
	this.setCreateAT = function (valor) { this.create_at = valor; }

	this.getRetorno = function () { return this.fl_retorno; }
	this.setRetorno = function (valor) { this.fl_retorno = valor; }
	
	this.getIProperty = function () { return this.obj_Iproperty; }
	this.setIProperty = function (valor) { this.obj_Iproperty = valor; }
	
	this.getIEvents = function () { return this.obj_Ievents; }
	this.setIEvents = function (valor) { this.obj_Ievents = valor; }
	
	this.getLEvents = function () { return this.obj_Levents; }
	this.setLEvents = function (valor) { this.obj_Levents = valor; }
}
