function testaEmail(txtInput) {
	email = txtInput.value;
	if (email == "") {
		return true;
	} else {
  		if ((email.indexOf('@') == email.lastIndexOf('@')) &&	// só tem um @
  			(email.indexOf('@') > 0) &&							// existe @ e não é prim
  			(email.charAt(email.length-1) != '@') &&			// @ não é o último
  			(email.indexOf(' ') == -1) &&						// não existe espaços
  			(email.lastIndexOf('.') > email.indexOf('@')) &&	// existe . após @
  			(email.charAt(email.indexOf('@') + 1) != '.') &&	// sem . logo após @
  			(email.charAt(email.indexOf('@') - 1) != '.') &&	// sem . logo antes @
  			(email.indexOf('.') > 0) &&							// existe . e não é prim
			(email.charAt(email.length-1) != '.')) {			// . não é o último
				
			// verifica se não há pontos seguidos
			sub = email.substring(email.indexOf('.')+1, email.length);
			while (sub.indexOf('.') != -1) {
				if (sub.charAt(0) == '.') {
					alert("Formato de e-mail incorreto!");
					txtInput.focus();
					return false;
				} else {
					sub = sub.substring(sub.indexOf('.')+1, sub.length);
				}
			}
			return true;
			
		} else {
			alert("Formato de e-mail incorreto!");
			txtInput.focus();
			return false;
		}
	}
}
