	function listbox(name)
		{
		this.name = name;
		this.longitud = 0;
		this.object = null;
		this.load = lst_load;
		this.loadXML = lst_loadXML;
		this.loadObject = lst_loadObject;
		this.fill = lst_fill;
		this.fillList = lst_fillList;
		this.setValue = lst_setValue;
		this.getValue = lst_getValue;
		this.getText = lst_getText;
		this.clear = lst_clear;
		this.clearFrom = lst_clearFrom;
		this.async = false;
		this.xmlDoc = null;
		this.objWait = null;
		this.longi = null;
		this.onreadystatechange = null;
		this.defaultName = null;
		this.defaultValue = null;
		}


	function lst_load(xmlPath,tagElement,nameAttribute,valueAttribute)
		{
		if (this.objWait!=null){
			this.objWait.style.display = "";
		}
		//this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		this.xmlDoc = XMLRemoteRequest.prototype.getXMLDOMComponentInstance();
		this.xmlDoc.async = this.async;
		if (this.async)
			this.xmlDoc.onreadystatechange = new Function(this.name + ".fill('" + tagElement + "','" + nameAttribute + "','" + valueAttribute + "')");
		var xmlCargado = this.xmlDoc.load(xmlPath);
		if (!this.async)
			{
			if (!xmlCargado) return;
			this.fill(tagElement,nameAttribute,valueAttribute);
			}
		}
		
	function lst_loadXML(xml,tagElement,nameAttribute,valueAttribute)
		{
		//this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		//alert("Toni");
		this.xmlDoc = XMLRemoteRequest.prototype.getXMLDOMComponentInstance(xml);
		this.xmlDoc.async = false;
		//if (!this.xmlDoc.loadXML(xml)) return;
		this.fill(tagElement,nameAttribute,valueAttribute);
		}
		
	function lst_loadObject(xmlObject,tagElement,nameAttribute,valueAttribute)
		{
		this.xmlDoc = xmlObject;
		this.fill(tagElement,nameAttribute,valueAttribute);
		}
		
	function lst_fillList(list,tagElement,nameAttribute,valueAttribute)
		{
		var rs = list;
		if (this.defaultValue && this.defaultName){
			this.object.options[this.object.options.length]  = new Option(this.defaultName, this.defaultValue, false, false);
		}
		var from = this.object.options.length;
		for (i=from;i<rs.length+from;i++)
			{
			nom = rs[i-from].getAttribute(nameAttribute);
			valor = rs[i-from].getAttribute(valueAttribute);
			if ((nom != null) && (valor != null))
				{
				if (this.longi!=null)
					{
					if (nom.length < this.longi)
						{
						var espais = "";
						for (n=1; n < (this.longi - nom.length); n++)  
							espais += " ";
						nom = nom + espais;
						}
					else
						nom = nom.substring(0, this.longi);
					}
				if (this.longitud != 0)
					nom = nom.substring(0,this.longitud)
				this.object.options[i]  = new Option(nom, valor, false, false);
				}
			}
			
			if (this.objWait!=null){
				this.objWait.style.display = "none";
			}
			if (this.onreadystatechange!=null){
				eval(this.onreadystatechange);
			}
		
		}

	function lst_fill(tagElement,nameAttribute,valueAttribute)
		{
		if (this.xmlDoc.readyState && this.xmlDoc.readyState != 4) return;
		var rs = this.xmlDoc.getElementsByTagName(tagElement);
		this.fillList(rs,tagElement,nameAttribute,valueAttribute);
				//alert("kk0");
/*		var from = this.object.options.length;
		//alert("kk1");
		for (i=from;i<rs.length+from;i++)
			{
			nom = rs[i-from].getAttribute(nameAttribute);
			valor = rs[i-from].getAttribute(valueAttribute);
			if ((nom != null) && (valor != null))
				{
				if (this.longi!=null)
					{
					if (nom.length < this.longi)
						{
						var espais = "";
						for (n=1; n < (this.longi - nom.length); n++)  
							espais += " ";
						nom = nom + espais;
						}
					else
						nom = nom.substring(0, this.longi);
					}
				if (this.longitud != 0)
					nom = nom.substring(0,this.longitud)
				this.object.options[i]  = new Option(nom, valor, false, false);
				}
			}
			
			if (this.objWait!=null){
				this.objWait.style.display = "none";
			}
			if (this.onreadystatechange!=null){
				eval(this.onreadystatechange);
			}*/
		
		}
		
	function lst_setValue(value)
		{
		for (i=0;i<this.object.options.length;i++)
			if (this.object.options[i].value==value)
				{
				this.object.options[i].selected = true;
				return;
				}
		return;
		}
	function lst_getValue()
		{
		//alert(this.object.options.selectedIndex);
		return this.object.options[this.object.options.selectedIndex].value;
		}
	function lst_getText()
		{
		return this.object.options[this.object.options.selectedIndex].text;
		}
	function lst_clear()	
		{
		return this.object.options.length=0;
		}
	function lst_clearFrom(num)	
		{
		return this.object.options.length=num;
		}
