﻿URLAtual = "";
splitURLAtual = location.href.split("/");
for (xURLAtual = 3; xURLAtual < splitURLAtual.length; xURLAtual++) {
    URLAtual = URLAtual + splitURLAtual[xURLAtual] + "/";
}

AreaPrivativaInicialTemp = "";
AreaPrivativaFinalTemp = "";
MetroInicialTemp = "";
MetroFinalTemp = "";
MenuAberto = "";
ValorInicialTemp = "";
ValorFinalTemp = "";

/*if (window.captureEvents) {
    window.captureEvents(Event.CLICK);
        window.onclick = VerificaClique;
} else {
    document.onclick = VerificaClique;
}
*/

function CarregaHome(idSite) {
    if (idSite == "3") {
        location.href = "http://www.fmeraprontos.com.br/";
        //location.href = "/prontos";
    } else if (idSite == "2") {
        location.href = "http://www.fernandezmera.com.br/sol";
    } else {
        location.href = "/";
    }
}

function VerificaClique(e) {
    if (MenuAberto.length > 0) {
        SomeAbas();
    }
}

function SomeAbas() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
}

function VerificaSelecionadosAjax(Layer) {
    if (document.getElementById(Layer + "_FinalidadeSelecionado") != undefined) {
        Selecionados = document.getElementById(Layer + "_FinalidadeSelecionado").value;
        if (Selecionados.length > 0) {
            splitSelecionados = Selecionados.split("|");
            for (x = 0; x < splitSelecionados.length - 1; x++) {
                Valor = splitSelecionados[x];
                if (document.getElementById(Layer + "_busca_detalhada_finalidade_campo_finalidade_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_finalidade_campo_finalidade_" + (x + 1)).className.indexOf("zero") < 0) {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById("busca_detalhada_finalidade_finalidade_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById("busca_detalhada_finalidade_finalidade_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        if (Valor == SelecionadoAtual) {
                            splitValor = document.getElementById(Layer + "_busca_detalhada_finalidade_refinarbusca2").innerHTML.split("layer_refinarbusca_FinalidadeRepetidor_ctl");
                            for (y = 0; y < splitValor.length; y++) {
                                if (y < 10) {
                                    ValorY = "0" + y;
                                } else {
                                    ValorY = y;
                                }
                                if (document.getElementById(Layer + "_FinalidadeRepetidor_ctl" + ValorY + "_busca_detalhada_finalidade_img_finalidade") != undefined) {
                                    document.getElementById(Layer + "_FinalidadeRepetidor_ctl" + ValorY + "_busca_detalhada_finalidade_img_finalidade").style.display = "block";
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (document.getElementById(Layer + "_TipoSelecionado") != undefined) {
        Selecionados = document.getElementById(Layer + "_TipoSelecionado").value;
        if (Selecionados.length > 0) {
            splitSelecionados = Selecionados.split("|");
            splitValor = document.getElementById(Layer + "_busca_detalhada_tipo_refinarbusca2").innerHTML.split("layer_refinarbusca_TipoRepetidor_ctl");
            for (x = 0; x < splitSelecionados.length - 1; x++) {
                Valor = splitSelecionados[x];                
                for (y = 0; y < splitValor.length; y++) {
                    if (y < 10) {
                        ValorY = "0" + y;
                    } else {
                        ValorY = y;
                    }
                    if (document.getElementById(Layer + "_TipoRepetidor_ctl" + ValorY + "_busca_detalhada_tipo_img_tipo") != undefined) {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById("busca_detalhada_tipo_tipo_" + (y + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById("busca_detalhada_tipo_tipo_" + (y + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        if (Valor == SelecionadoAtual) {
                            document.getElementById(Layer + "_TipoRepetidor_ctl" + ValorY + "_busca_detalhada_tipo_img_tipo").style.display = "block";
                        }
                    }
                }
                
                if (document.getElementById(Layer + "_busca_detalhada_tipo_campo_tipo_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_tipo_campo_tipo_" + (x + 1)).className.indexOf("zero") < 0) {
                        if (document.getElementById(Layer + "_TipoRepetidor_ctl" + Valor + "_busca_detalhada_tipo_img_tipo") != undefined) {
                            if (document.all) {
                                SelecionadoAtual = document.getElementById("busca_detalhada_tipo_tipo_" + (x + 1)).innerText;
                            } else {
                                SelecionadoAtual = document.getElementById("busca_detalhada_tipo_tipo_" + (x + 1)).textContent;
                            }
                            if (SelecionadoAtual.length > 0) {
                                if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                    SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                                }
                            }
                            if (Valor == SelecionadoAtual) {
                                splitValor = document.getElementById(Layer + "_busca_detalhada_tipo_refinarbusca2").innerHTML.split("layer_refinarbusca_TipoRepetidor_ctl");
                                for (y = 0; y < splitValor.length; y++) {
                                    if (y < 10) {
                                        ValorY = "0" + y;
                                    } else {
                                        ValorY = y;
                                    }
                                    if (document.getElementById(Layer + "_TipoRepetidor_ctl" + ValorY + "_busca_detalhada_tipo_img_tipo") != undefined) {
                                        document.getElementById(Layer + "_TipoRepetidor_ctl" + ValorY + "_busca_detalhada_tipo_img_tipo").style.display = "block";
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }
    }
    if (document.getElementById(Layer + "_EstagioObraSelecionado") != undefined) {
        Selecionados = document.getElementById(Layer + "_EstagioObraSelecionado").value;
        if (Selecionados.length > 0) {
            splitSelecionados = Selecionados.split("|");
            for (x = 0; x < splitSelecionados.length - 1; x++) {
                if (x < 10) {
                    Valor = "0" + splitSelecionados[x];
                } else {
                    Valor = splitSelecionados[x];
                }
                if (document.getElementById(Layer + "_busca_detalhada_estagio_campo_estagio_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_estagio_campo_estagio_" + (x + 1)).className.indexOf("zero") < 0) {
                        if (document.getElementById(Layer + "_EstagioObraRepetidor_ctl" + Valor + "_busca_detalhada_estagio_img_estagio") != undefined) {
                            document.getElementById(Layer + "_EstagioObraRepetidor_ctl" + Valor + "_busca_detalhada_estagio_img_estagio").style.display = "block";
                        }
                    }
                }
            }
        }
    }
    if (document.getElementById(Layer + "_DormitoriosSelecionado") != undefined) {
        Selecionados = document.getElementById(Layer + "_DormitoriosSelecionado").value;
        if (Selecionados.length > 0) {
            splitSelecionados = Selecionados.split("|");
            for (x = 0; x < splitSelecionados.length - 1; x++) {
                if (x < 10) {
                    Valor = "0" + splitSelecionados[x];
                } else {
                    Valor = splitSelecionados[x];
                }
                if (document.getElementById(Layer + "_busca_detalhada_dorms_campo_dorms_" + (x + 1)).className.indexOf("zero") != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_dorms_campo_dorms_" + (x + 1)).className.indexOf("zero") < 0) {
                        if (document.getElementById(Layer + "_DormitoriosRepetidor_ctl" + Valor + "_busca_detalhada_dorms_img_dorms") != undefined) {
                            document.getElementById(Layer + "_DormitoriosRepetidor_ctl" + Valor + "_busca_detalhada_dorms_img_dorms").style.display = "block";
                        }
                    }
                }
            }
        }
    }
}

function DestacaCidade(Objeto, Acao) {
    if (Acao == "over") {
        Objeto.style.cursor = "pointer";
        Objeto.style.backgroundColor = "#f0ecec";
        Objeto.style.color = "#eb1c24";
    } else {
        Objeto.style.cursor = "default";
        Objeto.style.backgroundColor = "";
        Objeto.style.color = "#777777";
    }
}

function VerificaSelecionadoDestaques(Objeto, Acao, Opcao, idSite, id) {
    if (idSite != "3") {
        if ((document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
            if (Acao == "over") {
                Objeto.style.cursor = "pointer";
            } else {
                Objeto.style.cursor = "default";
            }
        }
    } else {
        if ((document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
        if (Acao == "over") {
                Objeto.style.cursor = "pointer";
            } else {
                Objeto.style.cursor = "default";
            }
        }
    }
}

function SelecionaDestaques(Objeto, Opcao, idSite, id) {
    if (idSite != "3") {
        if ((document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
            for (x = 1; x <= 5; x++) {
                document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.backgroundColor = "#ffffff";
                if ((document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
                    document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color = "#444444";
                } else {
                    document.getElementById("home_empreendimentos_rolagem_menu_0" + x).style.color = "#b2b2b2";
                }
                document.getElementById("home_empreendimentos_rolagem_02_" + x).style.display = "none";
            }
            document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.backgroundColor = "#ec1c24";
            document.getElementById("home_empreendimentos_rolagem_menu_0" + Opcao).style.color = "#ffffff";
            document.getElementById("home_empreendimentos_rolagem_02_" + Opcao).style.display = "block";
        }
    } else {
        if ((document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
            for (x = 1; x <= 2; x++) {
                if (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x) != undefined) {
                    document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.backgroundColor = "#ffffff";
                    if ((document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color.toLowerCase() == "#ffffff") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color.toLowerCase() == "#444444") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color.toLowerCase() == "rgb(68, 68, 68)") || (document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color.toLowerCase() == "rgb(255, 255, 255)")) {
                        document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color = "#444444";
                    } else {
                        document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + x).style.color = "#b2b2b2";
                    }
                    document.getElementById("home_empreendimentos_rolagem_prontos_" + id + "_02_" + x).style.display = "none";
                }
            }
            document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.backgroundColor = "#ec1c24";
            document.getElementById("home_empreendimentos_rolagem_menu_prontos_" + id + "_0" + Opcao).style.color = "#ffffff";
            document.getElementById("home_empreendimentos_rolagem_prontos_" + id + "_02_" + Opcao).style.display = "block";
        }
    }
}

function ExibeDadosFavoritos() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "block";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeFavoritos(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }    
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_menu_02_04_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-favoritos']);
            ExibeDadosFavoritos();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function SomeDadosFichaProduto() {
    if (document.getElementById("indique_amigo") != undefined) {
        document.getElementById("indique_amigo").style.display = "none";        
    }
    if (document.getElementById("compartilhe_amigo") != undefined) {
        document.getElementById("compartilhe_amigo").style.display = "none";
    }
    if (document.getElementById("saiba_mais_produto") != undefined) {
        document.getElementById("saiba_mais_produto").style.display = "none";
    }
    if (document.getElementById("ligamos_para_voce") != undefined) {
        document.getElementById("ligamos_para_voce").style.display = "none";
    }
    if (document.getElementById("ligamos_para_voce") != undefined) {
        document.getElementById("ligamos_para_voce").style.display = "none";
    }
}

function SomeDadosErro() {
    if (document.getElementById("fale_conosco") != undefined) {
        document.getElementById("fale_conosco").style.display = "none";
    }
}

function ExibeDadosCidades() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "block";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeCidades(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_menu_03_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-alterar-cidade']);
            ExibeDadosCidades();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function ExibeDadosMaisContatos() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "block";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeMaisContatos(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_menu_02_02_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-mais-contatos']);
            ExibeDadosMaisContatos();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

ValorTelaAtual = 0;
ValorTelaAtual2 = 0;
ObjetoAtual = null;

function FadeON() {    
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";    
    ValorTelaAtual = ValorTelaAtual + 5;
    if (ValorTelaAtual <= 100) {
        timerID = setTimeout("FadeON()", 2);
    } else {

    }
}

function ExibeDadosEstilos() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "block";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();    
}

function ExibeEstilos(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-estilos']);
            ExibeDadosEstilos();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function ExibeDadosBuscaDetalhada() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "block";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeBuscaDetalhada(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);   
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-busca-detalhada']);
            ExibeDadosBuscaDetalhada();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function ExibeDadosIdioma() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "block";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set2.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function SelecionaIdioma(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_01_idioma_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-idiomas']);
            ExibeDadosIdioma();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function ExibeDadosTudoEmUmClique() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "block";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red2.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function SelecionaUmClique(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_05_box_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);               
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-tudo-em-um-clique']);
            ExibeDadosTudoEmUmClique();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function ExibeDadosLogin() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "block";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set2.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeDadosIntranet() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "block";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set2.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function SelecionaLogin(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_01_login_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-login']);
            ExibeDadosLogin();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function SelecionaIntranet(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_intranet_lista").style.display == "block") {
        if (Status == 0) {
            FechaTodasAbas();
            FechaSugestoes();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueFalse()", 250);
        }
    } else {
        _gaq.push(['_trackPageview', '/aba-intranet']);
        ExibeDadosIntranet();
        FechaAbasPesquisa();
        timerCLIQUE = setTimeout("CliqueTrue()", 250);
    }
}

function AlteraIdioma(Idioma) {
    location.href = "/alterar-idioma/" + Idioma.toString().toLowerCase();
    //location.href = "/alterar_idioma.aspx?Idioma=" + Idioma.toString().toLowerCase();
}

//window.onresize = VerificaFundoPreto;

function VerificaFundoPreto() {
    if (document.getElementById("fundo_preto").style.display == "block") {
        ExibeFundoPreto();
    }
}

function ExibeFundoPreto() {     
    var outer = document.createElement('div');   
    outer.style.position = "absolute";   
    outer.style.top = "0px";   
    outer.style.left = "0px";   
    outer.style.visibility = "hidden";   
    outer.style.width = "100%";   
    outer.style.height = "100%";   
    outer.style.overflow = "scroll";
    document.body.appendChild(outer);
    var w1 = outer.offsetWidth;       
    var w2 = outer.offsetHeight;
    document.body.removeChild(outer);
    document.getElementById("fundo_preto").style.display = "block";
    document.getElementById("fundo_preto").style.width = w1 + "px";
    document.getElementById("fundo_preto").style.height = w2 + "px";
}

function MudaCorEstilo(Objeto, Acao) {
    if (Acao == "over") {
        Objeto.style.backgroundColor = "#f0ecec";
    } else {
        Objeto.style.backgroundColor = "";
    }
}

function MudaCorTudoClique(Objeto, Acao, Cor) {
    if (Acao == "over") {
        Objeto.style.backgroundColor = "#f0ecec";
        Objeto.style.color = "#eb1c24";
    } else {
        Objeto.style.backgroundColor = "";
        Objeto.style.color = Cor;
    }
}

function MudaCorIdioma(Objeto, Acao, Cor) {
    if (Acao == "over") {
        Objeto.style.color = "#eb1c24";
    } else {
        Objeto.style.color = Cor;
    }
}

function SelecionaEstilo(Estilo) {
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    location.href = "/estilo/" + FormataURL(Estilo.toString().toLowerCase());
}

function FormataURL(Valor) {
    while (Valor.indexOf(" ") >= 0) {
        Valor = Valor.replace(" ", "-");
    }
    while (Valor.indexOf("/") >= 0) {
        Valor = Valor.replace("/", "-");
    }
    while (Valor.indexOf("+") >= 0) {
        Valor = Valor.replace("+", "-");
    }
    return Valor;
}

function VerificaSelecaoEstado(Objeto, Acao, Layer) {
    //if (Layer == "layer_topo") {
        return;
    //}
    //if (document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display == "none") {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
        //}
}

function VerificaSelecaoCidade(Objeto, Acao, Layer) {
    //if (Layer == "layer_topo") {
        return;
    //}
    //if (document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display == "none") {        
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
        //}
}

function VerificaSelecaoBairroRegiao(Objeto, Acao, Layer) {
    if (Layer == "layer_refinarbusca") {
        return;
    }
    //if (document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display == "none") {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
        //}
}

function VerificaSelecaoOutrasPropriedades(Objeto, Acao) {
    //if (document.getElementById("layer_topo_busca_detalhada_outras_propriedades_lista").style.display == "none") {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
    //}
}


function SelecionaAbaCidade(Layer) {
    //if (Layer == "layer_topo") {
        return;
    //}
    if (document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display == "none") {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosAbaCidade(Layer);
    } else {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosAbaEstado(Layer);
    }
}

function SelecionaAbaEstado(Layer) {
    if (Layer == "layer_topo") {
        return;
    }
    if (document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display == "none") {
        ExibeDadosBuscaDetalhada();
        ExibeDadosAbaEstado(Layer);
    } else {
        ExibeDadosBuscaDetalhada();
        ExibeDadosAbaCidade(Layer);
    }    
}

function ExibeDadosAbaCidade(Layer) {
    if (Layer == "layer_topo") {
        return;
    }
    document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_cidade_opcoes").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_estado").style.marginBottom = "5px";
    document.getElementById(Layer + "_busca_detalhada_cidade").style.marginBottom = "0px";
    document.getElementById(Layer + "_busca_detalhada_estado").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_cidade").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").src = "/imgs/topo/set2.png";
    document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").src = "/imgs/topo/set.png";
    if (Layer == "layer_refinarbusca") {
        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display = "none";
        document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.marginBottom = "5px";
        document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_opcoes").style.display = "none";
    }    
}

function SelecionaCidade(Objeto, Layer) {
    if (document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display == "none") {
        ExibeDadosAbaCidade(Layer);
    } else {
        SelecionaEstado(document.getElementById(Layer + "_busca_detalhada_estado"), Layer);
    }
}

function ExibeDadosAbaEstado(Layer) {
    document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_cidade_opcoes").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_estado").style.marginBottom = "0px";
    document.getElementById(Layer + "_busca_detalhada_estado").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_cidade").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").src = "/imgs/topo/set.png";
    document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").src = "/imgs/topo/set2.png";
}

function SelecionaEstado(Objeto, Layer) {
    return;
    if (document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display == "none") {
        ExibeDadosAbaEstado(Layer);
        if (Layer == "layer_refinarbusca") {
            document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display = "none";
            document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.marginBottom = "0px";
            document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
            document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
            document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").src = "/imgs/topo/set.png";
            document.getElementById(Layer + "_busca_detalhada_bairro_regiao_opcoes").style.display = "none";
        }
    } else {
        SelecionaCidade(document.getElementById(Layer + "_busca_detalhada_cidade"), Layer);
    }
}

function ExibeBairroRegiao(Layer) {
    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.marginBottom = "0px";
    document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_opcoes").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").src = "/imgs/topo/set2.png";
    if (Layer == "layer_topo") {
        document.getElementById(Layer + "_busca_detalhada_outras_propriedades_lista").style.display = "none";
        document.getElementById(Layer + "_busca_detalhada_outras_propriedades").style.display = "block";
        document.getElementById(Layer + "_busca_detalhada_outras_propriedades").style.backgroundColor = "#d4e0ed";
        document.getElementById(Layer + "_busca_detalhada_selecione_outras_propriedades_seta").style.display = "block";
        document.getElementById(Layer + "_busca_detalhada_selecione_outras_propriedades_seta").src = "/imgs/topo/set.png";
    } 
}

function SelecionaBairroRegiao(Objeto, Layer) {
    if (Layer == "layer_refinarbusca") {
        return;
    }
    if ((document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display == "none") || (Layer == "layer_refinarbusca")) {
        if (Layer == "layer_refinarbusca") {
            if (document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display == "block") {
                document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_cidade_opcoes").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_opcoes").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_estado").style.marginBottom = "5px";
                document.getElementById(Layer + "_busca_detalhada_cidade").style.marginBottom = "0px";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.marginBottom = "5px";
                document.getElementById(Layer + "_busca_detalhada_estado").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_cidade").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").src = "/imgs/topo/set.png";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").src = "/imgs/topo/set2.png";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").src = "/imgs/topo/set.png";
            } else {
                document.getElementById(Layer + "_busca_detalhada_estado_lista").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_cidade_opcoes").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_cidade_lista").style.display = "none";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_opcoes").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_estado").style.marginBottom = "5px";
                document.getElementById(Layer + "_busca_detalhada_cidade").style.marginBottom = "5px";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.marginBottom = "0px";
                document.getElementById(Layer + "_busca_detalhada_estado").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_cidade").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
                document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_seta").src = "/imgs/topo/set.png";
                document.getElementById(Layer + "_busca_detalhada_selecione_estado_seta").src = "/imgs/topo/set.png";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_seta").src = "/imgs/topo/set2.png";
            }
        } else {
            ExibeDadosBuscaDetalhada();
        }
        ExibeBairroRegiao(Layer);
    } else {
        SelecionaOutrasPropriedades(document.getElementById(Layer + "_busca_detalhada_outras_propriedades"));
    }
}

function ExibeOutrasPropriedades() {
    document.getElementById("layer_topo_busca_detalhada_outras_propriedades_lista").style.display = "table";
    document.getElementById("layer_topo_busca_detalhada_bairro_regiao_lista").style.display = "none";
    document.getElementById("layer_topo_busca_detalhada_outras_propriedades").style.display = "none";
    document.getElementById("layer_topo_busca_detalhada_bairro_regiao").style.marginBottom = "0px";
    document.getElementById("layer_topo_busca_detalhada_bairro_regiao").style.backgroundColor = "#d4e0ed";
    document.getElementById("layer_topo_busca_detalhada_outras_propriedades").style.backgroundColor = "#d4e0ed";
    document.getElementById("layer_topo_busca_detalhada_selecione_outras_propriedades_seta").style.display = "block";
    document.getElementById("layer_topo_busca_detalhada_selecione_bairro_regiao_seta").style.display = "block";
    document.getElementById("layer_topo_busca_detalhada_selecione_outras_propriedades_seta").src = "/imgs/topo/set2.png";
    document.getElementById("layer_topo_busca_detalhada_selecione_bairro_regiao_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_busca_detalhada_bairro_regiao_opcoes").style.display = "none";
}

function SelecionaOutrasPropriedades(Objeto) {
    if (document.getElementById("layer_topo_busca_detalhada_outras_propriedades_lista").style.display == "none") {
        ExibeDadosBuscaDetalhada();
        ExibeOutrasPropriedades();
    } else {
        SelecionaBairroRegiao(document.getElementById(Layer + "busca_detalhada_bairro_regiao"), Layer);
    }
}

function MarcarTudo(Opcao, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxCidade = null;
        var ajaxResultado = null;
        Selecionado = "";
        var Parametros = "";
        if (Opcao == "Cidade") {
            TotalSelecionadoGeral = 0;
            if (document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total") != undefined) {
                TotalSelecionadoGeral++;
                TotalCidades = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total").innerHTML);
                TotalCidadesSelecionadas = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML);
                if (TotalCidades != TotalCidadesSelecionadas) {
                    //if (TotalCidades > 15) {
                    //    alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 cidades por vez!");
                    //    return;
                    //}                
                    for (x = 1; x <= TotalCidades; x++) {
                        if (document.getElementById(Layer + "_busca_detalhada_cidade_" + x) != undefined) {
                            if (document.getElementById(Layer + "_busca_detalhada_cidade_" + x).className == "fundo_checkbox") {
                                document.getElementById(Layer + "_busca_detalhada_cidade_img_" + x).style.display = "block";
                                if (document.all) {
                                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_cidade_texto_" + x).innerText;
                                } else {
                                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_cidade_texto_" + x).textContent;
                                }
                                if (SelecionadoAtual.length > 0) {
                                    if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                        SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                                    }
                                }
                                Selecionado = Selecionado + SelecionadoAtual + "|";
                            }
                        }
                    }
                    document.getElementById(Layer + "_ListaDeCidadesSelecionados").value = Selecionado;
                    if (Selecionado.length == 0) {
                        document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemBairro3 + "</div>";
                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                    } else {
                        if (Layer == "layer_refinarbusca") {
                            ExibeMascaraBusca();
                        }                    
                        splitSelecionado = Selecionado.split("|");
                        document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = splitSelecionado.length - 1;
                        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemBairro + "</div>";
                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                        document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                        ajaxCidade = ajaxInit();
                        resultado = "";
                        if (ajaxCidade) {
                            EnviaLazer = document.getElementById(Layer + "_ListaDeLazerSelecionados").value;
                            EnviaCaracteristica = document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value;
                            while (EnviaLazer.indexOf("<br />") > 0) {
                                EnviaLazer = EnviaLazer.replace("<br />", "[br /]");
                            }
                            while (EnviaCaracteristica.indexOf("<br />") > 0) {
                                EnviaCaracteristica = EnviaCaracteristica.replace("<br />", "[br /]");
                            }
                            ValorInicial = document.getElementById(Layer + "_busca_detalhada_valor_inicial").value;
                            ValorFinal = document.getElementById(Layer + "_busca_detalhada_valor_final").value;

                            AreaPrivativaInicial = document.getElementById(Layer + "_busca_detalhada_area_privativa_inicial").value;
                            AreaPrivativaFinal = document.getElementById(Layer + "_busca_detalhada_area_privativa_final").value;

                            ProximoMetroInicial = document.getElementById(Layer + "_busca_detalhada_metro_inicial").value;
                            ProximoMetroFinal = document.getElementById(Layer + "_busca_detalhada_metro_final").value;

                            EstadosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeEstadosSelecionados").value.toLowerCase();
                            if (EstadosSelecionadosAJAX.length == 0) {
                                EstadosSelecionadosAJAX = "-";
                            }
                            CidadesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.toLowerCase();
                            if (CidadesSelecionadosAJAX.length == 0) {
                                CidadesSelecionadosAJAX = "-";
                            }
                            BairrosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeBairrosSelecionados").value.toLowerCase();
                            if (BairrosSelecionadosAJAX.length == 0) {
                                BairrosSelecionadosAJAX = "-";
                            }
                            RegioesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeRegioesSelecionados").value.toLowerCase();
                            if (RegioesSelecionadosAJAX.length == 0) {
                                RegioesSelecionadosAJAX = "-";
                            }
                            FinalidadeSelecionadosAJAX = document.getElementById(Layer + "_FinalidadeSelecionado").value.toLowerCase();
                            if (FinalidadeSelecionadosAJAX.length == 0) {
                                FinalidadeSelecionadosAJAX = "-";
                            }
                            TipoSelecionadosAJAX = document.getElementById(Layer + "_TipoSelecionado").value.toLowerCase();
                            if (TipoSelecionadosAJAX.length == 0) {
                                TipoSelecionadosAJAX = "-";
                            }
                            EstagioObraSelecionadosAJAX = document.getElementById(Layer + "_EstagioObraSelecionado").value.toLowerCase();
                            if (EstagioObraSelecionadosAJAX.length == 0) {
                                EstagioObraSelecionadosAJAX = "-";
                            }
                            DormitoriosSelecionadosAJAX = document.getElementById(Layer + "_DormitoriosSelecionado").value.toLowerCase();
                            if (DormitoriosSelecionadosAJAX.length == 0) {
                                DormitoriosSelecionadosAJAX = "-";
                            }
                            EnviaLazer = EnviaLazer.toLowerCase();
                            if (EnviaLazer.length == 0) {
                                EnviaLazer = "-";
                            }
                            EnviaCaracteristica = EnviaCaracteristica.toLowerCase();
                            if (EnviaCaracteristica.length == 0) {
                                EnviaCaracteristica = "-";
                            }
                            ValorInicial = ValorInicial.toLowerCase();
                            if (ValorInicial.length == 0) {
                                ValorInicial = "-";
                            }
                            ValorFinal = ValorFinal.toLowerCase();
                            if (ValorFinal.length == 0) {
                                ValorFinal = "-";
                            }
                            AreaPrivativaInicial = AreaPrivativaInicial.toLowerCase();
                            if (AreaPrivativaInicial.length == 0) {
                                AreaPrivativaInicial = "-";
                            }
                            AreaPrivativaFinal = AreaPrivativaFinal.toLowerCase();
                            if (AreaPrivativaFinal.length == 0) {
                                AreaPrivativaFinal = "-";
                            }
                            ProximoMetroInicial = ProximoMetroInicial.toLowerCase();
                            if (ProximoMetroInicial.length == 0) {
                                ProximoMetroInicial = "-";
                            }
                            ProximoMetroFinal = ProximoMetroFinal.toLowerCase();
                            if (ProximoMetroFinal.length == 0) {
                                ProximoMetroFinal = "-";
                            }
                            Layer = Layer.toLowerCase();
                            if (Layer.length == 0) {
                                Layer = "-";
                            }
                            TextoPesquisaAJAX = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value.toLowerCase();
                            if (TextoPesquisaAJAX.length == 0) {
                                TextoPesquisaAJAX = "-";
                            } else {
                                if (document.getElementById("layer_topo_cidade_atual").innerHTML.toLowerCase() != "rio de janeiro") {
                                    if (TextoPesquisaAJAX == "ex.: apartamento 2 dormitórios vila mariana são paulo ou id/código do imóvel") {
                                        TextoPesquisaAJAX = "-";
                                    }
                                } else {
                                    if (TextoPesquisaAJAX == "ex.: apartamento 2 quartos vila mariana são paulo ou id/código do imóvel") {
                                        TextoPesquisaAJAX = "-";
                                    }
                                }
                            }
                            if (Selecionado.length == 0) {
                                Selecionado = "-";
                            } else {
                                Selecionado = Selecionado.toLowerCase();
                            }
                            if (Layer == "layer_topo") {
                                ajaxCidade.open("GET", "/ajax/lista_bairros.aspx?Estados=" + EstadosSelecionadosAJAX + "&Cidades=" + Selecionado + "&Bairros=-&Finalidades=" + FinalidadeSelecionadosAJAX + "&Tipos=" + TipoSelecionadosAJAX + "&EstagioObra=" + EstagioObraSelecionadosAJAX + "&Dormitorios=" + DormitoriosSelecionadosAJAX + "&Lazer=" + EnviaLazer + "&Caracteristicas=" + EnviaCaracteristica + "&ValorInicial=" + ValorInicial + "&ValorFinal=" + ValorFinal + "&AreaPrivativaInicial=" + AreaPrivativaInicial + "&AreaPrivativaFinal=" + AreaPrivativaFinal + "&ProximoMetroInicial=" + ProximoMetroInicial + "&ProximoMetroFinal=" + ProximoMetroFinal + "&Layer=" + Layer + "&TextoPesquisa=" + TextoPesquisaAJAX + "&Rand=" + Math.ceil(Math.random() * 100000), true);
                                ajaxCidade.setRequestHeader("Content-type", "charset=iso-8859-1");
                                ajaxCidade.onreadystatechange = function () {
                                    if (ajaxCidade.readyState == 4) {
                                        if (ajaxCidade.status == 200) {
                                            resultado = ajaxCidade.responseText;
                                            TotalZonas = resultado.substring(resultado.indexOf("[total_zonas]") + "[total_zonas]".length, resultado.lastIndexOf("[/total_zonas]"));
                                            resultado = resultado.replace("[total_zonas]" + TotalZonas + "[/total_zonas]", "");
                                            document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML = TotalZonas;
                                            document.getElementById(Layer + "_TotalZona").value = TotalZonas;
                                            if (Layer == "layer_topo") {
                                                if (resultado.length == 0) {
                                                    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemBairro2 + "</div>";
                                                    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                                                    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                                                    document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                                    document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                                } else {
                                                    if (document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.length > 0) {
                                                        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = resultado;
                                                        TotalBairros = resultado.split("\"lista_bairros\"");
                                                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = TotalBairros.length - 1;
                                                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = resultado.split("block;").length - 1;
                                                    }
                                                }
                                            } else {
                                                if (resultado.length == 0) {
                                                    ErroMascaraBusca();
                                                    return;
                                                }
                                                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemBairro + "</div>";
                                                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                                                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                                                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                                Parametros = resultado;
                                                Parametros2 = resultado.substring(resultado.lastIndexOf("[/caracteristica]") + "[/caracteristica]".length, resultado.length);
                                                ParametrosPlantas = Parametros2.substring(Parametros2.indexOf("[plantas]") + "[plantas]".length, Parametros2.lastIndexOf("[/plantas]"));
                                                Parametros2 = Parametros2.substring(Parametros2.indexOf("[/plantas]") + "[/plantas]".length, Parametros2.length);
                                                AtualizaParciais(Parametros, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2);
                                                if (ParametrosPlantas.substring(0, 1) == "1") {
                                                    PopulaBusca("atualiza_pagina_busca_plantas", ParametrosPlantas, "", "", "", false);
                                                } else {
                                                    document.getElementById("total_plantas_imoveis").innerHTML = "(0)";
                                                    document.getElementById("plantas_imoveis_1").className = "abas_white_esq";
                                                    document.getElementById("plantas_imoveis_1").innerHTML = "<img id=\"imagem_planta_imoveis_1\" src=\"/imgs/resultado_busca_03_off.jpg\" alt=\"\" border=\"0\" />";
                                                    document.getElementById("plantas_imoveis").className = "abas_white_cen_off";
                                                    document.getElementById("plantas_imoveis_2").className = "abas_white_dir";
                                                    document.getElementById("plantas_imoveis_2").innerHTML = "<img id=\"imagem_planta_imoveis_2\" src=\"/imgs/resultado_busca_04_off.jpg\" alt=\"\" border=\"0\" />";
                                                }
                                                PopulaBusca("atualiza_pagina_busca", Parametros2, "", "", "");
                                                document.getElementById("resultado_busca_paginacao_plantas").style.display = "none";
                                                document.getElementById("resultado_busca_paginacao_plantas_2").style.display = "none";
                                                document.getElementById("resultado_busca_ordenar_plantas").style.display = "none";
                                                document.getElementById("resultado_busca_paginacao").style.display = "block";
                                                document.getElementById("resultado_busca_paginacao_2").style.display = "block";
                                                document.getElementById("resultado_busca_ordenar").style.display = "block";
                                                document.getElementById("resultado_busca").style.display = "block";
                                                document.getElementById("resultado_busca_plantas").style.display = "none";
                                            }
                                        }
                                    }
                                }
                                ajaxCidade.send(null);
                            } else {
                                ExibeMascaraBusca();                                
                                FiltrarRefinar(null);                                
                            }
                        }
                    }
                }
            }
            //}
        }
        if (Opcao == "Bairro_Regiao") {
            var ajaxBairro = null;        
            TotalSelecionadoGeral = 0;
            if (document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total") != undefined) {
                TotalBairros = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML);
                //if (TotalBairros > 15) {
                //    alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 bairros por vez!");
                //    return;
                //}
                TotalZona = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML);
                for (xZona = 1; xZona <= document.getElementById(Layer + "_TotalZona").value; xZona++) {
                    if (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona) != undefined) {
                        document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check.gif";
                        document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "block";                            
                    }
                    for (x = 1; x <= TotalBairros; x++) {
                        if (document.getElementById(Layer + "_busca_detalhada_bairro_" + x + "_" + xZona) != undefined) {
                            if (document.getElementById(Layer + "_busca_detalhada_bairro_" + x + "_" + xZona).className == "fundo_checkbox") {
                                TotalSelecionadoGeral++;
                                document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).style.display = "block";
                                if (document.all) {
                                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).innerText + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt;
                                } else {
                                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).textContent + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt;
                                }
                                if (SelecionadoAtual.length > 0) {
                                    Zona = "";
                                    if (SelecionadoAtual.indexOf("^^") > 0) {
                                        splitZona = SelecionadoAtual.split("^^");
                                        if (splitZona.length > 0) {
                                            Zona = splitZona[1].replace("|", "");
                                        }
                                    }
                                    if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                        SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1) + "^^" + Zona;
                                    }
                                }
                                Selecionado = Selecionado + SelecionadoAtual + "|";
                            }
                        }
                    }
                }
                document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = TotalSelecionadoGeral;
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = TotalZona;
                if (Layer == "layer_refinarbusca") {
                    ExibeMascaraBusca();                    
                    FiltrarRefinar(null);                    
                }            
            }
        }
        if (Opcao == "Lazer") {
            var ajaxLazer = null;        
            TotalSelecionadoGeral = 0;
            if (document.getElementById(Layer + "_busca_detalhada_selecione_lazer_total") != undefined) {
                TotalLazer = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_lazer_total").innerHTML);
                for (x = 1; x <= TotalLazer; x++) {
                    if (document.getElementById(Layer + "_busca_detalhada_lazer_" + x) != undefined) {
                        if (document.getElementById(Layer + "_busca_detalhada_lazer_" + x).className == "fundo_checkbox") {
                            TotalSelecionadoGeral++;
                            document.getElementById(Layer + "_busca_detalhada_lazer_img_" + x).style.display = "block";
                            if (document.all) {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_lazer_texto_" + x).innerText;
                            } else {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_lazer_texto_" + x).textContent;
                            }
                            if (SelecionadoAtual.length > 0) {
                                if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                    SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                                }
                            }
                            Selecionado = Selecionado + SelecionadoAtual + "|";
                        }
                    }
                }        
                document.getElementById(Layer + "_ListaDeLazerSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").innerHTML = TotalSelecionadoGeral;
                if (Layer == "layer_refinarbusca") {
                    ExibeMascaraBusca();                    
                    FiltrarRefinar(null);                    
                }
            }
        }
        if (Opcao == "Caracteristicas") {
            var ajaxCaracteristica = null;        
            TotalSelecionadoGeral = 0;
            if (document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_total") != undefined) {
                TotalCaracteristicas = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_total").innerHTML);
                for (x = 1; x <= TotalCaracteristicas; x++) {
                    if (document.getElementById(Layer + "_busca_detalhada_caracteristica_" + x) != undefined) {
                        if (document.getElementById(Layer + "_busca_detalhada_caracteristica_" + x).className == "fundo_checkbox") {
                            TotalSelecionadoGeral++;
                            document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + x).style.display = "block";
                            if (document.all) {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_caracteristica_texto_" + x).innerText;
                            } else {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_caracteristica_texto_" + x).textContent;
                            }
                            if (SelecionadoAtual.length > 0) {
                                if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                    SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                                }
                            }
                            Selecionado = Selecionado + SelecionadoAtual + "|";
                        }
                    }
                }      
                document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML = TotalSelecionadoGeral;
                if (Layer == "layer_refinarbusca") {
                    ExibeMascaraBusca();                    
                    FiltrarRefinar(null);                    
                }
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function PopulaRefinarBusca(Parametros, Layer, Mensagem3, Mensagem4, Mensagem5, Mensagem6, Mensagem7, Mensagem8, Mensagem2, Mensagem9, Mensagem, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Opcao) {
    var ajaxResultado = null;
    if (Opcao == "Lazer") {
        //document.getElementById(Layer + "_busca_detalhada_estado_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem3 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem5 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem2 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_caracteristicas_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemCaracteristica + "</div>";
    }
    if (Opcao == "Caracteristicas") {
        //document.getElementById(Layer + "_busca_detalhada_estado_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem3 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem5 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem2 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_lazer_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemLazer + "</div>";
    }
    if (Opcao == "Bairro_Regiao") {
        //document.getElementById(Layer + "_busca_detalhada_estado_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem3 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem5 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + Mensagem2 + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_lazer_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemLazer + "</div>";
        //document.getElementById(Layer + "_busca_detalhada_caracteristicas_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemCaracteristica + "</div>";
    }
    ajaxResultado = ajaxInit();
    resultado = "";
    if (ajaxResultado) {        
        EnviaLazer = document.getElementById(Layer + "_ListaDeLazerSelecionados").value;
        EnviaCaracteristica = document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value;
        while (EnviaLazer.indexOf("<br />") > 0) {
            EnviaLazer = EnviaLazer.replace("<br />", "[br /]");
        }
        while (EnviaCaracteristica.indexOf("<br />") > 0) {
            EnviaCaracteristica = EnviaCaracteristica.replace("<br />", "[br /]");
        }
        ValorInicial = document.getElementById(Layer + "_busca_detalhada_valor_inicial").value;
        ValorFinal = document.getElementById(Layer + "_busca_detalhada_valor_final").value;

        AreaPrivativaInicial = document.getElementById(Layer + "_busca_detalhada_area_privativa_inicial").value;
        AreaPrivativaFinal = document.getElementById(Layer + "_busca_detalhada_area_privativa_final").value;

        ProximoMetroInicial = document.getElementById(Layer + "_busca_detalhada_metro_inicial").value;
        ProximoMetroFinal = document.getElementById(Layer + "_busca_detalhada_metro_final").value;

        EstadosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeEstadosSelecionados").value.toLowerCase();
        if (EstadosSelecionadosAJAX.length == 0) {
            EstadosSelecionadosAJAX = "-";
        }
        CidadesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.toLowerCase();
        if (CidadesSelecionadosAJAX.length == 0) {
            CidadesSelecionadosAJAX = "-";
        }
        BairrosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeBairrosSelecionados").value.toLowerCase();
        if (BairrosSelecionadosAJAX.length == 0) {
            BairrosSelecionadosAJAX = "-";
        }
        RegioesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeRegioesSelecionados").value.toLowerCase();
        if (RegioesSelecionadosAJAX.length == 0) {
            RegioesSelecionadosAJAX = "-";
        }
        FinalidadeSelecionadosAJAX = document.getElementById(Layer + "_FinalidadeSelecionado").value.toLowerCase();
        if (FinalidadeSelecionadosAJAX.length == 0) {
            FinalidadeSelecionadosAJAX = "-";
        }
        TipoSelecionadosAJAX = document.getElementById(Layer + "_TipoSelecionado").value.toLowerCase();
        if (TipoSelecionadosAJAX.length == 0) {
            TipoSelecionadosAJAX = "-";
        }
        EstagioObraSelecionadosAJAX = document.getElementById(Layer + "_EstagioObraSelecionado").value.toLowerCase();
        if (EstagioObraSelecionadosAJAX.length == 0) {
            EstagioObraSelecionadosAJAX = "-";
        }
        DormitoriosSelecionadosAJAX = document.getElementById(Layer + "_DormitoriosSelecionado").value.toLowerCase();
        if (DormitoriosSelecionadosAJAX.length == 0) {
            DormitoriosSelecionadosAJAX = "-";
        }
        EnviaLazer = EnviaLazer.toLowerCase();
        if (EnviaLazer.length == 0) {
            EnviaLazer = "-";
        }
        EnviaCaracteristica = EnviaCaracteristica.toLowerCase();
        if (EnviaCaracteristica.length == 0) {
            EnviaCaracteristica = "-";
        }
        ValorInicial = ValorInicial.toLowerCase();
        if (ValorInicial.length == 0) {
            ValorInicial = "-";
        }
        ValorFinal = ValorFinal.toLowerCase();
        if (ValorFinal.length == 0) {
            ValorFinal = "-";
        }
        AreaPrivativaInicial = AreaPrivativaInicial.toLowerCase();
        if (AreaPrivativaInicial.length == 0) {
            AreaPrivativaInicial = "-";
        }
        AreaPrivativaFinal = AreaPrivativaFinal.toLowerCase();
        if (AreaPrivativaFinal.length == 0) {
            AreaPrivativaFinal = "-";
        }
        ProximoMetroInicial = ProximoMetroInicial.toLowerCase();
        if (ProximoMetroInicial.length == 0) {
            ProximoMetroInicial = "-";
        }
        ProximoMetroFinal = ProximoMetroFinal.toLowerCase();
        if (ProximoMetroFinal.length == 0) {
            ProximoMetroFinal = "-";
        }
        Layer = Layer.toLowerCase();
        if (Layer.length == 0) {
            Layer = "-";
        }
        TextoPesquisaAJAX = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value.toLowerCase();
        if (TextoPesquisaAJAX.length == 0) {
            TextoPesquisaAJAX = "-";
        }

        ajaxResultado.open("GET", "/ajax/popula_refinar_busca.aspx?Estados=" + EstadosSelecionadosAJAX + "&Cidades=" + CidadesSelecionadosAJAX + "&Bairros=" + BairrosSelecionadosAJAX + "&Regioes=" + RegioesSelecionadosAJAX + "&Finalidades=" + FinalidadeSelecionadosAJAX + "&Tipos=" + TipoSelecionadosAJAX + "&EstagioObra=" + EstagioObraSelecionadosAJAX + "&Dormitorios=" + DormitoriosSelecionadosAJAX + "&Lazer=" + EnviaLazer + "&Caracteristicas=" + EnviaCaracteristica + "&ValorInicial=" + ValorInicial + "&ValorFinal=" + ValorFinal + "&AreaPrivativaInicial=" + AreaPrivativaInicial + "&AreaPrivativaFinal=" + AreaPrivativaFinal + "&ProximoMetroInicial=" + ProximoMetroInicial + "&ProximoMetroFinal=" + ProximoMetroFinal + "&Layer=" + Layer + "&TextoPesquisa=" + TextoPesquisaAJAX + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxResultado.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxResultado.onreadystatechange = function() {
            if (ajaxResultado.readyState == 4) {
                if (ajaxResultado.status == 200) {
                    resultado = ajaxResultado.responseText;
                    if (resultado.length > 0) {
                        Parametros = resultado;
                        Parametros2 = resultado.substring(resultado.lastIndexOf("[/caracteristica]") + "[/caracteristica]".length, resultado.length);
                        ParametrosPlantas = Parametros2.substring(Parametros2.indexOf("[plantas]") + "[plantas]".length, Parametros2.lastIndexOf("[/plantas]"));
                        Parametros2 = Parametros2.substring(Parametros2.indexOf("[/plantas]") + "[/plantas]".length, Parametros2.length);
                        AtualizaParciais(Parametros, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2);
                        if (ParametrosPlantas.substring(0, 1) == "1") {
                            PopulaBusca("atualiza_pagina_busca_plantas", ParametrosPlantas, "", "", "", false);
                        } else {
                            document.getElementById("total_plantas_imoveis").innerHTML = "(0)";
                            document.getElementById("plantas_imoveis_1").className = "abas_white_esq";
                            document.getElementById("plantas_imoveis_1").innerHTML = "<img id=\"imagem_planta_imoveis_1\" src=\"/imgs/resultado_busca_03_off.jpg\" alt=\"\" border=\"0\" />";
                            document.getElementById("plantas_imoveis").className = "abas_white_cen_off";
                            document.getElementById("plantas_imoveis_2").className = "abas_white_dir";
                            document.getElementById("plantas_imoveis_2").innerHTML = "<img id=\"imagem_planta_imoveis_2\" src=\"/imgs/resultado_busca_04_off.jpg\" alt=\"\" border=\"0\" />";
                        }
                        PopulaBusca("atualiza_pagina_busca", Parametros2, "", "", "");
                        document.getElementById("resultado_busca_paginacao_plantas").style.display = "none";
                        document.getElementById("resultado_busca_paginacao_plantas_2").style.display = "none";
                        document.getElementById("resultado_busca_ordenar_plantas").style.display = "none";
                        document.getElementById("resultado_busca_paginacao").style.display = "block";
                        document.getElementById("resultado_busca_paginacao_2").style.display = "block";
                        document.getElementById("resultado_busca_ordenar").style.display = "block";
                        document.getElementById("resultado_busca").style.display = "block";
                        document.getElementById("resultado_busca_plantas").style.display = "none";
                    } else {
                        ErroMascaraBusca();
                    }
                } else {
                    ErroMascaraBusca();
                }
            }
        }
        ajaxResultado.send(null);
    }
}

function DesmarcarTudo(Opcao, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    TotalDesmarcar = 0;
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        Selecionado = "";
        if (Opcao == "Cidade") {
            if (document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total") != undefined) {
                TotalCidades = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total").innerHTML);
                TotalDesmarcar = TotalCidades;
                for (x = 1; x <= TotalCidades; x++) {
                    if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + x) != undefined) {
                        document.getElementById(Layer + "_busca_detalhada_cidade_img_" + x).style.display = "none";
                    }
                }
                document.getElementById(Layer + "_ListaDeCidadesSelecionados").value = Selecionado;
                document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = "";
                document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = "";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemCidade4 + "</div>";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
            }
        }
        if (Opcao == "Bairro_Regiao") {
            if (document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total") != undefined) {
                TotalBairros = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML);
                TotalDesmarcar = TotalBairros;
                TotalZona = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML);
                for (xZona = 1; xZona <= TotalZona; xZona++) {
                    if (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona) != undefined) {
                        document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "none";
                    }
                    for (x = 1; x <= TotalBairros; x++) {
                        if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).style.display = "none";
                        }
                    }
                }
                document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = Selecionado;
                document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
            }
        }
        if (Opcao == "Lazer") {
            if (document.getElementById(Layer + "_busca_detalhada_selecione_lazer_total") != undefined) {
                TotalLazer = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_lazer_total").innerHTML);
                TotalDesmarcar = TotalLazer;
                for (x = 1; x <= TotalLazer; x++) {
                    if (document.getElementById(Layer + "_busca_detalhada_lazer_img_" + x) != undefined) {
                        document.getElementById(Layer + "_busca_detalhada_lazer_img_" + x).style.display = "none";
                    }
                }
                document.getElementById(Layer + "_ListaDeLazerSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").innerHTML = "0";
            }
        }
        if (Opcao == "Caracteristicas") {
            if (document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_total") != undefined) {
                TotalCaracteristicas = parseInt(document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_total").innerHTML);
                TotalDesmarcar = TotalCaracteristicas;
                for (x = 1; x <= TotalCaracteristicas; x++) {
                    if (document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + x) != undefined) {
                        document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + x).style.display = "none";
                    }
                }
                document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value = Selecionado;
                document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML = "0";
            }
        }
        if (TotalDesmarcar > 0) {
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();                
                FiltrarRefinar(null);                
            } 
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function FiltrarRefinar(Objeto) {
    TotalBairros = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML);
    TotalBairrosGeral = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_bairro_regiao_total").innerHTML);
    TotalZonas = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_regiao_selecionado").innerHTML);
    TotalZonasGeral = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_regiao_total").innerHTML);
    if (TotalZonas > 15) {
        alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 regiões por vez!");
        history.go(0);        
        return;
    }
    TotalCidades = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_cidade_selecionado").innerHTML);
    if (TotalCidades > 15) {
        alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 cidades por vez!");
        history.go(0);        
        return;
    }
    TotalLazer = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_lazer_selecionado").innerHTML);
    if (TotalLazer > 15) {
        alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 itens de lazer por vez!");
        history.go(0);        
        return;
    }
    TotalCaracteristicas = parseInt(document.getElementById("layer_refinarbusca_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML);
    if (TotalCaracteristicas > 15) {
        alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 características por vez!");
        history.go(0);        
        return;
    }
    ListaDeEstadosSelecionados = document.getElementById("layer_refinarbusca_ListaDeEstadosSelecionados").value.toLowerCase();
    if (ListaDeEstadosSelecionados.length > 0) {
        while (ListaDeEstadosSelecionados.indexOf(" ") >= 0) {
            ListaDeEstadosSelecionados = ListaDeEstadosSelecionados.replace(" ", "-");
        }
        while (ListaDeEstadosSelecionados.indexOf("|") >= 0) {
            ListaDeEstadosSelecionados = ListaDeEstadosSelecionados.replace("|", ",");
        }
        if (ListaDeEstadosSelecionados.length > 0) {
            ListaDeEstadosSelecionados = ListaDeEstadosSelecionados.substring(0, ListaDeEstadosSelecionados.length - 1);
        }
    }
    ListaDeCidadesSelecionados = document.getElementById("layer_refinarbusca_ListaDeCidadesSelecionados").value.toLowerCase();
    if (ListaDeCidadesSelecionados.length > 0) {
        while (ListaDeCidadesSelecionados.indexOf(" ") >= 0) {
            ListaDeCidadesSelecionados = ListaDeCidadesSelecionados.replace(" ", "-");
        }
        while (ListaDeCidadesSelecionados.indexOf("|") >= 0) {
            ListaDeCidadesSelecionados = ListaDeCidadesSelecionados.replace("|", ",");
        }
        if (ListaDeCidadesSelecionados.length > 0) {
            ListaDeCidadesSelecionados = ListaDeCidadesSelecionados.substring(0, ListaDeCidadesSelecionados.length - 1);
        }
    }
    var TotalBairrosSelecionados = 0;
    ListaDeBairrosSelecionados = "";
    for (x = 1; x <= TotalZonasGeral; x++) {
        for (z = 1; z <= TotalBairrosGeral; z++) {
            if (document.getElementById("layer_refinarbusca_busca_detalhada_bairro_img_" + z + "_" + x) != undefined) {
                if (document.getElementById("layer_refinarbusca_busca_detalhada_bairro_img_" + z + "_" + x).style.display == "block") {
                    TotalBairrosSelecionados++;
                    if (document.all) {
                        ListaDeBairrosSelecionados += document.getElementById("layer_refinarbusca_busca_detalhada_bairro_texto_" + z + "_" + x).innerText.substring(0,document.getElementById("layer_refinarbusca_busca_detalhada_bairro_texto_" + z + "_" + x).innerText.indexOf("(") - 1) + "^^" + document.getElementById("layer_refinarbusca_busca_detalhada_zona_texto_" + x).innerText + "|";
                    } else {
                        ListaDeBairrosSelecionados += document.getElementById("layer_refinarbusca_busca_detalhada_bairro_texto_" + z + "_" + x).textContent.substring(0, document.getElementById("layer_refinarbusca_busca_detalhada_bairro_texto_" + z + "_" + x).textContent.indexOf("(") - 1) + "^^" + document.getElementById("layer_refinarbusca_busca_detalhada_zona_texto_" + x).textContent + "|";
                    }
                }
            }
        }
    }
    if (TotalBairrosSelecionados > 15) {
        alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 bairros de forma individual por vez!\n\nDica: utilize os agrupamentos por Região para poder selecionar mais do que 15 bairros por vez!");
        history.go(0);        
        return;
    }
    document.getElementById("layer_refinarbusca_ListaDeBairrosSelecionados").value = ListaDeBairrosSelecionados;
    ListaDeBairrosSelecionados = document.getElementById("layer_refinarbusca_ListaDeBairrosSelecionados").value.toLowerCase();
    if (ListaDeBairrosSelecionados.length > 0) {
        while (ListaDeBairrosSelecionados.indexOf(" - ") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace(" - ", " ");
        }
        while (ListaDeBairrosSelecionados.indexOf(" [+]") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace(" [+]", "");
        }
        while (ListaDeBairrosSelecionados.indexOf(" ,") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace(" ,", ",");
        }
        while (ListaDeBairrosSelecionados.indexOf("[") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace("[", "");
        }
        while (ListaDeBairrosSelecionados.indexOf("]") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace("]", "");
        }
        while (ListaDeBairrosSelecionados.indexOf("(") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace("(", "");
        }
        while (ListaDeBairrosSelecionados.indexOf(")") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace(")", "");
        }
        while (ListaDeBairrosSelecionados.indexOf("|") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace("|", ",");
        }
        while (ListaDeBairrosSelecionados.indexOf(" ") >= 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.replace(" ", "-");
        }
        if (ListaDeBairrosSelecionados.length > 0) {
            ListaDeBairrosSelecionados = ListaDeBairrosSelecionados.substring(0, ListaDeBairrosSelecionados.length - 1);
        }
    }
    ListaDeRegioesSelecionados = document.getElementById("layer_refinarbusca_ListaDeRegioesSelecionados").value.toLowerCase();
    if (ListaDeRegioesSelecionados.length > 0) {
        while (ListaDeRegioesSelecionados.indexOf(" - ") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace(" - ", " ");
        }
        while (ListaDeRegioesSelecionados.indexOf(" [+]") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace(" [+]", "");
        }
        while (ListaDeRegioesSelecionados.indexOf(" ,") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace(" ,", ",");
        }
        while (ListaDeRegioesSelecionados.indexOf("[") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace("[", "");
        }
        while (ListaDeRegioesSelecionados.indexOf("]") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace("]", "");
        }
        while (ListaDeRegioesSelecionados.indexOf("(") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace("(", "");
        }
        while (ListaDeRegioesSelecionados.indexOf(")") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace(")", "");
        }
        while (ListaDeRegioesSelecionados.indexOf("|") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace("|", ",");
        }
        while (ListaDeRegioesSelecionados.indexOf(" ") >= 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.replace(" ", "-");
        }
        if (ListaDeRegioesSelecionados.length > 0) {
            ListaDeRegioesSelecionados = ListaDeRegioesSelecionados.substring(0, ListaDeRegioesSelecionados.length - 1);
        }
    }
    ListaDeFinalidadesSelecionados = document.getElementById("layer_refinarbusca_FinalidadeSelecionado").value.toLowerCase();
    if (ListaDeFinalidadesSelecionados.length > 0) {
        while (ListaDeFinalidadesSelecionados.indexOf(" ") >= 0) {
            ListaDeFinalidadesSelecionados = ListaDeFinalidadesSelecionados.replace(" ", "-");
        }
        while (ListaDeFinalidadesSelecionados.indexOf("|") >= 0) {
            ListaDeFinalidadesSelecionados = ListaDeFinalidadesSelecionados.replace("|", ",");
        }
        if (ListaDeFinalidadesSelecionados.length > 0) {
            ListaDeFinalidadesSelecionados = ListaDeFinalidadesSelecionados.substring(0, ListaDeFinalidadesSelecionados.length - 1);
        }
    }
    ListaDeTiposSelecionados = document.getElementById("layer_refinarbusca_TipoSelecionado").value.toLowerCase();
    if (ListaDeTiposSelecionados.length > 0) {
        while (ListaDeTiposSelecionados.indexOf(" ") >= 0) {
            ListaDeTiposSelecionados = ListaDeTiposSelecionados.replace(" ", "-");
        }
        while (ListaDeTiposSelecionados.indexOf("|") >= 0) {
            ListaDeTiposSelecionados = ListaDeTiposSelecionados.replace("|", ",");
        }
        if (ListaDeTiposSelecionados.length > 0) {
            ListaDeTiposSelecionados = ListaDeTiposSelecionados.substring(0, ListaDeTiposSelecionados.length - 1);
        }
    }
    ListaDeEstagiosSelecionados = document.getElementById("layer_refinarbusca_EstagioObraSelecionado").value.toLowerCase();
    if (ListaDeEstagiosSelecionados.length > 0) {
        while (ListaDeEstagiosSelecionados.indexOf("/") >= 0) {
            ListaDeEstagiosSelecionados = ListaDeEstagiosSelecionados.replace(" / ", " ");
        }
        while (ListaDeEstagiosSelecionados.indexOf(" ") >= 0) {
            ListaDeEstagiosSelecionados = ListaDeEstagiosSelecionados.replace(" ", "-");
        }
        while (ListaDeEstagiosSelecionados.indexOf("|") >= 0) {
            ListaDeEstagiosSelecionados = ListaDeEstagiosSelecionados.replace("|", ",");
        }
        if (ListaDeEstagiosSelecionados.length > 0) {
            ListaDeEstagiosSelecionados = ListaDeEstagiosSelecionados.substring(0, ListaDeEstagiosSelecionados.length - 1);
        }
    }
    ListaDeDormitoriosSelecionados = document.getElementById("layer_refinarbusca_DormitoriosSelecionado").value.toLowerCase();
    if (ListaDeDormitoriosSelecionados.length > 0) {
        while (ListaDeDormitoriosSelecionados.indexOf(" ") >= 0) {
            ListaDeDormitoriosSelecionados = ListaDeDormitoriosSelecionados.replace(" ", "-");
        }
        while (ListaDeDormitoriosSelecionados.indexOf("|") >= 0) {
            ListaDeDormitoriosSelecionados = ListaDeDormitoriosSelecionados.replace("|", ",");
        }
        if (ListaDeDormitoriosSelecionados.length > 0) {
            ListaDeDormitoriosSelecionados = ListaDeDormitoriosSelecionados.substring(0, ListaDeDormitoriosSelecionados.length - 1);
        }
    }
    ListaDeSuitesSelecionados = document.getElementById("layer_refinarbusca_SuitesSelecionado").value.toLowerCase();
    if (ListaDeSuitesSelecionados.length > 0) {
        while (ListaDeSuitesSelecionados.indexOf(" ") >= 0) {
            ListaDeSuitesSelecionados = ListaDeSuitesSelecionados.replace(" ", "-");
        }
        while (ListaDeSuitesSelecionados.indexOf("|") >= 0) {
            ListaDeSuitesSelecionados = ListaDeSuitesSelecionados.replace("|", ",");
        }
        if (ListaDeSuitesSelecionados.length > 0) {
            ListaDeSuitesSelecionados = ListaDeSuitesSelecionados.substring(0, ListaDeSuitesSelecionados.length - 1);
        }
    }
    ListaDeVagasSelecionados = document.getElementById("layer_refinarbusca_VagasSelecionado").value.toLowerCase();
    if (ListaDeVagasSelecionados.length > 0) {
        while (ListaDeVagasSelecionados.indexOf(" ") >= 0) {
            ListaDeVagasSelecionados = ListaDeVagasSelecionados.replace(" ", "-");
        }
        while (ListaDeVagasSelecionados.indexOf("|") >= 0) {
            ListaDeVagasSelecionados = ListaDeVagasSelecionados.replace("|", ",");
        }
        if (ListaDeVagasSelecionados.length > 0) {
            ListaDeVagasSelecionados = ListaDeVagasSelecionados.substring(0, ListaDeVagasSelecionados.length - 1);
        }
    }
    ListaDeValorInicialSelecionados = document.getElementById("layer_refinarbusca_busca_detalhada_valor_inicial").value.toLowerCase();
    ListaDeValorFinalSelecionados = document.getElementById("layer_refinarbusca_busca_detalhada_valor_final").value.toLowerCase();
    ListaDeAreaPrivativaInicialSelecionados = document.getElementById("layer_refinarbusca_busca_detalhada_area_privativa_inicial").value.toLowerCase();
    ListaDeAreaPrivativaFinalSelecionados = document.getElementById("layer_refinarbusca_busca_detalhada_area_privativa_final").value.toLowerCase();
    ListaDeLazerSelecionados = document.getElementById("layer_refinarbusca_ListaDeLazerSelecionados").value.toLowerCase();
    if (ListaDeLazerSelecionados.length > 0) {
        while (ListaDeLazerSelecionados.indexOf(" ") >= 0) {
            ListaDeLazerSelecionados = ListaDeLazerSelecionados.replace(" ", "-");
        }
        while (ListaDeLazerSelecionados.indexOf("|") >= 0) {
            ListaDeLazerSelecionados = ListaDeLazerSelecionados.replace("|", ",");
        }
        if (ListaDeLazerSelecionados.length > 0) {
            ListaDeLazerSelecionados = ListaDeLazerSelecionados.substring(0, ListaDeLazerSelecionados.length - 1);
        }
    }
    ListaDeCaracteristicasSelecionados = document.getElementById("layer_refinarbusca_ListaDeCaracteristicasSelecionados").value.toLowerCase();
    if (ListaDeCaracteristicasSelecionados.length > 0) {
        while (ListaDeCaracteristicasSelecionados.indexOf(" ") >= 0) {
            ListaDeCaracteristicasSelecionados = ListaDeCaracteristicasSelecionados.replace(" ", "-");
        }
        while (ListaDeCaracteristicasSelecionados.indexOf("|") >= 0) {
            ListaDeCaracteristicasSelecionados = ListaDeCaracteristicasSelecionados.replace("|", ",");
        }
        if (ListaDeCaracteristicasSelecionados.length > 0) {
            ListaDeCaracteristicasSelecionados = ListaDeCaracteristicasSelecionados.substring(0, ListaDeCaracteristicasSelecionados.length - 1);
        }
    }
    URLFinal = "";
    if (ListaDeEstadosSelecionados.length > 0) {
        URLFinal = URLFinal + "estados=" + ListaDeEstadosSelecionados + "&";
    }
    if (ListaDeCidadesSelecionados.length > 0) {
        URLFinal = URLFinal + "cidades=" + ListaDeCidadesSelecionados + "&";
    }
    if (ListaDeBairrosSelecionados.length > 0) {
        URLFinal = URLFinal + "bairros=" + ListaDeBairrosSelecionados + "&";
    }
    if (ListaDeRegioesSelecionados.length > 0) {
        URLFinal = URLFinal + "regioes=" + ListaDeRegioesSelecionados + "&";
    }    
    if (ListaDeFinalidadesSelecionados.length > 0) {
        URLFinal = URLFinal + "finalidades=" + ListaDeFinalidadesSelecionados + "&";
    }
    if (ListaDeTiposSelecionados.length > 0) {
        URLFinal = URLFinal + "tipos=" + ListaDeTiposSelecionados + "&";
    }
    if (ListaDeEstagiosSelecionados.length > 0) {
        URLFinal = URLFinal + "estagios=" + ListaDeEstagiosSelecionados + "&";
    }
    if (ListaDeDormitoriosSelecionados.length > 0) {
        URLFinal = URLFinal + "dormitorios=" + ListaDeDormitoriosSelecionados + "&";
    }
    if (ListaDeSuitesSelecionados.length > 0) {
        URLFinal = URLFinal + "suites=" + ListaDeSuitesSelecionados + "&";
    }
    if (ListaDeVagasSelecionados.length > 0) {
        URLFinal = URLFinal + "vagas=" + ListaDeVagasSelecionados + "&";
    }    
    if (ListaDeValorInicialSelecionados.length > 0) {
        URLFinal = URLFinal + "valor_inicial=" + ListaDeValorInicialSelecionados + "&";
    }
    if (ListaDeValorFinalSelecionados.length > 0) {
        URLFinal = URLFinal + "valor_final=" + ListaDeValorFinalSelecionados + "&";
    }
    if (ListaDeAreaPrivativaInicialSelecionados.length > 0) {
        URLFinal = URLFinal + "area_privativa_inicial=" + ListaDeAreaPrivativaInicialSelecionados + "&";
    }
    if (ListaDeAreaPrivativaFinalSelecionados.length > 0) {
        URLFinal = URLFinal + "area_privativa_final=" + ListaDeAreaPrivativaFinalSelecionados + "&";
    }
    if (ListaDeLazerSelecionados.length > 0) {
        URLFinal = URLFinal + "lazer=" + ListaDeLazerSelecionados + "&";
    }
    if (ListaDeCaracteristicasSelecionados.length > 0) {
        URLFinal = URLFinal + "caracteristicas=" + ListaDeCaracteristicasSelecionados + "&";
    }
    TextoPesquisa = "";
    if (document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre") != null) {
        TextoPesquisa = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value.toLowerCase();
        if (TextoPesquisa == "ex.: apartamento 2 dormitórios vila mariana são paulo ou id/código do imóvel") {
            TextoPesquisa = "";
        }
    }
    if (TextoPesquisa.length > 0) {
        while (TextoPesquisa.indexOf(" ") >= 0) {
            TextoPesquisa = TextoPesquisa.replace(" ", "-");
        }
    }
    if (URLFinal.length > 0) {
        URLFinal = URLFinal.substring(0, URLFinal.length - 1);
        if (TextoPesquisa.length > 0) {
            location.href = "/buscar/" + TextoPesquisa + "/?" + URLFinal + "#refinar-busca";
        } else {
            location.href = "/busca-detalhada/?" + URLFinal + "#refinar-busca";
        }
    } else {
        if (TextoPesquisa.length > 0) {
            location.href = "/buscar/" + TextoPesquisa + "/#refinar-busca";
        } else {
            location.href = "/busca-detalhada/#refinar-busca";
        }
    }
    document.getElementById("loading_refinar").src = document.getElementById("loading_refinar").src;
}

function MarcarEstado(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxEstado = null;
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_estado_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_estado_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_estado_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_estado_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_estado_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_estado_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_estado_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_estado_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estado_texto_" + (x + 1)).innerText;

                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estado_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            document.getElementById(Layer + "_ListaDeEstadosSelecionados").value = Selecionado;
            if (Layer == "layer_topo") {
                document.getElementById(Layer + "_ListaDeCidadesSelecionados").value = "";
                document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = "";
                document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = "";
                if (Selecionado.length == 0) {
                    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemBairro3 + "</div>";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemCidade4 + "</div>";
                }
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
            }
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                                    
            } else {
                document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemCidade + "</div>";
                Valor = 0;
                ajaxEstado = ajaxInit();
                resultado = "";
                if (ajaxEstado) {
                    EnviaLazer = document.getElementById(Layer + "_ListaDeLazerSelecionados").value;
                    EnviaCaracteristica = document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value;
                    while (EnviaLazer.indexOf("<br />") > 0) {
                        EnviaLazer = EnviaLazer.replace("<br />", "[br /]");
                    }
                    while (EnviaCaracteristica.indexOf("<br />") > 0) {
                        EnviaCaracteristica = EnviaCaracteristica.replace("<br />", "[br /]");
                    }
                    ValorInicial = document.getElementById(Layer + "_busca_detalhada_valor_inicial").value;
                    ValorFinal = document.getElementById(Layer + "_busca_detalhada_valor_final").value;

                    AreaPrivativaInicial = document.getElementById(Layer + "_busca_detalhada_area_privativa_inicial").value;
                    AreaPrivativaFinal = document.getElementById(Layer + "_busca_detalhada_area_privativa_final").value;

                    ProximoMetroInicial = document.getElementById(Layer + "_busca_detalhada_metro_inicial").value;
                    ProximoMetroFinal = document.getElementById(Layer + "_busca_detalhada_metro_final").value;

                    if (Selecionado.length == 0) {
                        Selecionado = "-";
                    }
                    ajaxEstado.open("GET", "/ajax/lista_cidades.aspx?Estados=" + Selecionado.toLowerCase() + "&Layer=" + Layer + "&Rand=" + Math.ceil(Math.random() * 100000), true);
                    ajaxEstado.setRequestHeader("Content-type", "charset=iso-8859-1");
                    ajaxEstado.onreadystatechange = function() {
                        if (ajaxEstado.readyState == 4) {
                            if (ajaxEstado.status == 200) {
                                resultado = ajaxEstado.responseText;
                                if (resultado.length == 0) {
                                    document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemCidade3 + "</div>";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total").innerHTML = "0";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = "0";
                                } else {
                                    if (document.getElementById(Layer + "_ListaDeEstadosSelecionados").value.length > 0) {
                                        document.getElementById(Layer + "_busca_detalhada_cidade_lista").innerHTML = resultado;
                                        TotalCidades = resultado.split("\"lista_cidades\"");
                                        document.getElementById(Layer + "_busca_detalhada_selecione_cidade_total").innerHTML = TotalCidades.length - 1;
                                        document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = resultado.split("block;").length - 1;                                        
                                    }
                                }
                            }
                        }
                    }
                    ajaxEstado.send(null);
                }
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function MarcarBairro(Objeto, ValorZona, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("bairro_") + 7, ID.lastIndexOf("_"));
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + (x + 1) + "_" + ValorZona) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_bairro_img_" + (x + 1) + "_" + ValorZona).style.display = "none";
                        }
                    }
                }
            }
            var BairroAtual = "";
            var AcaoAtual = "";
            if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + Valor + "_" + ValorZona) != undefined) {
                if (document.all) {
                    BairroAtual = document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + Valor + "_" + ValorZona).innerText
                } else {
                    BairroAtual = document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + Valor + "_" + ValorZona).textContent;
                }
                if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + Valor + "_" + ValorZona).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_bairro_img_" + Valor + "_" + ValorZona).style.display = "none";
                    AcaoAtual = "desmarcar";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_bairro_img_" + Valor + "_" + ValorZona).style.display = "block";
                    AcaoAtual = "marcar";
                }
            }

            /*if (Opcao != "desmarcar") {
                if ((document.getElementById(Layer + "_ListaDeBairrosSelecionados").value.split("|").length) > 25) {
                    document.getElementById(Layer + "_busca_detalhada_bairro_img_" + Valor + "_" + ValorZona).style.display = "none";
                    alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 bairros por vez!");
                    return;
                }
            }*/
            var TempAtual = "";
            var TotalZona = 0;
            var TotalZonaSelecionado = 0;
            var TotalBairrosZona = 0;
            var TotalBairrosZonaSelecionados = 0;
            Selecionado = "";
            TotalZona = document.getElementById(Layer + "_TotalZona").value;
            SelecionadoAtualRegiao = "";
            if (document.getElementById(Layer + "_TotalZona").value.length > 0) {
                for (xZona = 1; xZona <= document.getElementById(Layer + "_TotalZona").value; xZona++) {
                    TotalBairrosZona = 0;
                    TotalBairrosZonaSelecionados = 0;
                    for (x = 1; x <= Total; x++) {
                        if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona) != undefined) {
                            TotalBairrosZona++;
                            if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).style.display == "block") {
                                TotalBairrosZonaSelecionados++;
                                if (document.all) {
                                    Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).innerText + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt + "|";
                                } else {
                                    Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).textContent + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt + "|";
                                }                                                                
                            }
                        }
                    }
                    if (TotalBairrosZonaSelecionados > 0) {                        
                        if (TotalBairrosZona == TotalBairrosZonaSelecionados) {
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "block";
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check.gif";
                        }
                        if ((TotalBairrosZona > TotalBairrosZonaSelecionados) && (TotalBairrosZona > 1)) {
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "block";
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check2.gif";
                        }
                        if ((TotalBairrosZona > TotalBairrosZonaSelecionados) && (TotalBairrosZona == 1)) {
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "none";
                            document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check.gif";
                        }
                    } else {
                        document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "none";
                        document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check.gif";
                    }
                    if (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona) != undefined) {
                        if ((document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display == "block") && (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src.indexOf("/imgs/topo/check.gif") >= 0)) {
                            if (document.all) {
                                SelecionadoAtualRegiao += document.getElementById(Layer + "_busca_detalhada_zona_texto_" + xZona).innerText + "|";
                            } else {
                                SelecionadoAtualRegiao += document.getElementById(Layer + "_busca_detalhada_zona_texto_" + xZona).textContent + "|";
                            }
                        }
                    }
                    if ((document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display == "block") && (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src.indexOf("/imgs/topo/check.gif") >= 0)) {
                        TotalZonaSelecionado++;
                    }    
                }
            }
            document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = TotalZonaSelecionado + "";
            document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = Selecionado;
            document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = SelecionadoAtualRegiao;
            if (Selecionado.length == 0) {
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
            } else {
                splitSelecionado = Selecionado.split("|");
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = splitSelecionado.length - 1;
                if (Layer == "layer_topo") {
                    Valor = 0;
                }
                if (Layer == "layer_refinarbusca") {
                    Valor = 1;
                }
            }
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();                                
                FiltrarRefinar(Objeto);                                
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function MarcarLazer(Objeto, Opcao, Total, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        document.getElementById(Layer + "_busca_detalhada_lazer_img_" + (x + 1)).style.display = "none";
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_lazer_img_" + Valor).style.display == "block") {
                document.getElementById(Layer + "_busca_detalhada_lazer_img_" + Valor).style.display = "none";
            } else {
                document.getElementById(Layer + "_busca_detalhada_lazer_img_" + Valor).style.display = "block";
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_lazer_img_" + (x + 1)).style.display == "block") {
                    if (document.all) {
                        Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_lazer_texto_" + (x + 1)).innerText;
                    } else {
                        Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_lazer_texto_" + (x + 1)).textContent;
                    }
                    if (Selecionado.length > 0) {
                        if (Selecionado.lastIndexOf("(") > 0) {
                            Selecionado = Selecionado.substring(0, Selecionado.lastIndexOf("(") - 1) + "|";
                        } else {
                            Selecionado = Selecionado + "|";
                        }
                    }
                    while (Selecionado.indexOf(String.fromCharCode(10)) > 0) {
                        Selecionado = Selecionado.replace(String.fromCharCode(10), "");
                    }
                    while (Selecionado.indexOf(String.fromCharCode(13)) > 0) {
                        Selecionado = Selecionado.replace(String.fromCharCode(13), "<br />");
                    }
                }
            }
            document.getElementById(Layer + "_ListaDeLazerSelecionados").value = Selecionado;
            if (Selecionado.length == 0) {
                if (document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado") != undefined) {
                    if (document.all) {
                        document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").innerText = "0";
                    } else {
                        document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").textContent = "0";
                    }
                }
            } else {
                splitSelecionado = Selecionado.split("|");
                if (document.all) {
                    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").innerText = (splitSelecionado.length - 1);
                } else {
                    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_selecionado").textContent = (splitSelecionado.length - 1);
                }
            }
            while (Selecionado.indexOf("<br />") > 0) {
                Selecionado = Selecionado.replace("<br />", "[br /]");
            }
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();                                
                FiltrarRefinar(Objeto);                                
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function MarcarCaracteristica(Objeto, Opcao, Total, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + (x + 1)).style.display = "none";
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + Valor).style.display == "block") {
                document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + Valor).style.display = "none";
            } else {
                document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + Valor).style.display = "block";
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_caracteristica_img_" + (x + 1)).style.display == "block") {
                    if (document.all) {
                        Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_caracteristica_texto_" + (x + 1)).innerText;
                    } else {
                        Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_caracteristica_texto_" + (x + 1)).textContent;
                    }
                    if (Selecionado.length > 0) {
                        if (Selecionado.lastIndexOf("(") > 0) {
                            Selecionado = Selecionado.substring(0, Selecionado.lastIndexOf("(") - 1) + "|";
                        } else {
                            Selecionado = Selecionado + "|";
                        }
                    }
                    while (Selecionado.indexOf(String.fromCharCode(10)) > 0) {
                        Selecionado = Selecionado.replace(String.fromCharCode(10), "");
                    }
                    while (Selecionado.indexOf(String.fromCharCode(13)) > 0) {
                        Selecionado = Selecionado.replace(String.fromCharCode(13), "<br />");
                    }
                }
            }
            document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value = Selecionado;
            if (Selecionado.length == 0) {
                if (document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_selecionado") != undefined) {
                    document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML = "0";
                }
            } else {
                splitSelecionado = Selecionado.split("|");
                document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML = splitSelecionado.length - 1;
            }
            while (Selecionado.indexOf("<br />") > 0) {
                Selecionado = Selecionado.replace("<br />", "[br /]");
            }
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                    
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function MarcarCidade(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    Parametros = "";
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxCidade = null;
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_cidade_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_cidade_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_cidade_img_" + Valor).style.display = "block";
                }
            }
            /*if (Opcao != "desmarcar") {
                if ((document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.split("|").length) > 25) {
                    document.getElementById(Layer + "_busca_detalhada_cidade_img_" + Valor).style.display = "none";
                    alert("ATENÇÃO:\n\nSó é permitido selecionar até 15 cidades por vez!");
                    return;
                }
            }*/
            
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_cidade_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_cidade_texto_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_cidade_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            document.getElementById(Layer + "_ListaDeCidadesSelecionados").value = Selecionado;
            if (Layer == "layer_topo") {
                document.getElementById(Layer + "_ListaDeBairrosSelecionados").value = "";
                document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = "";
            }
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);
            } else {
                splitSelecionado = Selecionado.split("|");
                document.getElementById(Layer + "_busca_detalhada_selecione_cidade_selecionado").innerHTML = splitSelecionado.length - 1;
                document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\"><img src=\"/images/loading2.gif\" style=\"10px;\" border=\"0\"><br />" + MensagemBairro + "</div>";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                if (Layer == "layer_topo") {
                    Valor = 0;
                }
                if (Layer == "layer_refinarbusca") {
                    Valor = 1;
                }
                ajaxCidade = ajaxInit();
                resultado = "";
                if (Layer == "layer_refinarbusca") {
                    ExibeMascaraBusca();
                }
                if (ajaxCidade) {
                    EnviaLazer = document.getElementById(Layer + "_ListaDeLazerSelecionados").value;
                    EnviaCaracteristica = document.getElementById(Layer + "_ListaDeCaracteristicasSelecionados").value;
                    while (EnviaLazer.indexOf("<br />") > 0) {
                        EnviaLazer = EnviaLazer.replace("<br />", "[br /]");
                    }
                    while (EnviaCaracteristica.indexOf("<br />") > 0) {
                        EnviaCaracteristica = EnviaCaracteristica.replace("<br />", "[br /]");
                    }
                    ValorInicial = document.getElementById(Layer + "_busca_detalhada_valor_inicial").value;
                    ValorFinal = document.getElementById(Layer + "_busca_detalhada_valor_final").value;

                    AreaPrivativaInicial = document.getElementById(Layer + "_busca_detalhada_area_privativa_inicial").value;
                    AreaPrivativaFinal = document.getElementById(Layer + "_busca_detalhada_area_privativa_final").value;

                    ProximoMetroInicial = document.getElementById(Layer + "_busca_detalhada_metro_inicial").value;
                    ProximoMetroFinal = document.getElementById(Layer + "_busca_detalhada_metro_final").value;

                    EstadosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeEstadosSelecionados").value.toLowerCase();
                    if (EstadosSelecionadosAJAX.length == 0) {
                        EstadosSelecionadosAJAX = "-";
                    }
                    CidadesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.toLowerCase();
                    if (CidadesSelecionadosAJAX.length == 0) {
                        CidadesSelecionadosAJAX = "-";
                    }
                    BairrosSelecionadosAJAX = document.getElementById(Layer + "_ListaDeBairrosSelecionados").value.toLowerCase();
                    if (BairrosSelecionadosAJAX.length == 0) {
                        BairrosSelecionadosAJAX = "-";
                    }
                    RegioesSelecionadosAJAX = document.getElementById(Layer + "_ListaDeRegioesSelecionados").value.toLowerCase();
                    if (RegioesSelecionadosAJAX.length == 0) {
                        RegioesSelecionadosAJAX = "-";
                    }
                    FinalidadeSelecionadosAJAX = document.getElementById(Layer + "_FinalidadeSelecionado").value.toLowerCase();
                    if (FinalidadeSelecionadosAJAX.length == 0) {
                        FinalidadeSelecionadosAJAX = "-";
                    }
                    TipoSelecionadosAJAX = document.getElementById(Layer + "_TipoSelecionado").value.toLowerCase();
                    if (TipoSelecionadosAJAX.length == 0) {
                        TipoSelecionadosAJAX = "-";
                    }
                    EstagioObraSelecionadosAJAX = document.getElementById(Layer + "_EstagioObraSelecionado").value.toLowerCase();
                    if (EstagioObraSelecionadosAJAX.length == 0) {
                        EstagioObraSelecionadosAJAX = "-";
                    }
                    DormitoriosSelecionadosAJAX = document.getElementById(Layer + "_DormitoriosSelecionado").value.toLowerCase();
                    if (DormitoriosSelecionadosAJAX.length == 0) {
                        DormitoriosSelecionadosAJAX = "-";
                    }
                    EnviaLazer = EnviaLazer.toLowerCase();
                    if (EnviaLazer.length == 0) {
                        EnviaLazer = "-";
                    }
                    EnviaCaracteristica = EnviaCaracteristica.toLowerCase();
                    if (EnviaCaracteristica.length == 0) {
                        EnviaCaracteristica = "-";
                    }
                    ValorInicial = ValorInicial.toLowerCase();
                    if (ValorInicial.length == 0) {
                        ValorInicial = "-";
                    }
                    ValorFinal = ValorFinal.toLowerCase();
                    if (ValorFinal.length == 0) {
                        ValorFinal = "-";
                    }
                    AreaPrivativaInicial = AreaPrivativaInicial.toLowerCase();
                    if (AreaPrivativaInicial.length == 0) {
                        AreaPrivativaInicial = "-";
                    }
                    AreaPrivativaFinal = AreaPrivativaFinal.toLowerCase();
                    if (AreaPrivativaFinal.length == 0) {
                        AreaPrivativaFinal = "-";
                    }
                    ProximoMetroInicial = ProximoMetroInicial.toLowerCase();
                    if (ProximoMetroInicial.length == 0) {
                        ProximoMetroInicial = "-";
                    }
                    ProximoMetroFinal = ProximoMetroFinal.toLowerCase();
                    if (ProximoMetroFinal.length == 0) {
                        ProximoMetroFinal = "-";
                    }
                    Layer = Layer.toLowerCase();
                    if (Layer.length == 0) {
                        Layer = "-";
                    }
                    TextoPesquisaAJAX = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value.toLowerCase();
                    if (TextoPesquisaAJAX.length == 0) {
                        TextoPesquisaAJAX = "-";
                    } else {
                        if (document.getElementById("layer_topo_cidade_atual").innerHTML.toLowerCase() != "rio de janeiro") {
                            if (TextoPesquisaAJAX == "ex.: apartamento 2 dormitórios vila mariana são paulo ou id/código do imóvel") {
                                TextoPesquisaAJAX = "-";
                            }
                        } else {
                            if (TextoPesquisaAJAX == "ex.: apartamento 2 quartos vila mariana são paulo ou id/código do imóvel") {
                                TextoPesquisaAJAX = "-";
                            }
                        }
                    }
                    if (Selecionado.length == 0) {
                        Selecionado = "-";
                    } else {
                        Selecionado = Selecionado.toLowerCase();
                    }
                    ajaxCidade.open("GET", "/ajax/lista_bairros.aspx?Estados=" + EstadosSelecionadosAJAX + "&Cidades=" + Selecionado + "&Bairros=-&Finalidades=" + FinalidadeSelecionadosAJAX + "&Tipos=" + TipoSelecionadosAJAX + "&EstagioObra=" + EstagioObraSelecionadosAJAX + "&Dormitorios=" + DormitoriosSelecionadosAJAX + "&Lazer=" + EnviaLazer + "&Caracteristicas=" + EnviaCaracteristica + "&ValorInicial=" + ValorInicial + "&ValorFinal=" + ValorFinal + "&AreaPrivativaInicial=" + AreaPrivativaInicial + "&AreaPrivativaFinal=" + AreaPrivativaFinal + "&ProximoMetroInicial=" + ProximoMetroInicial + "&ProximoMetroFinal=" + ProximoMetroFinal + "&Layer=" + Layer + "&TextoPesquisa=" + TextoPesquisaAJAX + "&Rand=" + Math.ceil(Math.random() * 100000), true);                    
                    
                    ajaxCidade.setRequestHeader("Content-type", "charset=iso-8859-1");
                    ajaxCidade.onreadystatechange = function () {
                        if (ajaxCidade.readyState == 4) {
                            if (ajaxCidade.status == 200) {
                                resultado = ajaxCidade.responseText;
                                TotalZonas = resultado.substring(resultado.indexOf("[total_zonas]") + "[total_zonas]".length, resultado.lastIndexOf("[/total_zonas]"));
                                resultado = resultado.replace("[total_zonas]" + TotalZonas + "[/total_zonas]", "");
                                document.getElementById(Layer + "_busca_detalhada_selecione_regiao_total").innerHTML = TotalZonas;
                                document.getElementById(Layer + "_TotalZona").value = TotalZonas;
                                if (resultado.length == 0) {
                                    document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = "<div style=\"margin: 10px; color: #777777;\">" + MensagemCidade4 + "</div>";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = "0";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = "0";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                    document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = "0";
                                } else {
                                    if ((Parametros.length > 0) && (Layer == "layer_refinarbusca")) {
                                        Parametros = resultado;
                                        Parametros2 = resultado.substring(resultado.lastIndexOf("[/caracteristica]") + "[/caracteristica]".length, resultado.length);
                                        ParametrosPlantas = Parametros2.substring(Parametros2.indexOf("[plantas]") + "[plantas]".length, Parametros2.lastIndexOf("[/plantas]"));
                                        Parametros2 = Parametros2.substring(Parametros2.indexOf("[/plantas]") + "[/plantas]".length, Parametros2.length);
                                        AtualizaParciais(Parametros, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2);
                                        if (ParametrosPlantas.substring(0, 1) == "1") {
                                            PopulaBusca("atualiza_pagina_busca_plantas", ParametrosPlantas, "", "", "", false);
                                        } else {
                                            document.getElementById("total_plantas_imoveis").innerHTML = "(0)";
                                            document.getElementById("plantas_imoveis_1").className = "abas_white_esq";
                                            document.getElementById("plantas_imoveis_1").innerHTML = "<img id=\"imagem_planta_imoveis_1\" src=\"/imgs/resultado_busca_03_off.jpg\" alt=\"\" border=\"0\" />";
                                            document.getElementById("plantas_imoveis").className = "abas_white_cen_off";
                                            document.getElementById("plantas_imoveis_2").className = "abas_white_dir";
                                            document.getElementById("plantas_imoveis_2").innerHTML = "<img id=\"imagem_planta_imoveis_2\" src=\"/imgs/resultado_busca_04_off.jpg\" alt=\"\" border=\"0\" />";
                                        }
                                        PopulaBusca("atualiza_pagina_busca", Parametros2, "", "", "");
                                        document.getElementById("resultado_busca_paginacao_plantas").style.display = "none";
                                        document.getElementById("resultado_busca_paginacao_plantas_2").style.display = "none";
                                        document.getElementById("resultado_busca_ordenar_plantas").style.display = "none";
                                        document.getElementById("resultado_busca_paginacao").style.display = "block";
                                        document.getElementById("resultado_busca_paginacao_2").style.display = "block";
                                        document.getElementById("resultado_busca_ordenar").style.display = "block";
                                        document.getElementById("resultado_busca").style.display = "block";
                                        document.getElementById("resultado_busca_plantas").style.display = "none";
                                    }
                                    if (document.getElementById(Layer + "_ListaDeCidadesSelecionados").value.length > 0) {
                                        document.getElementById(Layer + "_busca_detalhada_bairro_regiao_lista").innerHTML = resultado;
                                        TotalBairros = resultado.split("\"lista_bairros\"");
                                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerHTML = TotalBairros.length - 1;
                                        document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = resultado.split("block;").length - 1;
                                    }
                                }
                            } else {
                                ErroMascaraBusca();
                            }
                        }
                    }
                    ajaxCidade.send(null);
                }
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    } 
}

