function addOption(objectId, texto, valor){
	var object = document.getElementById(objectId);
	with(object){
		options[options.length] = new Option (texto, valor);
	}
}

function delOption(objectId){
	
	var object = document.getElementById(objectId);
  	if (object.length > 0){
    	object.remove(object.selectedIndex);
  	}

}

function clearOption(objectId){	
	var object = document.getElementById(objectId);
	var item = 0;
	var totalItems = object.options.length;
	
	while(item <= totalItems){
		delOption(objectId);
		item++;
	}
}

function selectOption(objectId, string, disable){
	var object = document.getElementById(objectId);
	var I = 0;
	var totalItems = object.options.length-1;
			
	while(I <= totalItems){
		if(object.options[I].value==string)	
			object.options[I].selected = true;
		else
			object.options[I].selected = false;
		
		I++;
	}
	
	object.disabled = disable;
}

function addOptionArray(objectId, string, disable, clear){
	
	var object = document.getElementById(objectId);
	var array = string.split('|');
		
		object.disabled = disable;
		
		if(clear != true) clearOption(objectId);
		
		for (var i = 0; i < array.length; i++) {
			array[i] = array[i].split('#');
			
			addOption(objectId, array[i][1], array[i][0]);
		}
}
