faleConosco = {
	nome : '',
	email : '',
	estado : '',
	cidade : '',
	sexo : '',
	cargo : '',
	telefone : '',
	nascimento : '',
	hobbies : '',
	assunto : '',
	mensagem : '',
	
	enviar : function(){
		this.limpaValidacao();
		msg = this.valida();
		if (msg == ''){
			classFaleConosco.inserir(this.nome, this.email, this.estado, this.cidade, this.sexo, this.cargo, this.telefone, this.nascimento,'',this.assunto, this.mensagem).value;
			document.divForm.reset();
			document.getElementById('msgErro').style.visibility = 'hidden';
			document.getElementById('divForm').style.display = 'none';
			document.getElementById('divTxtHeader').style.display = 'none';
			document.getElementById('msgSucesso').style.display = '';
		}else{
			document.getElementById('msgSucesso').style.display = 'none';
			document.getElementById('msgErro').style.visibility = 'visible';
		}
	},
	
	
	contatoSalaImprensa : function(){
		if (FuncoesGerais.BuscaParametro('contato')=='salaimprensa'){
			document.getElementById('cmbAssunto').selectedIndex = 6;
			this.subAssuntoCombo('Outros');
			document.getElementById('cmbSubAssunto').selectedIndex = 5;
		}
	},
	
	valida : function(){
		this.nome = document.getElementById('txtNome').value;
		this.email = document.getElementById('txtEmail').value;
		this.estado = document.getElementById('cmbEstado').value;
		this.cidade = document.getElementById('cmbCidade').value;
		if (document.getElementById('radioSexoM').checked){
			this.sexo = 'Masculino';
		}else if (document.getElementById('radioSexoF').checked){
			this.sexo = 'Feminino';
		}
//		this.cargo = document.getElementById('txtCargo').value;
		this.telefone = document.getElementById('txtTelDDD').value + '-' + document.getElementById('txtTel').value;
		this.nascimento = document.getElementById('txtAnoNascimento').value + '-' + document.getElementById('txtMesNascimento').value + '-' + document.getElementById('txtDiaNascimento').value;
//		this.hobbies = document.getElementById('txtHobbies').value;
//		this.assunto = document.getElementById('txtAssunto').value;
		this.cmbAssunto = document.getElementById('cmbAssunto').value;
		this.subAssunto = document.getElementById('cmbSubAssunto').value;
		this.mensagem = document.getElementById('txtMensagem').value;
		
		msg = '';
		if (this.nome == ''){
			document.getElementById('txtNome').style.backgroundColor="#ecb2b1"
			msg = 'Nome';
		}
		if (FuncoesGerais.ValidaEmail(this.email) == 0){
			document.getElementById('txtEmail').style.backgroundColor="#ecb2b1"
			msg = 'E-mail';
		}
		if (this.estado == ''){
			document.getElementById('cmbEstado').style.backgroundColor="#ecb2b1"
			msg = 'Estado';
		}
		if (this.cidade == ''){
			document.getElementById('cmbCidade').style.backgroundColor="#ecb2b1"
			msg = 'Cidade';
		}
		if (this.sexo == ''){
			document.getElementById('txtMasculino').style.backgroundColor="#ecb2b1"
			document.getElementById('txtFeminino').style.backgroundColor="#ecb2b1"
			msg = 'Sexo';
		}
		if (this.telefone == '-'){
			document.getElementById('txtTelDDD').style.backgroundColor="#ecb2b1"
			document.getElementById('txtTel').style.backgroundColor="#ecb2b1"
			msg = 'Telefone';
		}
		if (FuncoesGerais.ValidaDataSeparada(document.getElementById('txtDiaNascimento').value, document.getElementById('txtMesNascimento').value, document.getElementById('txtAnoNascimento').value) == 0){
			document.getElementById('txtDiaNascimento').style.backgroundColor="#ecb2b1"
			document.getElementById('txtMesNascimento').style.backgroundColor="#ecb2b1"
			document.getElementById('txtAnoNascimento').style.backgroundColor="#ecb2b1"
			msg = 'Nascimento';
		}

		if (this.cmbAssunto == ''){
			document.getElementById('cmbAssunto').style.backgroundColor="#ecb2b1"
			msg = 'Assunto';
		}
		
		if (this.subAssunto == ''){
			document.getElementById('cmbSubAssunto').style.backgroundColor="#ecb2b1"
			msg = 'Assunto';
		}
		
		this.assunto = this.cmbAssunto + ' - ' + this.subAssunto; 
		
		if (this.mensagem == ''){
			document.getElementById('txtMensagem').style.backgroundColor="#ecb2b1"
			msg = 'Mensagem';
		}
		
		return msg;
	},
	
	limpaValidacao : function(){
		document.getElementById('txtNome').style.backgroundColor="#ffffff";
		document.getElementById('txtEmail').style.backgroundColor="#ffffff";
		document.getElementById('cmbEstado').style.backgroundColor="#ffffff";
		document.getElementById('cmbCidade').style.backgroundColor="#ffffff";
		document.getElementById('txtMasculino').style.backgroundColor="#ffffff";
		document.getElementById('txtFeminino').style.backgroundColor="#ffffff";
		document.getElementById('txtTelDDD').style.backgroundColor="#ffffff";
		document.getElementById('txtTel').style.backgroundColor="#ffffff";
		document.getElementById('txtDiaNascimento').style.backgroundColor="#ffffff";
		document.getElementById('txtMesNascimento').style.backgroundColor="#ffffff";
		document.getElementById('txtAnoNascimento').style.backgroundColor="#ffffff";
		document.getElementById('cmbAssunto').style.backgroundColor="#ffffff";
		document.getElementById('cmbSubAssunto').style.backgroundColor="#ffffff";
		document.getElementById('txtMensagem').style.backgroundColor="#ffffff";
	},
	
	carregaCidade : function(estado){
		document.getElementById('cmbCidade').disabled = ''
		response = classCidades.seleciona(estado, '', 1);
		
		if(response.error == null){
			var retorno = response.value;
			var ds = retorno;
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
				//define a quantidade de itens do dropdown(1 a mais da quantidade de itens do dataset)
				document.getElementById('cmbCidade').length =ds.Tables[0].Rows.length+1;
				
				//adiciona um item no dropdown
				document.getElementById('cmbCidade').options[0].text= '*Cidade';
				document.getElementById('cmbCidade').options[0].value= '';
				
				//adiciona os itens do dataset no dropdown
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.getElementById('cmbCidade').options[i+1].text= row.cidade;
					document.getElementById('cmbCidade').options[i+1].value= row.cidade;
				}
			} 
		}else{
			document.getElementById('cmbCidade').length = 1;
		}
	},
	
	subAssuntoCombo : function(assunto){
		document.getElementById('cmbSubAssunto').style.visibility = 'visible';
		
		if ((assunto != '') && (assunto != 'Trabalhe Conosco')){
			document.getElementById('cmbSubAssunto').disabled = '';
			document.getElementById('cmbSubAssunto').style.display = '';
			
			if ((assunto == 'Acompanhamento de produto na autorizada') || (assunto == 'Indicação de rede autorizada')){
				document.getElementById('cmbSubAssunto').length = 5;

				document.getElementById('cmbSubAssunto').options[1].text= 'Áudio';
				document.getElementById('cmbSubAssunto').options[1].value= 'Áudio';
				document.getElementById('cmbSubAssunto').options[2].text= 'TV LCD';
				document.getElementById('cmbSubAssunto').options[2].value= 'TV LCD';
				document.getElementById('cmbSubAssunto').options[3].text= 'TV CRT';
				document.getElementById('cmbSubAssunto').options[3].value= 'TV CRT';
				document.getElementById('cmbSubAssunto').options[4].text= 'Multifuncionais';
				document.getElementById('cmbSubAssunto').options[4].value= 'Multifuncionais';
			
			}else if (assunto == 'Dúvida técnica'){
				document.getElementById('cmbSubAssunto').length = 6;

				document.getElementById('cmbSubAssunto').options[1].text= 'Áudio';
				document.getElementById('cmbSubAssunto').options[1].value= 'Áudio';
				document.getElementById('cmbSubAssunto').options[2].text= 'TV LCD';
				document.getElementById('cmbSubAssunto').options[2].value= 'TV LCD';
				document.getElementById('cmbSubAssunto').options[3].text= 'TV CRT';
				document.getElementById('cmbSubAssunto').options[3].value= 'TV CRT';
				document.getElementById('cmbSubAssunto').options[4].text= 'Calculadoras';
				document.getElementById('cmbSubAssunto').options[4].value= 'Calculadoras';
				document.getElementById('cmbSubAssunto').options[5].text= 'Multifuncionais';
				document.getElementById('cmbSubAssunto').options[5].value= 'Multifuncionais';
			}else if (assunto == 'Relação de distribuidores multifuncionais'){
				document.getElementById('cmbSubAssunto').length = 3;

				document.getElementById('cmbSubAssunto').options[1].text= 'Aquisição';
				document.getElementById('cmbSubAssunto').options[1].value= 'Aquisição';
				document.getElementById('cmbSubAssunto').options[2].text= 'Reclamação de dealer';
				document.getElementById('cmbSubAssunto').options[2].value= 'Reclamação de dealer';
			}else if (assunto == 'Sobre a empresa'){
				document.getElementById('cmbSubAssunto').length = 2;

				document.getElementById('cmbSubAssunto').options[1].text= 'Imprensa';
				document.getElementById('cmbSubAssunto').options[1].value= 'Imprensa';
			}else if (assunto == 'Outros'){
				document.getElementById('cmbSubAssunto').length = 6;

				document.getElementById('cmbSubAssunto').options[1].text= 'Marketing';
				document.getElementById('cmbSubAssunto').options[1].value= 'Marketing';
				document.getElementById('cmbSubAssunto').options[2].text= 'Vendas';
				document.getElementById('cmbSubAssunto').options[2].value= 'Vendas';
				document.getElementById('cmbSubAssunto').options[3].text= 'Revenda';
				document.getElementById('cmbSubAssunto').options[3].value= 'Revenda';
				document.getElementById('cmbSubAssunto').options[4].text= 'Jurídico';
				document.getElementById('cmbSubAssunto').options[4].value= 'Jurídico';
				document.getElementById('cmbSubAssunto').options[5].text= 'Imprensa';
				document.getElementById('cmbSubAssunto').options[5].value= 'Imprensa';
			}
		}else if (assunto == 'Trabalhe Conosco'){
			document.getElementById('cmbSubAssunto').style.visibility = 'hidden';
		}else{
			document.getElementById('cmbSubAssunto').length = 1;
			document.getElementById('cmbSubAssunto').value = '';
		}
	}
	

}