function MarcarBuscaDetalhadaLista() {
    StatusClique = false;
    timerCLIQUE = setTimeout("CliqueTrue()", 250);
}

function ArmazenaSelecionadosFinalidade(Layer, Total) {
    Selecionado = "";
    for (x = 0; x < Total; x++) {
        if (document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + (x + 1)) != undefined) {
            if (document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + (x + 1)).style.display == "block") {
                if (document.all) {
                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_finalidade_texto_" + (x + 1)).innerText;
                } else {
                    SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_finalidade_texto_" + (x + 1)).textContent;
                }
                if (SelecionadoAtual.length > 0) {
                    if (SelecionadoAtual.lastIndexOf("(") > 0) {
                        SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                    }
                }
                Selecionado = Selecionado + SelecionadoAtual + "|";
            }
        }
    }
    document.getElementById(Layer + "_FinalidadeSelecionado").value = Selecionado;
    return Selecionado;
}

function SelecionaFinalidade(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_finalidade_img_" + Valor).style.display = "block";
                }
            }
            Selecionado = ArmazenaSelecionadosFinalidade(Layer, Total);
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                                    
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function AtualizaParciais(Parametros, Layer, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2) {
    if (Parametros.length > 0) {
        TotalFinalidadeSelecionado = Parametros.substring(Parametros.indexOf("[total_finalidade_selecionado]") + "[total_finalidade_selecionado]".length, Parametros.indexOf("[/total_finalidade_selecionado]"));
        TotalFinalidade = Parametros.substring(Parametros.indexOf("[total_finalidade]") + "[total_finalidade]".length, Parametros.indexOf("[/total_finalidade]"));
        FinalidadeSelecionado = Parametros.substring(Parametros.indexOf("[finalidade_selecionado]") + "[finalidade_selecionado]".length, Parametros.indexOf("[/finalidade_selecionado]"));
        ExibeFinalidade = Parametros.substring(Parametros.indexOf("[finalidade]") + "[finalidade]".length, Parametros.indexOf("[/finalidade]"));
        if (ExibeFinalidade.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_finalidade_refinarbusca2").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_finalidade_refinarbusca").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_finalidade_refinarbusca2").innerHTML = ExibeFinalidade;
        } else {
            document.getElementById("layer_refinarbusca_busca_detalhada_finalidade_refinarbusca2").style.display = "none";
            document.getElementById("layer_refinarbusca_busca_detalhada_finalidade_refinarbusca").style.display = "none";
        }
        TotalTipoSelecionado = Parametros.substring(Parametros.indexOf("[total_tipo_selecionado]") + "[total_tipo_selecionado]".length, Parametros.indexOf("[/total_finalidade_selecionado]"));
        TotalTipo = Parametros.substring(Parametros.indexOf("[total_tipo]") + "[total_tipo]".length, Parametros.indexOf("[/total_tipo]"));
        TipoSelecionado = Parametros.substring(Parametros.indexOf("[tipo_selecionado]") + "[tipo_selecionado]".length, Parametros.indexOf("[/tipo_selecionado]"));
        ExibeTipo = Parametros.substring(Parametros.indexOf("[tipo]") + "[tipo]".length, Parametros.indexOf("[/tipo]"));
        if (ExibeTipo.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_tipo_refinarbusca2").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_tipo_refinarbusca").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_tipo_refinarbusca2").innerHTML = ExibeTipo;
        } else {
            document.getElementById("layer_refinarbusca_busca_detalhada_tipo_refinarbusca2").style.display = "none";
            document.getElementById("layer_refinarbusca_busca_detalhada_tipo_refinarbusca").style.display = "none";
        }
        TotalEstagioObraSelecionado = Parametros.substring(Parametros.indexOf("[total_estagio_obra_selecionado]") + "[total_estagio_obra_selecionado]".length, Parametros.indexOf("[/total_estagio_obra_selecionado]"));
        TotalEstagioObra = Parametros.substring(Parametros.indexOf("[total_estagio_obra]") + "[total_estagio_obra]".length, Parametros.indexOf("[/total_estagio_obra]"));
        EstagioObraSelecionado = Parametros.substring(Parametros.indexOf("[estagio_obra_selecionado]") + "[estagio_obra_selecionado]".length, Parametros.indexOf("[/estagio_obra_selecionado]"));
        ExibeEstagioObra = Parametros.substring(Parametros.indexOf("[estagio_obra]") + "[estagio_obra]".length, Parametros.indexOf("[/estagio_obra]"));
        if (ExibeTipo.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_estagio_refinarbusca2").style.display = "table";
            document.getElementById("layer_refinarbusca_busca_detalhada_estagio_refinarbusca").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_estagio_refinarbusca2").innerHTML = ExibeEstagioObra;
        } else {
            document.getElementById("layer_refinarbusca_busca_detalhada_estagio_refinarbusca2").style.display = "none";
            document.getElementById("layer_refinarbusca_busca_detalhada_estagio_refinarbusca").style.display = "none";
        }
        TotalDormitorioSelecionado = Parametros.substring(Parametros.indexOf("[total_dormitorios_selecionado]") + "[total_dormitorios_selecionado]".length, Parametros.indexOf("[/total_dormitorios_selecionado]"));
        TotalDormitorio = Parametros.substring(Parametros.indexOf("[total_dormitorios]") + "[total_dormitorios]".length, Parametros.indexOf("[/total_dormitorios]"));
        DormitorioSelecionado = Parametros.substring(Parametros.indexOf("[dormitorio_selecionado]") + "[dormitorio_selecionado]".length, Parametros.indexOf("[/dormitorio_selecionado]"));
        ExibeDormitorio = Parametros.substring(Parametros.indexOf("[dormitorios]") + "[dormitorios]".length, Parametros.indexOf("[/dormitorios]"));
        if (ExibeDormitorio.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_dormitorios_refinarbusca2").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_dormitorios_refinarbusca").style.display = "block";
            document.getElementById("layer_refinarbusca_busca_detalhada_dormitorios_refinarbusca2").innerHTML = ExibeDormitorio;
        } else {
            document.getElementById("layer_refinarbusca_busca_detalhada_dormitorios_refinarbusca2").style.display = "none";
            document.getElementById("layer_refinarbusca_busca_detalhada_dormitorios_refinarbusca").style.display = "none";
        }
        TotalEstadoSelecionado = Parametros.substring(Parametros.indexOf("[total_estados_selecionado]") + "[total_estados_selecionado]".length, Parametros.indexOf("[/total_estados_selecionado]"));
        TotalEstado = Parametros.substring(Parametros.indexOf("[total_estados]") + "[total_estados]".length, Parametros.indexOf("[/total_estados]"));
        ExibeEstado = Parametros.substring(Parametros.indexOf("[estados]") + "[estados]".length, Parametros.indexOf("[/estados]"));
        if (ExibeEstado.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_estado_lista").innerHTML = ExibeEstado;
        }
        TotalCidadeSelecionado = Parametros.substring(Parametros.indexOf("[total_cidades_selecionado]") + "[total_cidades_selecionado]".length, Parametros.indexOf("[/total_cidades_selecionado]"));
        TotalCidade = Parametros.substring(Parametros.indexOf("[total_cidades]") + "[total_cidades]".length, Parametros.indexOf("[/total_cidades]"));
        ExibeCidade = Parametros.substring(Parametros.indexOf("[cidades]") + "[cidades]".length, Parametros.indexOf("[/cidades]"));
        if (ExibeCidade.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_cidade_total").innerHTML = TotalCidade;
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_cidade_selecionado").innerHTML = TotalCidadeSelecionado;
            document.getElementById("layer_refinarbusca_busca_detalhada_cidade_lista").innerHTML = ExibeCidade;
        }
        TotalBairroSelecionado = Parametros.substring(Parametros.indexOf("[total_bairros_selecionado]") + "[total_bairros_selecionado]".length, Parametros.indexOf("[/total_bairros_selecionado]"));
        TotalBairro = Parametros.substring(Parametros.indexOf("[total_bairros]") + "[total_bairros]".length, Parametros.indexOf("[/total_bairros]"));
        ExibeBairro = Parametros.substring(Parametros.indexOf("[bairros]") + "[bairros]".length, Parametros.indexOf("[/bairros]"));
        if (ExibeBairro.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_bairro_regiao_total").innerHTML = TotalBairro;
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = TotalBairroSelecionado;
            document.getElementById("layer_refinarbusca_busca_detalhada_bairro_regiao_lista").innerHTML = ExibeBairro;
        }
        TotalLazerSelecionado = Parametros.substring(Parametros.indexOf("[total_lazer_selecionado]") + "[total_lazer_selecionado]".length, Parametros.indexOf("[/total_lazer_selecionado]"));
        TotalLazer = Parametros.substring(Parametros.indexOf("[total_lazer]") + "[total_lazer]".length, Parametros.indexOf("[/total_lazer]"));
        ExibeLazer = Parametros.substring(Parametros.indexOf("[lazer]") + "[lazer]".length, Parametros.indexOf("[/lazer]"));
        if (ExibeLazer.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_lazer_total").innerHTML = TotalLazer;
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_lazer_selecionado").innerHTML = TotalLazerSelecionado;
            document.getElementById("layer_refinarbusca_busca_detalhada_lazer_lista").innerHTML = ExibeLazer;
        }
        TotalCaracteristicaSelecionado = Parametros.substring(Parametros.indexOf("[total_caracteristica_selecionado]") + "[total_caracteristica_selecionado]".length, Parametros.indexOf("[/total_caracteristica_selecionado]"));
        TotalCaracteristica = Parametros.substring(Parametros.indexOf("[total_caracteristica]") + "[total_caracteristica]".length, Parametros.indexOf("[/total_caracteristica]"));
        ExibeCaracteristica = Parametros.substring(Parametros.indexOf("[caracteristica]") + "[caracteristica]".length, Parametros.indexOf("[/caracteristica]"));
        if (ExibeCaracteristica.length > 0) {
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_caracteristicas_total").innerHTML = TotalCaracteristica;
            document.getElementById("layer_refinarbusca_busca_detalhada_selecione_caracteristicas_selecionado").innerHTML = TotalCaracteristicaSelecionado;
            document.getElementById("layer_refinarbusca_busca_detalhada_caracteristicas_lista").innerHTML = ExibeCaracteristica;
        }
    }                         
}

