/** Crea una referencia a objeto Combo
 * 
 * @param {Object} obj el objeto combo 
 * @param {String} strInitText el texto que se mostrara al inicio
 */
function ComboBox(obj,				  
				  strInitText){
	this.obj = obj;
	this.strInitText = strInitText;
	
	this.reloadCombo = _reloadCombo_;
	this.showState = _showState_;	
}

/**
 * Recarga la informacion del combo
 * @param {Object} objAjaxParser la informacion
 */
function _reloadCombo_(objAjaxParser, intSelected){
	var valueSelected = 0;
	if (intSelected != null) 
		valueSelected = intSelected;
	this.obj.disabled = true;
	this.obj.length = 0;
	
	db = new DataBaseHandler(objAjaxParser);
	if (this.strInitText != "") {
		itemCmb = document.createElement("option");
		itemCmb.value = "";
		itemCmb.innerHTML = this.strInitText;
		this.obj.appendChild(itemCmb);
	}
	if(db.hasRows()){
		do{
			itemCmb=document.createElement("option");
			
			itemCmb.value=db.getRow(0);
			itemCmb.innerHTML=db.getRow(1);			
			if (db.getRow(0) == valueSelected)				
				itemCmb.selected = true;			
			this.obj.appendChild(itemCmb);			
		}while(db.next());
	}
	this.obj.disabled=false;
}


/**
 * Muestra el estado del proceso
 * @param {String} strLoadingText el texto
 */
function _showState_(strLoadingText){
	if (strLoadingText != "")		
		this.obj[0].innerHTML = strLoadingText;
}

	
	