function valida(){
	if (document.getElementById('nome').value == ""){
		alert('Aviso: Nome - Campo Vazio!');
		document.getElementById('nome').focus();
		return false;
	}
	if(document.getElementById('email').value.length < 4){
		alert("Aviso: E-mail - Campo Inválido!");
		document.getElementById('email').focus();
		return false;
	}else{
		if (validEmail(document.getElementById('email').value)) {
			alert("Aviso: E-mail - Campo Inválido!");
			document.getElementById('email').focus();
			return false;
		}
	}
	if (document.getElementById('mensagem').value == ""){
		alert('Aviso: Mensagem - Campo Vazio!');
		document.getElementById('mensagem').focus();
		return false;
	}
}
function valida2(){
	if(document.getElementById('usuario').value  == ""){
		alert("Atenção: Usuário - Campo Vazio!");
			document.getElementById('usuario').focus();
			return false;
	}
	if(document.getElementById('usuario').value != ""){
		if (!ValidarCNPJ (document.getElementById('usuario').value)) {
			alert("Atenção: Usuário inválido.");
			document.getElementById('usuario').focus();
			return false;
		}
	}
	if (document.getElementById('senha').value == ""){
		alert('Aviso: Senha - Campo Vazio!');
		document.getElementById('mensagem').focus();
		return false;
	}
}
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
function ValidarCNPJ (campo) {
	    if (campo.length == 14)
		{
				var CGC1, CGC2, Matriz; 
				var Soma, Digito;
				var i , j; 
				var ContIni , ContFim;
				var controle;
				CGC1 = campo.substring(0,12);
				CGC2 = campo.substring(12,14);
				controle = "";
				ContIni = 1;
				ContFim = 12;
				K = 0;
				for (j = 1; j <= 2; j++)
				{
					Soma = 0;
					for (i = ContIni; i <=ContFim; i++)
					{
						Mult = (ContFim + 1 + j - i);
						if (Mult > 9) Mult = Mult - 8;
						Soma = Soma + (parseInt(CGC1.substring(i - j, i-K)) * Mult);
					}
					if (j == 2) Soma = Soma + (2 * Digito);
					Digito = (Soma * 10) % 11;
				if (Digito == 10) Digito = 0;
					controle = controle + Digito;
					ContIni = 2;
					K=1;
					ContFim = 13;
				} 
				if (controle != CGC2) return false; 
	
				return true;
		}
		else
		{
			return false;
		}
}
function validEmail(email){
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0){
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
			return false;
  }
			return true;
}