function SelecionaTipo(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_tipo_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_tipo_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_tipo_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_tipo_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_tipo_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_tipo_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_tipo_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_tipo_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_tipo_texto_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_tipo_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            document.getElementById(Layer + "_TipoSelecionado").value = Selecionado;
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                                    
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function SelecionaEstagio(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_estagio_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_estagio_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_estagio_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_estagio_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_estagio_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_estagio_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_estagio_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_estagio_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            if (Layer == "layer_topo") {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estagio_texto_" + (x + 1)).innerHTML;
                            } else {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estagio_texto_" + (x + 1)).innerText;
                            }
                        } else {
                            if (Layer == "layer_topo") {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estagio_texto_" + (x + 1)).innerHTML;
                            } else {
                                SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_estagio_texto_" + (x + 1)).textContent; 
                            }
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            if (Selecionado.length > 0) {
                Selecionado = Selecionado.replace("\n", "").replace("<br />", "").replace("<br>","").replace("<BR>","").replace("/","/ ");
            }
            document.getElementById(Layer + "_EstagioObraSelecionado").value = Selecionado;
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                    
            } else {
                if (Selecionado.toLowerCase().indexOf("breve lançamento") >= 0) {
                    ValorInicialTemp = document.getElementById("layer_topo_busca_detalhada_valor_inicial").value;
                    ValorFinalTemp = document.getElementById("layer_topo_busca_detalhada_valor_final").value;
                    document.getElementById("layer_topo_busca_detalhada_valor_final").value = "";
                    document.getElementById("layer_topo_busca_detalhada_valor_inicial").value = "";
                    document.getElementById("layer_topo_busca_detalhada_valor_inicial").disabled = true;
                    document.getElementById("layer_topo_busca_detalhada_valor_final").disabled = true;
                    document.getElementById("layer_topo_mascara_valor").style.display = "block";
                } else {
                    document.getElementById("layer_topo_busca_detalhada_valor_inicial").value = ValorInicialTemp;
                    document.getElementById("layer_topo_busca_detalhada_valor_final").value = ValorFinalTemp;
                    document.getElementById("layer_topo_busca_detalhada_valor_inicial").disabled = false;
                    document.getElementById("layer_topo_busca_detalhada_valor_final").disabled = false;
                    document.getElementById("layer_topo_mascara_valor").style.display = "none";
                }
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function SelecionaDorms(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_dormitorios_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_dormitorios_texto_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_dormitorios_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            if (Selecionado.length > 0) {
                Selecionado = Selecionado.replace("4+", "4");
            }
            document.getElementById(Layer + "_DormitoriosSelecionado").value = Selecionado;
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                    
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function SelecionaSuites(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_suites_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_suites_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_suites_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_suites_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_suites_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_suites_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_suites_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_suites_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_suites_texto_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_suites_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            if (Selecionado.length > 0) {
                Selecionado = Selecionado.replace("4+", "4");
            }
            document.getElementById(Layer + "_SuitesSelecionado").value = Selecionado;
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);                    
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function SelecionaVagas(Objeto, Opcao, Total, MensagemEstado, MensagemEstado2, MensagemCidade, MensagemCidade2, MensagemCidade3, MensagemCidade4, MensagemBairro, MensagemBairro2, MensagemBairro3, MensagemBairro4, MensagemLazer, MensagemLazer2, MensagemCaracteristica, MensagemCaracteristica2, Layer) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "none";
        }
        var ajaxResultado = null;
        ID = Objeto.id;        
        if (ID.length > 0) {
            Selecionado = "";
            Valor = ID.substring(ID.lastIndexOf("_") + 1, ID.length);            
            if (Opcao == "desmarcar") {
                for (x = 0; x < Total; x++) {
                    if (parseInt(x + 1) != parseInt(Valor)) {
                        if (document.getElementById(Layer + "_busca_detalhada_vagas_img_" + (x + 1)) != undefined) {
                            document.getElementById(Layer + "_busca_detalhada_vagas_img_" + (x + 1)).style.display = "none";
                        }
                    }
                }
            }
            if (document.getElementById(Layer + "_busca_detalhada_vagas_img_" + Valor) != undefined) {
                if (document.getElementById(Layer + "_busca_detalhada_vagas_img_" + Valor).style.display == "block") {
                    document.getElementById(Layer + "_busca_detalhada_vagas_img_" + Valor).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_vagas_img_" + Valor).style.display = "block";
                }
            }
            for (x = 0; x < Total; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_vagas_img_" + (x + 1)) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_vagas_img_" + (x + 1)).style.display == "block") {
                        if (document.all) {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_vagas_texto_" + (x + 1)).innerText;
                        } else {
                            SelecionadoAtual = document.getElementById(Layer + "_busca_detalhada_vagas_texto_" + (x + 1)).textContent;
                        }
                        if (SelecionadoAtual.length > 0) {
                            if (SelecionadoAtual.lastIndexOf("(") > 0) {
                                SelecionadoAtual = SelecionadoAtual.substring(0, SelecionadoAtual.lastIndexOf("(") - 1);
                            }
                        }
                        Selecionado = Selecionado + SelecionadoAtual + "|";
                    }
                }
            }
            if (Selecionado.length > 0) {
                Selecionado = Selecionado.replace("4+", "4");
            }
            document.getElementById(Layer + "_VagasSelecionado").value = Selecionado;
            if (Layer == "layer_refinarbusca") {
                ExibeMascaraBusca();
                FiltrarRefinar(Objeto);
            }
        }
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

