// Agrega rubros selecionados, pero con un limite: no mas rubros de los indicados
// en el parametro limite. Si limite es cero,  no limitamos
//
function agregar(limite)
{
	// Esta funcion recorre el combobox de rubros
	// y las mueve al combobox de rubros activos, solo si ha seleccionado algo
	//
	inactivo= document.fm.elements['cmbRubros[]'];
	activo	= document.fm.elements['rubros[]'];
	limite	= (limite == 0)?2000:limite;
	
	if(activo.options.length >= limite){
		alert("Lo lamentamos, solo puede inscribir " + limite +" Rubro(s).");		
		return;
	}

	if(inactivo.selectedIndex == -1){
		alert("Error, debe seleccionar un Rubro antes de ejecutar esta acción.");
		return;
	}
	// Moviendo de combobox todas las seleccionadas
	i=0;
//Cambiado por Roberto Ovalle
//	while(i <= inactivo.options.length && activo.options.length < limite){
	while(i < inactivo.options.length && activo.options.length < limite){
		if(inactivo.options[i].selected){

			texto	= inactivo.options[i].text;
			indice	= inactivo.options[i].value;

			activo.options[activo.length] = new Option(texto, indice);
			inactivo.options[i]=null;
			i=0;
		}else
			i= i + 1;
	}
}
function eliminar()
{
	// Esta funcion recorre el combobox de rubros activos
	// y las mueve al combobox de rubros, solo si ha seleccionado algo
	//
	inactivo= document.fm.elements['cmbRubros[]'];
	activo	= document.fm.elements['rubros[]'];

	if(activo.selectedIndex == -1){
		alert("Error, debe seleccionar un Rubro antes de ejecutar esta acción.");
		return;
	}
	// Moviendo de combobox
	i=0;
//Cambiado por Roberto Ovalle
//	while(i <= activo.options.length){
	while(i < activo.options.length){
		if(activo.options[i].selected){
			texto	= activo.options[i].text;
			indice	= activo.options[i].value;

			inactivo.options[inactivo.length] = new Option(texto, indice);
			activo.options[i]=null;
			i=0;
		}else
			i= i + 1;
	}
}
function selecciona()
{
	activo	= document.fm.elements['rubros[]'];

	for(i=0;i<activo.options.length;i++){
			activo.options[i].selected = true;
	}

	return true;
}
