﻿// JavaScript Document
function Ajax() {
    var ajax;
    try {
        ajax = new XMLHttpRequest();
    }
    catch (e) {
        try {
            ajax = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                ajax = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Seu browser não da suporte à AJAX!");
                return false;
            }
        }
    }
    return ajax;
    }


function AbreFecha(id) {
    if (document.getElementById(id).style.display == "none") {
        document.getElementById(id).style.display = "block";
    }
    else {
        document.getElementById(id).style.display = "none";
    }
}

function TrocaValor(id, valor) {
    if (valor == id) {
        document.getElementById(id).value = "";
    }
    if (valor == "") {
        document.getElementById(id).value = id;
    }
}

function PreLoadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) {
            d.MM_p = new Array();
        }
        var i, j = d.MM_p.length, a = PreLoadImages.arguments;
        for (i = 0; i < a.length; i++) {
            if (a[i].indexOf("#") != 0) {
                d.MM_p[j] = new Image; d.MM_p[j++].src = a[i];
            }
        }
    }
}

function BotaoAtivo(id, tag, classe) {
    var ArrayTag = document.getElementsByTagName(tag);
    for (i = 0; i < ArrayTag.length; i++) {
        if ((ArrayTag[i].className == classe) || (ArrayTag[i].className == classe + '_over')) {
            if (ArrayTag[i].id == id) {
                if (ArrayTag[i].className == classe + '_over') {
                    ArrayTag[i].className = classe;
                }
                else {
                    ArrayTag[i].className = classe + '_over';
                }
            }
            else {
                ArrayTag[i].className = classe;
            }
        }
    }
}

function BotaoCheck(id, classe) {
    var resultado = classe.indexOf("_over");
    if (Number(resultado) > 0) {
        document.getElementById(id).value = 'S';
    }
    else {
        document.getElementById(id).value = 'N';
    }
}

var selectId = "";
var selectAtivo = "";
var selectAltura = "";

function SelExp(id, fim, mais) {
    document.getElementById(id).style.visibility = "visible";
    var altura = document.getElementById(id).style.height;
    altura = altura.split("p");
    altura = altura[0];
    if (Number(altura) < Number(fim)) {
        var px_altura = Number(altura) + Number(mais);
        document.getElementById(id).style.height = px_altura + 'px';
        window.setTimeout("SelExp('" + id + "', '" + fim + "', '" + mais + "')", 1);
    }
    if (Number(altura) == Number(fim)) {
        selectAltura = Number(fim);
        selectAtivo = "S";
        selectId = id;
    }
}

function SelEnc(id, menos) {
    var altura = document.getElementById(id).style.height;
    altura = altura.split("p");
    altura = altura[0];
    if (Number(altura) > 1) {
        var px_altura = Number(altura) - Number(menos);
        document.getElementById(id).style.height = px_altura + 'px';
        window.setTimeout("SelEnc('" + id + "', " + menos + ")", 1);
    }
    if (Number(altura) == 0) {
        selectAtivo = "";
        selectAltura = "";
        document.getElementById(id).style.visibility = "hidden";
    }
}

window.onload = function() {
    elementos = document.body.getElementsByTagName('*');
    for (i = 0; i < elementos.length; i++) {
        if (elementos[i].onclick == undefined) {
            elementos[i].onclick = function() {
                if (this.tagName == 'LI') {
                    if (this.className == 'opcao_ativa') {
                        Id = 'lista_' + this.title;
                        var title = document.getElementById(Id).title;
                        var title = title.split("_");
                        var fim = title[0];
                        var mais = title[1];

                        if (selectAtivo == "S") {
                            SelExp(Id, fim, mais);
                            SelEnc(selectId, mais);
                        }
                        if (selectAtivo == "") {
                            SelExp(Id, fim, mais);
                        }
                    }
                    if (this.className == 'li_op') {
                        document.getElementById('ativa_' + this.title).innerHTML = this.innerHTML;
                        document.getElementById('valor_' + this.title).value = this.id;
                        selectId = 'lista_' + this.title;
                        selectAtivo = "";
                        var title = document.getElementById(selectId).title;
                        var title = title.split("_");
                        var menos = title[1];

                        if (selectAltura != "") {
                            SelEnc(selectId, menos);
                        }
                    }
                }
                else {
                    if (selectAtivo == 'S') {
                        if (selectAltura != '') {
                            var title = document.getElementById(selectId).title;
                            var title = title.split("_");
                            var menos = title[1];
                            selectAtivo = "";
                            SelEnc(selectId, menos);
                        }
                    }
                }
            }
        }
    }
}

function Resize() {
    var largura = document.body.clientWidth;
    var navegador = navigator.appVersion;
    var navegador = navegador.split(" ");
    var tipo = navegador[2];
    if (tipo == "MSIE") {
        var versao = navegador[3];
        if (versao == "6.0;") {
            if (largura < 896) {
                document.getElementById('geral').style.width = '895px';
            }
            else {
                document.getElementById('geral').style.width = '';
            }
        }
    }
}