function ExibeDadosExpandirBuscaDetalhada() {
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.marginLeft = "100px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.width = "715px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_topo").style.width = "715px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_topo").style.backgroundImage = "url(/imgs/combo_busca_detalhada_topo2.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_rodape").style.width = "715px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_rodape").style.backgroundImage = "url(/imgs/combo_busca_detalhada_rodape2.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_conteudo").style.width = "715px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_conteudo").style.backgroundImage = "url(/imgs/combo_busca_detalhada_fundo2.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.width = "715px";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.backgroundImage = "url(/imgs/combo_busca_detalhada_fundo2.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_menos_opcoes").style.display = "table";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.display = "none";
    document.getElementById("layer_topo_busca_detalhada_area_privativa_lista").style.display = "block";
    document.getElementById("layer_topo_busca_detalhada_area_privativa_lista").style.marginTop = "3px";
    document.getElementById("layer_topo_busca_detalhada_metro_lista").style.display = "block";
    //document.getElementById("layer_topo_busca_detalhada_area_privativa_inicial").value = AreaPrivativaInicialTemp;
    //document.getElementById("layer_topo_busca_detalhada_area_privativa_final").value = AreaPrivativaFinalTemp;
    document.getElementById("layer_topo_busca_detalhada_metro_inicial").value = MetroInicialTemp;
    document.getElementById("layer_topo_busca_detalhada_metro_final").value = MetroFinalTemp;
    document.getElementById("layer_topo_busca_detalhada_buscar").style.width = "183px";
    document.getElementById("layer_topo_busca_detalhada_buscar").style.marginTop = "10px";
    document.getElementById("layer_topo_busca_detalhada_novas_opcoes").style.display = "block";
    document.getElementById("layer_topo_posicao_clicavel_topo").style.marginLeft = "-40px";
}

function ExpandirBuscaDatalhada(Status) {
    if (Status == undefined) {
        Status = 0;
    }
    if (Status == 0) {
        _gaq.push(['_trackPageview', '/aba-expandir-busca-detalhada']);
        ExibeDadosBuscaDetalhada();
        ExibeDadosExpandirBuscaDetalhada();
    }
}

function FocoCampoBusca() {
    document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").focus();
    document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value;
    ExibeBuscaDetalhada();
}

function ExibeDadosMinimizarBuscaDetalhada() {
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.marginLeft = "300px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.width = "515px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_topo").style.width = "515px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_topo").style.backgroundImage = "url(/imgs/combo_busca_detalhada_topo.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_rodape").style.width = "515px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_rodape").style.backgroundImage = "url(/imgs/combo_busca_detalhada_rodape.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_conteudo").style.width = "515px";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista_conteudo").style.backgroundImage = "url(/imgs/combo_busca_detalhada_fundo.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.width = "515px";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.backgroundImage = "url(/imgs/combo_busca_detalhada_fundo.png)";
    document.getElementById("layer_topo_menu_superior_form_principal_menos_opcoes").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_mais_opcoes").style.display = "table";
    document.getElementById("layer_topo_busca_detalhada_area_privativa_lista").style.display = "none";
    document.getElementById("layer_topo_busca_detalhada_area_privativa_lista").style.marginTop = "0px";
    document.getElementById("layer_topo_busca_detalhada_metro_lista").style.display = "none";
    //AreaPrivativaInicialTemp = document.getElementById("layer_topo_busca_detalhada_area_privativa_inicial").value;
    //AreaPrivativaFinalTemp = document.getElementById("layer_topo_busca_detalhada_area_privativa_final").value;
    //document.getElementById("layer_topo_busca_detalhada_area_privativa_inicial").value = "";
    //document.getElementById("layer_topo_busca_detalhada_area_privativa_final").value = "";
    MetroInicialTemp = document.getElementById("layer_topo_busca_detalhada_metro_inicial").value;
    MetroFinalTemp = document.getElementById("layer_topo_busca_detalhada_metro_final").value;
    document.getElementById("layer_topo_busca_detalhada_metro_inicial").value = "";
    document.getElementById("layer_topo_busca_detalhada_metro_final").value = "";

    document.getElementById("layer_topo_busca_detalhada_buscar").style.width = "293px";
    document.getElementById("layer_topo_busca_detalhada_buscar").style.marginTop = "5px";
    document.getElementById("layer_topo_busca_detalhada_novas_opcoes").style.display = "none";
    document.getElementById("layer_topo_posicao_clicavel_topo").style.marginLeft = "-240px";
}

function MinimizarBuscaDatalhada(Status) {
    if (Status == undefined) {
        Status = 0;
    }
    if (Status == 0) {
        _gaq.push(['_trackPageview', '/aba-minimizar-busca-detalhada']);
        ExibeDadosBuscaDetalhada();
        ExibeDadosMinimizarBuscaDetalhada();
    }
}

function VerificaSelecaoLazer(Objeto, Acao, Layer) {
    //if (document.getElementById(Layer + "_busca_detalhada_lazer_lista").style.display == "none") {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
    //}
}

function VerificaSelecaoCaracteristicas(Objeto, Acao) {
    //if (document.getElementById("layer_topo_busca_detalhada_caracteristicas_lista").style.display == "none") {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    //} else {
    //    Objeto.style.cursor = "default";
    //}
}

function ExibeDadosLazer(Layer) {
    document.getElementById(Layer + "_busca_detalhada_caracteristicas_lista").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas_opcoes").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_lazer_opcoes").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_lazer_lista").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_lazer").style.marginBottom = "0px";
    document.getElementById(Layer + "_busca_detalhada_lazer").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_seta").src = "/imgs/topo/set2.png";
    document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_seta").src = "/imgs/topo/set.png";
}

function SelecionaLazer(Objeto, Layer) {
    if (document.getElementById(Layer + "_busca_detalhada_lazer_lista").style.display == "none") {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosLazer(Layer);
    } else {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosCaracteristicas(Layer);
    }
}

function ExibeDadosCaracteristicas(Layer) {
    document.getElementById(Layer + "_busca_detalhada_lazer_lista").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_lazer_opcoes").style.display = "none";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas_opcoes").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas_lista").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas").style.marginBottom = "0px";
    document.getElementById(Layer + "_busca_detalhada_caracteristicas").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_lazer").style.backgroundColor = "#d4e0ed";
    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_seta").style.display = "block";
    document.getElementById(Layer + "_busca_detalhada_selecione_lazer_seta").src = "/imgs/topo/set.png";
    document.getElementById(Layer + "_busca_detalhada_selecione_caracteristicas_seta").src = "/imgs/topo/set2.png";
}

