var reasonsCity=[];reasonsCity[G_GEO_SUCCESS]="Sucesso";reasonsCity[G_GEO_MISSING_ADDRESS]="Cidade não informada: O campo de cidade está vazio.";reasonsCity[G_GEO_UNKNOWN_ADDRESS]="Cidade desconhecida:  Não foi encontrada nenhuma coordenada correspondente a cidade.";reasonsCity[G_GEO_UNAVAILABLE_ADDRESS]="Cidade indisponível:  Não é possível encontrar a cidade devido a questões legais ou contratuais.";reasonsCity[G_GEO_BAD_KEY]="Chave inválida: A chave é inválida para esse domínio";reasonsCity[G_GEO_TOO_MANY_QUERIES]="Consultas demais: O número de consultas para esse site ultrapassou o limite permitido.";reasonsCity[G_GEO_SERVER_ERROR]="Erro no servidor: A cidade não foi corretamente processada. Tente novamente";var reasonsAddress=[];reasonsAddress[G_GEO_SUCCESS]="Sucesso";reasonsAddress[G_GEO_MISSING_ADDRESS]="Endereço vazio: O endereço está vazio.";reasonsAddress[G_GEO_UNKNOWN_ADDRESS]="Endereço não encontrado: Tente novamente.";reasonsAddress[G_GEO_UNAVAILABLE_ADDRESS]="Endereço indisponível:  Não é possível encontrar o endereço devido a questões legais ou contratuais.";reasonsAddress[G_GEO_BAD_KEY]="Chave inválida: A chave é inválida para esse domínio";reasonsAddress[G_GEO_TOO_MANY_QUERIES]="Consultas demais: O número de consultas para esse site ultrapassou o limite permitido.";reasonsAddress[G_GEO_SERVER_ERROR]="Erro no servidor: O endereço não foi corretamente processado. Tente novamente";var contMarkers=0;var marker;var contLocal=0;var contFocoLocal=0;var comFoco=false;var contLocalCidade=0;var contFocoLocalCidade=0;var comFocoCidade=0;var cidadeBusca="São Paulo";var estadoBusca="SP";var pointBusca=new GLatLng(-23.55,-46.63);var valorZoomBusca=11;var validCityPlacemarks;var selectedCityPlacemark;var validAddressPlacemarks;var selectedAddressPlacemark;var NOT_AVAILABLE="consultar";var MSGTIMER=20;var MSGSPEED=5;var MSGOFFSET=20;var MSGHIDE=3;var errorFeedBackTimer;function inlineMsg(H,F,E){var C;var I;if(!document.getElementById("msg")){C=document.createElement("div");C.id="msg";I=document.createElement("div");I.id="msgcontent";document.body.appendChild(C);C.appendChild(I);C.style.filter="alpha(opacity=0)";C.style.opacity=0;C.alpha=0}else{C=document.getElementById("msg");I=document.getElementById("msgcontent")}I.innerHTML=F;C.style.display="block";var D=C.offsetHeight;var B=document.getElementById(H);B.focus();var G=B.offsetHeight;var K=B.offsetWidth;var A=topPosition(B)-((D-G)/2);var J=leftPosition(B)+K+MSGOFFSET;C.style.top=A+"px";C.style.left=J+"px";clearInterval(errorFeedBackTimer);errorFeedBackTimer=setInterval("fadeMsg(1)",MSGTIMER);if(!E){E=MSGHIDE}window.setTimeout("hideMsg()",(E*1000))}function hideMsg(){var A=document.getElementById("msg");if(!errorFeedBackTimer){errorFeedBackTimer=setInterval("fadeMsg(0)",MSGTIMER)}}function fadeMsg(A){if(A==null){A=1}var C=document.getElementById("msg");var B;if(A==1){B=C.alpha+MSGSPEED}else{B=C.alpha-MSGSPEED}C.alpha=B;C.style.opacity=(B/100);C.style.filter="alpha(opacity="+B+")";if(B>=99){clearInterval(errorFeedBackTimer);errorFeedBackTimer=null}else{if(B<=1){C.style.display="none";clearInterval(errorFeedBackTimer)}}}function leftPosition(B){var A=0;if(B.offsetParent){while(1){A+=B.offsetLeft;if(!B.offsetParent){break}B=B.offsetParent}}else{if(B.x){A+=B.x}}return A}function topPosition(B){var A=0;if(B.offsetParent){while(1){A+=B.offsetTop;if(!B.offsetParent){break}B=B.offsetParent}}else{if(B.y){A+=B.y}}return A}if(document.images){arrow=new Image(7,80);arrow.src="img/msg_arrow.gif"}function validateSelectedError(B,A){if(B==0){A.innerHTML="Selecione um tipo de erro.";return false}return true}function validateEmail(A,C){var B=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;if(B.test(A)==false){C.innerHTML="Forneça um e-mail válido.";return false}return true}function validateCaptcha(B,A){if(B==null||B==""){A.innerHTML="Digite o conteúdo da imagem abaixo.";return false}return true}function startFeedback(){document.getElementById("loadingFeedBack").style.display="block"}function endFeedback(){document.getElementById("loadingFeedBack").style.display="none"}function addressNumber(A){var B=A.length-1;while((!isNaN(A.substr(B,A.length-B)))&&(B>=0)){B--}return parseInt(A.substr(B+1,A.length-B+1))}function removeEndSpaces(B){var A=B.length-1;while((B.substr(A,1)==" ")&&(A>=0)){A--}return B.substr(0,A+1)}function suggestOverAddress(A){contFocoLocal=A;for(i=0;i<validAddressPlacemarks.length;i++){if(i!=contFocoLocal){document.getElementById("divLocal"+i).className="suggest_link"}else{document.getElementById("divLocal"+i).className="suggest_link_over"}}}function suggestOverCity(A){contFocoLocalCidade=A;for(i=0;i<validCityPlacemarks.length;i++){if(i!=contFocoLocalCidade){document.getElementById("divLocalCidade"+i).className="suggest_link"}else{document.getElementById("divLocalCidade"+i).className="suggest_link_over"}}}function setSearch(A){document.form.getElementById("addressInput").value=A;document.getElementById("search_suggest").innerHTML="";document.getElementById("search_suggest").style.display="none"}function processKeyAddres(A){switch(A){case 27:comFoco=false;document.getElementById("search_suggest").innerHTML="";document.getElementById("search_suggest").style.display="none";break;case 13:choseAddress(validAddressPlacemarks[contFocoLocal]);break;case 38:contFocoLocal--;if(contFocoLocal<0){contFocoLocal=0}suggestOverAddress(contFocoLocal);break;case 40:contFocoLocal++;if(contFocoLocal>=validAddressPlacemarks.length){contFocoLocal=validAddressPlacemarks.length-1}suggestOverAddress(contFocoLocal);break}}function processKeyCity(A){if(document.getElementById("cityInput").value==""){document.getElementById("cityContainer").className=""}switch(A){case 27:comFocoCidade=false;document.getElementById("search_suggest_cidade").innerHTML="";document.getElementById("search_suggest_cidade").style.display="none";break;case 13:choseCity(validCityPlacemarks[contFocoLocalCidade]);break;case 38:contFocoLocalCidade--;if(contFocoLocalCidade<0){contFocoLocalCidade=0}suggestOverCity(contFocoLocalCidade);break;case 40:contFocoLocalCidade++;if(contFocoLocalCidade>=validCityPlacemarks.length){contFocoLocalCidade=validCityPlacemarks.length-1}suggestOverCity(contFocoLocalCidade);break}}function inputKeyPress(B){if(comFoco||comFocoCidade){var A;if(window.event){A=window.event.keyCode}else{A=B.which}if(comFoco){processKeyAddres(A)}else{if(comFocoCidade){processKeyCity(A)}}}}function resetErrorCidade(A){if(A.value==""){document.getElementById("cityContainer").className=""}}function cityGeocodeRequest(A){if(homeFilter.searchValidation()){geocoder.setBaseCountryCode("BR");if((A.search(/brasil/i)==-1)&&(A.search(/brazil/i)==-1)){A+=", Brasil"}geocoder.getLocations(A,processCityGeocodeRequet)}}function processCityGeocodeRequet(A){switch(A.Status.code){case G_GEO_TOO_MANY_QUERIES:case G_GEO_BAD_KEY:case G_GEO_UNAVAILABLE_ADDRESS:alert(reasonsCity[A.Status.code]);break;case G_GEO_SERVER_ERROR:case G_GEO_MISSING_ADDRESS:case G_GEO_UNKNOWN_ADDRESS:alert(reasonsCity[A.Status.code]);document.getElementById("cityContainer").className="error";document.getElementById("cityInput").focus();break;case G_GEO_SUCCESS:validCityPlacemarks=new filterCityGeocodeRequet(A.Placemark);if(validCityPlacemarks.length==0){alert(reasonsCity[G_GEO_UNKNOWN_ADDRESS]);document.getElementById("cityContainer").className="error";document.getElementById("cityInput").focus()}else{if(validCityPlacemarks.length==1){setCity(validCityPlacemarks[0])}else{askDidYouMeanCity()}}break;default:alert("Cidade não encontrada. Tente novamente.");document.getElementById("cityContainer").className="error";document.getElementById("cityInput").focus();break}}function addressGeocodeRequest(A){geocoder.setBaseCountryCode("BR");A+=", "+document.getElementById("cityInput").value;A+=", Brasil";geocoder.getLocations(A,processAddressGeocodeRequet)}function processAddressGeocodeRequet(A){switch(A.Status.code){case G_GEO_SERVER_ERROR:case G_GEO_TOO_MANY_QUERIES:case G_GEO_BAD_KEY:case G_GEO_UNAVAILABLE_ADDRESS:alert(reasonsAddress[A.Status.code]);break;case G_GEO_MISSING_ADDRESS:alert(reasonsAddress[A.Status.code]);document.getElementById("addressContainer").className="error";document.getElementById("addressInput").focus();break;case G_GEO_UNKNOWN_ADDRESS:alert(reasonsAddress[A.Status.code]);document.getElementById("addressInput").focus();setAddress(selectedCityPlacemark);break;case G_GEO_SUCCESS:validAddressPlacemarks=new filterAddressGeocodeRequet(A.Placemark);if(validAddressPlacemarks.length==0){alert(reasonsAddress[G_GEO_UNKNOWN_ADDRESS])}else{if(validAddressPlacemarks.length==1){setAddress(validAddressPlacemarks[0])}else{askDidYouMeanAddress()}}break;default:alert("Endereço não encontrado. Siga as dicas e tente novamente.");document.getElementById("addressInput").focus();setAddress(selectedCityPlacemark);break}}function filterCityGeocodeRequet(A){var D=new Array();var B=0;for(j=0;(j<A.length);j++){place=new parsedPlacemark(A[j]);var C=true;if(place.pais!="BR"){C=false}if(place.accuracy>4){C=false}if(place.estado==""){C=false}if(place.cidade==""){C=false}for(k=0;k<D.length;k++){if(RetiraAcentos(place.cidade)==RetiraAcentos(D[k].cidade)&&RetiraAcentos(place.estado)==RetiraAcentos(D[k].estado)){C=false}}if(C){D[B]=place;B++}}return D}function filterAddressGeocodeRequet(A){var D=new Array();var B=0;for(j=0;(j<A.length);j++){place=new parsedPlacemark(A[j]);var C=true;if(place.pais!="BR"){C=false}if(RetiraAcentos(place.estado)!=RetiraAcentos(selectedCityPlacemark.estado)){C=false}if(RetiraAcentos(place.cidade)!=RetiraAcentos(selectedCityPlacemark.cidade)){C=false}for(k=0;k<D.length;k++){if(RetiraAcentos(place.estado)==RetiraAcentos(D[k].estado)&&RetiraAcentos(place.cidade)==RetiraAcentos(D[k].cidade)&&RetiraAcentos(place.rua)==RetiraAcentos(D[k].rua)&&RetiraAcentos(place.bairro)==RetiraAcentos(D[k].bairro)){C=false}}if(C){D[B]=place;B++}}return D}function setAddress(A){selectedAddressPlacemark=A;newFilter=new Filter();newFilter.loadFromHtml();newFilter.lat=A.lat;newFilter.lng=A.lng;newFilter.zoom=A.valorZoom;newFilter.action="Nova Busca";homeFilter.resetEvents();homeFilter.searchEvent=true;homeFilter.addFilter(newFilter);homeFilter.getCurrent().applyFormFilter();homeFilter.getCurrent().applyMapFilter();homeFilter.addToSession();mainList.findFirstResults()}function choseAddress(A){document.getElementById("addressInput").value="";if(A.rua!=""){document.getElementById("addressInput").value+=A.rua;if(A.numero!=0){document.getElementById("addressInput").value+=" "+A.numero}}if(A.bairro!=""){if(A.rua!=""){document.getElementById("addressInput").value+=" - "}document.getElementById("addressInput").value+=A.bairro}document.getElementById("search_suggest").innerHTML="";document.getElementById("search_suggest").style.display="none";comFoco=false;setAddress(A)}function setCity(A){selectedCityPlacemark=A;document.getElementById("cityContainer").className="";addressGeocodeRequest(document.getElementById("addressInput").value)}function choseCity(A){document.getElementById("cityInput").value=A.cidade+", "+A.estado;document.getElementById("search_suggest_cidade").innerHTML="";document.getElementById("search_suggest_cidade").style.display="none";comFocoCidade=0;setCity(A)}function askDidYouMeanAddress(){var B=document.getElementById("search_suggest_cidade");var A=document.getElementById("search_suggest");var D=findPos(document.getElementById("addressInput"));B.innerHTML="";B.style.display="none";A.innerHTML="";A.style.display="none";A.innerHTML="<div class='suggest_title'>Escolha o endereço correto:</div>";for(j=0;(j<validAddressPlacemarks.length);j++){var C="<div id='divLocal"+j+"'";C+='onmouseover="javascript:suggestOverAddress('+j+');" ';C+='onmousedown="javascript:choseAddress(validAddressPlacemarks['+j+']);"';C+=" class='suggest_link'>";C+=validAddressPlacemarks[j].endereco;C+="</div>";A.innerHTML+=C;comFocoCidade=false}A.style.display="block";A.style.top=D[1]+22+"px";A.style.left=D[0]+1+"px";suggestOverAddress(0);comFoco=true;document.getElementById("addressInput").focus()}function askDidYouMeanCity(){var B=document.getElementById("search_suggest");var A=document.getElementById("search_suggest_cidade");var D=findPos(document.getElementById("cityInput"));B.innerHTML="";B.style.display="none";A.innerHTML="";A.style.display="none";A.innerHTML="<div class='suggest_title'>Escolha o endereço correto:</div>";for(j=0;(j<validCityPlacemarks.length);j++){var C="<div id='divLocalCidade"+j+"'";C+='onmouseover="javascript:suggestOverCity('+j+');" ';C+='onmousedown="javascript:choseCity(validCityPlacemarks['+j+']);"';C+=" class='suggest_link'>";C+=validCityPlacemarks[j].cidade+", "+validCityPlacemarks[j].estado;C+="</div>";A.innerHTML+=C;comFoco=false}A.style.display="block";A.style.top=D[1]+22+"px";A.style.left=D[0]+1+"px";comFocoCidade=1;suggestOverCity(0);document.getElementById("cityInput").focus()}function parsedPlacemark(A){this.pais="";this.estado="";this.rua="";this.numero=0;this.cidade="";this.endereco="";this.bairro="";this.valorZoom=4;this.lng=A.Point.coordinates[0];this.lat=A.Point.coordinates[1];this.accuracy=A.AddressDetails.Accuracy;try{this.pais=A.AddressDetails.Country.CountryNameCode;this.estado=A.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;this.cidade=A.AddressDetails.Country.AdministrativeArea.Locality.LocalityName}catch(B){}try{this.rua=A.AddressDetails.Country.AdministrativeArea.Locality.DependentLocality.Thoroughfare.ThoroughfareName}catch(B){try{this.rua=A.AddressDetails.Country.AdministrativeArea.Locality.Thoroughfare.ThoroughfareName}catch(B){}}var C=addressNumber(this.rua);if(isNaN(C)){this.numero=0}else{this.numero=C;this.rua=this.rua.substring(0,this.rua.length-this.numero.toString().length);this.rua=removeEndSpaces(this.rua)}try{this.endereco=A.address}catch(B){}try{this.bairro=A.AddressDetails.Country.AdministrativeArea.Locality.DependentLocality.DependentLocalityName}catch(B){}switch(A.AddressDetails.Accuracy){case 1:this.valorZoom=4;break;case 2:this.valorZoom=6;break;case 3:this.valorZoom=10;break;case 4:this.valorZoom=14;break;case 5:this.valorZoom=15;break;case 6:this.valorZoom=16;break;case 7:this.valorZoom=16;break;case 8:case 9:case 10:case 11:this.valorZoom=16;break}}function EBubble(A,B,G,E,H,D,I){thatBubble=this;this.map=A;this.image=B;this.size=G;this.insize=E;this.inset=H;this.anchor=D;this.noCloseOnClick=I;this.visible=false;this.ie=false;var C=navigator.userAgent.toLowerCase();if((C.indexOf("msie")>-1)&&(C.indexOf("opera")<1)){this.ie=true}else{this.ie=false}this.div1=document.createElement("div");this.div1.style.position="absolute";this.div1.style.display="none";document.body.appendChild(this.div1);if(this.ie&&this.image.indexOf(".png")>-1){var F="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.image+"', sizingMethod='scale');";this.div1.innerHTML='<div style="height:'+this.size.height+"px; width:"+this.size.width+"px; "+F+'" ></div>'}else{this.div1.innerHTML='<img src="'+this.image+'" width="'+this.size.width+'" height="'+this.size.height+'">'}GEvent.addListener(A,"dragstart",function(){thatBubble.hide()});GEvent.addListener(A,"moveend",function(){thatBubble.hide()});GEvent.addDomListener(this.div1,"click",function(){if(!thatBubble.noCloseOnClick){thatBubble.hide()}GEvent.trigger(thatBubble,"click")});GEvent.addDomListener(this.div1,"mousedown",function(){if(!thatBubble.noCloseOnClick){thatBubble.hide()}GEvent.trigger(thatBubble,"click")});this.div2=document.createElement("div");this.div1.appendChild(this.div2);this.div2.style.position="absolute";this.div2.style.left=this.inset.x+"px";this.div2.style.top=this.inset.y+"px";this.div2.style.width=this.insize.width+"px";this.div2.style.height=this.insize.height+"px"}EBubble.prototype.openOnMap=function(B,C,F){this.offset=F||new GPoint(0,0);this.point=B;this.div2.innerHTML=C;var E=this.map.fromLatLngToDivPixel(B);var D=this.map.getPane(G_MAP_MAP_PANE).parentNode;var A=E.x+parseInt(D.style.left);var G=E.y+parseInt(D.style.top);G+=this.map.getContainer().offsetTop;A+=this.map.getContainer().offsetLeft;G-=this.anchor.y;A-=this.anchor.x;G-=this.offset.y;A-=this.offset.x;this.div1.style.left=A+"px";this.div1.style.top=G+"px";this.visible=true;this.show()};EBubble.prototype.openOnMarker=function(A,C){var D=A.getIcon().iconAnchor.x-A.getIcon().infoWindowAnchor.x;var B=A.getIcon().iconAnchor.y-A.getIcon().infoWindowAnchor.y;this.openOnMap(A.getPoint(),C,new GPoint(D,B))};EBubble.prototype.show=function(){this.div1.style.display="";this.div2.style.display="";this.visible=true};EBubble.prototype.hide=function(){this.div1.style.display="none";this.visible=false};EBubble.prototype.isHidden=function(){return !this.visible};EBubble.prototype.supportsHide=function(){return true};var bubble;function addCommas(B){B+="";x=B.split(".");x1=x[0];x2=x.length>1?","+x[1]:"";var A=/(\d+)(\d{3})/;while(A.test(x1)){x1=x1.replace(A,"$1.$2")}return x1+x2}function htm2xhtm(B){toStr=new String();toStr=B+"";var C=["á","â","à","ã","ç","é","ê","í","ó","ô","õ","ú","ü"," Á","Â","À","Ã","Ç","É","Ê","Í","Ó","Ô","Õ","Ú","Ü","<",">","&"];var A=["xhtmaacute","xhtmacirc","xhtmagrave","xhtmatilde","xhtmccedil","xhtmeacute","xhtmecirc","xhtmiacute","xhtmoacute","xhtmocirc","xhtmotilde","xhtmuacute","xhtmuuml","xhtmAacute","xhtmAcirc","xhtmAgrave","xhtmAtilde","xhtmCcedil","xhtmEacute","xhtmEcirc","xhtmIacute","xhtmOacute","xhtmOcirc","xhtmOtilde","xhtmUacute","xhtmUuml","xhtmlt","xhtmgt","xhtmamp"];for(i=0;i<C.length;i++){while(toStr.search(C[i])!=-1){toStr=toStr.replace(C[i],A[i])}}return toStr}function xhtm2htm(B){toStr=new String();toStr=B+"";var A=["á","â","à","ã","ç","é","ê","í","ó","ô","õ","ú","ü"," Á","Â","À","Ã","Ç","É","Ê","Í","Ó","Ô","Õ","Ú","Ü","<",">","&"];var C=["xhtmaacute","xhtmacirc","xhtmagrave","xhtmatilde","xhtmccedil","xhtmeacute","xhtmecirc","xhtmiacute","xhtmoacute","xhtmocirc","xhtmotilde","xhtmuacute","xhtmuuml","xhtmAacute","xhtmAcirc","xhtmAgrave","xhtmAtilde","xhtmCcedil","xhtmEacute","xhtmEcirc","xhtmIacute","xhtmOacute","xhtmOcirc","xhtmOtilde","xhtmUacute","xhtmUuml","xhtmlt","xhtmgt","xhtmamp"];for(i=0;i<C.length;i++){while(toStr.search(C[i])!=-1){toStr=toStr.replace(C[i],A[i])}}return toStr}function Filter(){this.address1="";this.address2="";this.buyRent=1;this.houseFlag=true;this.apartmentFlag=true;this.bedrooms=0;this.parking=0;this.minValueIndex=0;this.minValue=0;this.maxValueIndex=5;this.maxValue=0;this.action="Início";this.lat=-15.62;this.lng=-49.3;this.zoom=3;this.current=true;this.check=0;this.userId=-1;this.userLogin=-1;this.userName=-1;this.logo=-1;this.phoneNumber=-1;this.orderingType=-1;this.debug=A;function A(){alert("\nthis.address1 = "+this.address1+"\nthis.address2 = "+this.address2+"\nthis.buyRent = "+this.buyRent+"\nthis.houseFlag = "+this.houseFlag+"\nthis.apartmentFlag = "+this.apartmentFlag+"\nthis.bedrooms = "+this.bedrooms+"\nthis.parking = "+this.parking+"\nthis.minValueIndex = "+this.minValueIndex+"\nthis.minValue = "+this.minValue+"\nthis.maxValueIndex = "+this.maxValueIndex+"\nthis.maxValue = "+this.maxValue+"\nthis.action = "+this.action+"\nthis.lat = "+this.lat+"\nthis.lng = "+this.lng+"\nthis.zoom = "+this.zoom+"\nthis.current = "+this.current+"\nthis.orderingType = "+this.orderingType+"\nthis.check = "+this.check+"\nthis.userId = "+this.userId+"\nthis.userName = "+this.userName+"\nthis.logo = "+this.logo+"\nthis.phoneNumber = "+this.phoneNumber)}this.getLongDescription=B;function B(){var H="";var F=[];if(this.houseFlag){F.push("casa")}if(this.apartmentFlag){F.push("apartamento")}var E=[];if(this.bedrooms&2){E.push("1")}if(this.bedrooms&4){E.push("2")}if(this.bedrooms&8){E.push("3")}if(this.bedrooms&16){E.push("4 ou mais")}var D=[];if(this.parking&1){D.push("0")}if(this.parking&2){D.push("1")}if(this.parking&4){D.push("2")}if(this.parking&8){D.push("3 ou mais")}H+=(this.buyRent==1)?"comprar":"alugar";H+=" ";if(F.length==1){H+=F[0]}else{if(F.length==2){H+=F[0]+" ou "+F[1]}}H+=" com ";if(!(this.bedrooms&16)){switch(E.length){case 1:H+=E[0];H+=(E[0]=="1")?" dormitório":" dormitórios";break;case 2:H+=E[0]+" ou "+E[1];H+=" dormitórios";break;case 3:H+=E[0]+", "+E[1]+" ou "+E[2];H+=" dormitórios";break}}else{if((this.bedrooms&16)){switch(E.length){case 1:H+=E[0];break;case 2:H+=E[0]+", "+E[1];break;case 3:H+=E[0]+", "+E[1]+", "+E[2];break;case 4:H+=E[0]+", "+E[1]+", "+E[2]+", "+E[3];break}H+=" dormitórios"}}H+=" e ";if(!(this.parking&8)){switch(D.length){case 1:H+=D[0];H+=(D[0]=="1")?" vaga":" vagas";break;case 2:H+=D[0]+" ou "+D[1];H+=" vagas";break;case 3:H+=D[0]+", "+D[1]+" ou "+D[2];H+=" vagas";break}}else{if((this.parking&8)){switch(D.length){case 1:H+=D[0];break;case 2:H+=D[0]+", "+D[1];break;case 3:H+=D[0]+", "+D[1]+", "+D[2];break;case 4:H+=D[0]+", "+D[1]+", "+D[2]+", "+D[3];break}H+=" vagas"}}H+=" ";if((this.minValueIndex!=0)&&(this.maxValueIndex==6)){H+="a partir de R$ ";var G=new Number;H+=addCommas(this.minValue);H+=" "}if((this.minValueIndex!=0)&&(this.maxValueIndex!=6)){H+="a partir de R$ ";H+=addCommas(this.minValue);H+=" até R$ ";H+=addCommas(this.maxValue);H+=" "}if((this.minValueIndex==0)&&(this.maxValueIndex!=6)){H+="até R$ ";H+=addCommas(this.maxValue);H+=" "}H+="na região abaixo";return H}this.getShortDescription=C;function C(){var G="";var F=[];if(this.houseFlag){F.push("casa")}if(this.apartmentFlag){F.push("apto")}var E=[];if(this.bedrooms&2){E.push("1")}if(this.bedrooms&4){E.push("2")}if(this.bedrooms&8){E.push("3")}if(this.bedrooms&16){E.push("4 ou mais")}var D=[];if(this.parking&1){D.push("0")}if(this.parking&2){D.push("1")}if(this.parking&4){D.push("2")}if(this.parking&8){D.push("3 ou mais")}G+=(this.buyRent==1)?"comprar":"alugar";G+=" ";if(F.length==1){G+=F[0]}else{if(F.length==2){G+=F[0]+" ou "+F[1]}}G+=" com ";if(!(this.bedrooms&16)){switch(E.length){case 1:G+=E[0];G+=(E[0]=="1")?" dorm":" dorms";break;case 2:G+=E[0]+" ou "+E[1];G+=" dorms";break;case 3:G+=E[0]+", "+E[1]+" ou "+E[2];G+=" dorms";break}}else{if((this.bedrooms&16)){switch(E.length){case 1:G+=E[0];break;case 2:G+=E[0]+", "+E[1];break;case 3:G+=E[0]+", "+E[1]+", "+E[2];break;case 4:G+=E[0]+", "+E[1]+", "+E[2]+", "+E[3];break}G+=" dorms"}}G+=" e ";if(!(this.parking&8)){switch(D.length){case 1:G+=D[0];G+=(D[0]=="1")?" vaga":" vagas";break;case 2:G+=D[0]+" ou "+D[1];G+=" vagas";break;case 3:G+=D[0]+", "+D[1]+" ou "+D[2];G+=" vagas";break}}else{if((this.parking&8)){switch(D.length){case 1:G+=D[0];break;case 2:G+=D[0]+", "+D[1];break;case 3:G+=D[0]+", "+D[1]+", "+D[2];break;case 4:G+=D[0]+", "+D[1]+", "+D[2]+", "+D[3];break}G+=" vagas"}}if((this.minValueIndex!=0)&&(this.maxValueIndex==6)){G+=" a partir de R$ ";G+=addCommas(this.minValue)}if((this.minValueIndex!=0)&&(this.maxValueIndex!=6)){G+=" de R$ ";G+=addCommas(this.minValue);G+=" até R$ ";G+=addCommas(this.maxValue)}if((this.minValueIndex==0)&&(this.maxValueIndex!=6)){G+=" até R$ ";G+=addCommas(this.maxValue)}return G}this.loadFromHtml=function(){this.address1=document.getElementById("addressInput").value;this.address2=document.getElementById("cityInput").value;this.buyRent=(document.getElementById("rdoComprar").checked==true)?1:0;this.houseFlag=(document.getElementById("chkCasa").checked==true)?1:0;this.apartmentFlag=(document.getElementById("chkApartamento").checked==true)?1:0;this.bedrooms=0;if(document.getElementById("chk1Quarto").checked){this.bedrooms+=2}if(document.getElementById("chk2Quarto").checked){this.bedrooms+=4}if(document.getElementById("chk3Quarto").checked){this.bedrooms+=8}if(document.getElementById("chk4Quarto").checked){this.bedrooms+=16}this.parking=0;if(document.getElementById("chk0Vaga").checked){this.parking+=1}if(document.getElementById("chk1Vaga").checked){this.parking+=2}if(document.getElementById("chk2Vaga").checked){this.parking+=4}if(document.getElementById("chk3Vaga").checked){this.parking+=8}this.minValueIndex=document.getElementById("formSelectValorDe").selectedIndex;this.minValue=document.getElementById("formSelectValorDe")[this.minValueIndex].value;this.maxValueIndex=document.getElementById("formSelectValorAte").selectedIndex;this.maxValue=document.getElementById("formSelectValorAte")[this.maxValueIndex].value;this.lat=map.getCenter().lat();this.lng=map.getCenter().lng();this.zoom=map.getZoom();this.current=true;this.check=(document.getElementById("chkUser").checked==true)?1:0;this.userId=homeFilter.getCurrent().userId;this.userLogin=homeFilter.getCurrent().userLogin;this.userName=homeFilter.getCurrent().userName;this.logo=homeFilter.getCurrent().logo;this.phoneNumber=homeFilter.getCurrent().phoneNumber;this.orderingType=document.getElementById("orderingType1").options[document.getElementById("orderingType1").selectedIndex].value};this.loadFromXmlNode=function(E){try{this.current=(E.getAttribute("current")=="true")?true:false}catch(F){this.current=false}try{this.action=xhtm2htm(E.getElementsByTagName("action")[0].childNodes[0].nodeValue)}catch(F){this.action="Histórico"}try{this.address2=xhtm2htm(E.getElementsByTagName("address2")[0].childNodes[0].nodeValue)}catch(F){this.address2=""}try{this.address1=xhtm2htm(E.getElementsByTagName("address1")[0].childNodes[0].nodeValue)}catch(F){this.address1=""}try{this.houseFlag=(E.getElementsByTagName("chkHouse")[0].childNodes[0].nodeValue==1)?true:false}catch(F){this.houseFlag=true}try{this.apartmentFlag=(E.getElementsByTagName("chkApto")[0].childNodes[0].nodeValue==1)?true:false}catch(F){this.apartmentFlag=true}try{this.buyRent=E.getElementsByTagName("buyRent")[0].childNodes[0].nodeValue}catch(F){this.buyRent=1}try{this.bedrooms=E.getElementsByTagName("bedroomsQty")[0].childNodes[0].nodeValue}catch(F){this.bedrooms=2+4+8+16}try{this.parking=E.getElementsByTagName("parkingQty")[0].childNodes[0].nodeValue}catch(F){this.parking=1+2+4+8}try{this.minValueIndex=E.getElementsByTagName("minValue")[0].childNodes[0].nodeValue}catch(F){this.minValueIndex=0}this.minValue=document.getElementById("formSelectValorDe")[this.minValueIndex].value;try{this.maxValueIndex=E.getElementsByTagName("maxValue")[0].childNodes[0].nodeValue}catch(F){this.maxValueIndex=0}this.maxValue=document.getElementById("formSelectValorAte")[this.maxValueIndex].value;try{this.lat=E.getElementsByTagName("lat")[0].childNodes[0].nodeValue}catch(F){this.lat=-15.62}try{this.lng=E.getElementsByTagName("lng")[0].childNodes[0].nodeValue}catch(F){this.lng=-49.3}try{this.zoom=E.getElementsByTagName("zoom")[0].childNodes[0].nodeValue}catch(F){this.zoom=3}try{mainList.setCurrentPage(E.getElementsByTagName("page")[0].childNodes[0].nodeValue)}catch(F){mainList.setCurrentPage(1)}try{this.orderingType=E.getElementsByTagName("orderBy")[0].childNodes[0].nodeValue}catch(F){this.orderingType=-1}try{this.check=E.getElementsByTagName("check")[0].childNodes[0].nodeValue}catch(F){this.check=0}try{this.userId=E.getElementsByTagName("userId")[0].childNodes[0].nodeValue}catch(F){this.userId=-1}try{this.userLogin=E.getElementsByTagName("login")[0].childNodes[0].nodeValue}catch(F){this.userLogin=-1}try{this.userName=E.getElementsByTagName("username")[0].childNodes[0].nodeValue;if(this.userName.length>37){this.userName=this.userName.substring(0,37)+" ..."}}catch(F){this.userName=-1}try{var D="";D=E.getElementsByTagName("logo")[0].childNodes[0].nodeValue;D=D.replace(/fraslfrasl/g,"/");this.logo=D}catch(F){this.logo=-1}try{this.phoneNumber=E.getElementsByTagName("phone_number")[0].childNodes[0].nodeValue}catch(F){this.phoneNumber=-1}};this.applyFormFilter=function(){document.getElementById("cityInput").value=this.address2;document.getElementById("addressInput").value=this.address1;document.getElementById("chkCasa").checked=this.houseFlag;document.getElementById("chkApartamento").checked=this.apartmentFlag;if(this.buyRent==1){document.getElementById("rdoComprar").checked=true}else{document.getElementById("rdoAlugar").checked=true}homeFilter.processBuyRentChange();document.getElementById("chk1Quarto").checked=(this.bedrooms&2)?true:false;document.getElementById("chk2Quarto").checked=(this.bedrooms&4)?true:false;document.getElementById("chk3Quarto").checked=(this.bedrooms&8)?true:false;document.getElementById("chk4Quarto").checked=(this.bedrooms&16)?true:false;document.getElementById("chkTodosQuartos").checked=(this.bedrooms==2+4+8+16)?true:false;document.getElementById("chk0Vaga").checked=(this.parking&1)?true:false;document.getElementById("chk1Vaga").checked=(this.parking&2)?true:false;document.getElementById("chk2Vaga").checked=(this.parking&4)?true:false;document.getElementById("chk3Vaga").checked=(this.parking&8)?true:false;document.getElementById("chkTodosVagas").checked=(this.parking==1+2+4+8)?true:false;document.getElementById("formSelectValorDe").selectedIndex=this.minValueIndex;document.getElementById("formSelectValorAte").selectedIndex=this.maxValueIndex;document.getElementById("filterLongDesc").innerHTML=this.getShortDescription();if(this.userId==-1){document.getElementById("userFilter").style.display="none"}else{document.getElementById("userFilter").style.display="block";document.getElementById("chkUser").checked=(this.check==1)?true:false;document.getElementById("userName").innerHTML=(this.userName!=-1)?wordbreak(this.userName,20):this.userLogin;document.getElementById("userLogo").innerHTML=(this.logo!=-1)?'<img  max-width="120" max-height="50" alt="logo imobiliária" src="'+this.logo+'" />':"";document.getElementById("userPhoneNumber").innerHTML=(this.phoneNumber!=-1)?this.phoneNumber:""}var E=document.getElementById("orderingType1");var D=document.getElementById("orderingType2");switch(this.orderingType){case"-1":E.options[0].selected=true;break;case"100":E.options[1].selected=true;break;case"101":E.options[2].selected=true;break;case"104":E.options[3].selected=true;break;case"105":E.options[4].selected=true;break;case"106":E.options[5].selected=true;break}D.options[E.selectedIndex].selected=true;mainList.setOrderingType(this.orderingType)};this.applyMapFilter=function(){map.setCenter(new GLatLng(this.lat*1,this.lng*1),this.zoom*1)}}function FilterHistory(){this.contFocoFilter=0;maxLen=9;this.loadEvent=false;this.searchEvent=false;this.zoomEvent=false;this.moveEvent=false;this.prevEvent=false;this.nextEvent=false;this.choseEvent=false;this.isHistoryOpen=false;var filterTimer;this.resetEvents=function(){this.searchEvent=false;this.zoomEvent=false;this.moveEvent=false;this.loadEvent=false;this.prevEvent=false;this.nextEvent=false;this.choseEvent=false};this.newEvent=function(){return(!(this.searchEvent||this.zoomEvent||this.moveEvent||this.loadEvent||this.prevEvent||this.nextEvent||this.choseEvent))};filters=new Array(arguments.length);for(i=0;i<arguments.length;i++){filters[i]=arguments[i]}onEndLoadFromSession="";this.setTimer=setTimer;function setTimer(script,miliseconds){miliseconds=miliseconds||2000;clearTimeout(filterTimer);filterTimer=setTimeout(script,2000)}this.clearTimer=clearTimer;function clearTimer(){clearTimeout(filterTimer)}this.onFilterChange=function(){if(this.searchValidation()){newFilter=new Filter();newFilter.loadFromHtml();newFilter.action="Novo filtro";addFilter(newFilter);addToSession();document.getElementById("filterLongDesc").innerHTML=newFilter.getShortDescription();mainList.startLoading();setTimer("mainList.findFirstResults();")}else{clearTimer();mainList.clearAllMarkers();mainList.print()}};this.onZoomEndScript=function(){if(this.searchValidation()){newFilter=new Filter();newFilter.loadFromHtml();newFilter.action="Zoom";addFilter(newFilter);addToSession();document.getElementById("filterLongDesc").innerHTML=newFilter.getShortDescription();mainList.startLoading();setTimer("mainList.findFirstResults();")}else{clearTimer();mainList.clearAllMarkers();mainList.print()}};this.onMoveEndScript=function(){if(this.searchValidation()){newFilter=new Filter();newFilter.loadFromHtml();newFilter.action="Moveu Mapa";addFilter(newFilter);addToSession();document.getElementById("filterLongDesc").innerHTML=newFilter.getShortDescription();mainList.startLoading();setTimer("mainList.findFirstResults();")}else{clearTimer();mainList.clearAllMarkers();mainList.print()}};this.getFiltersLen=function(){return filters.length};this.setOnEndLoadFromSession=function(script){onEndLoadFromSession=script};this.loadFromSession=function(){var strGetRequest=new String();strGetRequest="/imoveis/getHomeFilter/"+Math.ceil(Math.random()*100000);GDownloadUrl(strGetRequest,this.processLoadRequest)};this.processLoadRequest=function(data){pos=data.indexOf("<!--");data=(pos==-1)?data:data.substring(0,pos);xmlHomeFilter=GXml.parse(data);var xml=GXml.parse(data);var filterNodes=xml.documentElement.getElementsByTagName("filter");clearAllFilters();for(var i=0;i<filterNodes.length;i++){newFilter=new Filter;newFilter.loadFromXmlNode(filterNodes[i]);filters.push(newFilter)}getCurrent().applyFormFilter();getCurrent().applyMapFilter();eval(this.onEndLoadFromSession)};this.addFilter=addFilter;function addFilter(filter){popFilters(getCurrentPos()+1);if(filters.length>=maxLen){filters=filters.slice(filters.length-maxLen,filters.length)}for(var i=0;i<filters.length;i++){filters[i].current=false}filter.current=true;filters.push(filter);colorFade("searchBar","background","FF9900","FFFFCC")}this.popFilters=popFilters;function popFilters(newLen){while(filters.length>newLen){filters.pop()}}this.clearAllFilters=clearAllFilters;function clearAllFilters(){while(filters.length>0){popFilters(0)}}this.getCurrent=getCurrent;function getCurrent(){for(var i=0;i<filters.length;i++){if(filters[i].current){return filters[i]}}return new Filter()}this.getCurrentPos=getCurrentPos;function getCurrentPos(){for(var i=0;i<filters.length;i++){if(filters[i].current){return i}}return 0}this.setCurrent=setCurrent;function setCurrent(pos){colorFade("searchBar","background","FF9900","FFFFCC");for(var i=0;i<filters.length;i++){if(i==pos){filters[i].current=true}else{filters[i].current=false}}}this.prev=function(){hideFilterHistory();var prevPos=getCurrentPos()-1;if(prevPos>=0){setCurrent(prevPos);this.prevEvent=true;getCurrent().applyFormFilter();getCurrent().applyMapFilter();setSessionPosition();mainList.findResults()}};this.next=function(){hideFilterHistory();var nextPos=getCurrentPos()+1;if(nextPos<filters.length){setCurrent(nextPos);this.nextEvent=true;getCurrent().applyFormFilter();getCurrent().applyMapFilter();setSessionPosition();mainList.findResults()}};this.showHistory=function(){this.isHistoryOpen=!this.isHistoryOpen;if(!this.isHistoryOpen){this.hideFilterHistory();return }var divSuggest=document.getElementById("suggest_filter");var xmlElementsHomeFilter=xmlHomeFilter.documentElement.getElementsByTagName("filter");var XPosition=document.getElementById("map_canvas").offsetLeft;divSuggest.style.left=(XPosition+100)+"px";divSuggest.innerHTML="";divSuggest.style.display="none";var html="";html="<div class='suggest_title'>Histórico de ações:</div>";for(var j=filters.length-1;j>=0;j--){var suggest="<div id='divFilter"+j+"'";suggest+='onmouseover="javascript:homeFilter.suggestOverFilter('+j+');" ';suggest+='onmousedown="javascript:homeFilter.choseFilter('+j+');"';if(j<getCurrentPos()){suggest+=" class='suggest_link'>"}else{if(j==getCurrentPos()){suggest+=" class='suggest_link_over'>"}else{suggest+=" class='suggest_link_hist'>"}}suggest+="<div>";if(j==getCurrentPos()){suggest+=filters[j].action+" ( estou aqui )"}else{suggest+=filters[j].action}suggest+="</div>";suggest+='<div class="suggest_desc">';suggest+=filters[j].getShortDescription();suggest+="</div></div>";html+=suggest}html+='<div class="suggest_footer linkLike" onclick="javascript:homeFilter.hideFilterHistory();">fechar</div>';divSuggest.innerHTML=html;divSuggest.style.display="block";this.contFocoFilter=getCurrentPos()};this.suggestOverFilter=function(index){this.contFocoFilter=index;for(i=0;i<filters.length;i++){if(i<this.contFocoFilter){document.getElementById("divFilter"+i).className="suggest_link"}else{if(i==this.contFocoFilter){document.getElementById("divFilter"+i).className="suggest_link_over"}else{document.getElementById("divFilter"+i).className="suggest_link_hist"}}}};this.choseFilter=function(pos){this.choseEvent=true;hideFilterHistory();setCurrent(pos);getCurrent().applyFormFilter();getCurrent().applyMapFilter();setSessionPosition();mainList.findFirstResults()};this.hideFilterHistory=hideFilterHistory;function hideFilterHistory(){this.isHistoryOpen=false;document.getElementById("suggest_filter").innerHTML="";document.getElementById("suggest_filter").style.display="none"}this.searchValidation=function(){if(!document.getElementById("chkCasa").checked&&!document.getElementById("chkApartamento").checked){document.getElementById("chkCasa").focus();inlineMsg("formLabelCasa","Selecione um tipo de imóvel");return false}if(!document.getElementById("chk1Quarto").checked&&!document.getElementById("chk2Quarto").checked&&!document.getElementById("chk3Quarto").checked&&!document.getElementById("chk4Quarto").checked){inlineMsg("chk4Quarto","Selecione o número de quartos");document.getElementById("chk1Quarto").focus();return false}if(!document.getElementById("chk0Vaga").checked&&!document.getElementById("chk1Vaga").checked&&!document.getElementById("chk2Vaga").checked&&!document.getElementById("chk3Vaga").checked){inlineMsg("chk3Vaga","Selecione o número de vagas");document.getElementById("chk1Vaga").focus();return false}i=document.getElementById("formSelectValorDe").selectedIndex;valueFrom=document.getElementById("formSelectValorDe").options[i].value;j=document.getElementById("formSelectValorAte").selectedIndex;valueTo=document.getElementById("formSelectValorAte").options[j].value;if(Number(valueFrom)>=Number(valueTo)&&Number(valueFrom)!=-1&&Number(valueTo)!=-1){inlineMsg("formSelectValorAte","Selecione uma faixa de valores válida");document.getElementById("formSelectValorDe").focus();return false}return true};this.processBedroomCheckAll=function(){if(document.getElementById("chkTodosQuartos").checked){document.getElementById("chk1Quarto").checked=true;document.getElementById("chk2Quarto").checked=true;document.getElementById("chk3Quarto").checked=true;document.getElementById("chk4Quarto").checked=true}else{document.getElementById("chk1Quarto").checked=false;document.getElementById("chk2Quarto").checked=false;document.getElementById("chk3Quarto").checked=false;document.getElementById("chk4Quarto").checked=false}};this.processParkingCheckAll=function(){if(document.getElementById("chkTodosVagas").checked){document.getElementById("chk0Vaga").checked=true;document.getElementById("chk1Vaga").checked=true;document.getElementById("chk2Vaga").checked=true;document.getElementById("chk3Vaga").checked=true}else{document.getElementById("chk0Vaga").checked=false;document.getElementById("chk1Vaga").checked=false;document.getElementById("chk2Vaga").checked=false;document.getElementById("chk3Vaga").checked=false}};this.processBuyRentChange=function(){optionDe=document.getElementById("formSelectValorDe");optionDe.selectedIndex=0;optionAte=document.getElementById("formSelectValorAte");optionAte.selectedIndex=6;if(document.getElementById("rdoComprar").checked){optionDe[0].value=-1;optionDe[1].value=50000;optionDe[2].value=100000;optionDe[3].value=150000;optionDe[4].value=200000;optionDe[5].value=300000;optionDe[6].value=500000;optionAte[0].value=50000;optionAte[1].value=100000;optionAte[2].value=150000;optionAte[3].value=200000;optionAte[4].value=300000;optionAte[5].value=500000;optionAte[6].value=-1;optionDe[0].text="0";optionDe[1].text="50.000";optionDe[2].text="100.000";optionDe[3].text="150.000";optionDe[4].text="200.000";optionDe[5].text="300.000";optionDe[6].text="500.000";optionAte[0].text="50.000";optionAte[1].text="100.000";optionAte[2].text="150.000";optionAte[3].text="200.000";optionAte[4].text="300.000";optionAte[5].text="500.000";optionAte[6].text="máx"}else{optionDe[0].value=-1;optionDe[1].value=500;optionDe[2].value=1000;optionDe[3].value=1500;optionDe[4].value=2000;optionDe[5].value=3000;optionDe[6].value=5000;optionAte[0].value=500;optionAte[1].value=1000;optionAte[2].value=1500;optionAte[3].value=2000;optionAte[4].value=3000;optionAte[5].value=5000;optionAte[6].value=-1;optionDe[0].text="0";optionDe[1].text="500";optionDe[2].text="1.000";optionDe[3].text="1.500";optionDe[4].text="2.000";optionDe[5].text="3.000";optionDe[6].text="5.000";optionAte[0].text="500";optionAte[1].text="1.000";optionAte[2].text="1.500";optionAte[3].text="2.000";optionAte[4].text="3.000";optionAte[5].text="5.000";optionAte[6].text="máx"}};this.processBedroomCheck=function(){if(document.getElementById("chk1Quarto").checked&&document.getElementById("chk2Quarto").checked&&document.getElementById("chk3Quarto").checked&&document.getElementById("chk4Quarto").checked){document.getElementById("chkTodosQuartos").checked=true}else{document.getElementById("chkTodosQuartos").checked=false}};this.processParkingCheck=function(){if(document.getElementById("chk0Vaga").checked&&document.getElementById("chk1Vaga").checked&&document.getElementById("chk2Vaga").checked&&document.getElementById("chk3Vaga").checked){document.getElementById("chkTodosVagas").checked=true}else{document.getElementById("chkTodosVagas").checked=false}};this.searchSubmit=function(e){var key;if(window.event){key=window.event.keyCode}else{key=e.which}if(key==13){cityGeocodeRequest(document.getElementById("cityInput").value)}};this.addToSession=addToSession;function addToSession(){var strSetRequest="imoveis/setHomeFilter/";strSetRequest=strSetRequest+getCurrentPos()+"/";strSetRequest=strSetRequest+"1/";strSetRequest=strSetRequest+htm2xhtm(getCurrent().action)+"/";strSetRequest=strSetRequest+getCurrent().buyRent+"/";var chkHouse=(getCurrent().houseFlag)?"1":"0";strSetRequest=strSetRequest+chkHouse+"/";var chkApto=(getCurrent().apartmentFlag)?"1":"0";strSetRequest=strSetRequest+chkApto+"/";strSetRequest=strSetRequest+getCurrent().bedrooms+"/";strSetRequest=strSetRequest+getCurrent().parking+"/";strSetRequest=strSetRequest+getCurrent().minValueIndex+"/";strSetRequest=strSetRequest+getCurrent().maxValueIndex+"/";strSetRequest=strSetRequest+getCurrent().lat+"/";strSetRequest=strSetRequest+getCurrent().lng+"/";strSetRequest=strSetRequest+getCurrent().zoom+"/";strSetRequest=strSetRequest+mainList.getCurrentPage()+"/";strSetRequest=strSetRequest+getCurrent().orderingType+"/";strSetRequest=strSetRequest+getCurrent().check+"/";strSetRequest=strSetRequest+getCurrent().userId+"/";strSetRequest=strSetRequest+getCurrent().userName+"/";strSetRequest=strSetRequest+getCurrent().userLogin+"/";var strAux="";strAux=getCurrent().logo+"";strAux=strAux.replace(/\//g,"fraslfrasl");strSetRequest=strSetRequest+strAux+"/";strSetRequest=strSetRequest+getCurrent().phoneNumber+"/";strSetRequest=strSetRequest+htm2xhtm(getCurrent().address2)+"/";strSetRequest=strSetRequest+htm2xhtm(getCurrent().address1);GDownloadUrl(strSetRequest)}function setSessionPosition(){var strSetRequest="imoveis/setHomeFilter/";strSetRequest=strSetRequest+getCurrentPos()+"/";strSetRequest=strSetRequest+"0";GDownloadUrl(strSetRequest)}this.showUserCheck=function(){document.getElementById("formShowAllUsers").style.color="#000000"};this.hideUserCheck=function(){document.getElementById("formShowAllUsers").style.color="#999999"}}function Marker(){this.property_id=0;this.hash="";this.latitude=0;this.longitude=0;this.type_cd=0;this.bedrooms_qty=0;this.suites_qty=0;this.parking_spaces_qty=0;this.address="";this.property_long_desc="";this.rent_flag=false;this.rent_amount=0;this.sale_flag=false;this.sale_amount=0;this.condominium_charge=0;this.area=0;this.launch_flag=false;this.neighborhood="";this.city="";this.pic="";this.logo="";this.strMarkerHTML="";var B;var E;var A;this.mainListMouseOver=function(){elem=document.getElementById("main_"+this.property_id);elem.style.backgroundImage="url(img/yellow_gradient.gif)";elem.style.border="1px solid #FF9933"};this.mainListMouseOut=function(){elem=document.getElementById("main_"+this.property_id);elem.style.backgroundImage="";elem.style.borderBottom="1px solid #CCCCCC";elem.style.borderTop="1px solid #FFFFFF";elem.style.borderLeft="1px solid #FFFFFF";elem.style.borderRight="1px solid #FFFFFF"};this.favListMouseOver=function(){elem=document.getElementById("fav_"+this.property_id);elem.style.backgroundImage="url(img/yellow_gradient.gif)";elem.style.border="1px solid #FF9933"};this.favListMouseOut=function(){elem=document.getElementById("fav_"+this.property_id);elem.style.backgroundImage="";elem.style.borderBottom="1px solid #CCCCCC";elem.style.borderTop="1px solid #FFFFFF";elem.style.borderLeft="1px solid #FFFFFF";elem.style.borderRight="1px solid #FFFFFF"};this.trigerClick=function(){GEvent.trigger(B,"click")};that=this;this.getGoogleMarker=function(){return B};this.createGoogleMarker=function(){var G=C();this.strMarkerHTML=G};this.setPoint=D;function D(H,G){A=new GLatLng(H,G)}function F(){E=new GIcon();if(that.type_cd==1){E.image="img/marca_pequena.png";E.shadow="img/marca_sombra_pequena.png";E.iconSize=new GSize(24,29);E.shadowSize=new GSize(43,28);E.iconAnchor=new GPoint(12,29);E.infoWindowAnchor=new GPoint(8,17);E.printImage="img/marca_pequena.png";E.mozPrintImage="http://google.webassist.com/google/markers/house/pacifica_mozprint.png";E.printShadow="img/marca_sombra_pequena.png";E.transparent="img/marca_pequena.png"}else{if(that.type_cd==2){E.image="img/marca_apartamento.png";E.shadow="img/marca_apartamento_sombra.png";E.iconSize=new GSize(27,40);E.shadowSize=new GSize(45,40);E.iconAnchor=new GPoint(13,40);E.infoWindowAnchor=new GPoint(14,25);E.printImage="img/marca_apartamento.png";E.mozPrintImage="http://google.webassist.com/google/markers/house/pacifica_mozprint.png";E.printShadow="img/marca_apartamento_sombra.png";E.transparent="img/marca_apartamento.png"}}}this.getMarkerHTML=C;function C(){var M='<div class="corpoBalao"><div class="lblRuaBalao fonte6Balao"><a href="/imoveis/detail/@@propId0@@/@@hash0@@">@@end@@</a></div><div class="fotoImovelBalaoBorder"><a href="/imoveis/detail/@@propId1@@/@@hash1@@"><img class="fotoImovelBalao" src="@@srcFoto@@" /></a></div><div class="image_set imgFecharListaBalao" onclick="thatBubble.hide();"></div><div class="precoVendaImovelBalao fonte5Balao">R$ @@preco@@</div><div class="lblTipoBalao fonte6Balao">@@tipo@@</div><div class="lblQuartoVagaBalao fonte6Balao">@@quartos@@   @@vagas@@</div><div class="lblM2Balao fonte6Balao">@@mm@@</div><div onclick="favoriteList.animatedAddMarker(mainList.getMarkerById(@@j@@));" class="linkFavoritosListaBalao"><img border="0" src="img/adicionar_favoritos.gif" />favoritos</div><a href="/imoveis/detail/@@propId2@@/@@hash2@@"><div class="linkSaibaMaisListaBalao"><img border="0" src="img/detalhes.gif" />saiba mais</div></a></div>';var I="";var L="";var G="";var K="";var H="";var J="";strTipo=(that.type_cd==1)?"Casa":"Apartamento";strQuartos=(that.bedrooms_qty<=1)?that.bedrooms_qty+" dorm":that.bedrooms_qty+" dorms";K=(that.parking_spaces_qty<=1)?that.parking_spaces_qty+" vaga":that.parking_spaces_qty+" vagas";if(that.bedrooms_qty<1){strQuartos=""}if(that.parking_spaces_qty<0){K=""}if(that.area>0){J=that.area+" m&sup2;"}else{J=""}if(homeFilter.getCurrent().buyRent==1){I=addCommas(that.sale_amount)}else{if(homeFilter.getCurrent().buyRent==0){I=addCommas(that.rent_amount)}}if(that.address==""){H=that.city}else{H=that.address}if(H.length>30){H=H.substr(0,30)+"..."}M=M.replace(/@@srcFoto@@/,that.pic);M=M.replace(/@@preco@@/,I);M=M.replace(/@@tipo@@/,strTipo);M=M.replace(/@@quartos@@/,strQuartos);M=M.replace(/@@vagas@@/,K);M=M.replace(/@@mm@@/,J);M=M.replace(/@@end@@/,H);M=M.replace(/@@j@@/,that.property_id);M=M.replace(/@@propId0@@/,that.property_id);M=M.replace(/@@propId1@@/,that.property_id);M=M.replace(/@@propId2@@/,that.property_id);M=M.replace(/@@hash0@@/,that.hash);M=M.replace(/@@hash1@@/,that.hash);M=M.replace(/@@hash2@@/,that.hash);return M}this.getMainHTML=function(){var R='<div id="main_@@propId5@@" class="imovelLista" onmouseover="mainList.getMarkerById(@@propId6@@).mainListMouseOver();" onmouseout="mainList.getMarkerById(@@propId7@@).mainListMouseOut();"><div class="fotoImovelListaBorda"><img class="fotoImovelLista" src="@@srcFoto@@" onclick="location=\'/imoveis/detail/@@propId9@@/@@hash3@@\';" alt=\'foto do imóvel\'/>  </div>@@lancamento@@<div class="valorlLista">R$ @@preco@@</div><div class="lblTipoLista">@@tipo@@</div><div class="lblQuartoLista">@@quartos@@</div><div class="lblVagaLista">@@vagas@@</div><div class="lblMMLista">@@mm@@</div><a href="/imoveis/detail/@@propId1@@/@@hash1@@"><div class="lblEnderecoLista">@@end@@</div></a><div class="logoLista">@@imgLogoAnunciante@@  </div><div class="lblComentarioLista">@@obs@@</div><a href="#topo"><div onclick="showBubbleById(@@propId4@@);" class="linkMapaLista"><div class="image_set imgMapaLista"></div> mapa</div></a><div onclick="favoriteList.animatedAddMarker(mainList.getMarkerById(@@propId2@@));" class="linkFavoritosLista"><div class="image_set imgFavoritosLista"></div> favoritos</div><a href="/imoveis/detail/@@propId3@@/@@hash2@@"><div class="linkSaibaMaisLista"><div class= "image_set imgSaibaMaisLista"></div> saiba mais</div></a><div class="linkReportarErro" onClick="mainList.reportError(@@propId8@@)"><div class= "image_set imgReportarErro"></div> reportar erro</div></div>';var K="";var H="";var M="";var J="";var S="";var G="";var N="";var L=0;var Q=new Number();var P=0;var O="";var I="";O=(this.launch_flag!=0)?'<div class="image_set imgLancamentoLista"></div>':"";if(this.logo!=""){K='<img  max-width="120" max-height="50" src="'+this.logo+'" />'}strTipo=(this.type_cd==1)?"Casa":"Apartamento";strQuartos=(this.bedrooms_qty<=1)?this.bedrooms_qty+" dorm":this.bedrooms_qty+" dorms";G=(this.parking_spaces_qty<=1)?this.parking_spaces_qty+" vaga":this.parking_spaces_qty+" vagas";if(this.bedrooms_qty<1){strQuartos=""}if(this.parking_spaces_qty<0){G=""}if(this.area>0){N=this.area+" m&sup2;"}else{N=""}if(homeFilter.getCurrent().buyRent==1){H=addCommas(this.sale_amount)}else{if(homeFilter.getCurrent().buyRent==0){H=addCommas(this.rent_amount)}}if(this.address==""){I=this.city}else{I=this.address+"-"+this.city}if(I.length>55){I=I.substr(0,55)+"..."}strObs=this.property_long_desc;R=R.replace(/@@lancamento@@/,O);R=R.replace(/@@srcFoto@@/,this.pic);R=R.replace(/@@imgLogoAnunciante@@/,K);R=R.replace(/@@preco@@/,H);R=R.replace(/@@tipo@@/,strTipo);R=R.replace(/@@quartos@@/,strQuartos);R=R.replace(/@@vagas@@/,G);R=R.replace(/@@mm@@/,N);R=R.replace(/@@end@@/,I);R=R.replace(/@@obs@@/,strObs);R=R.replace(/@@propId1@@/,this.property_id);R=R.replace(/@@propId2@@/,this.property_id);R=R.replace(/@@propId3@@/,this.property_id);R=R.replace(/@@propId4@@/,this.property_id);R=R.replace(/@@propId5@@/,this.property_id);R=R.replace(/@@propId6@@/,this.property_id);R=R.replace(/@@propId7@@/,this.property_id);R=R.replace(/@@propId8@@/,this.property_id);R=R.replace(/@@propId9@@/,this.property_id);R=R.replace(/@@hash1@@/,this.hash);R=R.replace(/@@hash2@@/,this.hash);R=R.replace(/@@hash3@@/,this.hash);return R};this.getFavoriteHTML=function(){str='<div id="fav_@@propId2@@" class="imovelListaFav" onmouseover="favoriteList.getMarkerById(@@propId3@@).favListMouseOver();" onmouseout="favoriteList.getMarkerById(@@propId4@@).favListMouseOut();"> <a href="/imoveis/detail/@@propId@@/@@hash@@"><div class="fotoImovelListaFav"><img class="imgImovelListaFav" src="@@figura@@" alt=\'\' onclick="location=\'/imoveis/detail/@@propId5@@/@@hash1@@\';" /></div></a>@@lancamento@@<div class="image_set imgFecharListaFav" onclick="favoriteList.removeMarker(favoriteList.getMarkerById(@@i@@));"> </div><div class="lblAlugaListaFav">Aluga</div><div class="lblVendeListaFav">Vende</div><div class="valorAluguelListaFav">@@aluguel@@</div><div class="valorVendaListaFav">@@venda@@</div><div class="lblTipoListaFav">@@tipo@@</div><div class="lblQuartoListaFav">@@quarto@@</div><div class="lblVagaListaFav">@@vaga@@</div></div>';var M=new Number();var H=new Number();var L="";var N="";var G="";var K="";var J="";var I="";M=this.sale_amount;L=this.sale_flag?addCommas(M):"-";H=this.rent_amount;N=this.rent_flag?addCommas(H):"-";strQuartos=(this.bedrooms_qty<=1)?this.bedrooms_qty+" qt":this.bedrooms_qty+" qts";K=(this.parking_spaces_qty<=1)?this.parking_spaces_qty+" vg":this.parking_spaces_qty+" vgs";I=(this.type_cd==1)?"Casa":"Apartamento";if(this.bedrooms_qty<1){strQuartos=""}if(this.parking_spaces_qty<0){K=""}str=str.replace(/@@figura@@/,this.pic);str=str.replace(/@@lancamento@@/,J);str=str.replace(/@@venda@@/,L);str=str.replace(/@@aluguel@@/,N);str=str.replace(/@@quarto@@/,strQuartos);str=str.replace(/@@vaga@@/,K);str=str.replace(/@@tipo@@/,I);str=str.replace(/@@i@@/,this.property_id);str=str.replace(/@@propId@@/,this.property_id);str=str.replace(/@@propId2@@/,this.property_id);str=str.replace(/@@propId3@@/,this.property_id);str=str.replace(/@@propId4@@/,this.property_id);str=str.replace(/@@propId5@@/,this.property_id);str=str.replace(/@@hash@@/,this.hash);str=str.replace(/@@hash1@@/,this.hash);return str};this.loadFromNode=function(G){this.property_id=G.getAttribute("property_id");this.hash=G.getAttribute("hash");this.latitude=G.getAttribute("latitude");this.longitude=G.getAttribute("longitude");this.pic=unescape(G.getAttribute("pic"));this.type_cd=G.getAttribute("type_cd");this.bedrooms_qty=G.getAttribute("bedrooms_qty");this.suites_qty=G.getAttribute("suites_qty");this.parking_spaces_qty=G.getAttribute("parking_spaces_qty");this.rent_amount=G.getAttribute("rent_amount");this.sale_amount=G.getAttribute("sale_amount");this.comdominium_charge=G.getAttribute("comdominium_charge");this.area=G.getAttribute("area");this.rent_flag=G.getAttribute("rent_flag");this.sale_flag=G.getAttribute("sale_flag");this.launch_flag=G.getAttribute("launch_flag");this.neighborhood=G.getAttribute("neighborhood");this.logo=unescape(G.getAttribute("logo"));this.address=unescape(G.getAttribute("address"));this.city=unescape(G.getAttribute("city"));this.property_long_desc=unescape(G.getAttribute("property_long_desc"));if(this.sale_amount<1){this.sale_amount=NOT_AVAILABLE}if(this.rent_amount<1){this.rent_amount=NOT_AVAILABLE}};this.reportPropError=function(){var H="/imoveis/reportPropError/";if(!popupReport.validateSelectedError()){popupReport.setFocus("errorCd",0);return 0}if(!popupReport.validateEmail()){popupReport.setFocus("email",0);return 0}if(!popupReport.validateCaptcha()){popupReport.setFocus("captcha",0);return 0}var G="data[PropertyError][property_id]="+this.property_id+"&data[PropertyError][property_error_cd]="+popupReport.getErrorCdValue()+"&data[PropertyError][reporter_email]="+encodeURIComponent(popupReport.getEmailTxtValue())+"&data[PropertyError][description]="+url_encode(popupReport.getReportErrorDesc())+"&data[PropertyError][captchaTxt]="+encodeURIComponent(popupReport.getCaptchaTxtValue());popupReport.disableBtn(true);popupReport.displayFeedback(true);GDownloadUrl(H,this.processReportError,G,"application/x-www-form-urlencoded")};this.processReportError=function(G){popupReport.displayFeedback(false);popupReport.disableBtn(false);if(G.indexOf("@@ErrorReportSaved@@")>-1){popupReport.showInstruct("Agradecemos a sua colaboração.");setTimeout("popupReport.setVisible(0);",2000)}if(G.indexOf("@@CaptchaFailed@@")>-1){popupReport.changeCaptchaImg(1);popupReport.setFocus("captcha",1);popupReport.showInstruct("Código incorreto, tente novamente.")}else{if(G.indexOf("@@NOTSaved@@")>-1){popupReport.showInstruct("Não foi possível cadastrar o erro do anúncio, tente outra vez mais tarde.")}}}}function MarkerCluster(){this.latitude=0;this.longitude=0;var B;var E;var A;this.clusterItems=new Array();that=this;showBubble=function(H,I){var G=C(markerClusters[I].clusterItems,H,I);bubble.openOnMarker(markerClusters[I].getGoogleMarker(),G)};showBubbleById=function(I){for(var G=0;G<markerClusters.length;G++){for(var H=0;H<markerClusters[G].clusterItems.length;H++){if(markerClusters[G].clusterItems[H].property_id==I){showBubble(H,G)}}}};this.getGoogleMarker=function(){return B};this.createGoogleMarker=function(G){D(markerClusters[G].latitude,markerClusters[G].longitude);F(markerClusters[G].clusterItems);var H=C(markerClusters[G].clusterItems,0,G);B=new GMarker(A,E);GEvent.addListener(B,"click",function(){showBubble(0,G)})};this.setPoint=D;function D(H,G){A=new GLatLng(H,G)}function F(H){var G=1;if(H.length==1&&H[0].type_cd==1){G=1}else{if(H.length==1&&H[0].type_cd==2){G=2}else{if(H.length>1&&H[0].type_cd==2){G=3;for(i=0;i<H.length;i++){if(H[i].type_cd==1){G=5}}}else{if(H.length>1&&H[0].type_cd==1){G=4;for(i=0;i<H.length;i++){if(H[i].type_cd==2){G=5}}}}}}E=new GIcon();switch(G){case 1:E.image="img/marca_pequena.png";E.shadow="img/marca_sombra_pequena.png";E.iconSize=new GSize(24,29);E.shadowSize=new GSize(43,28);E.iconAnchor=new GPoint(12,29);E.infoWindowAnchor=new GPoint(8,17);break;case 2:E.image="img/marca_apartamento.png";E.shadow="img/marca_apartamento_sombra.png";E.iconSize=new GSize(27,40);E.shadowSize=new GSize(45,40);E.iconAnchor=new GPoint(13,40);E.infoWindowAnchor=new GPoint(14,25);break;case 3:E.image="img/cluster_apartamento_"+H.length+".png";E.shadow="img/cluster_apartamento_sombra.png";E.iconSize=new GSize(38,53);E.shadowSize=new GSize(55,64);E.iconAnchor=new GPoint(19,53);E.infoWindowAnchor=new GPoint(19,30);break;case 4:E.image="img/cluster_casa_"+H.length+".png";E.shadow="img/cluster_casa_sombra.png";E.iconSize=new GSize(32,37);E.shadowSize=new GSize(49,46);E.iconAnchor=new GPoint(12,37);E.infoWindowAnchor=new GPoint(8,17);break;case 5:E.image="img/cluster_apartamento_casa_"+H.length+".png";E.shadow="img/cluster_apartamento_casa_sombra.png";E.iconSize=new GSize(38,53);E.shadowSize=new GSize(54,64);E.iconAnchor=new GPoint(19,53);E.infoWindowAnchor=new GPoint(19,30);break}}function C(G,J,M){if(G.length==1){var L=G[0].strMarkerHTML}else{if(G.length>1){var L='<div class="corpoBalao"><div class="topoBalao"></div>'+G[J].strMarkerHTML+'<div id="bubblePagination">@@prevButton@@@@lblPagina@@@@nextButton@@</div></div>';var I='<div class="lblPageBalao"><span >'+(J*1+1)+"</span><span>&nbsp</span>de<span>&nbsp</span><span>"+G.length+"</span></div>";if(J>0){var H='<a href="javascript:showBubble('+(J*1-1)+", "+M+');"><div class="linkPrevBalao">	</div></a>'}else{var H=""}if(J<(G.length-1)){var K='<a href="javascript:showBubble('+(J*1+1)+", "+M+');"><div class="linkNextBalao"> </div></a>'}else{var K=""}L=L.replace(/@@prevButton@@/,H);L=L.replace(/@@lblPagina@@/,I);L=L.replace(/@@nextButton@@/,K)}}return L}}function MainList(){var currentPage=1;var pageLen=15;var totalResults=0;var orderingType=-1;this.propIdWithError=-1;markers=new Array();markerClusters=new Array();this.getOrderingType=getOrderingType;function getOrderingType(){return orderingType}this.setOrderingType=setOrderingType;function setOrderingType(type){orderingType=type}this.getCurrentPage=getCurrentPage;function getCurrentPage(){return currentPage}this.setCurrentPage=setCurrentPage;function setCurrentPage(page){currentPage=page}this.startLoading=startLoading;function startLoading(){document.getElementById("listaImoveis").innerHTML="";document.getElementById("loadingFeedBack").style.display="block";document.getElementById("loadingFeedBack").style.top="430px";document.getElementById("loadingFeedBack").style.left="50%";bubble.hide();showNavigator(false)}onEndFindResults="";this.setOnEndFindResults=function(script){onEndFindResults=script};this.reportError=function(propId){this.propIdWithError=propId;popupReport.setVisible(1);popupReport.setPopupTop();popupReport.ie6LayerHack();popupReport.setFocus("errorCd",0)};this.addMarker=addMarker;function addMarker(marker){markers.push(marker)}this.clearAllMarkerClusters=clearAllMarkerClusters;function clearAllMarkerClusters(){for(i=0;i<markerClusters.length;i++){map.removeOverlay(markerClusters[i].getGoogleMarker())}markerClusters=[];markers=[]}this.clearAllMarkers=clearAllMarkers;function clearAllMarkers(){while(markers.length>0){markers.pop().getGoogleMarker()}map.clearOverlays()}this.popMarkeCluster=popMarkerCluster;function popMarkerCluster(){map.removeOverlay(markerClusters.pop().getGoogleMarker())}this.findFirstResults=findFirstResults;function findFirstResults(){currentPage=1;this.findResults()}this.findResults=findResults;function findResults(){startLoading();var currentFilter=new Filter();currentFilter=homeFilter.getCurrent();var typeCdArg=0;typeCdArg=currentFilter.houseFlag?2:typeCdArg;typeCdArg=currentFilter.apartmentFlag?(typeCdArg+4):typeCdArg;var launchFlagArg=0;var forSaleFlagArg=0;var forRentFlagArg=0;if(currentFilter.buyRent==1){forSaleFlagArg=1}else{if(currentFilter.buyRent==0){forRentFlagArg=1}}var bedroosmQtyArg=0;bedroosmQtyArg=document.getElementById("chk4Quarto").checked?16:bedroosmQtyArg;bedroosmQtyArg=document.getElementById("chk3Quarto").checked?(bedroosmQtyArg+8):bedroosmQtyArg;bedroosmQtyArg=document.getElementById("chk2Quarto").checked?(bedroosmQtyArg+4):bedroosmQtyArg;bedroosmQtyArg=document.getElementById("chk1Quarto").checked?(bedroosmQtyArg+2):bedroosmQtyArg;var spacesQtyArg=0;spacesQtyArg=document.getElementById("chk3Vaga").checked?8:spacesQtyArg;spacesQtyArg=document.getElementById("chk2Vaga").checked?(spacesQtyArg+4):spacesQtyArg;spacesQtyArg=document.getElementById("chk1Vaga").checked?(spacesQtyArg+2):spacesQtyArg;spacesQtyArg=document.getElementById("chk0Vaga").checked?(spacesQtyArg+1):spacesQtyArg;var minValue=-1;minValue=currentFilter.minValue;if(minValue==0){minValue=-1}var maxValue=-1;maxValue=currentFilter.maxValue;if(maxValue==0){maxValue=-1}var userId=-1;if(currentFilter.check==1&&currentFilter.userId!=-1){userId=currentFilter.userId}var url="/imoveis/find/"+map.getBounds().getSouthWest().lat()+"/"+map.getBounds().getNorthEast().lat()+"/"+map.getBounds().getSouthWest().lng()+"/"+map.getBounds().getNorthEast().lng()+"/"+typeCdArg+"/"+launchFlagArg+"/"+bedroosmQtyArg+"/"+spacesQtyArg+"/"+forRentFlagArg+"/"+forSaleFlagArg+"/"+minValue+"/"+maxValue+"/"+currentPage+"/"+pageLen+"/"+orderingType+"/"+userId;GDownloadUrl(url,this.processFindResults)}this.processFindResults=function(data){clearAllMarkerClusters();pos=data.indexOf("<!--");data=(pos==-1)?data:data.substring(0,pos);var xml=GXml.parse(data);var xmlMarkers=xml.documentElement.getElementsByTagName("marker");var xmlCountTags=xml.documentElement.getElementsByTagName("count");if(xmlCountTags.length>0){totalResults=xmlCountTags[0].getAttribute("value")*1;if(xmlMarkers.length>2){showNavigator(true)}}for(var i=0;i<xmlMarkers.length;i++){var marker=new Marker();marker.loadFromNode(xmlMarkers[i]);marker.createGoogleMarker();addMarker(marker)}eval(onEndFindResults)};function pxDistance(marker1,marker2){var sw=map.getBounds().getSouthWest();var ne=map.getBounds().getNorthEast();var mapCoordHeight=Math.abs(ne.lat()-sw.lat());var mapCoordWidth=Math.abs(ne.lng()-sw.lng());var cte=mapCoordWidth/600;var dx=marker2.latitude*1-marker1.latitude*1;var dy=marker2.longitude*1-marker1.longitude*1;var distCoord=Math.sqrt(dx*dx+dy*dy);return distCoord/cte}function px2Coord(px){var sw=map.getBounds().getSouthWest();var ne=map.getBounds().getNorthEast();var mapCoordHeight=Math.abs(ne.lat()-sw.lat());var mapCoordWidth=Math.abs(ne.lng()-sw.lng());var cte=mapCoordWidth/600;return cte*px}this.print=print;function print(){document.getElementById("loadingFeedBack").style.display="none";html="";if(markers.length>0){for(var i=0;i<markers.length;i++){html=html+markers[i].getMainHTML()}}else{html='<div style="margin-left:100px; margin-top:10px;">Não encontramos nenhum anúncio com esses critérios nessa região.<br/><br/>Sugestões:<ul><li>Use outros critérios de busca ou</li><li>Diminua o zoom ou</li><li>Reposicione o mapa ou</li><li><a href=\'#topo\' onclick="regionSubscribe.subscribe()" >Clique aqui</a> e cadastre alertas de novos anúncios na região</li></ul></div>'}document.getElementById("listaImoveis").innerHTML=html;document.getElementById("resultadoDe2").innerHTML=(totalResults==0)?"0 ":(currentPage-1)*pageLen+1+" ";document.getElementById("resultadoDe3").innerHTML=(totalResults==0)?"0 ":(currentPage-1)*pageLen+1+" ";document.getElementById("resultadoAte2").innerHTML=(pageLen*currentPage<totalResults)?pageLen*currentPage:totalResults;document.getElementById("resultadoAte3").innerHTML=(pageLen*currentPage<totalResults)?pageLen*currentPage:totalResults;document.getElementById("resultadoTotal2").innerHTML=totalResults;document.getElementById("resultadoTotal3").innerHTML=totalResults}this.groupMarkers=groupMarkers;function groupMarkers(){var lowerPxDistance=15;var maxPxDistanceAllowed=15;var clusterPair=new Array();var makeCluster=false;for(var i=0;i<markers.length;i++){markerClusters[i]=new MarkerCluster();markerClusters[i].clusterItems[0]=markers[i];markerClusters[i].latitude=markers[i].latitude;markerClusters[i].longitude=markers[i].longitude}while(lowerPxDistance<=maxPxDistanceAllowed&&markerClusters.length>1){lowerPxDistance=9999;makeCluster=false;for(var i=0;i<markerClusters.length;i++){for(var j=i+1;j<markerClusters.length;j++){var newDistance=(pxDistance(markerClusters[i],markerClusters[j]));if(newDistance<maxPxDistanceAllowed){clusterPair[0]=i;clusterPair[1]=j;lowerPxDistance=newDistance;makeCluster=true}}}if(makeCluster==true){markerClusters[clusterPair[0]].clusterItems=markerClusters[clusterPair[0]].clusterItems.concat(markerClusters[clusterPair[1]].clusterItems);markerClusters[clusterPair[0]].latitude=(markers[clusterPair[0]].latitude*1+markers[clusterPair[1]].latitude*1)/2;markerClusters[clusterPair[0]].longitude=(markers[clusterPair[0]].longitude*1+markers[clusterPair[1]].longitude*1)/2;markerClusters.splice(clusterPair[1],1);makeCluster=false}}for(var i=0;i<markerClusters.length;i++){markerClusters[i].createGoogleMarker(i)}}this.displayMarkerClusters=displayMarkerClusters;function displayMarkerClusters(){for(var i=0;i<markerClusters.length;i++){map.addOverlay(markerClusters[i].getGoogleMarker())}}this.displayMarkers=displayMarkers;function displayMarkers(){for(var i=0;i<markers.length;i++){map.addOverlay(markers[i].getGoogleMarker())}}this.getMarkerById=function(id){for(var i=0;i<markers.length;i++){if(markers[i].property_id==id){return markers[i]}}return 0};this.next=function(){if(((currentPage*pageLen)+1)<=totalResults){currentPage++;homeFilter.addToSession();this.findResults()}};this.prev=function(){if(currentPage>1){currentPage--;homeFilter.addToSession();this.findResults()}};this.orderListBy=function(i){if(i==1){var optionListA=document.getElementById("orderingType1");var optionListB=document.getElementById("orderingType2")}else{var optionListA=document.getElementById("orderingType2");var optionListB=document.getElementById("orderingType1")}orderingType=optionListA.options[optionListA.selectedIndex].value;optionListB.options[optionListA.selectedIndex].selected=true;if(homeFilter.getCurrent().buyRent==0&&(orderingType==100||orderingType==101)){orderingType=parseInt(orderingType)+2}newFilter=new Filter();newFilter.loadFromHtml();newFilter.action="Nova ordem";homeFilter.addFilter(newFilter);homeFilter.addToSession();this.findFirstResults()};function showNavigator(show){var nav=document.getElementById("tituloLista2");if(show){nav.style.display="block"}else{nav.style.display="none"}}}function FavoriteList(){this.maxLen=10;favMarkers=new Array(arguments.length);for(i=0;i<arguments.length;i++){favMarkers[i]=favMarkers[i]}this.addMarker=B;function B(G){favMarkers.push(G)}this.setFormVisible=function(){if(favMarkers.length==0){alert("Adicione imóveis na sua lista de favoritos e envie a lista por e-mail.")}else{popupFavorites.setVisible(1);popupFavorites.ie6LayerHack();popupFavorites.setFocus("email",0)}};this.animatedAddMarker=function(I){if(F(I)){alert("Este imóvel já foi definido como favorito.");return 0}if(favMarkers.length>=this.maxLen){alert("Só é possível definir"+this.maxLen+"imóveis favoritos.");return 0}var J=document.getElementById("divAnimation");var H=document.documentElement.clientWidth/2-450;var G=535;J.style.top=(yMousePos-90)+"px";J.style.left=xMousePos+"px";J.style.display="block";D(J,xMousePos,H,yMousePos-90,G,25,10,0.8,I)};function D(G,K,P,H,O,N,J,M,L){if(G.posChangeMemInt){window.clearInterval(G.posChangeMemInt)}var I=0;G.posChangeMemInt=window.setInterval(function(){G.currentLeft=E(K,P,N,I,M);G.style.left=G.currentLeft+"px";G.currentTop=E(H,O,N,I,M);G.style.top=G.currentTop+"px";I++;if(I>N){window.clearInterval(G.posChangeMemInt);document.getElementById("divAnimation").style.display="none";B(L);C();A()}},J)}function E(J,L,K,I,G){var M=L-J;var H=J+(Math.pow(((1/K)*I),G)*M);return Math.ceil(H)}this.animatedAddMarkerAntigo=function(I){if(F(I)){alert("Este imóvel já foi definido como favorito.");return 0}if(favMarkers.length>=this.maxLen){alert("Só é possível definir"+this.maxLen+"imóveis favoritos.");return 0}var H={points:{from:[xMousePos,yMousePos-90],to:[document.documentElement.clientWidth/2-450,520]}};var J=new YAHOO.util.Motion("divAnimation",H,0.5);var G=function(){document.getElementById("divAnimation").style.display="none";B(I);C();A()};J.onComplete.subscribe(G);document.getElementById("divAnimation").style.display="block";J.animate()};this.isFavorite=F;function F(G){for(j=0;j<favMarkers.length;j++){if(favMarkers[j].property_id==G.property_id){return true}}return false}this.removeMarker=function(G){for(j=0;j<favMarkers.length;j++){if(favMarkers[j].property_id==G.property_id){favMarkers.splice(j,1)}}C();A()};this.setFavorites=A;function A(){var G="imoveis/setFavorites/";for(j=0;j<favMarkers.length;j++){G=G+favMarkers[j].property_id;if(j!=(favMarkers.length-1)){G=G+","}}G=G+"/"+Math.ceil(Math.random()*100000);GDownloadUrl(G)}this.loadFromSession=function(){var G=new String();G="/imoveis/getFavorites/"+Math.ceil(Math.random()*100000);GDownloadUrl(G,this.processLoadFromSession)};this.processLoadFromSession=function(K){pos=K.indexOf("<!--");K=(pos==-1)?K:K.substring(0,pos);var I=GXml.parse(K);var H=I.documentElement.getElementsByTagName("marker");for(var J=0;J<H.length;J++){var G=new Marker();G.loadFromNode(H[J]);B(G)}C()};this.print=C;function C(){html="";for(var G=favMarkers.length-1;G>=0;G--){html=html+favMarkers[G].getFavoriteHTML()}document.getElementById("listaFavoritos").innerHTML=html}this.getMarkerById=function(H){for(var G=0;G<favMarkers.length;G++){if(favMarkers[G].property_id==H){return favMarkers[G]}}return 0};this.sendFavorites=function(){var H="";var G=document.getElementById("btnSendFavorites");for(j=0;j<favMarkers.length;j++){H=H+favMarkers[j].property_id;if(j!=(favMarkers.length-1)){H=H+","}}if(!popupFavorites.validateEmail(true)){popupFavorites.setFocus("email",0);return 0}if(!popupFavorites.validateCaptcha()){popupFavorites.setFocus("captcha",0);return 0}popupFavorites.disableBtn(true);popupFavorites.displayFeedback(true);url="/users/sendFavorites/"+popupFavorites.getEmailTxtValue()+"/"+H+"/"+popupFavorites.getCaptchaTxtValue()+"/"+Math.ceil(Math.random()*100000);GDownloadUrl(url,this.processSendFavorites)};this.processSendFavorites=function(G){popupFavorites.displayFeedback(false);popupFavorites.disableBtn(false);if(G.indexOf("@@FavoritesEmailSent@@")>-1){popupFavorites.showInstruct("Email enviado com sucesso.");setTimeout("popupFavorites.setVisible(0);",2000)}else{popupFavorites.changeCaptchaImg(1);if(G.indexOf("CaptchaFailed@@")>-1){popupFavorites.showInstruct("A imagem e o texo não conferem.");popupFavorites.setFocus("captcha",1)}else{popupFavorites.showInstruct("Não foi possível enviar o email, tente outra vez mais tarde.")}}}}function RegionSubscribe(){var E;subscribeActive=false;var D;var A;this.subscribe=function(){if(!subscribeActive){subscribeActive=true;B();dragZoom.initiateZoom()}};function C(M,I,O,T,U,G,S,P){if(typeof (dragZoom)!="undefined"){map.removeControl(dragZoom)}subscribeActive=false;if(map.getZoom()<12){alert("Selecione uma região menor. Aumente o zoom e tente novamente.")}else{var K=230;var L=map.getBounds().getSouthWest();var F=map.getBounds().getNorthEast();var Q=Math.abs(F.lat()-L.lat());var R=Q/250;var N=M.lat()-T.lat();var H=N/R;var J=K+H/2;E=new GPolygon([M,I,O,T,M],"#FC6600",2,1,"#FC6600",0.2);D=I;A=T;popupSubscribe.setVisible(1);popupSubscribe.setPopupTop(J);popupSubscribe.ie6LayerHack();popupSubscribe.setFocus("email",0);map.addOverlay(E)}}this.removePoly=function(){if(E!=null){map.removeOverlay(E)}};function B(){var H={opacity:0.2,border:"2px solid #CC6600"};var F={buttonStartingStyle:{height:"15px",padding:"4px",border:"solid 1px #DEDEDE",background:"#FFFFC8"},buttonHTML:'<strong ><font color="#000000">Clique aqui. </font><font color="#003399"><u>Para selecionar uma regiao.</u></font></strong>',buttonZoomingStyle:{height:"15px",padding:"4px",border:"solid 1px #DEDEDE",background:"#FFFFC8"},buttonZoomingHTML:'<strong ><font color="#000000">Selecione a região desejada</font></strong>',overlayRemoveTime:1,minDragSize:0};var G={buttonclick:function(){},dragend:function(K,P,N,I,J,M,L,O){C(K,P,N,I,J,M,L,O)}};if(typeof (dragZoom)!="undefined"){map.removeControl(dragZoom)}map.addControl(dragZoom=new DragZoomControl(H,F,G),new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(50,10)))}this.subscribeAlerts=function(){var K=-1;if(!popupSubscribe.validateEmail(true)){popupSubscribe.setFocus("email",0);return 0}if(!popupSubscribe.validateCaptcha()){popupSubscribe.setFocus("captcha",0);return 0}popupSubscribe.disableBtn(true);popupSubscribe.displayFeedback(true);var L=homeFilter.getCurrent();var J=0;J=L.houseFlag?2:J;J=L.apartmentFlag?(J+4):J;var F=0;var H=0;if(L.buyRent==1){F=1}else{if(L.buyRent==0){H=1}}var I=0;I=document.getElementById("chk4Quarto").checked?16:I;I=document.getElementById("chk3Quarto").checked?(I+8):I;I=document.getElementById("chk2Quarto").checked?(I+4):I;I=document.getElementById("chk1Quarto").checked?(I+2):I;var N=0;N=document.getElementById("chk3Vaga").checked?8:N;N=document.getElementById("chk2Vaga").checked?(N+4):N;N=document.getElementById("chk1Vaga").checked?(N+2):N;N=document.getElementById("chk0Vaga").checked?(N+1):N;var O=-1;O=L.minValue;var M=-1;M=L.maxValue;var G="/regionSubscribers/subscribe/"+A.lat()+"/"+D.lat()+"/"+A.lng()+"/"+D.lng()+"/"+popupSubscribe.getEmailTxtValue()+"/"+J+"/"+H+"/"+F+"/"+I+"/"+N+"/"+O+"/"+M+"/"+K+"/"+popupSubscribe.getCaptchaTxtValue()+"/";popupSubscribe.displayFeedback(true);GDownloadUrl(G,this.processSubscribeAlerts)};this.processSubscribeAlerts=function(F){popupSubscribe.displayFeedback(false);popupSubscribe.disableBtn(false);if(F.indexOf("@@SubscribedToRegion@@")>-1){popupSubscribe.showInstruct("Cadastro de alerta efetuado com sucesso.");setTimeout("popupSubscribe.setVisible(0); regionSubscribe.removePoly();",2000)}else{popupSubscribe.changeCaptchaImg(1);if(F.indexOf("CaptchaFailed@@")>-1){popupSubscribe.setFocus("captcha",1);popupSubscribe.showInstruct("A imagem e o texo não conferem.")}else{popupSubscribe.showInstruct("Não foi possível cadastrar o seu alerta, tente outra vez mais tarde.")}}}}function initialize(){if(GBrowserIsCompatible()){map.enableDoubleClickZoom();map.addControl(new GSmallMapControl());var A=new GLatLng(-15.62,-49.3);map.setCenter(A,3)}bubble=new EBubble(map,"img/bubble_pag.gif",new GSize(220,152),new GSize(220,152),new GPoint(0,0),new GPoint(125,0),true);homeFilter=new FilterHistory();mainList=new MainList();favoriteList=new FavoriteList();popupSubscribe=new StdPopup();popupSubscribe.popupId="regionSubscribePopup";popupSubscribe.instructId="popup_instrucoes_subscribe";popupSubscribe.captchaId="captcha_region";popupSubscribe.txtCaptchaId="captchaCodeAlert";popupSubscribe.msg="Cadastre <strong>divesas regiões</strong> e receba um <strong>único alerta diário</strong> com novos anuncios que atendam aos critérios usados na busca.<br/><br/>";popupSubscribe.msg+="Para interromper o envio de alertas, basta clicar no link <span class='linkLike'>'Cancelar alertas'</span> enviado em todos e-mails.";popupSubscribe.txtEmailId="emailSubscribe";popupSubscribe.btnId="btnSubscribeAlert";popupFavorites=new StdPopup();popupFavorites.popupId="favoritesSubscribe";popupFavorites.instructId="popup_instrucoes_favorites_subscribe";popupFavorites.captchaId="captcha_favorites";popupFavorites.txtCaptchaId="captchaCodeEmail";popupFavorites.msg="Simples assim: envie a lista dos anúncios favoritos para seu e-mail e feche o melhor negócio!";popupFavorites.txtEmailId="emailSendFavorites";popupFavorites.btnId="btnSendFavorites";popupReport=new StdPopup();popupReport.popupId="propErrorPopup";popupReport.instructId="propErrorInstruct";popupReport.captchaId="propErrorCaptcha";popupReport.txtCaptchaId="propErrorCaptchaTxt";popupReport.msg="Indique abaixo o problema encontrado no anúncio.";popupReport.txtEmailId="propErrorEmail";popupReport.errorCdId="propErrorSelect";popupReport.btnId="propErrorSendBtn";popupReport.txtReportErrorDescId="propErrorDetailTxt";StdPopup.popups=new Array(popupSubscribe,popupReport,popupFavorites);regionSubscribe=new RegionSubscribe();homeFilter.loadEvent=true;homeFilter.setOnEndLoadFromSession("mainList.findResults()");mainList.setOnEndFindResults("print();groupMarkers();displayMarkerClusters();");homeFilter.loadFromSession();favoriteList.loadFromSession();GEvent.addListener(map,"zoomend",function(){if(homeFilter.newEvent()){homeFilter.zoomEvent=true;homeFilter.onZoomEndScript()}});GEvent.addListener(map,"moveend",function(){if(homeFilter.newEvent()){homeFilter.moveEvent=true;homeFilter.onMoveEndScript()}homeFilter.resetEvents()})}window.onfocus=function(){};