function Retorno() {
    var largura = document.body.clientWidth;
    var altura = document.body.clientHeight;

    document.getElementById('retorno_capa').style.width = largura + 'px';
    document.getElementById('retorno_capa').style.height = altura + 'px';

    document.getElementById('retorno_capa').style.display = 'block';
    document.getElementById('retorno').style.display = 'block';
}

function AbaHome(id_aba_on) {

    if (id_aba_on == 'cp_destaques') {
        document.getElementById('cp_destaques').className = 'cp_destaques';
        document.getElementById('cp_lancamentos').className = 'cp_lancamentos' + '_off';
        document.getElementById('destaques').style.display = 'block';
        document.getElementById('lancamentos').style.display = 'none';
    }
    else if (id_aba_on == 'cp_lancamentos') {
        document.getElementById('cp_lancamentos').className = 'cp_lancamentos';
        document.getElementById('cp_destaques').className = 'cp_destaques' + '_off';
        document.getElementById('lancamentos').style.display = 'block';
        document.getElementById('destaques').style.display = 'none';
    }
}

function ImgGrande(caminho) {

    document.getElementById('imovel_det_img_G').src = caminho;
}

function Titulo(id, classe) {

    var marcado = document.getElementById(id).checked;

    if (marcado == true) {
        document.getElementById(classe).className = 'cadastro_' + classe + '_on';
    }
    else {
        document.getElementById(classe).className = 'cadastro_' + classe;
    }

}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

function maskLogin(id, texto) {
    var textField = document.getElementById('' + id + '');
    if (textField.value == texto) {
        textField.value = "";
    }
}
function exibeFileUpload() {
    for (i = 0; i < 10; i++) {
        var div = document.getElementById(i);
        if ($(div).css("display") == "none") {
            div.style.display = 'block';
            if (i == 9) {
                var div2 = document.getElementById('divBtnUpLoad');
                div2.style.display = 'none';
            }
            return;
        }
    }

}
$(document).ready(function() {

    $(".scroll-pane img").each(function(i) {
        $(this).click(function() {
            $(".scroll-pane img").removeClass("active");
            $(".scroll-pane img").eq(i).addClass("active");
            var tamanho = $(".scroll-pane img").size();
            if (i == 0) {
                $(".imovel_foto_anterior").fadeIn("fast").hide();
            } else if (i == (tamanho - 1)) {
                $(".imovel_foto_proxima").fadeIn("fast").hide();
            } else {
                $(".imovel_foto_anterior").fadeIn("fast").show();
                $(".imovel_foto_proxima").fadeIn("fast").show();
            }

        });
    });

    /* Botões de 'voltar' e 'avançar' na lista de imagens dos stands ... */
    $(".scroll-pane img:first").addClass("active");
    $("#curImg").val("0");
    $(".imovel_foto_anterior").hide();
    $(".imovel_foto_anterior").click(function() {
        var posicao = -1;
        $(".scroll-pane img").each(function(i) {
            if ($(this).hasClass("active")) {
                $(this).removeClass("active");
                posicao = i;
            }
        });
        if (posicao > -1) {
            var thumb = $(".scroll-pane img").eq(posicao - 1);
            $(".imovel_det_img_G #imovel_det_img_G").fadeOut("fast",
                    function() {
                        $(".imovel_det_img_G #imovel_det_img_G").attr({ src: thumb.attr("rel") }).fadeIn("slow");
                    }
                );
            thumb.addClass("active");
            $("#curImg").val(posicao - 1);
        }
        if ($(".imovel_foto_proxima").is(":hidden")) {
            $(".imovel_foto_proxima").fadeIn("fast").show();
        }
        if ((posicao - 1) == 0) {
            $(".imovel_foto_anterior").fadeOut("fast").hide();
        }
    });
    $(".imovel_foto_proxima").click(function() {
        var posicao = -1;
        $(".scroll-pane img").each(function(i) {
            if ($(this).hasClass("active")) {
                $(this).removeClass("active");
                posicao = i;
            }
        });
        if (posicao > -1) {
            var thumb = $(".scroll-pane img").eq(posicao + 1);
            $(".imovel_det_img_G #imovel_det_img_G").fadeOut("fast",
                    function() {
                        $(".imovel_det_img_G #imovel_det_img_G").attr({ src: thumb.attr("rel") }).fadeIn("slow");
                    }
                );
            thumb.addClass("active");
            $("#curImg").val(posicao + 1);
        }
        if ($(".imovel_foto_anterior").is(":hidden")) {
            $(".imovel_foto_anterior").fadeIn("fast").show();
        }
        if ((posicao + 1) == ($(".scroll-pane img").size() - 1)) {
            $(".imovel_foto_proxima").fadeOut("fast").hide();
        }
    });

    //Abre o conteudo do saiba mais
    if ($('.saiba_bloco').html() != null) {
        window.scrollTo(0, 0);
    }
    if ($('.saiba_bloco2').html() != null) {
        window.scrollTo(0, 500);
    }
    if ($('.saiba_bloco_HousingClub').html() != null) {
        window.scrollTo(0, 500);
    }
    if ($('.saiba_bloco_authentic').html() != null) {
        window.scrollTo(0, 500);
    }
    if ($('.saiba_bloco_nature').html() != null) {
        window.scrollTo(0, 500);
    }
    if ($('.saiba_bloco_lanc_generic').html() != null) {
        window.scrollTo(0, 500);
    }
    if ($('.saiba_bloco_altos').html() != null) {
        window.scrollTo(0, 500);
    }
    

    
//    else () {
//        window.scrollTo(0, 500);
//    }
    
//    if ($(".saiba_bloco2")) {
//        $(".saiba_bloco2").slideDown("slow");
//    }
//    if ($(".saiba_bloco_HousingClub")) {
//        $(".saiba_bloco_HousingClub").slideDown("slow");
//    }
//    if ($(".saiba_bloco_authentic")) {
//        $(".saiba_bloco_authentic").slideDown("slow");
//    }
});