function SelecionaCaracteristicas(Objeto, Layer) {
    if (document.getElementById(Layer + "_busca_detalhada_caracteristicas_lista").style.display == "none") {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosCaracteristicas(Layer);
    } else {
        if (Layer == "layer_topo") {
            ExibeDadosBuscaDetalhada();
        }
        ExibeDadosLazer(Layer);
    }
}

function GravaSelecao(Tipo, Campo) {
    var ajaxSelecao = null;
    ajaxSelecao = ajaxInit();
    resultado = "";
    if (ajaxSelecao) {
        ajaxSelecao.open("GET", "/ajax/atualiza_selecao.aspx?Tipo=" + Tipo + "&Campo=" + Campo + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxSelecao.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxSelecao.onreadystatechange = function() {
        if (ajaxSelecao.readyState == 4) {
                if (ajaxSelecao.status == 200) {
                    resultado = ajaxSelecao.responseText;                    
                    if (Tipo == 0) {
                        MenuAberto = Campo;
                    }
                }
            }
        }
        ajaxSelecao.send(null);
    }
}

function LimpaOpcoesBuscaAvancada() {
    var ajaxSelecao = null;
    ajaxSelecao = ajaxInit();
    resultado = "";
    if (ajaxSelecao) {
        ajaxSelecao.open("GET", "/limpa-opcoes_busca-avancada/" + Math.ceil(Math.random() * 100000), true);
        //ajaxSelecao.open("GET", "/ajax/limpa_opcoes_busca_avancada.aspx?Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxSelecao.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxSelecao.onreadystatechange = function() {
            if (ajaxSelecao.readyState == 4) {
                if (ajaxSelecao.status == 200) {
                    resultado = ajaxSelecao.responseText;
                }
            }
        }
        ajaxSelecao.send(null);
    }
}

