// Funções do formulário de Contato
function IsSpace(field) {
	ic_spaces = false;
	for (pos = 0;pos < field.length;pos ++)
		if (field.charAt(pos) != " ")
			ic_spaces = true;

	if (!ic_spaces)
		return true;

	return false;
}


function validaEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {						// verifica se está preenchido
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// verifica se contém caracteres válidos
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// verifica se contém "@"
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// apenas um "@"
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// verifica se contém "." após "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// verifica se contém pelo menos 2 caracteres após "."
		return false
	}
	return true
}

function ConsistefrmEventos() {
	if (IsSpace(document.frmEventos.nome.value)) {
		alert("Por favor, informe seu nome.");
		document.frmEventos.nome.focus();
		return false;
	}

	if (!validaEmail(document.frmEventos.submit_by.value)) {
		alert("Você precisa digitar um e-mail válido.")
		document.frmEventos.submit_by.focus();
		return false
	}
	

	if (IsSpace(document.frmEventos.telefone.value)) {
		alert("Por favor, informe seu telefone.");
		document.frmEventos.telefone.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.endereco.value)) {
		alert("Por favor, informe seu endereço.");
		document.frmEventos.endereco.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.numero.value)) {
		alert("Por favor, informe o número da sua residência.");
		document.frmEventos.numero.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.cidade.value)) {
		alert("Por favor, informe sua cidade.");
		document.frmEventos.cidade.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.estado.value)) {
		alert("Por favor, informe seu estado.");
		document.frmEventos.estado.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.CEP.value)) {
		alert("Por favor, informe seu CEP.");
		document.frmEventos.CEP.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.profissao.value)) {
		alert("Por favor, informe sua profissão.");
		document.frmEventos.profissao.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.ocupacao.value)) {
		alert("Por favor, informe sua ocupação atual.");
		document.frmEventos.ocupacao.focus();
		return false;
	}
	
	if (IsSpace(document.frmEventos.ultimo_grau.value)) {
		alert("Por favor, informe seu último grau obtido.");
		document.frmEventos.ultimo_grau.focus();
		return false;
	}
	

	
	return true;
}
