/* * 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 = "2011015077"; // Série usada para inquilinos e proprietários gcSpaSrInqPro = "2010123102"; // Nome do container principal da página (aquele que contém todo o conteúdo) gcSpaIDCtnBase = "sitebg"; // Nome do container onde os resultados das pesquisas serão exibidos gcSpaIDCtn = "right"; gcIDCtn = "cnt_pesq"; function carregaPagina() { jQuery.ajaxSetup({async:false}); doDestaques(); jQuery.ajaxSetup({async:true}); doSliderDtq(); $('.sumo').SumoSelect(); } function carregaCombos() { if (document.getElementById("finalidade").value != ""){ //jQuery.ajaxSetup({async:false}); $("#bairro").prop("disabled",true); doCarregaTipos(); ativaOpcAv(); } } function jssor(){ var _SlideshowTransitions = []; var options = { $AutoPlay: true, $AutoPlayInterval: 6000, $ArrowNavigatorOptions: { $Class: $JssorArrowNavigator$, $ChanceToShow: 1, $Transitions: _SlideshowTransitions, $TransitionsOrder: 0 }, $SlideshowOptions: { $Class: $JssorSlideshowRunner$, $Transitions: _SlideshowTransitions, $TransitionsOrder: 1, $ShowLink: 2, $ContentMode: false } }; var jssor_slider1 = new $JssorSlider$('slider1_container', options); $('#slider1_container').show(); } function doSliderDtq(){ var options = { $SlideWidth: 220, $SlideSpacing: 20, $DisplayPieces: 4, $DragOrientation: 1, $ArrowNavigatorOptions: { $Class: $JssorArrowNavigator$, $ChanceToShow: 2, $Transitions: _SlideshowTransitions, $TransitionsOrder: 0, }, $SlideshowOptions: { $Class: $JssorSlideshowRunner$, $Transitions: _SlideshowTransitions, $TransitionsOrder: 1, $ShowLink: 2, $ContentMode: true } }; var _SlideshowTransitions = []; var jssor_slider2 = new $JssorSlider$('slider_venda', options); var jssor_slider3 = new $JssorSlider$('slider_locacao', options); } function mostraMapa(bairro, cidade){ endereco = window.btoa(bairro + " " + cidade + " Brasil"); //base64 window.open("/spaicnet/views/google_maps/mapa.php?end=" + endereco); } //////////////////////////////////// /* DESTAQUES */ //////////////////////////////////// function doDestaques() { var oJson; $.get("/spaicnet/json/imoveis/destaques.php?sr=" + gcSpaSrImv, function (data) { oJson = eval("(" + data + ")"); $("#cnt_dtq").html('

* DESTAQUES DE VENDA

'+htmlDestaques(oJson,'V')); $("#cnt_dtql").html('

* DESTAQUES DE LOCAÇÃO

'+htmlDestaques(oJson,'L')); }); } function htmlDestaques(oJson,tipo) { var nIV = 0; var cDtq = ""; if (tipo=="V") { sliderId = "slider_venda"; } else if (tipo=="L") { sliderId = "slider_locacao"; } cDtq += '
' + '
'; nIV = 0; for (nI = 0; nI < oJson.destaques.length; nI++) { if (oJson.destaques[nI].tipc != tipo) { continue; } nIV ++; tableDtq = '
' + '

' + oJson.destaques[nI].bairro + '


' + '

' + oJson.destaques[nI].tipo + '


' + '

Código: ' + oJson.destaques[nI].codigo + '


' + '

R$ ' + oJson.destaques[nI].preco + '


' + '
' + '
'; cDtq += tableDtq; } cDtq += '
' + '' + '' + '' + '' + '
'; return cDtq; } //////////////////////////////////////////////////// // CONFIGURAÇÕES EXTRAS DO SITE //////////////////// //////////////////////////////////////////////////// // 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 = $("#dormitorio").val(); oVaga = $("#garagem").val(); 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 + "&vag=" + oVaga + "&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); }); } } // BUSCA POR CÓDIGO FOOTER function doBuscaCodigoFooter() { var oCodImv = document.getElementById("codigofooter"); if (oCodImv.value.indexOf('Digite')){ oCodImv.value = oCodImv.value.replace(/ /g,''); } tipoImv = oCodImv.value.substring(0,3).toUpperCase(); if (tipoImv=="VEN" || tipoImv=="LOC"){ finImv=(tipoImv=="VEN")?"vendafooter":(tipoImv=="LOC")?"alugafooter":""; document.getElementById(finImv).checked = true; oCodImv.value = oCodImv.value.substring(3,oCodImv.value.length); } var cRet = $('input[name=fin]:checked').last().val(); if (typeof cRet == 'undefined') { alert('Selecione Venda ou Locação!'); return false; } $.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("9183").trigger('change'); //Guarulhos }); } // 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."); 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; } //////////////////////////////////////////////////// // FIM DAS CONFIGURAÇÕES EXTRAS DO SITE //////////// //////////////////////////////////////////////////// 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 = ""; }); }); } function exibeDetImv(cTipC, nCod) { spaImvExibeDetalhe(nCod, null, cTipC, gcSpaSrImv, true); } function doNav(nOpc) { 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; case 7: //doServicos() cURL = "/servicos.php"; break; case 8: //doTrabalhe() cURL = "/trabalhe-conosco.php"; break; case 9: //doCadImovel() cURL = "/cadimovel.php"; break; case 10: //doMeuImovel() cURL = "/meuimovel.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."); } }); } // 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 = ""; $('#dormitorio').val(""); $('#garagem').val(""); $('#opc-av').hide(); }