// JavaScript Document
function chkform() {
	var frmNome = document.getElementById("Nome").value;
	var frmProfissao = document.getElementById("Profissao").value;
	var frmEndereco = document.getElementById("Endereco").value;
	var frmBairro = document.getElementById("Bairro").value;
	var frmCidade = document.getElementById("Cidade").value;
	var frmEmail = document.getElementById("email").value;
	var frmFone = document.getElementById("Fone").value;
	var frmCEP = document.getElementById("CEP").value;
	var frmCel = document.getElementById("Cel").value;
		if (frmNome == "") {
		alert("Favor preencher o campo Nome");
		nomefocus();
		return false;
	}
	
	if (frmProfissao == "") {
		alert("Favor preencher o campo Profissão");
		profissaofocus();
		return false;
	}
	
		if (frmEndereco == "") {
		alert("Favor preencher o campo Endereço");
		enderecofocus();
		return false;
	}
	
		if (frmBairro == "") {
		alert("Favor preencher o campo Bairro");
		bairrofocus();
		return false;
	}
	
		if (frmCidade == "") {
		alert("Favor preencher o campo Cidade");
		cidadefocus();
		return false;
	}
	
		if (frmEmail == "") {
		alert("Favor preencher o campo E-Mail");
		emailfocus();
		return false;
	}

		var F = frmEmail;
		if (F.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
    	alert("Endereço E-mail errado. \nFavor verifique.");
		emailfocus();
    	return false;
  }
	
		if (!frmCEP == "") {
			if (isNaN(frmCEP) || frmCEP.length < 8 || frmCEP.length > 8) {
			alert("CEP errado! Favor verificar");
			cepfocus();
			return false;
	}
		}
		
		if (! frmFone == "") {
			if (isNaN(frmFone)) {
			alert("Telefone errado! Favor verificar");
			fonefocus();
			return false;
		}
			}
		
		if (! frmCel == "") {
			if (isNaN(frmCel)) {
			alert("Celular errado! Favor verificar");
			celfocus();
			return false;
		}
			}
		document.contato.submit();
	return true;				
}

function nomefocus() {
		document.getElementById("Nome").focus();
}

function profissaofocus() {
		document.getElementById("Profissao").focus();
}

function enderecofocus() {
		document.getElementById("Endereco").focus();
}

function bairrofocus() {
		document.getElementById("Bairro").focus();
		
}

function cidadefocus() {
		document.getElementById("Cidade").focus();
}

function emailfocus() {
		document.getElementById("email").focus();
		document.getElementById("email").select();
}

function cepfocus() {
	document.getElementById("CEP").focus();
	document.getElementById("CEP").select();
}

function fonefocus() {
	document.getElementById("Fone").focus();
	document.getElementById("Fone").select();
}

function celfocus() {
	document.getElementById("Cel").focus();
	document.getElementById("Cel").select();
}

function chknews() {
	var frmNome = document.getElementById("Nome").value;
	var frmProfissao = document.getElementById("Profissao").value;
	var frmEmail = document.getElementById("email").value;
	var frmcheck_news = document.getElementById("check_news").checked;
	var frmCidade = document.getElementById("Cidade").value;
	
	if (frmcheck_news == false) {
		alert("Favor marque a caixa de opçao");
		return false;
	}
	
	if (frmNome == "") {
		alert("Favor preencher o campo Nome");
		nomefocus();
		return false;
	}
	
	if (frmProfissao == "") {
		alert("Favor preencher o campo Profissão");
		profissaofocus();
		return false;
	}
	
	if (frmEmail == "") {
		alert("Favor preencher o campo E-Mail");
		emailfocus();
		return false;
	}

		var F = frmEmail;
		if (F.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) {
    	alert("Endereço E-mail errado. \nFavor verifique.");
		emailfocus();
    	return false;
  }
  		if (frmCidade == "") {
			alert("Favor preencher o campo Cidadde");
			cidadefocus();
			return false;
		}
	document.news.submit();
	return true;
}

