// ------------------------------------------------------------------------------------------
// Validar envio do Fale Conosco
// ------------------------------------------------------------------------------------------
function validaFale()
{
	try {
		var erro = new Array(0);
		
		var f = document.frmFale;
		
		if ( isEmpty(f.nome) )			erro.push('Nome');
		if ( !isEmail(f.email) )		erro.push('E-mail');	
		if ( isEmpty(f.assunto) )		erro.push('Assunto');	
		if ( isEmpty(f.mensagem) )		erro.push('Mensagem');	
		
		if ( erro.length ) {
			alert('Preencha corretamente o(s) campo(s): \n'+ erro.join(', ') +'.');
			return false;
		}
		return true;
	
	} catch (e) {
		
		if ( showError )	alert(e.message);
		return true;
	}
}

// ------------------------------------------------------------------------------------------
// Validar envio do Fale Conosco
// ------------------------------------------------------------------------------------------

function validaCadastre()
{
	try {
		
		pf =document.getElementById("pessoaF");
		pj =document.getElementById("pessoaJ");
		
		var erro = new Array(0);
		
		var f = document.frmCadastre;
		
		if( f.tipo.value == 'J' )
		{
			if ( !isCnpj(f.cnpj) )				erro.push('CNPJ inválido');
			if ( isEmpty(f.representante2) )	erro.push('Razão Social');
			if ( isEmpty(f.nomeFantasia) )		erro.push('Nome Fantasia');
		}
		
		if( f.tipo.value == 'F' )
		{
			if ( !isCpf(f.cpf) )				erro.push('CPF inválido');
			if ( isEmpty(f.representante1) )	erro.push('Nome');
		}
		
		if ( isEmpty(f.senha) )			erro.push('Senha');
		if ( isEmpty(f.cidade) )		erro.push('Cidade');
		if ( isEmpty(f.uf) )			erro.push('UF');
		if ( !isEmail(f.email) )		erro.push('E-mail');	
		
		if ( erro.length ) {
			alert('Preencha corretamente o(s) campo(s): \n'+ erro.join(', ') +'.');
			return false;
		}
		return true;
	
	} catch (e) {
		
		if ( showError )	alert(e.message);
		return true;
	}
}

function abrirDiv( valor )
{
	var f = document.getElementById("divCPF");
	var fcpf = document.getElementById("cpf");
	var j = document.getElementById("divCNPJ");
	var fcnpj = document.getElementById("cnpj");
	var fant = document.getElementById("nomeFantasia");
	
	if( valor == "F" )
	{
		f.style.display = "";
		j.style.display = "none";
		fcnpj.value = '';
		fant.value = '';
		document.getElementById("representante2").value = '';
	
	} else {
		
		j.style.display = "";
		f.style.display = "none";
		fcpf.value = '';
		document.getElementById("representante1").value = '';
	}		
}
