// libreriaDOM.js
// v1.0.0
// Fecha creación: 04/05/2008
// Fecha última modif: 15/05/2008

function agregarElemento(idElementoPadre,tipoElementoHijo,nombreEIdElementoHijo,textoInterno) {
  var ni = document.getElementById(idElementoPadre);
  if (document.getElementById(nombreEIdElementoHijo) == undefined) { // Sólo crea el elemento si no existe, así no crea varios del mismo.
    var newdiv = document.createElement(tipoElementoHijo);
    newdiv.setAttribute('name',nombreEIdElementoHijo);
    newdiv.setAttribute('id',nombreEIdElementoHijo);
    newdiv.innerHTML = textoInterno;
    ni.appendChild(newdiv);
  }
}

function eliminarElemento(idElementoPadre,idElementoAEliminar) {
  var elementoPadre = document.getElementById(idElementoPadre);
  var elementoHijo = document.getElementById(idElementoAEliminar);
  if (elementoHijo != undefined) { // Si no existe que no tire error.
    elementoPadre.removeChild(elementoHijo);
  }
}

function agregarTextoAP(idP,textoInterno) {
  var ni = document.getElementById(idP);
  /*
  if (document.getElementById(nombreEIdElementoHijo) == undefined) {
    var newdiv = document.createElement(tipoElementoHijo);
    newdiv.setAttribute('name',nombreEIdElementoHijo);
    newdiv.setAttribute('id',nombreEIdElementoHijo);
    newdiv.innerHTML = textoInterno;
    ni.appendChild(newdiv);
  }
  */
  ni.innerHTML = textoInterno;
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
