// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
function checkContacto(theForm) {
    var why = "";
    why += isEmpty(theForm.txtnombre.value, 'nombre');
    why += checkEmail(theForm.txtemail.value);
	
    if (why != "") {
       alert("Se encontraron los siguientes errores:\n\n" + why + "\nPor favor revisa el formulario de contacto y corrige los errores");
       return false;
    }
	return true;
}

function checkEmail (strng) {
	var error="";
	if (strng == "") 
	{
		error = " - Dirección de correo faltante.\n";	   
	}
	else
	{
		var emailFilter=/^.+@.+\..{2,3}$/;
		if (!(emailFilter.test(strng))) { 
		   error = " - Dirección de correo no valida.\n";
		}
		else {
		   var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
			 if (strng.match(illegalChars)) {
			  error = " - La dirección de correo contiene caracteres no permitidos.\n";
		   }
		}    
	}
	return error;
}

function isEmpty(strng, nombreCampo) {
var error = "";
  if (strng.length == 0) {
     error = " - El campo de " + nombreCampo + " esta vacío.\n"
  }
return error;	  
}