function select_add (f, item, count_item) {
  // 0. collect our new option(s) from the user
  word = prompt ('Agregando nuevas opciones a la encuesta -- separe multiples opciones con comas (ejemplo: Excelente, Bueno, Regular, Malo)','');
  if (word == null || word.length == 0) {
  	return false;
  }
  words = word.split (/, ?/);
  
  //alert(words.length);
  
  // 2. add the selected option to the list
  for (i = 0; i < words.length; i++) {
  	if (document.all) {
  		f.elements[item].options[f.elements[item].options.length] = new Option (words[i], ""+words[i], false, true);
  	} else {
  		o = document.createElement ('option');
  		o.text = words[i];
  		o.value = ""+words[i];
  		f.elements[item].add (o, null);
  	}
    //f.elements[count_item].value = f.elements[item].options.length;
  }
  // 3. cancel the click
  return false;
}

function select_remove (f, item, count_item) {
  // 0. collect the selected option from the "item" field
  word = '';
  sep = '';
  for (i = 0; i < f.elements[item].options.length; i++) {
  	if (f.elements[item].options[i].selected) {
  		word = word + sep + f.elements[item].options[i].text;
  		//sep = ',';
  		sep = "\n";
  	}
  }
  
  // 0.1	. confirm that they want to delete the selected list
  c = confirm ("Seguro de eliminar esta(s) opcion(es) ?  \n" + word);
  if (! c) {
  	return false;
  }

  // 2. remove the selected options from the list
  for (i = f.elements[item].options.length - 1; i >= 0; i--) {
  	if (f.elements[item].options[i].selected) {
  		// remove
  		if (document.all) {
  			f.elements[item].options.remove (i);
  		} else {
  			f.elements[item].options[i] = null;
  		}
  	}
  }

  f.elements[count_item].value = f.elements[item].options.length;
  // 3. cancel the click
  return false;
}

// Selecciona a todos los elementos de la lista
function select_all (f, item) {
  for (i = f.elements[item].options.length - 1; i >= 0; i--) {
    f.elements[item].options[i].selected = true;
  }
}

// Selecciona a todos los elementos de la lista
function seleccionar_todos(idelemento) {
	//alert("aqui en seleccionar todos");
   var lista=document.getElementById(idelemento);
  for (i = lista.options.length - 1; i >= 0; i--) {
    lista.options[i].selected = true;
  }
}

//Recibe(elemento,liga,texto)
function crearLiga(elemento,liga,texto){
	elemento=elemento.appendChild(document.createElement("<ul>"));
	elemento=elemento.appendChild(document.createElement("<li>"));
	elemento=elemento.appendChild(document.createElement("<a>"));
	elemento.href=liga;
	elemento.appendChild(document.createTextNode(texto));
	return elemento;
}


function removeChilds(o){
	if(o !=null){
	    while(o.childNodes.length>0)
    	    o.removeChild(o.childNodes[0]);
	}
}

function unselect_all(f, item) {
	for (i = f.elements[item].options.length - 1; i >= 0; i--) {
		f.elements[item].options[i].selected = false;
	}
}

function sel(chkbox, item) {
	if (chkbox.checked)
		select_all(chkbox.form, item);
	else
		unselect_all(chkbox.form, item);
}