function FormataCampo(Objeto, Tipo, e) {
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        if (Tipo == "Moeda") {
            if (Objeto.value.length >= 12) {
                return false;
            }
            var objTextBox = Objeto;
            var SeparadorMilesimo = ".";
            var SeparadorDecimal = ",";
            var sep = 0;
            var key = '';
            var i = j = 0;
            var len = len2 = 0;
            var strCheck = '0123456789';
            var aux = aux2 = '';
            whichCode = e.keyCode;
            if (whichCode == 0) {
                whichCode = e.which;
            }
            // var whichCode = (window.Event) ? e.which : e.keyCode;
            if (whichCode == 13) {
                Objeto.blur();
                return false;
            } 
            if (whichCode == 8) return true;
            if (whichCode == 46) return false;
            if (whichCode == 44) return false;
            key = String.fromCharCode(whichCode); // Valor para o código da Chave
            if (strCheck.indexOf(key) == -1) return false; // Chave inválida
            len = objTextBox.value.length;
            for (i = 0; i < len; i++)
                if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
            aux = '';
            for (; i < len; i++)
                if (strCheck.indexOf(objTextBox.value.charAt(i)) != -1) aux += objTextBox.value.charAt(i);
            aux += key;
            len = aux.length;
            if (len == 0) objTextBox.value = '';
            if (len == 1) objTextBox.value = '0' + SeparadorDecimal + '0' + aux;
            if (len == 2) objTextBox.value = '0' + SeparadorDecimal + aux;
            if (len > 2) {
                aux2 = '';
                for (j = 0, i = len - 3; i >= 0; i--) {
                    if (j == 3) {
                        aux2 += SeparadorMilesimo;
                        j = 0;
                    }
                    aux2 += aux.charAt(i);
                    j++;
                }
                objTextBox.value = '';
                len2 = aux2.length;
                for (i = len2 - 1; i >= 0; i--)
                    objTextBox.value += aux2.charAt(i);
                objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
            }
            return false;
        }
    } else {
        return false;
    }
}

function VerificaEnter(Objeto, e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }
    if (key == "13") {
        Objeto.blur();
        return false;
    }
    if ((key == "45") || (key == "46") || (key == "47")) {
        return true;
    } else {
        keychar = String.fromCharCode(key);
        reg = /\d/;
        return reg.test(keychar);
    }
}

function bloquearTeclas(Objeto, e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }
    if (key == "13") {
        Objeto.blur();
        return false;
    }
    if ((key == "45") || (key == "46") || (key == "47")) {
        return true;
    } else {
        keychar = String.fromCharCode(key);
        reg = /\d/;
        return reg.test(keychar);
    }
}

function bloquearEnter(e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }
    if (key == "13") {
        return false;
    } else {
        return true;
    }
}

function SelecionaTudoClique(Link) {
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    if (Link.indexOf("http://") >= 0) {
        window.open(Link);
    } else {
        location.href = Link;
    }
}

function EsqueceuSenha() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

function VoltarEsqueceuSenha() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
    document.getElementById("layer_topo_usuario_esqueceu_senha_campo").value = "";
}

function VoltarEsqueceuSenha2() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

function VoltarLogin() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

EmailAtual = "";

function EnviarEsqueceuSenha(Mensagem) {
    var ajaxEsqueceuSenha = null;
    if (document.getElementById("layer_topo_usuario_esqueceu_senha_campo").value.length == 0) {
        alert(Mensagem);
        document.getElementById("layer_topo_usuario_esqueceu_senha_campo").focus();
        return;
    }
    ajaxEsqueceuSenha = ajaxInit();
    resultado = "";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";    
    if (ajaxEsqueceuSenha) {
        //ajaxEsqueceuSenha.open("GET", "/esqueceu_senha/" + document.getElementById("layer_topo_usuario_esqueceu_senha_campo").value + "/" + Math.ceil(Math.random() * 100000), true);
        ajaxEsqueceuSenha.open("GET", "/ajax/esqueceu_senha.aspx?EmailUsuario=" + document.getElementById("layer_topo_usuario_esqueceu_senha_campo").value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxEsqueceuSenha.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxEsqueceuSenha.onreadystatechange = function() {
            if (ajaxEsqueceuSenha.readyState == 4) {
                if (ajaxEsqueceuSenha.status == 200) {
                    resultado = ajaxEsqueceuSenha.responseText;
                    splitResultado = resultado.split("|");
                    if (splitResultado[0] == "0") {
                        timerID = setTimeout("ExibeErroEsqueceuSenha()", 500);
                    }
                    if (splitResultado[0] == "1") {
                        EmailAtual = splitResultado[1];
                        timerID = setTimeout("ExibeOKEsqueceuSenha()", 500);
                    }
                } else {
                    timerID = setTimeout("ExibeErroEsqueceuSenha()", 500);
                }
            }
        }
        ajaxEsqueceuSenha.send(null);
    }
}

function ExibeOKEsqueceuSenha() {
    document.getElementById("layer_topo_usuario_esqueceu_senha_sucesso_email").innerHTML = EmailAtual;
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

function ExibeErroEsqueceuSenha() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

function ExibeErroLogin() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
}

function ExibeOKLogin(Acessos, Saudacao, Nome, Apelido, Texto1, Texto2, Foto, Unidade, idSite) {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "block";
    document.getElementById("layer_topo_saudacao_usuario").innerHTML = Saudacao + ", ";
    document.getElementById("layer_topo_mensagem_usuario").innerHTML = "<b>" + Nome + "</b>";
    document.getElementById("layer_topo_acesso_usuario").innerHTML = "Este é o seu acesso nº <b>" + Acessos + "</b>";
    if (Unidade != idSite) {
        if (Unidade == "3") {
            document.getElementById("layer_topo_links_usuario").innerHTML = "<a href='http://www.fmeraprontos.com.br/corretor/" + Apelido + "'>" + Texto1 + "</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='javascript:Logout();'>" + Texto2 + "</a>";
        } else {
            document.getElementById("layer_topo_links_usuario").innerHTML = "<a href='http://www.fernandezmera.com.br/corretor/" + Apelido + "'>" + Texto1 + "</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='javascript:Logout();'>" + Texto2 + "</a>";
        }
    } else {
        document.getElementById("layer_topo_links_usuario").innerHTML = "<a href='/corretor/" + Apelido + "'>" + Texto1 + "</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href='javascript:Logout();'>" + Texto2 + "</a>";
    }    
    if (Foto.length > 0) {
        document.getElementById("layer_topo_foto_usuario").src = Foto;
    } else {
        document.getElementById("layer_topo_foto_usuario").src = "/images/semfoto.jpg";
    }
}

function ExibeOKLogout() {
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
    document.getElementById("layer_topo_usuario_login_campo").value = "";
    document.getElementById("layer_topo_senha_login_campo").value = "";
}

function Logout() {
    var ajaxLogout = null;
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
    ajaxLogout = ajaxInit();
    resultado = "";
    if (ajaxLogout) {
        //ajaxLogout.open("GET", "/efetuar_logout/" + Math.ceil(Math.random() * 100000), true);
        ajaxLogout.open("GET", "/ajax/logout.aspx?Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxLogout.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxLogout.onreadystatechange = function() {
            if (ajaxLogout.readyState == 4) {
                if (ajaxLogout.status == 200) {
                    resultado = ajaxLogout.responseText;
                    timerID = setTimeout("ExibeOKLogout()", 500);
                }
            }
        }
        ajaxLogout.send(null);
    } 
}

function EfetuarLogin(Mensagem1, Mensagem2) {
    var ajaxLogin = null;
    if (document.getElementById("layer_topo_usuario_login_campo").value.length == 0) {
        alert(Mensagem1);
        document.getElementById("layer_topo_usuario_login_campo").focus();
        return;
    }
    if (document.getElementById("layer_topo_senha_login_campo").value.length == 0) {
        alert(Mensagem2);
        document.getElementById("layer_topo_senha_login_campo").focus();
        return;
    }
    ajaxLogin = ajaxInit();
    resultado = "";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_ok").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela1").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_tabela2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_erro").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "block";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_errologin").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista_conteudo_oklogin").style.display = "none";
    if (ajaxLogin) {
        //ajaxLogin.open("GET", "/efetuar_login/" + document.getElementById("layer_topo_usuario_login_campo").value + "/" + document.getElementById("layer_topo_senha_login_campo").value + "/" + Math.ceil(Math.random() * 100000), true);
        ajaxLogin.open("GET", "/ajax/login.aspx?EmailUsuario=" + document.getElementById("layer_topo_usuario_login_campo").value + "&SenhaUsuario=" + document.getElementById("layer_topo_senha_login_campo").value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajaxLogin.setRequestHeader("Content-type", "charset=iso-8859-1");
        ajaxLogin.onreadystatechange = function() {
            if (ajaxLogin.readyState == 4) {
                if (ajaxLogin.status == 200) {
                    resultado = ajaxLogin.responseText;
                    splitResultado = resultado.split("|");
                    if (splitResultado[0] == "0") {
                        timerID = setTimeout("ExibeErroLogin()", 500);
                    }
                    if (splitResultado[0] == "1") {
                        EmailAtual = splitResultado[1];
                        timerID = setTimeout("ExibeOKLogin('" + splitResultado[2] + "','" + splitResultado[3] + "','" + splitResultado[1] + "','" + splitResultado[4] + "','" + splitResultado[5] + "','" + splitResultado[6] + "','" + splitResultado[7] + "','" + splitResultado[8] + "','" + splitResultado[9]+ "')", 500);
                    }
                } else {
                    timerID = setTimeout("ExibeErroLogin()", 500);
                }
            }
        }
        ajaxLogin.send(null);
    }
}

