window.onerror= manejador;
function manejador(msj,url,linea) {
  var texto="Se ha producido el siguiente error:\n";
  texto+= msj + "\n";
  texto+="(URL: " + url + ". Línea " + linea + ")";
  alert(texto);
  return true;
}

function addRowSelect(miSelect, cad, valor)
{	
	if (cad!="" && !IsNumeric(cad) && !existElemSelect(miSelect, cad)){
	
		var op1 = document.createElement('option');
		op1.value = valor;
		op1.text = cad;
		//var txt1 = document.createTextNode(cad);
		//op1.appendChild(txt1);
		//miSelect.options[miSelect.length]=op1;
				
		try {
		  miSelect.add(op1,null); // standards compliant; doesn't work in IE
		}
		catch(ex) {
		  miSelect.add(op1); // IE only
		}

		//SCROLL HACIA ABAJO
		miSelect.scrollTop=  miSelect.scrollHeight - miSelect.offsetHeight+5 ;

	}
	else { alert("Introduzca un nombre correcto: no blanco, no numérico, no repetido en lista."); }
}

function existElemSelect(miSelect, elem)
{
	for(i=0; i<miSelect.length; i++){
		if(miSelect.options[i].text == elem){
			return true;
		}
	}
	return false;
}

function delRowSelect(miSelect)
{	
	for(i=0; i<miSelect.length; i++){
		if(miSelect.options[i].selected){
			miSelect.options[i] = null;
			i--;
		}
	}
}

function selTodos(miForm)
{
	var i;
	var j;
	for(i=0; i<miForm.elements.length; i++){		
		if (miForm.elements[i].type == "select-multiple"){
			for(j=0; j<miForm.elements[i].options.length; j++){
				miForm.elements[i].options[j].selected=true;	
			}
		}
	}
}

function IsNumeric(expression)  
{  
    return (String(expression).search(/^\d+$/) != -1);  
	//return(true);
} 