function fValidaFormContato(){
	if (document.frmContato.TxNome.value == ""){
		alert("Você deve preencher o campo Nome");
		document.frmContato.TxNome.focus();
		return false;
	}
	if (document.frmContato.InCodEstado.value == ""){
		alert("Você deve selecionar um Estado");
		document.frmContato.InCodEstado.focus();
		return false;
	}
	if (document.frmContato.InCodCidade.value == ""){
		alert("Você deve selecionar uma Cidade");
		document.frmContato.InCodCidade.focus();
		return false;
	}
	if (document.frmContato.TxLoja.value == ""){
		alert("Você deve preencher o campo Loja");
		document.frmContato.TxLoja.focus();
		return false;
	}
	if (document.frmContato.TxOriente.value == ""){
		alert("Você deve preencher o campo Oriente");
		document.frmContato.TxOriente.focus();
		return false;
	}
	if (document.frmContato.TxPotencia.value == ""){
		alert("Você deve preencher o campo Potência");
		document.frmContato.TxPotencia.focus();
		return false;
	}
	if (document.frmContato.TxGrau.value == ""){
		alert("Você deve preencher o campo Grau");
		document.frmContato.TxGrau.focus();
		return false;
	}
	if (document.frmContato.TxMensagem.value == ""){
		alert("Você deve preencher o campo Mensagem");
		document.frmContato.TxMensagem.focus();
		return false;
	}
	return true;
}

function fCarregarCidade(IDEstado,IDCidade,Label,Obrigatorio){
	clientSideInclude("tdCidade", "contato.asp?acao=CARREGAR_CIDADE&estado="+IDEstado+"&cidade="+IDCidade+"&label="+Label+"&obrig="+Obrigatorio);
}

function fCarregarCidade2(IDEstado,IDCidade, alvo){
	var cont = document.getElementById("hddContarLinhasEnderecos").value;
	clientSideInclude(alvo, "montar_endereco.asp?acao=CARREGAR_CIDADE&estado="+IDEstado+"&cidade="+IDCidade+"&cont="+cont);
}

function fAbrirGaleria(tipo){
	clientSideInclude("tdConteudo", "galeria.asp?tipo="+tipo);
}

function fAbrirFoto(tipo, IdFoto){
	clientSideInclude("tdVerFoto", "ver_foto.asp?tipo="+tipo+"&idfoto="+IdFoto);
}

function fAbrirLink(Link, Alvo){
	if (Alvo!="" && Alvo!=undefined){
		window.open(Link);
	}else{
		clientSideInclude("tdConteudo", Link);
	}
	sobe_();
}

function fAbrirMenu(Link){
	document.location.href = Link;
	sobe_();
}

function sobe_(){
	if (document.body.scrollTop > 0){
		document.body.scrollTop = 0;
	}
}

function fTrocarMes(Nome,Mes,Ano){
	clientSideInclude("div"+Nome, "montar_calendario.asp?nome="+Nome+"&mes="+Mes+"&ano="+Ano);
}

function fBoasVindas(){
	clientSideInclude("trHideBoasVindas", "boas_vindas.asp");
	document.all.trBoasVindas.innerHTML = document.all.trHideBoasVindas.innerHTML;
	if (document.all.trBoasVindas.innerHTML != ""){
		document.all.trBoasVindas.style.display = "";
	}else{
		document.all.trBoasVindas.style.display = "none";
	}
}

function validaLogin(){
	if ( !TestaUser() ) {
		return false;
	}
	if ( !TestaSenha() ) {
		return false;
	}
	return true;
}

function dropBlanks( oStrToBeDropped ){
	var oRet = "";
	var c_next = 0;
	var c_prev = 0;
	for( i = 0; i < oStrToBeDropped.length; i++ ){
		c_next = oStrToBeDropped.charAt( i );
		if( c_next == ' ' ){
		}else{
			oRet = oRet + c_next;
		}
		c_prev = c_next;
	}
	return oRet;
}

function TestaUser() {
	var user = dropBlanks(document.frmLogin.txtUsuario.value.toLowerCase());
	var user_ = document.frmLogin.txtUsuario;
	if(user.length < 4) {
		alert(" USUÁRIO inválido.  Mínimo 4 caracteres.");
		user_.select();
		user_.focus();
		return false;
	}
	if(user.length > 10) {
		alert(" USUÁRIO inválido.  Máximo 10 caracteres.");
		user_.select();
		user_.focus();
		return false;
	}
	var usval = /[^a-z0-9_.]/.exec(user);
	if(usval != null) {
		alert("USUÁRIO inválido. Possui caracteres inválidos.");
		user_.select();
		user_.focus();
		return false;
	}
	return true;
}

function TestaSenha() {
	var senha = dropBlanks(document.frmLogin.txtSenha.value.toLowerCase());
	var senha_ = document.frmLogin.txtSenha;
	if(senha.length < 4) {
		alert(" SENHA inválida.  Mínimo 4 caracteres.");
		senha_.select();
		senha_.focus();
		return false;
	}
	if(senha.length > 8) {
		alert(" SENHA inválida.  Máximo 8 caracteres.");
		senha_.select();
		senha_.focus();
		return false;
	}
	var usval = /[^a-z0-9_.]/.exec(senha);
	if(usval != null) {
		alert("SENHA inválida. Possui caracteres inválidos.");
		senha_.select();
		senha_.focus();
		return false;
	}
	return true;
}

function fFiltrarAniversariantes(){
	var mes = document.getElementById("cmbFiltroMes").value;
	var componente = document.getElementById("chkComponente").checked ? "1" : "0";
	var esposa = document.getElementById("chkEsposa").checked ? "1" : "0";
	var filho = document.getElementById("chkFilhos").checked ? "1" : "0";
	var endereco = document.getElementById("chkEnderecos").checked ? "1" : "0";
	var Link = "aniversariantes.asp?cmbFiltroMes="+mes+"&chkComponente="+componente+"&chkEsposa="+esposa+"&chkFilhos="+filho+"&chkEnderecos="+endereco;
	
	fAbrirLink(Link);
}