function MarcarCidadePadrao(Cidade) {
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    location.href = "/cidade/" + Cidade;
}

function SelecionaSitePadrao(Site, idSite) {
    if (Site == "1") {
        if (idSite != 3) {
            location.href = "/site/1";
        } else {
            location.href = "http://www.fernandezmera.com.br/site/1";
        }
    }
    if (Site == "2") {
        if (idSite != 3) {
            location.href = "/sol";
        } else {
            location.href = "http://www.fernandezmera.com.br/sol";
        }
    }
    if (Site == "3") {
        location.href = "http://www.fmeraprontos.com.br";
        //location.href = "/prontos";
    }    
}

function MarcarOpcaoBuscaPadrao(idOpcao, Opcao, Total) {
    var ajaxOpcao = null;
    if (Opcao.length > 0) {
        document.getElementById("layer_topo_opcoes_busca_conteudo").innerHTML = Opcao;
        document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
        document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
        for (x = 1; x <= Total; x++) {
            document.getElementById("opcao_busca_" + x).style.display = "block";
        }
        document.getElementById("opcao_busca_" + idOpcao).style.display = "none";
        ajaxOpcao = ajaxInit();
        resultado = "";
        if (ajaxOpcao) {
            ajaxOpcao.open("GET", "/atualiza-opcao-busca/" + idOpcao + "/" + Math.ceil(Math.random() * 100000), true);
            //ajaxOpcao.open("GET", "/ajax/atualiza_opcao_busca.aspx?idOpcao=" + idOpcao + "&Rand=" + Math.ceil(Math.random() * 100000), true);
            ajaxOpcao.setRequestHeader("Content-type", "charset=iso-8859-1");
            ajaxOpcao.onreadystatechange = function() {
                if (ajaxOpcao.readyState == 4) {
                    if (ajaxOpcao.status == 200) {
                        resultado = ajaxOpcao.responseText;
                        VerificaSugestoesPesquisa(document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre"));
                        document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").focus();
                        document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value = document.getElementById("layer_topo_layer_pesquisa_pesquisa_livre").value;                        
                    }
                }
            }
            ajaxOpcao.send(null);
        }        
    }
}

function ExibeDadosOpcoesBusca() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "block";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "none";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set2.png";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function ExibeOpcoesBusca(Status) {
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_opcoes_busca_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();                  
            }
        } else {
            ExibeOpcoesBusca();
        }
    }    
}

function DestacaOpcaoBusca(Objeto, Acao) {
    if (Acao == "over") {
        Objeto.style.cursor = "pointer";
        Objeto.style.backgroundColor = "#f0ecec";
        Objeto.style.color = "#eb1c24";
    } else {
        Objeto.style.cursor = "default";
        Objeto.style.backgroundColor = "";
        Objeto.style.color = "#777777";
    }
}

function AtualizaValores(Objeto) {
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_valor_inicial") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_valor_inicial_temp").value) {
            return;
        }
    }
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_valor_final") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_valor_final_temp").value) {
            return;
        }
    }
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_area_privativa_inicial") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_area_privativa_inicial_temp").value) {
            return;
        }
    }
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_area_privativa_final") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_area_privativa_final_temp").value) {
            return;
        }
    }
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_metro_inicial") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_metro_inicial_temp").value) {
            return;
        }
    }
    if (Objeto.id == "layer_refinarbusca_busca_detalhada_metro_final") {
        if (Objeto.value == document.getElementById("layer_refinarbusca_metro_final_temp").value) {
            return;
        }
    }
    StatusMascara = true;
    if (document.getElementById("resultado_busca_mascara_mensagem_loading") != undefined) {
        if (document.getElementById("resultado_busca_mascara_mensagem_loading").style.display != "block") {
            StatusMascara = true;
        } else {
            StatusMascara = false;
        }
    }
    if (StatusMascara) {
        ExibeMascaraBusca();                
        FiltrarRefinar(Objeto);        
    } else {
        if (document.getElementById("erro_msg_refinamento") != undefined) {
            document.getElementById("erro_msg_refinamento").style.display = "block";
        }
    }
}

ValorTelaAtual = 100;
TotalOpcoesMapa = 0;
idMapaPai0Geral = 0;
idMapaPai1Geral = 0;
TotalMapaPai0Geral = 0;
TotalMapaPai1Geral = 0;
NivelGeral = 0;
idMapaGeral = 0;
idMapaTempGeral = 0;
TotalMapaTempGeral = 0;
EstadoGeral = "";
CidadeGeral = "";
ZonaGeral = "";
TotalNivel0Geral = 0;

function SelecionaLinkMapa(idMapaTemp, TotalMapaTemp, idMapaPai0, TotalMapaPai0, idMapaPai1, TotalMapaPai1, Total, Cidade, Estado, Zona, Nivel, idMapa) {
    ValorTelaAtual = 95;
    idMapaTempGeral = idMapaTemp;
    TotalMapaTempGeral = TotalMapaTemp;
    TotalOpcoesMapa = Total;
    idMapaPai0Geral = idMapaPai0;
    idMapaPai1Geral = idMapaPai1;
    TotalMapaPai0Geral = TotalMapaPai0;
    TotalMapaPai1Geral = TotalMapaPai1;
    NivelGeral = Nivel;
    idMapaGeral = idMapa;
    EstadoGeral = Estado;
    CidadeGeral = Cidade;
    ZonaGeral = Zona;
    FadeOFFMapa();
}

ValorTelaAtual = 100;
ValorTelaAtual2 = 0;

function BuscarMapa(Estado, Cidade, Zona, Nivel) {
    /*if (Nivel == 0) {
        location.href = "/busca-detalhada/?estados=" + Estado;
    } else {
        if (Nivel == 2) {
            location.href = "/busca-detalhada/?estados=" + Estado + "&cidades=" + Estado + "&regioes=" + Estado + "-" + Estado + "-" + Zona;
        } else {
            location.href = "/busca-detalhada/?estados=" + Estado + "&cidades=" + Cidade;
        }
    }
    */
    if (Nivel == 0) {
        location.href = "/buscar/" + Estado;
    } else {
        if (Nivel == 2) {
            location.href = "/buscar/" + Estado + "-" + Zona;
        } else {
            if (Estado == Cidade) {
                location.href = "/buscar/" + Estado;
            } else {
                location.href = "/buscar/" + Estado + "-" + Cidade;
            }
        }
    }
}

function SelecionaLinkMapaV2(Nivel, idMapaPai0, TotalPai0, idMapaPai1, TotalPai1, idMapaPai2, TotalPai2, Estado, Cidade, Zona) {
    if ((TotalPai1 == 0) && (TotalPai2 == 0)) {
        BuscarMapa(Estado, Cidade, Zona, Nivel);
        return;
    }
    if (idMapaPai2 == 0) {
        BuscarMapa(Estado, Cidade, Zona, Nivel);
        return;
    }
    if (Nivel == 2) {
        BuscarMapa(Estado, Cidade, Zona, Nivel);
        return;
    }
    if (Nivel != 0) {
        if (document.getElementById("voltar_opcao_mapa_" + Nivel) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + Nivel).style.opacity = ValorTelaAtual / 100;
            document.getElementById("voltar_opcao_mapa_" + Nivel).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
        }
    }
    if (Nivel == 0) {
        idMapaPai = idMapaPai0;
        TotalPai = TotalPai0;
    }
    if (Nivel == 1) {
        idMapaPai = idMapaPai1;
        TotalPai = TotalPai1;
    }
    if (Nivel == 2) {
        idMapaPai = idMapaPai2;
        TotalPai = TotalPai2;
    }
    ObjetoAtual = document.getElementById("mapa_principal_" + Nivel + "_" + idMapaPai);
    if (ObjetoAtual == undefined) {
        BuscarMapa(Estado, Cidade, Zona, Nivel);
        return;
    }
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    for (x = 1; x <= TotalPai; x++) {
        document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.display = "table";
        document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.opacity = (ValorTelaAtual / 100);
        document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    }

    ValorTelaAtual -= 5;
    if (ValorTelaAtual >= 0) {
        timerID = setTimeout("SelecionaLinkMapaV2(" + Nivel + "," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ",'" + Estado + "','" + Cidade + "','" + Zona + "')", 20);
    } else {
        ObjetoAtual.style.display = "none";
        for (x = 1; x <= TotalPai; x++) {
            document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.display = "none";
        }
        if (document.getElementById("voltar_opcao_mapa_" + Nivel) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + Nivel).style.display = "none";
        }
        ValorTelaAtual2 = 0;
        ValorTelaAtual = 100;
        timerID = setTimeout("ExibeMapaON(" + Nivel + "," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 1);
    }
}

function VoltarLinkMapaV2(Nivel, idMapaPai0, TotalPai0, idMapaPai1, TotalPai1, idMapaPai2, TotalPai2) {
    if (Nivel == 1) {
        if (document.getElementById("voltar_opcao_mapa_" + Nivel) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + Nivel).style.opacity = ValorTelaAtual / 100;
            document.getElementById("voltar_opcao_mapa_" + Nivel).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
        }
    } else {
        if (idMapaPai1 == 0) {
            if (document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai2) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai2).style.opacity = ValorTelaAtual / 100;
                document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai2).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
            }
        } else {
            if (document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai1) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai1).style.opacity = ValorTelaAtual / 100;
                document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai1).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
            }
        }
    }
    if (Nivel == 1) {
        idMapaPai = idMapaPai1;
        TotalPai = TotalPai1;
    }
    if (Nivel == 2) {
        idMapaPai = idMapaPai2;
        TotalPai = TotalPai2;
    }
    ObjetoAtual = document.getElementById("mapa_principal_" + Nivel + "_" + idMapaPai);
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    for (x = 1; x <= TotalPai; x++) {
        if (Nivel == 2) {
            if (idMapaPai1 == 0) {
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai2 + "_" + x).style.display = "table";
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai2 + "_" + x).style.opacity = (ValorTelaAtual / 100);
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai2 + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
            } else {
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai1 + "_" + x).style.display = "table";
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai1 + "_" + x).style.opacity = (ValorTelaAtual / 100);
                document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai1 + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
            }
        } else {
            document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.display = "table";
            document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.opacity = (ValorTelaAtual / 100);
            document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
        }
    }
    ValorTelaAtual -= 5;
    if (ValorTelaAtual >= 0) {
        timerID = setTimeout("VoltarLinkMapaV2(" + Nivel + "," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 20);
    } else {
        if (Nivel == 1) {
            if (document.getElementById("voltar_opcao_mapa_" + Nivel) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + Nivel).style.display = "none";
            }
        } else {
            if (idMapaPai1 == 0) {
                if (document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai2) != undefined) {
                    document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai2).style.display = "none";
                }
            } else {
                if (document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai1) != undefined) {
                    document.getElementById("voltar_opcao_mapa_" + Nivel + "_" + idMapaPai1).style.display = "none";
                }
            }
        }
        for (x = 1; x <= TotalPai; x++) {
            if (Nivel == 2) {
                if (idMapaPai1 == 0) {
                    document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai2 + "_" + x).style.display = "none";
                } else {
                    document.getElementById("opcao_mapa_" + Nivel + "_" + idMapaPai1 + "_" + x).style.display = "none";
                }
            } else {
                document.getElementById("opcao_mapa_" + Nivel + "_" + x).style.display = "none";
            }
        }
        ObjetoAtual.style.display = "none";
        ValorTelaAtual = 100;
        ValorTelaAtual2 = 0;
        if (Nivel == 1) {
            timerID = setTimeout("ExibeMapaON(-1," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 1);
        } else {
            if ((TotalPai1 == 0) && (TotalPai2 > 0)) {
                timerID = setTimeout("ExibeMapaON(-1," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 1);
            } else {
                timerID = setTimeout("ExibeMapaON(0," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 1);
            }
        }
    }
}


function ExibeMapaON(Nivel, idMapaPai0, TotalPai0, idMapaPai1, TotalPai1, idMapaPai2, TotalPai2) {
    Fator = 1;
    if ((TotalPai1 == 0) && (TotalPai2 > 0) && (Nivel == 0)) {
        Fator = 2;
    }
    if ((Nivel + Fator) != 0) {
        if ((Nivel + Fator) == 1) {
            if (document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator)) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator)).style.display = "table";
                document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator)).style.opacity = ValorTelaAtual2 / 100;
                document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator)).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            }
        } else {
            if ((idMapaPai1 == 0) && (idMapaPai2 > 0)) {
                if (document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2) != undefined) {
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2).style.display = "table";
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2).style.opacity = ValorTelaAtual2 / 100;
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                }
            } else {
                if (document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1) != undefined) {
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1).style.display = "table";
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1).style.opacity = ValorTelaAtual2 / 100;
                    document.getElementById("voltar_opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                }
            }
        }
    }
    if ((Nivel + Fator) == 0) {
        idMapaPai = idMapaPai0;
        TotalPai = TotalPai0;
    }
    if ((Nivel + Fator) == 1) {
        idMapaPai = idMapaPai1;
        TotalPai = TotalPai1;
    }
    if ((Nivel + Fator) == 2) {
        idMapaPai = idMapaPai2;
        TotalPai = TotalPai2;
    }
    ObjetoAtual = document.getElementById("mapa_principal_" + (Nivel + Fator) + "_" + idMapaPai);
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual2 / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
    for (x = 1; x <= TotalPai; x++) {
        if ((Nivel+Fator) != 2) {
            document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + x).style.display = "table";
            document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + x).style.opacity = (ValorTelaAtual2 / 100);
            document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        } else {
            if (idMapaPai1 == 0) {
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2 + "_" + x).style.display = "table";
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2 + "_" + x).style.opacity = (ValorTelaAtual2 / 100);
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai2 + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            } else {
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1 + "_" + x).style.display = "table";
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1 + "_" + x).style.opacity = (ValorTelaAtual2 / 100);
                document.getElementById("opcao_mapa_" + (Nivel + Fator) + "_" + idMapaPai1 + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            }
        }
    }

    ValorTelaAtual2 += 5;
    if (ValorTelaAtual2 <= 100) {
        timerID = setTimeout("ExibeMapaON(" + Nivel + "," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 20);
    } else {
        //ObjetoAtual.style.display = "none";
        //for (x = 1; x <= TotalPai; x++) {
        //    document.getElementById("opcao_mapa_" + (Nivel+1) + "_" + x).style.display = "table";
        //}
        //if (document.getElementById("voltar_opcao_mapa_" + (Nivel+1)) != undefined) {
        //    document.getElementById("voltar_opcao_mapa_" + (Nivel+1)).style.display = "none";
        //}
        ValorTelaAtual2 = 0;
        ValorTelaAtual = 100;
        //timerID = setTimeout("ExibeMapaON(" + Nivel + "," + idMapaPai0 + "," + TotalPai0 + "," + idMapaPai1 + "," + TotalPai1 + "," + idMapaPai2 + "," + TotalPai2 + ")", 1);
    }    
}

function VoltarLinkMapa(idMapaTemp, TotalMapaTemp, idMapaPai0, TotalMapaPai0, idMapaPai1, TotalMapaPai1, Total, Nivel, TotalNivel0, idMapa) {
    ValorTelaAtual = 95;
    idMapaTempGeral = idMapaTemp;
    TotalMapaTempGeral = TotalMapaTemp;
    TotalOpcoesMapa = Total;
    idMapaPai0Geral = idMapaPai0;
    idMapaPai1Geral = idMapaPai1;
    TotalMapaPai0Geral = TotalMapaPai0;
    TotalMapaPai1Geral = TotalMapaPai1;
    NivelGeral = Nivel;
    idMapaGeral = idMapa;
    TotalNivel0Geral = TotalNivel0;
    if (Nivel == "1") {
        ValorTelaAtual = 95;
        FadeOFFMapaNivel0();
    }
    if (Nivel == "2") {
        if ((idMapaPai1.length == 0) && (idMapaPai0.length > 0)) {
            ValorTelaAtual = 95;
            idMapaPai0Geral = idMapaTemp;
            TotalOpcoesMapa = TotalMapaTemp;
            FadeOFFMapaNivel0();
        } else {
            ValorTelaAtual = 95;            
            FadeOFFMapaNivel1();
        }
    }
}

function FadeOFFMapaNivel1() {
    if (document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral) != undefined) {
        document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral).style.opacity = ValorTelaAtual / 100;
        document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
        document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral).style.display = "table";
    }
    ObjetoAtual = document.getElementById("mapa_principal_" + idMapaPai1Geral + "_" + NivelGeral);
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    for (x = 1; x <= TotalMapaPai1Geral; x++) {
        document.getElementById("opcao_mapa_" + idMapaPai1Geral + "_" + x).style.display = "table";
        document.getElementById("opcao_mapa_" + idMapaPai1Geral + "_" + x).style.opacity = (ValorTelaAtual / 100);
        document.getElementById("opcao_mapa_" + idMapaPai1Geral + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    }

    ValorTelaAtual -= 5;
    if (ValorTelaAtual >= 0) {
        timerID = setTimeout("FadeOFFMapaNivel1()", 20);
    } else {
        ObjetoAtual.style.display = "none";
        for (x = 1; x <= TotalMapaPai1Geral; x++) {
            document.getElementById("opcao_mapa_" + idMapaPai1Geral + "_" + x).style.display = "none";
        }
        if (document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + idMapaPai1Geral).style.display = "none";
        }
        ValorTelaAtual2 = 0;
        FadeONNivel1();
    }
}

function FadeONNivel1() {
    if (ValorTelaAtual2 < 100) {
        ObjetoAtual = document.getElementById("mapa_principal_" + idMapaPai0Geral + "_1");
        ObjetoAtual.style.display = "table";
        ObjetoAtual.style.opacity = (ValorTelaAtual2 / 100);
        ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        for (x = 1; x <= TotalMapaPai0Geral; x++) {
            document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.display = "table";
            document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.opacity = (ValorTelaAtual2 / 100);
            document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        }
        if (document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.opacity = ValorTelaAtual2 / 100;
            document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.display = "table";
        }        
        ValorTelaAtual2 += 5;
        timerID2 = setTimeout("FadeONNivel1()", 20);
    }
}

function FadeOFFMapaNivel0() {
    if (document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral) != undefined) {
        document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.opacity = ValorTelaAtual / 100;
        document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    }
    ObjetoAtual = document.getElementById("mapa_principal_" + idMapaPai0Geral + "_" + NivelGeral);
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    for (x = 1; x <= TotalOpcoesMapa; x++) {
        document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.display = "table";
        document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.opacity = (ValorTelaAtual / 100);
        document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    }
    
    ValorTelaAtual -= 5;
    if (ValorTelaAtual >= 0) {
        timerID = setTimeout("FadeOFFMapaNivel0()", 20);
    } else {
        ObjetoAtual.style.display = "none";
        for (x = 1; x <= TotalOpcoesMapa; x++) {
            document.getElementById("opcao_mapa_" + idMapaPai0Geral + "_" + x).style.display = "none";
        }        
        if (document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral) != undefined) {
            document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.display = "none";
        }
        ValorTelaAtual2 = 0;
        FadeONNivel0();
    }
}

