// JavaScript Document

function checkFields() {

 
 if (document.form.Name.value.length < 1)
  {
    alert("Write at least one character in \"Name\".");
    document.form.Name.focus();
    return (false);
  }
 
   if (document.form.Email.value.length < 1)
  {
    alert("The field \"email\". is empty");
    document.form.Email.focus();
    return (false);
  }
   
  if (document.form.Comments.value.length < 1)
  {
    alert("The field \"comments\". is empty");
    document.form.Comments.focus();
    return (false);
  }
 

  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = document.form.Name.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  if (!allValid)
  {
    alert("Write just letters in \"Name\".");
    document.form.Name.focus();
    return (false);
  }
 
  if(document.form.Email.value.length > 0){
	  if ((document.form.Email.value.indexOf ('@', 0) == -1)) { 
		alert("Write a valid email address in \"email\"."); 
		document.form.Email.focus();
		return (false); 
	  }
  }
  return (true);
}//end

function checkEmail() {
   if (document.ccoptin.ea.value.length < 1)
  {
    alert("The field \"email\" is empty");
    document.ccoptin.ea.focus();
    return (false);
  }
 
  if(document.ccoptin.ea.value.length > 0){
	  if ((document.ccoptin.ea.value.indexOf ('@', 0) == -1)) { 
		alert("Write a valid email address in \"email\"."); 
		document.ccoptin.ea.focus();
		return (false); 
	  }
  }
  return (true);
}//end
