faleconosco = {
	nome : '',
	email : '',
	estado : '',
	cidade : '',
	telefone : '',
	celular : '',
	comercial : '',
	ramal : '',
	assunto : '',
	mensagem : '',
	receberNews : 0,
		
	enviar : function(){
		this.limpaValidacao();
		msg = this.valida();
		if (msg == ''){
			_faleconosco.enviaFaleConosco(this.nome, this.email, this.estado, this.cidade, this.telefone, this.celular, this.comercial, this.ramal, this.assunto, this.mensagem, this.receberNews).value;
			document.divForm.reset();
			document.getElementById('msgErro').style.visibility = 'hidden';
			//document.getElementById('divForm').style.display = 'none';
			document.getElementById('msgSucesso').style.display = '';
		}else{
			document.getElementById('msgSucesso').style.display = 'none';
			document.getElementById('msgErro').style.visibility = 'visible';
		}
	},
	
	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;
		this.telefone1 = document.getElementById('txtTel1DDD').value + '-' + document.getElementById('txtTel1').value;
		this.telefone2 = document.getElementById('txtTel2DDD').value + '-' + document.getElementById('txtTel2').value;
		this.telefoneComercial = document.getElementById('txtTelComercialDDD').value + '-' + document.getElementById('txtTelComercial').value;
		this.ramal = document.getElementById('txtRamal').value;
		if (document.getElementById('radioAssunto1').checked){
			this.assunto = document.getElementById('radioAssunto1').value;
		}else if (document.getElementById('radioAssunto2').checked){
			this.assunto = document.getElementById('radioAssunto2').value;
		}else if (document.getElementById('radioAssunto3').checked){
			this.assunto = document.getElementById('radioAssunto3').value;
		}else if (document.getElementById('radioAssunto4').checked){
			this.assunto = document.getElementById('radioAssunto4').value;
		}else if (document.getElementById('radioAssunto5').checked){
			this.assunto = document.getElementById('radioAssunto5').value;
		}
		this.mensagem = document.getElementById('txtMensagem').value;
		this.receberNews = FuncoesGerais.RetornaValorCheckUnico(document.getElementById('chkReceberNews'));
				
		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.telefone == '-'){
			document.getElementById('txtTel1DDD').style.backgroundColor="#ecb2b1"
			document.getElementById('txtTel1').style.backgroundColor="#ecb2b1"
			msg = 'Telefone1';
		}
		if (this.celular == '-'){
			document.getElementById('txtTel2DDD').style.backgroundColor="#ecb2b1"
			document.getElementById('txtTel2').style.backgroundColor="#ecb2b1"
			msg = 'Telefone2';
		}
		if (this.comercial == '-'){
			document.getElementById('txtTelComercialDDD').style.backgroundColor="#ecb2b1"
			document.getElementById('txtTelComercial').style.backgroundColor="#ecb2b1"
			msg = 'Telefone Comercial';
		}
		if (this.ramal == ''){
			document.getElementById('txtRamal').style.backgroundColor="#ecb2b1"
			msg = 'Ramal';
		}*/
		if (this.assunto == ''){
			document.getElementById('txtAssunto').style.backgroundColor="#ecb2b1"
			msg = 'Carro';
		}
		if (this.mensagem == ''){
			document.getElementById('txtMensagem').style.backgroundColor="#ecb2b1"
			msg = 'Carro';
		}
		
		return msg;
	},
	
	limpaCampo : function(campo){
		campo.value = '';
	},
	
	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('txtTel1DDD').style.backgroundColor="#ffffff";
		document.getElementById('txtTel1').style.backgroundColor="#ffffff";
		document.getElementById('txtTel2DDD').style.backgroundColor="#ffffff";
		document.getElementById('txtTel2').style.backgroundColor="#ffffff";
		document.getElementById('txtTelComercialDDD').style.backgroundColor="#ffffff";
		document.getElementById('txtTelComercial').style.backgroundColor="#ffffff";
		document.getElementById('txtRamal').style.backgroundColor="#ffffff";
		document.getElementById('txtAssunto').style.backgroundColor="";
		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;
		}
	}
}