/* * As variáveis abaixo devem sempre estar declaradas no javascript do site em desenvolvimento, pois são esperadas pelos serviços Spaic */ // Série usada nos imóveis gcSpaSrImv = "2090805213"; // Série usada para inquilinos e proprietários gcSpaSrInqPro = "2010123130"; // Nome do container principal da página (aquele que contém todo o conteúdo) gcSpaIDCtnBase = "wrapper"; // Nome do container onde os resultados das pesquisas serão exibidos gcSpaIDCtn = "column_w530"; gcIDCtn = "cnt_pesq"; function carregaPagina() { doDestaques("V"); doDestaques("L"); $('.sumo').SumoSelect(); } function carregaCombos() { if (document.getElementById("finalidade").value != ""){ //jQuery.ajaxSetup({async:false}); $("#bairro").prop("disabled",true); doCarregaTipos(); ativaOpcAv(); } } function exibeDetImv(cTipC, nCod) { spaImvExibeDetalhe(nCod, null, cTipC, gcSpaSrImv, true); } //////////////////////////////////// /* DESTAQUES */ //////////////////////////////////// function doDestaques(tipo) { var oJson; $.get("/spaicnet/json/imoveis/destaques.php?sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); if (tipo=="V") { cDtq = ''; dtqDiv = "#cnt_dtq"; } else if (tipo=="L") { cDtq = ''; dtqDiv = "#cnt_dtql"; } nIV = 0; for (nI = 0; nI < oJson.destaques.length; nI++) { if (oJson.destaques[nI].tipc != tipo) { continue; } nIV ++; if (nIV > 4) { break; } cDtq += '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
 ' + oJson.destaques[nI].bairro + '
 ' + oJson.destaques[nI].tipo + '
 Codigo: ' + oJson.destaques[nI].codigo + '
 
R$ ' + oJson.destaques[nI].preco + '
 
