function Form1_Validator(theForm)
{

  var alertsay = ""; 
  
   if (theForm.Assunto.value == "")
  {
    alert("Por favor, o assunto do seu contacto");
    theForm.Assunto.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.Assunto.value.length < 3)
  {
    alert("O campo assunto tem de ser mais longo do que isso");
    theForm.Assunto.focus();
    return (false);
  }

  if (theForm.Nome.value == "")
  {
    alert("Preencha o campo Nome sff.");
    theForm.Nome.focus();
    return (false);
  }

  // require at least 3 characters be entered
  if (theForm.Nome.value.length < 3)
  {
    alert("O seu nome tem de ser mais longo que isso.");
    theForm.Nome.focus();
    return (false);
  }

 if (theForm.Email.value == "")
  {
    alert("Por favor, forneça o seu \"Email\".");
    theForm.Email.focus();
    return (false);
  }


  // test if valid email address, must have @ and .
  var checkEmail = "@.";
  var checkStr = theForm.Email.value;
  var EmailValid = false;
  var EmailAt = false;
  var EmailPeriod = false;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkEmail.length;  j++)
    {
      if (ch == checkEmail.charAt(j) && ch == "@")
        EmailAt = true;
      if (ch == checkEmail.charAt(j) && ch == ".")
        EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
    if (EmailAt && EmailPeriod)
    {
		EmailValid = true
		break;
	}
  }
  if (!EmailValid)
  {
    alert("Por favor, forneça um email válido.");
    theForm.Email.focus();
    return (false);
  }

   if (theForm.Email2.value == "")
  {
    alert("Por favor, repita o seu Email");
    theForm.Email2.focus();
    return (false);
  }

  
   if (theForm.Email.value != theForm.Email2.value)
  {
	alert("Os Emails inseridos não são iguais.");
	theForm.Email2.focus();
	return (false);
  }

if (theForm.Phone.value == "")
  {
    alert("Por favor, forneça um número de contacto.");
    theForm.Phone.focus();
    return (false);
  }


  var checkOK = "0123456789";
  var checkStr = theForm.Phone.value;
  var allValid = true;
  var allNum = "";
  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 (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("O campo telefone tem de ser um valor numerico e sem espaços.");
    theForm.Phone.focus();
    return (false);
  }


   if (theForm.Descobriu.value == "")
  {
    alert("Por favor, indique como descobriu a ActiveBit");
    theForm.Descobriu.focus();
    return (false);
  }


  if (theForm.Mensagem.value == "")
  {
    alert("Está se esquecendo do campo mensagem.");
    theForm.Mensagem.focus();
    return (false);
  }

  return (true);

}
