
function limpiaErrores(maxErrores){

 var oTable;
 var obj;
 entro =false;

 for (indice=0;indice<maxErrores;indice++){

	 obj = document.getElementById('Error_' +indice);

	 if (obj != null){
		  entro=true;
		  oTable = obj.parentNode;
		  oTable.deleteRow(obj.rowIndex);
	 }

  }
  if (entro){
	  return true;
  }else{
	return  false;
  }

}

function enfocar(tdArray){
		oTd1 = document.getElementById(tdArray);
		if(oTd1.getElementsByTagName("*")[0]!=null){
			input = oTd1.getElementsByTagName("*")[0];
			nombre = "#"+input.name;
			window.location.href=nombre;
		}
	
}


function muestraErrores(tdArray, msgArray){

	NN=(navigator.appName=="Netscape")? 1:0;
	IE=(navigator.appName=="Microsoft Internet Explorer")?1:0
  
  var oTr1
  var oTable
  var oTd2
  var oTr2
  var foco=true;

  for (indice=0;indice<tdArray.length;indice++){
  	
	
	idTd =  tdArray[indice];
  	msg  =  msgArray[indice];
  	oTd1 = document.getElementById(idTd);
	oTr1 = oTd1.parentNode;	
	oTable = oTr1.parentNode;

	if(foco){
		if(oTd1.getElementsByTagName("*")[0]!=null && oTd1.getElementsByTagName("*")[0].type=="text"){
			oTd1.getElementsByTagName("*")[0].focus();
			foco=false;
		}
	}
	
  	if ((oTable.rows[oTr1.rowIndex + 1] == null) || (oTable.rows[oTr1.rowIndex + 1].id.indexOf("Error_") != 0)){
  		//Caso normal
		oTr2 = oTable.insertRow(oTr1.rowIndex + 1);
	  	oTr2.id = 'Error_'+indice;
	
		for (i=0; i<= oTd1.cellIndex; i++){
			
			z= oTr2.cells.length
			oTd2 = oTr2.insertCell(z);
		}
	}
	else{
		//Ya existe error en este tr, por lo que no se aņade otro tr, sino un td en su sitio.
		oTr2 = oTable.rows[oTr1.rowIndex + 1];
		oTr2.id = 'Error_' + indice
		for (i=0; i<= (oTd1.cellIndex - oTr2.cells.length + 1); i++){
			z= oTr2.cells.length
			oTd2 = oTr2.insertCell(z);
		}
	}

	
	if(NN) {
		elmText = document.createTextNode(msg);
		oTd2.appendChild(elmText);
	}
	oTd2.className="rojo";
	oTd2.style.color = "#FF0000";
  	if(IE)oTd2.innerText = msg;
  }
}