/* Logica de troca de abas da pagina seja franqueado (BEGIN)  */
$(document).ready(function() {

$(".a_aux_predial_div").css('display', 'block'); //inicializa exibindo a div

    $(".abas_franquia h2").click(function() {
        var classe = $(this).attr("class");
        if (classe == "depoimentos") {
            $(this).removeClass().attr('class', 'depoimentos_on');
            $(".beneficios_on").removeClass().attr('class', 'beneficios');
            $(".franquia_on").removeClass().attr('class', 'franquia');
            $(".a_aux_predial_on").removeClass().attr('class', 'a_aux_predial');
            $(".contato_sf_on").removeClass().attr('class', 'contato_sf');

            $(".depoimentos_div").css('display', 'block');
            $(".beneficios_div").css('display', 'none');
            $(".a_aux_predial_div").css('display', 'none');
            $(".franquia_div").css('display', 'none');
            $(".contato_div").css('display', 'none');

        }
        if (classe == "beneficios") {
            $(this).removeClass().attr('class', 'beneficios_on');
            $(".depoimentos_on").removeClass().attr('class', 'depoimentos');
            $(".franquia_on").removeClass().attr('class', 'franquia');
            $(".a_aux_predial_on").removeClass().attr('class', 'a_aux_predial');
            $(".contato_sf_on").removeClass().attr('class', 'contato_sf');

            $(".depoimentos_div").css('display', 'none');
            $(".beneficios_div").css('display', 'block');
            $(".a_aux_predial_div").css('display', 'none');
            $(".franquia_div").css('display', 'none');
            $(".contato_div").css('display', 'none');
        }
        if (classe == "franquia") {
            $(this).removeClass().attr('class', 'franquia_on');
            $(".depoimentos_on").removeClass().attr('class', 'depoimentos');
            $(".beneficios_on").removeClass().attr('class', 'beneficios');
            $(".a_aux_predial_on").removeClass().attr('class', 'a_aux_predial');
            $(".contato_sf_on").removeClass().attr('class', 'contato_sf');

            $(".depoimentos_div").css('display', 'none');
            $(".beneficios_div").css('display', 'none');
            $(".a_aux_predial_div").css('display', 'none');
            $(".franquia_div").css('display', 'block');
            $(".contato_div").css('display', 'none');
        }
        if (classe == "a_aux_predial") {
            $(this).removeClass().attr('class', 'a_aux_predial_on');
            $(".depoimentos_on").removeClass().attr('class', 'depoimentos');
            $(".beneficios_on").removeClass().attr('class', 'beneficios');
            $(".franquia_on").removeClass().attr('class', 'franquia');
            $(".contato_sf_on").removeClass().attr('class', 'contato_sf');

            $(".depoimentos_div").css('display', 'none');
            $(".beneficios_div").css('display', 'none');
            $(".a_aux_predial_div").css('display', 'block');
            $(".franquia_div").css('display', 'none');
            $(".contato_div").css('display', 'none');
        }
        if (classe == "contato_sf") {
            $(this).removeClass().attr('class', 'contato_sf_on');
            $(".depoimentos_on").removeClass().attr('class', 'depoimentos');
            $(".beneficios_on").removeClass().attr('class', 'beneficios');
            $(".franquia_on").removeClass().attr('class', 'franquia');
            $(".a_aux_predial_on").removeClass().attr('class', 'a_aux_predial');

            $(".depoimentos_div").css('display', 'none');
            $(".beneficios_div").css('display', 'none');
            $(".a_aux_predial_div").css('display', 'none');
            $(".franquia_div").css('display', 'none');
            $(".contato_div").css('display', 'block');
        }
    });

});


$(document).ready(function() {
    var maskHeight = $(document).height();
    //alert(maskHeight);
    if (maskHeight > 350 && maskHeight < 800) {
        $(".centraliza").css("top", "55%");
    }
});
        
    


