function btnClick(source) {
	while(source !=null && source.tagName !='FORM')
	{ source = source.parentNode; }

	var formulario = source.id;

	switch (formulario) {
			/*CadatrarNewsletter*/
			case 'frmNewsCad' :
				var acao		= 'CadastrarNewsletter';
				var nome		= $("#txtNomeCad").val();
				var email		= $("#txtEmailCad").val();
				
				$.post('acoes.php', {acao: acao, nome: nome, email: email},function(resposta){

				$("#statusNews").html("<img src='../imagens/loader.gif' alt='Enviando' />");
					
					if (resposta != false) {
						$("#statusNews").html(resposta);
					} else {
						$("#statusNews").html("Obrigado!");
						$("#frmNewsCad")[0].reset();
						$('#btnCadNews').attr("hidden",true);
					}
				});
				break;
			/*IndicarImovel*/
			case 'frmIndicaImovel' :
				var acao		 	= 'IndicarImovel';
				var nome		 	= $("#txtNome").val();
				var nomeInd	 		= $("#txtNomeInd").val();
				var emailInd	 	= $("#txtEmailInd").val();
				var idImovel		= $("#txtIdImovel").val();

				$("#statusIndicaImovel").html("<img src='../imagens/loader.gif' alt='Enviando' />");

				$.post('acoes.php', {acao: acao, nome: nome, nomeInd: nomeInd, emailInd: emailInd, idImovel: idImovel}, function(resposta){
					
					if (resposta != false) {
						$("#statusIndicaImovel").html(resposta);
					} else {
						$("#statusIndicaImovel").html("Obrigado!");
						$("#frmIndicaImovel")[0].reset();
						$('#btnIndicaImovel').attr("hidden", true);
					}
				});
				break;
			/*IndicarSite*/
			case 'frmIndiqueSite' :
				var acao			= 'IndicarSite';
				var nome			= $("#txtNome").val();
				var nomeInd			= $("#txtNomeInd").val();
				var emailInd		= $("#txtEmailInd").val();

				$.post('acoes.php', {acao: acao, nome: nome, nomeInd: nomeInd, emailInd: emailInd}, function(resposta){

				$("#statusIndicaSite").html("<img src='../imagens/loader.gif' alt='Enviando' />");					

				if (resposta != false) {
						$("#statusIndicaSite").html(resposta);
				} else {
						$("#statusIndicaSite").html("Obrigado!");
						$("#frmIndiqueSite")[0].reset();
						$('#btnIndicaSite').attr("hidden",true);
					}
				});
				break;				
			/*InteresseImovel*/
			case 'frmInteresseImovel' :
				var acao			= 'InteresseImovel';
				var nome			= $("#txtNomeInt").val();
				var telRes			= $("#txtTelRes").val();
				var telCom			= $("#txtTelCom").val();
				var telCel			= $("#txtTelCel").val();
				var email			= $("#txtEmailInt").val();
				var idImovel		= $("#txtIdImovel").val();

				$.post('acoes.php', {acao: acao, nome: nome, telRes: telRes, telCom: telCom, telCel: telCel, email: email, idImovel: idImovel}, function(resposta){

				$("#statusInteresseImovel").html("<img src='../imagens/loader.gif' alt='Enviando' />");
					
					if (resposta != false) {
						$("#statusInteresseImovel").html(resposta);
					} else {
						$("#statusInteresseImovel").html("Obrigado!");
						$("#frmInteresseImovel")[0].reset();
						$('#btnInteresseImovel').attr("hidden",true);
					}
				});
				break;						
			/*Contato*/
			case 'frmContato':
				var acao					= 'Contato';
  			    var departamento	= $("#cboDestContato").val();
				var nome 				= $("#txtNomeContato").val();
				var cidade 				= $("#txtCidadeContato").val();
				var estado 				= $("#cboEstadoContato").val();
				var email					= $("#txtEmailContato").val();
				var telefone 			= $("#txtTelContato").val();
				var assunto				= $("#txtAssuntoContato").val();
				var mensagem 		= $("#txtCorpoContato").val();

				$.post('acoes.php',{acao: acao, departamento: departamento, nome: nome, cidade: cidade, estado: estado, email: email, telefone: telefone, assunto: assunto, mensagem: mensagem}, function(resposta){

				$("#statusContato").html("<img src='../imagens/loader.gif' alt='Enviando' />");
									
					if (resposta != false) {
							$("#statusContato").html(resposta);
						} else {
							$("#statusContato").html("Obrigado!");
							$("#frmContato")[0].reset();
							$('#btnContato').attr("hidden", true);
						}
				});
				break;
			/*Suporte*/
			case 'frmSuporte':
				var acao					= 'Suporte';
  			    var departamento	= $("#cboDestContato").val();
				var nome 				= $("#txtNomeContato").val();
				var cidade 				= $("#txtCidadeContato").val();
				var estado 				= $("#cboEstadoContato").val();
				var email					= $("#txtEmailContato").val();
				var telefone 			= $("#txtTelContato").val();
				var assunto				= $("#txtAssuntoContato").val();
				var mensagem 		= $("#txtCorpoContato").val();

				$.post('acoes.php',{acao: acao, departamento: departamento, nome: nome, cidade: cidade, estado: estado, email: email, telefone: telefone, assunto: assunto, mensagem: mensagem}, function(resposta){

				$("#statusSuporte").html("<img src='../imagens/loader.gif' alt='Enviando' />");
									
						if (resposta != false) {
							$("#statusSuporte").html(resposta);
						} else {
							$("#statusSuporte").html("Obrigado!");
							$("#frmSuporte").reset();
							$('#btnSuporte').attr("hidden",true);
						}
				});
				break;				
			/*AnunciarImovel*/
			case 'frmAnunciarImovel':
				var acao				= 'AnunciarImovel';
				var nome 				= $("#txtNomeAI").val();
				var cidade 				= $("#txtCidadeAI").val();
				var estado 				= $("#cboEstadoAI").val();
				var email				= $("#txtEmailAI").val();
				var telefone 			= $("#txtTelefoneAI").val();
				var assunto				= $("#txtAssuntoAI").val();
				var mensagem 			= $("#txtCorpoAI").val();

				$.post('acoes.php',{acao: acao,  nome: nome, cidade: cidade, estado: estado, email: email, telefone: telefone, assunto: assunto, mensagem: mensagem}, function(resposta){

				$("#statusAnunciarImovel").html("<img src='../imagens/loader.gif' alt='Enviando' />");
									
						if (resposta != false) {
							$("#statusAnunciarImovel").html(resposta);
						} else {
							$("#statusAnunciarImovel").html("Obrigado!");
							$("#frmAnunciarImovel")[0].reset();
							$('#btnAnunciarImovel').attr("hidden",true);
						}
				});
				break;
			/*Fazer Proposta*/
			case 'frmFazerProposta':
				var acao				= 'fazerProposta';
				var idImovel			= $("#txtIdImovel").val();
				var nome 				= $("#txtNomeProposta").val();
				var cidade 				= $("#txtCidadeProposta").val();
				var estado 				= $("#cboEstadoProposta").val();
				var email				= $("#txtEmailProposta").val();
				var telefone 			= $("#txtTelefoneProposta").val();
				var assunto				= $("#txtAssuntoProposta").val();
				var mensagem 			= $("#txtCorpoProposta").val();

				$.post('acoes.php',{acao: acao,  nome: nome, cidade: cidade, estado: estado, email: email, telefone: telefone, assunto: assunto, mensagem: mensagem}, function(resposta){

				$("#statusFazerProposta").html("<img src='../imagens/loader.gif' alt='Enviando' />");					
				
						if (resposta != false) {
							$("#statusFazerProposta").html(resposta);
						} else {
							$("#statusFazerProposta").html("Obrigado!");
							$("#frmFazerProposta")[0].reset();
							$('#btnFazerProposta').attr("hidden",true);
						}
				});
				break;
			};
		};
		
		/* Processa Busca Dinamica */
		$(document).ready(function(){
			$("select[name=alugar]").change(function(){
				$("select[name=cidade]").html('<option value="0" selected="selected">Carregando...</option>');
					$.post("http://www.federalimoveis.com.br/processa-busca.php",{acao:1,alugar:$(this).val()},
						function(valor){
						$("select[name=cidade]").html(valor);
						$("select[name=cidade]").removeAttr("disabled");
					})
				})
		$("select[name=cidade]").change(function(){
			$("select[name=bairro]").html('<option value="0" selected="selected">Carregando...</option>');
				$.post("http://www.federalimoveis.com.br/processa-busca.php",{acao:2,cidade:$(this).val()},
					function(valor){
						$("select[name=bairro]").html(valor);
						$("select[name=bairro]").removeAttr("disabled");
					})
				})
		$("select[name=bairro]").change(function(){
			$("select[name=tipoImovel]").html('<option value="0" selected="selected">Carregando...</option>');
				$.post("http://www.federalimoveis.com.br/processa-busca.php",{acao:3,bairro:$(this).val()},
					function(valor){
					$("select[name=tipoImovel]").html(valor);
					$("select[name=tipoImovel]").removeAttr("disabled");
					})
				})
		$("select[name=tipoImovel]").change(function(){
			$("select[name=quartos]").html('<option value="0" selected="selected">Carregando...</option>');
				$.post("http://www.federalimoveis.com.br/processa-busca.php", {acao:4,tipoImovel:$(this).val()},
					function(valor){
					$("select[name=quartos]").html(valor);
					$("select[name=quartos]").removeAttr("disabled");
					})
				})
		$("select[name=quartos]").change(function(){
			$("select[name=faixaValor]").html('<option value="0" selected="selected">Carregando...</option>');
				$.post("http://www.federalimoveis.com.br/processa-busca.php", {acao:5,quartos:$(this).val()},
					function(valor){
					$("select[name=faixaValor]").html(valor);
					$("select[name=faixaValor]").removeAttr("disabled");
					})
				})
		})

		/*funcao de redirecionamento */
		$("#SiteExterno").click(function( e ){
			if( confirm('Mensagem') )
				window.location = '';
			else {
				alert('Okay, nada feito!');
				e.preventDefault();
			}
		});

		/*Efeito MouseOver na tr*/
		$(function(){
			$('#myTable tr')
				.mouseover(function(){
				$(this).addClass('tr-over');
			})
				.mouseout(function(){
				$(this).removeClass('tr-over');
			});
		});
		