'; } $(dtqDiv).html(cDtq); }); } function doModalDetalhes(cTipC, nCod) { cURL = "/spaicnet/views/imoveis/detalhe.php?sr=" + gcSpaSrImv + "&tc=" + cTipC + "&id=" + nCod + "&depup=1&stl="; $("#myModal").load(cURL,function(){ $("#myModal").append('×'); //$("#myModal").reveal(); $("#myModal").reveal().bind('reveal:close', function () { hs.close(); hs.anchors = ""; }); }); } // BUSCA PERSONALIZADA function doBuscaTopo() { if (valida()) { oFinalidade = document.getElementById("finalidade"); oTipo = document.getElementById("tipo"); oValor = document.getElementById("valor"); oCidade = document.getElementById("cidade"); oEstado = document.getElementById("estado"); oBairro = document.getElementById("bairro"); oValorMin = document.getElementById("valor_min"); oValorMax = document.getElementById("valor_max"); oDorm = document.getElementById("dormitorio"); oVaga = document.getElementById("garagem"); oTipo = ($('#tipo').val()) ? $('#tipo').val().toString() : ""; oBairro = ($('#bairro').val()) ? $('#bairro').val().toString() : ""; if (typeof window.filtro_av == 'undefined') { window.filtro_av = ""; } cURL = "/spaicnet/views/imoveis/resultado.php?tpa=" + window.filtro_av + "&tc=" + oFinalidade.value + "&uf=" + oEstado.value + "&cid=" + oCidade.value + "&bai=" + oBairro + "&tim=" + oTipo + "&vli=" + oValorMin.value + "&vlf=" + oValorMax.value + "&val=" + oValor.value + "&dor=" + oDorm.value + "&vag=" + oVaga.value + "&pa=1&pg=1<=0&depup=1&sr=" + gcSpaSrImv; $.get(cURL, function(data){ oDiv = document.getElementById(gcSpaIDCtn); oDiv.innerHTML = data; $('html, body').animate({ scrollTop: $('#right').offset().top },500); }); } } function doBuscaCodigo() { var oCodImv = document.getElementById("codigo"); oCodImv.value = oCodImv.value.replace(/ /g,''); tipoImv = oCodImv.value.substring(0,3).toUpperCase(); if (tipoImv=="VEN" || tipoImv=="LOC"){ finImv=(tipoImv=="VEN")?"venda":(tipoImv=="LOC")?"aluga":""; document.getElementById(finImv).checked = true; oCodImv.value = oCodImv.value.substring(3,oCodImv.value.length); } cRet = ""; oTipV = spaImvPegaCampoPesq("venda"); if (oTipV.type.toUpperCase() == "RADIO") { oTipL = spaImvPegaCampoPesq("aluga"); if (oTipV.checked) { cRet = oTipV.value; } else { cRet = oTipL.value; } } else { cRet = oTipV.value; } $.get("/spaicnet/views/imoveis/detalhe.php?tc=" + cRet + "&id=" + oCodImv.value + "&sr=" + gcSpaSrImv, function (data) { if (data.indexOf("*NE*") != -1) { window.alert("Imóvel não encontrado."); } else if (oCodImv.value == "") { window.alert("Digite o código do imóvel!"); oCodImv.focus(); } else { //spaImvExibeDetalhe(cURL, oCodImv, cRet, gcSpaSrImv, true); //exibeDetImv(cRet, oCodImv.value) doModalDetalhes(cRet, oCodImv.value); } }); } // CARREGA OS TIPOS DE IMÓVEIS function doCarregaTipos() { var oJson; $.get("/spaicnet/json/imoveis/tipos.php?lt=1&sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); var html = ""; html += " " ; $("#tipos").html(html); doCarregaEstados(); }); } // CARREGA ESTADOS function doCarregaEstados() { oFinalidade = document.getElementById("finalidade"); // Função para carregar Valor de Venda e Locação if (oFinalidade.value == "V") { document.getElementById("valor_locacao").style.display='none'; document.getElementById("valor_venda").style.display='block'; } if (oFinalidade.value == "L") { document.getElementById("valor_venda").style.display='none'; document.getElementById("valor_locacao").style.display='block'; } var oJson; $.get("/spaicnet/json/imoveis/estados.php?tc=" + oFinalidade.value + "&sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); var html = ""; html += " " ; $("#estados").html(html); $("#estado").val("SP").trigger('change'); }); } // CARREGA CIDADES function doCarregaCidades() { oFinalidade = document.getElementById("finalidade"); var elem = document.getElementById("estado"); var UF = elem.options[elem.options.selectedIndex]; var oJson; $.get("/spaicnet/json/imoveis/cidades.php?tc=" + oFinalidade.value + "&uf=" + UF.value + "<=1&sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); var html = ""; html += " " ; $("#cidades").html(html); $("#cidade").val("9369").trigger('change'); //Mogi das Cruzes }); } // CARREGA BAIRROS function doCarregaBairros() { oFinalidade = document.getElementById("finalidade"); var elem = document.getElementById("cidade"); var CID = elem.options[elem.options.selectedIndex]; var oJson; $.get("/spaicnet/json/imoveis/bairros.php?tc=" + oFinalidade.value + "&cid=" + CID.value + "<=1&sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); var html = ""; html += " " ; $("#bairros").html(html); $("#bairro").prop("disabled",false); $('.sumo').SumoSelect(); $('#tipo')[0].sumo.selectItem(0); $('#bairro')[0].sumo.selectItem(0); $(".SlectBox").show(); //coloca tooltips $('ul.options label').each(function(i,v){ //if ($(this).text().length > 10) { $(this).attr('title',$(this).text()); //} }); window.tip_ind = true; window.bai_ind = true; $('#tipo').change(function() { sel = $(this).val(); if (this.value == 0 && !window.tip_ind) { $('#tipo')[0].sumo.unSelectAll(); $('#tipo')[0].sumo.selectItem(0); window.tip_ind = true; } else if (sel && sel.length > 1 && window.tip_ind) { $('#tipo')[0].sumo.unSelectItem(0); window.tip_ind = false; } }) $('#bairro').change(function() { sel = $(this).val(); if (this.value == 0 && !window.bai_ind) { $('#bairro')[0].sumo.unSelectAll(); $('#bairro')[0].sumo.selectItem(0); window.bai_ind = true; } else if (sel && sel.length > 1 && window.bai_ind) { $('#bairro')[0].sumo.unSelectItem(0); window.bai_ind = false; } }) }); } // VALIDA CAMPOS DOS FORMS function validaFormAuto(form){ for (i=0;i 0){ var nome = form[i].name.substring(1,form[i].name.length); var ident = form[i].id; // alert("O campo " + ident + " é necessário."); alert("O campo " + ident + " \u00e9 necess\u00e1rio."); form[i].focus(); return false; } } } return true; } // VALIDA CAMPOS DA BUSCA function valida(){ fin = $('#finalidade'); if(!fin.val()) { alert("Por favor, escolha a finalidade.\nCompra ou Locação!"); fin.focus(); return false; } uf = $('#estado'); if(!uf.val()) { alert("Por favor, selecione o Estado!"); uf.focus(); return false; } cid = $('#cidade'); if(cid.val() == "0") { alert("Por favor, selecione a Cidade!"); cid.focus(); return false; } vmin = $('#valor_min'); vmax = $('#valor_max'); if (!vmin.val()=="" || !vmax.val()=="") { if(!($.isNumeric(vmin.val()) && vmin.val()>=0)) { alert("Por favor, insira um valor positivo!"); vmin.focus(); return false; } vmax = $('#valor_max'); if(!($.isNumeric(vmax.val()) && vmax.val()>0)) { alert("Por favor, insira um valor positivo!"); vmax.focus(); return false; } } return true; } function doNav(nOpc) { // Fecha menu de serviços ao clicar document.getElementById("menuServ").style.display = "none"; // Usado para posicionar a página na área de conteúdo quando uma opção é escolhida //location.href = "#c"; switch(nOpc){ case 1: //doEmpresa() cURL = "/empresa.php"; break; case 2: //doPesqAv() // Aqui podemos passar o parâmetro tc caso o cliente use só um dos tipos (Venda ou Locação) cURL = "/spaicnet/views/imoveis/pesq.php?atpa=1&sr=" + gcSpaSrImv + "&depup=1"; break; case 3: //doProprietarios() cURL = "/spaicnet/views/proprietarios/login.php?sr=" + gcSpaSrInqPro; break; case 4: //doInquilinos() cURL = "/spaicnet/views/inquilinos/login.php?sr=" + gcSpaSrInqPro; break; case 5: //doLocalizacao() cURL = "/localizacao.php"; break; case 6: //doFale() cURL = "/fale.php"; break; default: break; } $("#" + gcSpaIDCtn).load(cURL, function() { if (nOpc == 3 || nOpc == 4){ focusElement = (nOpc==3)?"spa-pro-usuario":"spa-inq-usuario"; document.getElementById(focusElement).focus(); } }); } function envioFale() { oID = document.getElementById("cod"); oNome = document.getElementById("nome"); oEMail = document.getElementById("email"); oDDDFone = document.getElementById("ddd_fone"); oNumFone = document.getElementById("num_fone"); oDDDCel = document.getElementById("ddd_cel"); oNumCel = document.getElementById("num_cel"); oObs = document.getElementById("obs"); /* * Expressões regulares para validação dos campos */ oERNome = /\D{3,}/; oEREMail = /.+@{1}.+\.+.+/; oERDDDFone = /\d{2,}/; oERNumFone = /\d{2,4}-{0,1}\d{4}.*/; if (!oNome.value.match(oERNome)) { window.alert("Informe seu nome por favor."); oNome.select(); oNome.focus(); return; } if (oDDDFone.value.length > 0) { if (!oDDDFone.value.match(oERDDDFone)) { window.alert("O DDD deve conter apenas dígitos (pelo menos 2)."); oDDDFone.select(); oDDDFone.focus(); return; } } if (oNumFone.value.length > 0) { if (!oNumFone.value.match(oERNumFone)) { window.alert("O número do telefone informado não é válido."); oNumFone.select(); oNumFone.focus(); return; } } if (oDDDCel.value.length > 0) { if (!oDDDCel.value.match(oERDDDFone)) { window.alert("O DDD deve conter apenas dígitos (pelo menos 2)."); oDDDCel.select(); oDDDCel.focus(); return; } } if (oNumCel.value.length > 0) { if (!oNumCel.value.match(oERNumFone)) { window.alert("O número do celular informado não é válido."); oNumCel.select(); oNumCel.focus(); return; } } if (oEMail.value.length > 0) { if (!oEMail.value.match(oEREMail)) { window.alert("O e-mail informado não é válido."); oEMail.select(); oEMail.focus(); return; } } if (oEMail.value.length == 0 && oNumFone.value.length == 0 && oNumCel.value.length == 0) { window.alert("Preencha pelo menos uma forma de contato (e-mail ou telefone)."); return; } if (oObs.value.length == 0) { window.alert("Informe o assunto por favor."); return; } cURL = "/spaicnet/email/e-mail.php?&tp=ev-con&fl=g&sr=" + gcSpaSrImv + "&nm=" + escape(oNome.value) + "&em=" + escape(oEMail.value) + "&df=" + escape(oDDDFone.value) + "&nf=" + escape(oNumFone.value) + "&dc=" + escape(oDDDCel.value) + "&nc=" + escape(oNumCel.value) + "&obs=" + escape(oObs.value); $.get(cURL, function (data) { if (data.indexOf("*OK*") != -1) { window.alert("Mensagem enviada com sucesso. Obrigado."); } }); } function criaAjax() { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); } catch (ie1) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (ie2) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; } } } return xmlhttp; } // BUSCA AVANÇADA function mostraOpcAv(){ $('#opc-av').show(); } function ativaOpcAv(){ cancelaOpcAv(); $('#pesq-avancada button').prop('disabled', false); } function aplicaOpcAv(){ var filtro_av = []; $('#pesq-avancada input[type="checkbox"]').each(function() { if ($(this).is(":checked")) { filtro_av.push($(this).val()); } }); window.filtro_av = filtro_av.join(';'); doBuscaTopo(); $('#opc-av').hide(); } function cancelaOpcAv(){ $('#pesq-avancada input[type="checkbox"]').prop('checked', false); window.filtro_av = ""; $('#opc-av').hide(); }