function FadeONNivel0() {
    if (ValorTelaAtual2 < 100) {
        ObjetoAtual = document.getElementById("mapa_principal_0_0");
        ObjetoAtual.style.display = "table";
        ObjetoAtual.style.opacity = (ValorTelaAtual2 / 100);
        ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        for (x = 1; x <= TotalNivel0Geral; x++) {
            document.getElementById("opcao_mapa_0_" + x).style.display = "table";
            document.getElementById("opcao_mapa_0_" + x).style.opacity = (ValorTelaAtual2 / 100);
            document.getElementById("opcao_mapa_0_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        }
        ValorTelaAtual2 += 5;
        timerID2 = setTimeout("FadeONNivel0()", 20);
    }
}

function FadeOFFMapa() {
    if (NivelGeral == 0) {
        idMapaPai0Geral = "0";
    }
    if (NivelGeral <= 1) {
        TotalAtual = TotalMapaPai0Geral;
        idPaiAtual = idMapaGeral;
    } else {
        TotalAtual = TotalMapaPai1Geral;
        idPaiAtual = idMapaGeral;
    }
    if (EstadoGeral.length > 0) {
        EstadoGeral = EstadoGeral.toLowerCase();
        EstadoGeral = EstadoGeral.replace("<br />", " ");
        EstadoGeral = EstadoGeral.replace("<br-/>", " ");
        EstadoGeral = EstadoGeral.replace("/", "");
        while (EstadoGeral.indexOf(" ") >= 0) {
            EstadoGeral = EstadoGeral.replace(" ", "-");
        }
    }
    if (CidadeGeral.length > 0) {
        CidadeGeral = CidadeGeral.toLowerCase();
        CidadeGeral = CidadeGeral.replace("<br />", " ");
        CidadeGeral = CidadeGeral.replace("<br-/>", " ");
        CidadeGeral = CidadeGeral.replace("/", "");        
        while (CidadeGeral.indexOf(" ") >= 0) {
            CidadeGeral = CidadeGeral.replace(" ", "-");
        }
    }
    if (ZonaGeral.length > 0) {
        ZonaGeral = ZonaGeral.toLowerCase();
        ZonaGeral = ZonaGeral.replace("<br />", " ");
        ZonaGeral = ZonaGeral.replace("<br-/>", " ");
        ZonaGeral = ZonaGeral.replace("/", "");
        while (ZonaGeral.indexOf(" ") >= 0) {
            ZonaGeral = ZonaGeral.replace(" ", "-");
        }
    }
    if (CidadeGeral.toLowerCase() == "grande-sp") {
        CidadeGeral = "";
    }
    if (NivelGeral == 2) {
        if (ZonaGeral.length > 0) {
            if (CidadeGeral.length == 0) {
                location.href = "/buscar/" + EstadoGeral + "-" + ZonaGeral;
            } else {
                if (EstadoGeral != CidadeGeral) {
                    location.href = "/buscar/" + EstadoGeral + "-" + CidadeGeral + "-" + ZonaGeral;
                } else {
                    location.href = "/buscar/" + EstadoGeral + "-" + ZonaGeral;
                }
            }            
        } else {
            if (CidadeGeral.length == 0) {
                location.href = "/buscar/" + EstadoGeral;
            } else {
                if (EstadoGeral != CidadeGeral) {
                    location.href = "/buscar/" + EstadoGeral + "-" + CidadeGeral;
                } else {
                    location.href = "/buscar/" + EstadoGeral;
                }
            }
        }        
        return;
    }
    if (document.getElementById("mapa_principal_" + idPaiAtual + "_" + (parseInt(NivelGeral)+1)) == undefined) {
        if (document.getElementById("mapa_principal_" + idMapaTempGeral + "_2") == undefined) {
            if (ZonaGeral.length > 0) {
                if (CidadeGeral.length == 0) {
                    location.href = "/buscar/" + EstadoGeral + "-" + ZonaGeral;
                } else {
                    if (EstadoGeral != CidadeGeral) {
                        location.href = "/buscar/" + EstadoGeral + "-" + CidadeGeral + "-" + ZonaGeral;
                    } else {
                        location.href = "/buscar/" + EstadoGeral + "-" + ZonaGeral;
                    }
                }                            
            } else {
                if (CidadeGeral.length == 0) {
                    location.href = "/buscar/" + EstadoGeral;
                } else {
                    if (EstadoGeral != CidadeGeral) {
                        location.href = "/buscar/" + EstadoGeral + "-" + CidadeGeral;
                    } else {
                        location.href = "/buscar/" + EstadoGeral;
                    }
                }
            }
            return;
        }
    }

    if (document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral) != undefined) {
        document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.opacity = ValorTelaAtual2 / 100;
        document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
        document.getElementById("voltar_opcao_mapa_" + idMapaPai0Geral).style.display = "table";
    }

    ObjetoAtual = document.getElementById("mapa_principal_" + idMapaPai0Geral + "_" + NivelGeral);
    ObjetoAtual.style.display = "table";
    ObjetoAtual.style.opacity = (ValorTelaAtual / 100);
    ObjetoAtual.style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
    if (TotalOpcoesMapa > 0) {
        if (NivelGeral == 0) {
            idAtual = 0;
        } else {
            if (NivelGeral == "1") {
                idAtual = idMapaPai0Geral;
            } else {
                idAtual = idMapaPai0Geral;
            }
        }
        for (x = 1; x <= TotalOpcoesMapa; x++) {
            if (document.getElementById("opcao_mapa_" + idAtual + "_" + x) != undefined) {
                document.getElementById("opcao_mapa_" + idAtual + "_" + x).style.display = "table";
                document.getElementById("opcao_mapa_" + idAtual + "_" + x).style.opacity = (ValorTelaAtual / 100);
                document.getElementById("opcao_mapa_" + idAtual + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual + ");";
            }
        }
    }
    ValorTelaAtual -= 5;
    if (ValorTelaAtual >= 0) {
        timerID = setTimeout("FadeOFFMapa()", 20);
    } else {
        ObjetoAtual.style.display = "none";
        for (x = 1; x <= TotalOpcoesMapa; x++) {
            if (document.getElementById("opcao_mapa_" + idAtual + "_" + x) != undefined) {
                document.getElementById("opcao_mapa_" + idAtual + "_" + x).style.display = "none";
            }
        }
        ExibeMapa(idPaiAtual, TotalAtual, parseInt(NivelGeral) + 1);
    }
}

function ExibeMapa(idPaiAtual, TotalPai, NivelGeral) {
    if (document.getElementById("mapa_principal_" + idPaiAtual + "_" + NivelGeral) == undefined) {
        ValorTelaAtual2 = 0;
        FadeONMapa(1, '', '');
    } else {
        ValorTelaAtual2 = 0;
        FadeONMapa(2, idPaiAtual, NivelGeral);
    }
}

function FadeONMapa(Opcao, idPaiAtual, NivelGeral) {
    if (ValorTelaAtual2 < 100) {
        if (Opcao == 1) {
            document.getElementById("mapa_principal_" + idMapaTempGeral + "_2").style.opacity = ValorTelaAtual2 / 100;
            document.getElementById("mapa_principal_" + idMapaTempGeral + "_2").style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            document.getElementById("mapa_principal_" + idMapaTempGeral + "_2").style.display = "table";

            if (document.getElementById("voltar_opcao_mapa_" + idMapaTempGeral) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + idMapaTempGeral).style.opacity = ValorTelaAtual2 / 100;
                document.getElementById("voltar_opcao_mapa_" + idMapaTempGeral).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                document.getElementById("voltar_opcao_mapa_" + idMapaTempGeral).style.display = "table";
            }
            for (x = 1; x <= TotalMapaTempGeral; x++) {
                document.getElementById("opcao_mapa_" + idMapaTempGeral + "_" + x).style.opacity = ValorTelaAtual2 / 100;
                document.getElementById("opcao_mapa_" + idMapaTempGeral + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                document.getElementById("opcao_mapa_" + idMapaTempGeral + "_" + x).style.display = "table";
            }
        } else {
            document.getElementById("mapa_principal_" + idPaiAtual + "_" + NivelGeral).style.opacity = ValorTelaAtual2 / 100;
            document.getElementById("mapa_principal_" + idPaiAtual + "_" + NivelGeral).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
            document.getElementById("mapa_principal_" + idPaiAtual + "_" + NivelGeral).style.display = "table";

            if (document.getElementById("voltar_opcao_mapa_" + idPaiAtual) != undefined) {
                document.getElementById("voltar_opcao_mapa_" + idPaiAtual).style.opacity = ValorTelaAtual2 / 100;
                document.getElementById("voltar_opcao_mapa_" + idPaiAtual).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                document.getElementById("voltar_opcao_mapa_" + idPaiAtual).style.display = "table";
            }
            if (TotalMapaPai1Geral > 0) {
                TotalMapaTempGeral = TotalMapaPai1Geral;
            } else {
                TotalMapaTempGeral = TotalMapaPai0Geral;
            }
            for (x = 1; x <= TotalMapaTempGeral; x++) {
                if (document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x) != undefined) {
                    if (TotalMapaPai1Geral > 0) {
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.opacity = ValorTelaAtual2 / 100;
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.display = "table";
                    } else {
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.opacity = ValorTelaAtual2 / 100;
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.filter = "alpha(opacity = " + ValorTelaAtual2 + ");";
                        document.getElementById("opcao_mapa_" + idPaiAtual + "_" + x).style.display = "table";
                    }
                }
            }
        }
        ValorTelaAtual2 += 5;
        timerID2 = setTimeout("FadeONMapa(" + Opcao + ",'" + idPaiAtual + "','" + NivelGeral + "')", 20);
    }
}

function RolagemDestaque(Valor,idSite,id) {
    var Objeto;
    if (idSite != "3") {
        if (document.getElementById("home_empreendimentos_rolagem_02_1").style.display == "block") {
            Objeto = document.getElementById("home_empreendimentos_rolagem_02_1");
        }
        if (document.getElementById("home_empreendimentos_rolagem_02_2").style.display == "block") {
            Objeto = document.getElementById("home_empreendimentos_rolagem_02_2");
        }
        if (document.getElementById("home_empreendimentos_rolagem_02_3").style.display == "block") {
            Objeto = document.getElementById("home_empreendimentos_rolagem_02_3");
        }
        if (document.getElementById("home_empreendimentos_rolagem_02_4").style.display == "block") {
            Objeto = document.getElementById("home_empreendimentos_rolagem_02_4");
        }
        if (document.getElementById("home_empreendimentos_rolagem_02_5").style.display == "block") {
            Objeto = document.getElementById("home_empreendimentos_rolagem_02_5");
        }
    } else {
        if (id == "1") {
            if (document.getElementById("home_empreendimentos_rolagem_prontos_1_02_1").style.display == "block") {
                Objeto = document.getElementById("home_empreendimentos_rolagem_prontos_1_02_1");
            }
            if (document.getElementById("home_empreendimentos_rolagem_prontos_1_02_2").style.display == "block") {
                Objeto = document.getElementById("home_empreendimentos_rolagem_prontos_1_02_2");
            }
        }
        if (id == "2") {
            if (document.getElementById("home_empreendimentos_rolagem_prontos_2_02_1").style.display == "block") {
                Objeto = document.getElementById("home_empreendimentos_rolagem_prontos_2_02_1");
            }
            if (document.getElementById("home_empreendimentos_rolagem_prontos_2_02_2").style.display == "block") {
                Objeto = document.getElementById("home_empreendimentos_rolagem_prontos_2_02_2");
            }
        }
        if (id == "3") {
            if (document.getElementById("home_empreendimentos_rolagem_prontos_3_02_1").style.display == "block") {
                Objeto = document.getElementById("home_empreendimentos_rolagem_prontos_3_02_1");
            }
        }
    }
    Objeto.scrollLeft += Valor;
}

timerRolagem = null;

function IniciaRolagemDestaque(Valor) {
    RolagemDestaque(Valor);
    timerRolagem = setTimeout("IniciaRolagemDestaque(" + Valor + ")", 1);    
}

function CancelaRolagem() {
    clearTimeout(timerRolagem);
}

function Institucional() {
    location.href = "/institucional";
}

function ExibeDadosEmpresas() {
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.display = "none";
    document.getElementById("layer_topo_layer_pesquisa_img_seta_pesquisa").src = "/images/seta_pesquisa.png";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderTop = "0px dashed #eeeeee";
    document.getElementById("layer_topo_layer_pesquisa_resultado_sugestoes_pesquisa").style.borderBottom = "0px solid #bdbdbd";
    document.getElementById("layer_topo_layer_pesquisa_seta_pesquisa").style.marginTop = "1px";
    document.getElementById("layer_topo_opcoes_busca_lista").style.display = "none";
    document.getElementById("layer_topo_topo_05_box_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_login_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_03_lista").style.display = "none";
    document.getElementById("layer_topo_topo_01_idioma_lista").style.display = "none";
    document.getElementById("layer_topo_seta_idioma").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_opcoes_busca_seta").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_login").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_seta_tudo_clique").src = "/imgs/topo/set_red.jpg";
    document.getElementById("layer_topo_topo_menu_02_04_lista").style.display = "none";
    document.getElementById("layer_topo_topo_menu_02_02_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_estilo_lista").style.display = "none";
    document.getElementById("layer_topo_menu_superior_form_principal_detalhada_lista").style.display = "none";
    document.getElementById("layer_topo_topo_02_box_lista").style.display = "block";
    document.getElementById("layer_topo_seta_empresas").src = "/imgs/topo/set_red2.jpg";
    document.getElementById("layer_topo_seta_intranet").src = "/imgs/topo/set.png";
    document.getElementById("layer_topo_topo_01_intranet_lista").style.display = "none";
    SomeDadosFichaProduto();
    SomeDadosErro();
}

function Empresas(Status) {
    StatusClique = false;
    if (Status == undefined) {
        Status = 0;
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display = "none";
    }
    if (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "") {
        document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display = "none";
    }
    if ((document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading").style.display == "none") && (document.getElementById("layer_topo_topo_01_login_lista_conteudo_loading2").style.display == "none")) {
        if (document.getElementById("layer_topo_topo_02_box_lista").style.display == "block") {
            if (Status == 0) {
                FechaTodasAbas();
                FechaSugestoes();
                FechaAbasPesquisa();    
                timerCLIQUE = setTimeout("CliqueFalse()", 250);
            }
        } else {
            _gaq.push(['_trackPageview', '/aba-empresas']);
            ExibeDadosEmpresas();
            FechaAbasPesquisa();
            timerCLIQUE = setTimeout("CliqueTrue()", 250);
        }
    }
}

function Servicos() {
    location.href = "/servicos";
}

function Lojas(idSite) {
    if (idSite == "3") {
        location.href = "/institucional/lojas";
    } else {
        location.href = "/institucional/proximos-eventos";
    }
}

function TrabalheConosco() {
    location.href = "/trabalhe-conosco";
}

function FaleConosco() {
    SomeDadosFichaProduto();
    location.href = "/fale-conosco";
}

function LigamosPraVoce() {
    SomeDadosFichaProduto();
    location.href = "/ligamos-para-voce";
}

function NossasUnidades() {
    SomeDadosFichaProduto();
    location.href = "/institucional/nossas-unidades";
}

function LinkRedeSocial(Link) {
    if (Link.length > 0) {
        window.open(Link);
    }
}

function VerificaRedeSocial(Objeto, Acao) {
    if (Objeto.src.indexOf("_off") < 0) {
        if (Acao == "over") {
            Objeto.style.cursor = "pointer";
        } else {
            Objeto.style.cursor = "default";
        }
    }
}

function ExpandirZona(ValorZona, Layer) {
    ObjetoZona = document.getElementById(Layer + "_lista_geral_regiao_" + ValorZona);
    if (ObjetoZona != undefined) {
        if (ObjetoZona.style.display == "none") {
            ObjetoZona.style.display = "block";
        } else {
            ObjetoZona.style.display = "none";
        }                
    }
}

SelecionadoAtualRegiao = "";

function MarcarZona(Objeto, ValorZona, Layer, TotalBairros) {
    ObjetoZona = document.getElementById(Layer + "_busca_detalhada_zona_img_" + ValorZona);
    if (ObjetoZona != undefined) {
        if (ObjetoZona.style.display == "none") {
            ObjetoZona.style.display = "block";
        } else {
            ObjetoZona.style.display = "none";            
        }
        TotalZonaSelecionado = 0;
        if (document.getElementById(Layer + "_TotalZona").value.length > 0) {
            for (xZona = 1; xZona <= document.getElementById(Layer + "_TotalZona").value; xZona++) {
                if ((document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display == "block") && (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src.indexOf("/imgs/topo/check.gif") >= 0)) {                
                    TotalZonaSelecionado++;
                }
            }
        }
        document.getElementById(Layer + "_busca_detalhada_selecione_regiao_selecionado").innerHTML = TotalZonaSelecionado + "";        ;
        ObjetoZona.src = "/imgs/topo/check.gif";        
        for (x = 1; x <= TotalBairros; x++) {
            if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + ValorZona) != null) {
                if (ObjetoZona.style.display == "none") {
                    document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + ValorZona).style.display = "none";
                } else {
                    document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + ValorZona).style.display = "block";
                }
            }
        }
    }
    TotalBairroSelecionado = 0;
    Selecionado = "";
    SelecionadoAtualRegiao = "";
    if (document.getElementById(Layer + "_TotalZona").value.length > 0) {
        for (xZona = 1; xZona <= document.getElementById(Layer + "_TotalZona").value; xZona++) {
            if (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona) != undefined) {
                if ((document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display == "block") && (document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src.indexOf("/imgs/topo/check.gif") >= 0)) {
                    if (document.all) {
                        SelecionadoAtualRegiao += document.getElementById(Layer + "_busca_detalhada_zona_texto_" + xZona).innerText + "|";
                    } else {
                        SelecionadoAtualRegiao += document.getElementById(Layer + "_busca_detalhada_zona_texto_" + xZona).textContent + "|";
                    }                                                                                    
                }
            }
            for (x = 1; x <= TotalBairros; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona) != undefined) {
                    if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).style.display == "block") {
                        TotalBairroSelecionado++;
                        if (document.all) {
                            Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).innerText + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt + "|";
                        } else {
                            Selecionado = Selecionado + document.getElementById(Layer + "_busca_detalhada_bairro_texto_" + x + "_" + xZona).textContent + "^^" + document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).alt + "|";
                        }                                                                
                    }
                }
            }
        }
    }
    document.getElementById(Layer + "_ListaDeRegioesSelecionados").value = SelecionadoAtualRegiao;
    document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_selecionado").innerHTML = TotalBairroSelecionado + "";
}

function VerificaZonas(Layer) {
    TotalZona = document.getElementById(Layer + "_TotalZona").value;
    TotalBairrosZona = 0;
    TotalBairrosZonaSelecionado = 0;    
    if (document.all) {
        TotalBairros = document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").innerText;
    } else {
        TotalBairros = document.getElementById(Layer + "_busca_detalhada_selecione_bairro_regiao_total").textContent;
    }
    TotalBairros = parseInt(TotalBairros);
    if (document.getElementById(Layer + "_TotalZona").value.length > 0) {
        for (xZona = 1; xZona <= document.getElementById(Layer + "_TotalZona").value; xZona++) {
            TotalBairrosZona = 0;
            TotalBairrosZonaSelecionado = 0;            
            for (x = 1; x <= TotalBairros; x++) {
                if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona) != undefined) {
                    TotalBairrosZona++;
                    if (document.getElementById(Layer + "_busca_detalhada_bairro_img_" + x + "_" + xZona).style.display == "block") {
                        TotalBairrosZonaSelecionado++;
                    }
                }
            }
            if (TotalBairrosZona == TotalBairrosZonaSelecionado) {
                document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "block";
                document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check.gif";
            } else {
                if (TotalBairrosZonaSelecionado >= 1) {
                    document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).style.display = "block";
                    document.getElementById(Layer + "_busca_detalhada_zona_img_" + xZona).src = "/imgs/topo/check2.gif";
                }
            }
        }
    }
}

