// JavaScript Document
var popUpWin;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
function cambiarDisplay(id) {
  if (!document.getElementById) return false;
  fila = document.getElementById(id);
  if (fila.style.display != "none") {
    fila.style.display = "none"; //ocultar fila
  } else {
    fila.style.display = ""; //mostrar fila
  }
}
function requerido(campo) {
	if(campo.value.length == 0)	{
		alert("El campo " + campo.name + " es obligatorio");
		return false;
	} else {
		return true;
	}
}
function comprobarEmail(campo) {
	if(campo.value.indexOf('@') == -1 || campo.value.indexOf('@') == 0 || campo.value.indexOf('@') == campo.length - 1 || campo.value.indexOf('.') == campo.value.length - 1 || campo.value.indexOf('.') == -1 || campo.value.indexOf('@') != campo.value.lastIndexOf('@')) {
		alert("El campo email es incorrecto");
		return false;
	} else {
		return true;
	}
}
function validar_form() {
	id = document.contacto;
	if(id.nombre.value != 'tu nombre *') {
		if((id.email.value != 'e-mail *') && (comprobarEmail(id.email))) {		
			id.submit();
		} else { alert("Debe escribir un e-mail"); }								
	} else { alert("Debe escribir un nombre"); }							
}