﻿var nomeEmpreendimento = "";



function hideBuscaDrops() {
    var element = document.getElementById('divSelectsBusca');
    if (element != null) {
        document.getElementById('divSelectsBusca').style.display = "none";
    }
}

function showBuscaDrops() {
    var element = document.getElementById('divSelectsBusca');
    if (element != null) {
        document.getElementById('divSelectsBusca').style.display = "block";
    }
}

$(document).ready(function () {
    var y_fixo = $("#chat").offset().top;
    $(window).scroll(function () {
        $("#chat").animate({
            top: y_fixo + $(document).scrollTop() + "px"
        }, { duration: 150, queue: false
        });
    });

});      

function splashDestaqueFechar() {
    document.getElementById("chat").style.display = "none";
    document.cookie = "fechaChat=true;path=/";
}

var pageViewAtendimentoPorEmail = "";
function onbeforeUnload() {
}

var GafCookies = function () {
    var DateNow = new Date();
    return {
        Set: function (name, value, days) {

            if (days) {
                DateNow.setTime(DateNow.getTime() + (days * 24 * 60 * 60 * 1000));
                var expires = "; expires=" + DateNow.toGMTString();
            } else {
                var expires = "";
            }
            document.cookie = name + "=" + value + expires + "; path=/";
        },
        Get: function (name) {
            var cookieName = name + "=";
            var cookieValue = document.cookie.split(";");
            for (var i = 0; i < cookieValue.length; i++) {
                var value = cookieValue[i];
                while (value.charAt(0) == ' ') {
                    value = value.substring(1, value.length);
                }

                if (value.indexOf(cookieName) == 0) {
                    return value.substr(cookieName.length, value.length);
                }
            }
            return null;
        }
    };
} ();

$(function () {
    var cookies = GafCookies.Get("NAOEXBIBIRFLOATER");
    if (cookies == null) {
        $(".appIpad").css("display", "block");
    }

    $("a.fecharApp").click(function () {
        var cookieIsValue = new String(GafCookies.Get("NAOEXBIBIRFLOATER"));
        if (cookieIsValue == "null") {
            GafCookies.Set("NAOEXBIBIRFLOATER", "IPADOUIPHONE", 10);
        }
        $(".appIpad").fadeOut(500);
    })
});

$(function () {
    var getTermo = function () {
        var location = unescape(window.location.href);
        if (location.indexOf("?") > -1) {
            var params = location.split("?");
            var paramSplit = params[1].split("&")
            for (var i = 0; i < paramSplit.length; i++) {
                params = paramSplit[i].split('=');
                if (params[0] == "termos") {
                    return params[1].replace(/\+/g, " ");
                }
            }
        }
        return null;
    }

    var value = "Digite aqui sua busca...";
    if (getTermo() != null) {
        $(".inputBusca").val(getTermo());
    } else {
        $(".inputBusca").val(value);
    }
    $(".inputBusca").focusin(function () {
        if ($(this).val() == value) {
            $(this).val("");
        }
    }).focusout(function () {
        if ($(this).val().length == 0) {
            $(this).val(value);
        }
    });


})


$(document).ready(function () {
    $(".modalform").colorbox({ iframe: true, innerWidth: 570, innerHeight: 542 });
    $(".modalformVote").colorbox({ iframe: true, innerWidth: 350, innerHeight: 250 });
    $(".modalMarinha").colorbox({ iframe: true, innerWidth: 499, innerHeight: 401 });
    //$(".featured>a:first-child").colorbox({ iframe: true, innerWidth: 570, innerHeight: 542 });
    //$(".featured>a:eq(2)").colorbox({ iframe: true, innerWidth: 520, innerHeight: 420 });
    jQuery(".lnkEmailTopo").colorbox({ iframe: true, innerWidth: 570, innerHeight: 400 });
    jQuery(".lnkAgendeConsultor").colorbox({ iframe: true, innerWidth: 570, innerHeight: 320 });
    jQuery(".lnkFloorPlanner").colorbox({ iframe: true, innerWidth: 825, innerHeight: 800, overlayClose: false, escKey: false, onOpen: function () {
        if (this.id == "floorPlannerModalButton") {
            trackViewAnalytics("/interacoes/floorplanner/planta/" + nomeEmpreendimento);
        } else {
            trackViewAnalytics("/interacoes/floorplanner/novaPlanta/" + nomeEmpreendimento);
        }
        
    }
    });
});

var paginaAtual;

function DefaultButton(event, btn) {
    //alert(event);
    
    var numeroTecla = 0;
    if (window.event) {// se for IE...
        numeroTecla = event.keyCode;
    } else if (event.which) {//se for opera, chrome, firefox.....
        numeroTecla = event.which;
    }

    //alert(event.which);
    if (numeroTecla == 13) {
        
        event.returnValue = false;
        event.cancel = true;
        

        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
            var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion >= 9) {
                event.preventDefault();
            }
        }
        
        btn.click();
    }
}

function openPopUp() {
    window.open('EnviarPagina.aspx?url=' + document.location.href, 'popup', 'height = 600, width = 550,location = no,toolbar = no,scrollbars = auto, status=no, menubar=no');
}

function AtualizaImagemSite(site, zoom, legenda) {
    document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_dvListaImagensZoom").style.display = "none";
    if (zoom != null && zoom != "") {            
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_lbImagemZoom").style.display = "block";
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeSemZoom").style.display = "none";
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeComZoom").style.display = "block";
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeComZoom").src = "/multimidia/images/" + site;
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeComZoom").alt = legenda;
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeComZoom").title = legenda;
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_hfImageZoomPage").value = zoom;    
    }
    else {
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_lbImagemZoom").style.display = "none";        
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeSemZoom").style.display = "block";
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeSemZoom").src = "/multimidia/images/" + site;
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeSemZoom").alt = legenda;
        document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgGrandeSemZoom").title = legenda;
    }
    document.getElementById("legendaImagemGrande").innerHTML = legenda;
}

function CarregaPlanta(CaminhoHumanizada, CaminhoSimplificadaMedia, Legenda) {
    document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgDadosPlantas_ImagemGrande").src = CaminhoSimplificadaMedia;
    document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgDadosPlantas_ImagemGrande").alt = Legenda;
    document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_imgDadosPlantas_ImagemGrande").title = Legenda;
    document.getElementById("ctl00_ctl00_ContentPlaceHolderConteudo_OrfaoContent_hlDownloadPlanta").href = CaminhoHumanizada;
    document.getElementById("dadosPlantaConteudo").innerHTML = Legenda;

}

function SelectImpressaoProdutosOnChange(dropdown, urlDomain, produtoId) {
    var myindex = dropdown.selectedIndex
    var SelValue = dropdown.options[myindex].value

    var baseURL;

    if (myindex == 1) {       
        var url = 'http://' + urlDomain + '/popup-impressao.aspx?id='+ produtoId + '&imagens=0';
        window.open(url, 'popWindow', 'width=680, height=700, menubar=auto, scrollbars=yes, resizable=no');
    }
    if (myindex == 2) {
        var url = 'http://' + urlDomain + '/popup-impressao.aspx?id=' + produtoId + '&imagens=1';
        window.open(url, 'popWindow', 'width=680, height=700, menubar=auto, scrollbars=yes, resizable=no');
    }

    return false;
}

function ConsultorOnline(sCampanha, tipoBotao) {
    var paramEmpreendimento = (sCampanha.length == 0) ? "?origem=Gafisa%20-%20Home" : "?origem=" + sCampanha;

    //Analytics
    if (typeof pageTracker != 'undefined') {
        var paramAnalyticsEmpreendimento = (nomeEmpreendimento.length == 0) ? "" : nomeEmpreendimento;

        var pageView = '/conversoes/chat-online/links/' + tipoBotao + '/' + nomeEmpreendimento;
        //alert(pageView);
        pageTracker._trackPageview(pageView);
    }


    // Notificação do Omniture
    // ALTERAÇÃO AUNICA - TAGG
    // trackView('Contato - Consultor on line - Tela inicial', '', 'Contato');
    trackOmni('Contato - Consultor on line - Tela inicial', '');
    
    // Implementação de Tracking Admotion / by Luis Fernando 20/06/2011
    AdmotionPostTag.Call('Chat Online');

    window.open('http://www13.directtalk.com.br/clientes/custom/Gafisa/init.asp' + paramEmpreendimento, 'popup', 'height = 700, width = 490');
    return;
}

function Simulador(infoProduto, institucional) {
    
    var url = "/Simulador/CarregaSimulador.aspx?nomeEmpreendimento=" + infoProduto+ "&isInstitucional="+institucional;
    //var url = "/swf/SimuladorFinanciamento.swf";                    

    // Implementação de Tracking Admotion / by Luis Fernando 20/06/2011
    AdmotionPostTag.Call('Simule Financiamento');


    trackViewAnalytics("/interacoes/simulador/links/" + nomeEmpreendimento);

    window.open(url, 'popup', 'width = 550, height = 408, location = no,toolbar = no,scrollbars = auto, status=no, menubar=no');
}

function SimuladorConcluiu() {
    // Notificação do Omniture

    // Implementação de Tracking Admotion / by Luis Fernando 20/06/2011
    AdmotionPostTag.Call('Simule Financiamento');
    // ALTERAÇÃO AUNICA-TAGG
    //trackView('Institucional - Simule seu Financiamento - Resultado', 'event10', 'Institucional');
    return true;
}

function EscondeCarregando() {
    var carregando = document.getElementById('_divCarregando');    
    if (carregando != null) {
        carregando.style.display = "none";
    }
}

function EsconderBtnRecebeNovidades() {
    var carregando = document.getElementById('divbtnRecebeNovidades');
    if (carregando != null) {
        carregando.style.display = 'none';
    }
}



function EnvieEmail(nomeEmpreendimento) {

    // Notificação do Omniture
    //ALTERAÇÃO AUNICA-TAGG
    //trackView('Contato - Contato por Email - Formulario', '', 'Contato');
    trackOmni('Contato - Contato por Email - Formulario', '');

    if ($find('ctl00$ctl00$EnviePagina1$hdnNomeEmpreendimento')) $find('ctl00$ctl00$EnviePagina1$hdnNomeEmpreendimento').value = nomeEmpreendimento;
    if ($find('ctl00_ctl00_EnviePagina1_MPESiteEmail')) $find('ctl00_ctl00_EnviePagina1_MPESiteEmail').show();
    if ($find('ctl00_EnviePagina1_MPESiteEmail')) $find('ctl00_EnviePagina1_MPESiteEmail').show();
}

function EnvieEmailMeioProduto(nomeEmpreendimento) {

    // Notificação do Omniture
    //ALTERAÇÃO AUNICA-TAGG
    //trackView('Contato - Contato por Email - Formulario', '', 'Contato');
    trackOmni('Contato - Contato por Email - Formulario', '');

    if ($find('ctl00$ctl00$EnviaEmailMeioProduto1$hdnNomeEmpreendimento')) $find('ctl00$ctl00$EnviaEmailMeioProduto1$hdnNomeEmpreendimento').value = nomeEmpreendimento;
    if ($find('ctl00_ctl00_EnviaEmailMeioProduto1_MPESiteEmail')) $find('ctl00_ctl00_EnviaEmailMeioProduto1_MPESiteEmail').show();
    if ($find('ctl00_EnviaEmailMeioProduto1_MPESiteEmail')) $find('ctl00_EnviaEmailMeioProduto1_MPESiteEmail').show();
}

    // Adiciona um empreendimento nos favoritos
    function AdicionaFavorito(imgObject, codigo, textoObject, nomeEmpreendimento, txtDesmarcarFavorito, txtAdicionarFavorito) {

        // Encontro o controle do campo de texto preparado para abrir o empreendimento
        if (document.getElementById('ctl00_ctl00_ccoBuscaGafisa_ctrFavoritosContador_hfCodigoEmpreendimento') || document.getElementById('ctl00_ccoBuscaGafisa_ctrFavoritosContador_hfCodigoEmpreendimento')) {

            var oHfCodigoEmpreendimento;
            if (document.getElementById('ctl00_ctl00_ccoBuscaGafisa_ctrFavoritosContador_hfCodigoEmpreendimento')) oHfCodigoEmpreendimento = document.getElementById('ctl00_ctl00_ctrFavoritosContador_hfCodigoEmpreendimento');
            if (document.getElementById('ctl00_ccoBuscaGafisa_ctrFavoritosContador_hfCodigoEmpreendimento')) oHfCodigoEmpreendimento = document.getElementById('ctl00_ccoBuscaGafisa_ctrFavoritosContador_hfCodigoEmpreendimento');

            // Atribuo o código
            oHfCodigoEmpreendimento.value = codigo;

            // Encontro o controle que aciona o updatePanel
            if (document.getElementById('ctl00_ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos') || document.getElementById('ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos')) {
                var oBtnFavoritos;

                if (document.getElementById('ctl00_ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos')) oBtnFavoritos = 'ctl00_ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos';
                if (document.getElementById('ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos')) oBtnFavoritos = 'ctl00_ccoBuscaGafisa_ctrFavoritosContador_btnFavoritos';

                if (imgObject != null) {
                    // Se passou um objeto de imagem, tento trocar a opção
                    if (document.getElementById(imgObject)) {
                        var imageObject = document.getElementById(imgObject);
                        var imgHabilitada = '/images/ck_verde.gif';
                        var imgDesabilitada = '/images/ck_vermelho.gif';

                        var imgPathEnd = imageObject.src.substring(imageObject.src.length - 10);
                        imageObject.src = (imgPathEnd == imgHabilitada.substring(imgHabilitada.length - 10)) ? imgDesabilitada : imgHabilitada;
                    }

                }

                if (textoObject != null) {

                    if (document.getElementById(textoObject)) {

                        var linkObject = document.getElementById(textoObject);
                        var txtHabilitado = txtDesmarcarFavorito;
                        var txtDesabilitado = txtAdicionarFavorito;

                        var txtLinkChange = linkObject.innerHTML.substr(0, 7);
                        if (txtLinkChange == txtHabilitado.substring(0, 7)) {
                            linkObject.innerHTML = txtDesabilitado;
                        } else {
                            // Notificação do Omniture
                            // ALTERAÇÃO AUNICA-TAGG
                            //trackView('Imoveis - ' + nomeEmpreendimento + ' - Adic a favoritos', '', 'Imoveis');
                            linkObject.innerHTML = txtHabilitado;

                        }

                    }
                }

                __doPostBack(oBtnFavoritos);
            }
        }
    }

    function IndiqueAmigo() {

        // Notificação do Omniture
        // ALTERAÇÃO AUNICA-TAGG
        //if (nomeEmpreendimento.length > 0) trackView('Imoveis - ' + nomeEmpreendimento + ' - Enviar para amigo - Formulario', '', 'Imoveis');
        //else trackView('Institucional - Indique este site - Formulario', '', 'Institucional');

        $(".modalform").colorbox({ iframe: true, innerWidth: 570, innerHeight: 542 });

        //if ($find('ctl00_ctl00_EnviePaginaAmigo1_MPEIndique')) $find('ctl00_ctl00_EnviePaginaAmigo1_MPEIndique').show();
        //else if ($find('ctl00_EnviePaginaAmigo1_MPEIndique')) $find('ctl00_EnviePaginaAmigo1_MPEIndique').show();
    }

function RSSInstrucoes() {
    if ($find('ctl00_ctl00_EnviePaginaAmigo1_MPEIndique')) $find('ctl00_ctl00_EnviePaginaAmigo1_MPEIndique').show();
    else if ($find('ctl00_EnviePaginaAmigo1_MPEIndique')) $find('ctl00_EnviePaginaAmigo1_MPEIndique').show();
}

function AgendeContato() {

    // Notificação do Omniture
    //Alteração AUNICA-TAGG
    //trackView('Contato - Agende seu Contato - Formulario', '', 'Contato');
    trackOmni('Contato - Agende seu Contato - Formulario', '');
    
    //alert('Agende');
    
    if ($find('ctl00_ctl00_Consultor1_MPESiteAgende')) 
        $find('ctl00_ctl00_Consultor1_MPESiteAgende').show();

    if ($find('ctl00_Consultor1_MPESiteAgende'))
        $find('ctl00_Consultor1_MPESiteAgende').show();
}

function ClickToCall(origem, tipoBotao) {  
    var url;
    //url = 'http://ngn2.tmais.com.br/uc/external/view/index.jsf?s=MKWQD4B5D2A9823FHO9814D6174X93GD';

    url = "/LigamosParaVoce.html";
    
    //Analytics
    if (typeof pageTracker != 'undefined') {
        var paramAnalyticsEmpreendimento = (nomeEmpreendimento.length == 0) ? "" : nomeEmpreendimento;

        var pageView = '/conversoes/ligamos-para-voce/links/' + tipoBotao + '/' + nomeEmpreendimento;
        //alert(pageView);
        pageTracker._trackPageview(pageView);
    }



    //Contato - Ligamos para voce
    // ALTERAÇÃO AUNICA-TAGG
    //trackView('Contato - Ligamos para voce', 'event12', 'Contato');
    trackOmni('Contato - Ligamos para voce','event12');
    window.open(url, 'popup', 'height = 404, width = 504, menubar=no, scrollbars=auto, resizable=no');
   
}

//Função que recupera o server control ID passando como parametro o ID
function findObjWithClientId(Id) {
    var ctrls = document.all;

    for (var count = 0; count < ctrls.length; count++) {
        var index = ctrls[count].id.indexOf(Id);

        if (index != -1) {
            if ((ctrls[count].id.length - index) == Id.length) {
                return ctrls[count];
            }
        }
    }
    return null;
}

//Funcao que pega o HTML da pagina
function getHtml() {
    var conteudoDiv = document.getElementById('DivConteudoSite').innerHTML;
    findObjWithClientId("txtConteudoHtml").value = conteudoDiv;
}

// VisualizarMidia
function popUpVisualizarMidia(url, height, width) {
    height = height;
    width = width;
    window.open(url, 'popWindow', "height=" + height + ",width=" + width + ",menubar=no, scrollbars=auto, resizable=yes");
}

// Muda o tamanho das fontes nas telas que possuem tal função
function mudaTamanho(idAlvo, acao) {
    if (!document.getElementById) return
    var selecionados = null;
    tamanho = tamanhoInicial;
    var i;
    var j;
    var tagsAlvo;

    tamanho += acao;

    if (tamanho < 0) tamanho = 0;
    if (tamanho > 3) tamanho = 3;

    //zero todos as instruções de aumento e diminuição do tamanho da font
    document.getElementById("Amenos").style.display = "none";
    document.getElementById("Amais").style.display = "none";
    document.getElementById("spanOu").style.display = "none";

    switch (tamanho) {
        case 0:
            document.getElementById("Amenos").style.display = "none";
            document.getElementById("Amais").style.display = "inline";
        break;

        case 3:
            document.getElementById("Amais").style.display = "none";
            document.getElementById("Amenos").style.display = "inline";
        break;

        default:
            document.getElementById("Amenos").style.display = "inline";
            document.getElementById("Amais").style.display = "inline";
            document.getElementById("spanOu").style.display = "inline";
        break;
    }

    tamanhoInicial = tamanho;

    if (!(selecionados = document.getElementById(idAlvo))) selecionados = document.getElementsByTagName(idAlvo)[0];

    selecionados.style.fontSize = tamanhos[tamanho];

    for (i = 0; i < tagAlvo.length; i++) {
        tagsAlvo = selecionados.getElementsByTagName(tagAlvo[i]);
        for (j = 0; j < tagsAlvo.length; j++) tagsAlvo[j].style.fontSize = tamanhos[tamanho];
    }
}

// Efetua a geolocalização do usuário
function geolocate() {
    if (google != null &&
        google.loader != null &&
        google.loader.ClientLocation != null &&
        google.loader.ClientLocation.address != null &&
        google.loader.ClientLocation.address.country_code == "BR" &&
        google.loader.ClientLocation.address.region != null) {


        var possuiCidade = false;
        var arrCookies = document.cookie.split(';');

        // Procuro por um ID de cidadde
        for (var i = 0; i < arrCookies.length; ++i) {
            if (arrCookies[i].indexOf('cidadeid') > 0) possuiCidade = true;
        }

        // Se não achou chave de localização, move para SP
        if (!possuiCidade) {
            document.cookie = 'LOCALIZACAO_CIDADE=cidadeid=' + google.loader.ClientLocation.address.region + ';';
            document.location.reload();
        }
    }
}

// Gera um movie Flash
function flashMovieConsultor(url, id, width, height, flashVars) {

    //alert('chegou aqui - ' + flashVars);

    AC_FL_RunContent(
        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
        'width', width,
        'height', height,
        'src', '/swf/' + url,
        'quality', 'high',
        'pluginspage', 'http://www.adobe.com/go/getflashplayer',
        'align', 'middle',
        'play', 'true',
        'loop', 'true',
        'scale', 'noscale',
        'wmode', 'transparent',
        'devicefont', 'false',
        'id', id,
        'bgcolor', '#ffffff',
        'name', id,
        'menu', 'true',
        'allowFullScreen', 'true',
        'allowScriptAccess', 'sameDomain',
        'movie', '/swf/' + url,
        'flashvars', 'ida = ' + flashVars,
        'salign', 'lt'
        ); //end AC code
}

function flashMovie55anos(url, id, width, height, flashVars) {
    AC_FL_RunContent(
        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
        'width', width,
        'height', height,
        'src', '/55anos/' + url,
        'quality', 'high',
        'pluginspage', 'http://www.adobe.com/go/getflashplayer',
        'align', 'middle',
        'play', 'true',
        'loop', 'true',
        'scale', 'noscale',
        'wmode', 'transparent',
        'devicefont', 'false',
        'id', id,
        'bgcolor', '#ffffff',
        'name', id,
        'menu', 'true',
        'allowFullScreen', 'true',
        'allowScriptAccess', 'sameDomain',
        'movie', '/55anos/' + url,
        'flashvars', flashVars,
        'salign', 'lt'
        ); //end AC code
}

// Gera um movie Flash
function flashMovie(url, id, width, height, flashVars) {
    AC_FL_RunContent(
        'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
        'width', width,
        'height', height,
        'src', '/swf/' + url,
        'quality', 'high',
        'pluginspage', 'http://www.adobe.com/go/getflashplayer',
        'align', 'middle',
        'play', 'true',
        'loop', 'true',
        'scale', 'noscale',
        'wmode', 'transparent',
        'devicefont', 'false',
        'id', id,
        'bgcolor', '#ffffff',
        'name', id,
        'menu', 'true',
        'allowFullScreen', 'true',
        'allowScriptAccess', 'sameDomain',
        'movie', '/swf/' + url,
        'flashvars', flashVars,
        'salign', 'lt'
        ); //end AC code
}

// Trata o fim das requisições AJAX
function EndRequestHandler(sender, args) {

    // Se não deu nenhum erro
    if (args.get_error() == undefined) {
        // Página de Envie um email
        var objSucessoEmail = document.getElementById("hfSucessoEnvioEmailMensagem");
        if (objSucessoEmail != null && objSucessoEmail.value == "sucesso") {
            //ALTERAÇÃO AUNICA-TAGG
            //trackView('Contato - Contato por Email - Confirmado', 'event2', 'Contato');
            trackOmni('Contato - Contato por Email - Confirmado','event2');
        }

        // Página de envie página para um amigo
        var objSucessoAmigo = document.getElementById("hfSucessoEnvioPaginaAmigo");
        if (objSucessoAmigo != null && objSucessoAmigo.value == "sucesso") {
            //ALTERAÇÃO AUNICA-TAGG
            //if (nomeEmpreendimento.length > 0) trackView('Imoveis - ' + nomeEmpreendimento + ' - Enviar para amigo - Enviado', 'event8', 'Imoveis');
            //else trackView('Institucional - Indique este site - Confirmado', '', 'Institucional');
        }

        // Página de envie página agende um contato
        var objSucessoAgende = document.getElementById("hfSucessoEnvioAgendeContato");
        if (objSucessoAgende != null && objSucessoAgende.value == "sucesso") {
            //ALTERAÇÃO AUNICA-TAGG
            //trackView('Contato - Agende seu Contato - Confirmado', 'event3', 'Contato');
            trackOmni('Contato - Agende seu Contato - Confirmado','event3');
        }

        // Página de envie página receba novidades
        var objSucessoNews = document.getElementById("hfSucessoRecebaNews");
        if (objSucessoNews != null && objSucessoNews.value == "sucesso") {
            //ALTERAÇÃO AUNICA-TAGG
            //trackView('Institucional - Cadastre se - Confirmado', 'event4', 'Institucional');
            trackOmni('Institucional - Cadastre se - Confirmado', 'event4');
        }

        // Página de produto - form de breves lançamentos
        var objSucessoBL = document.getElementById("hfSucessoBrevesLancamentos");
        if (objSucessoBL != null && objSucessoBL.value == "sucesso") {
            if (nomeEmpreendimento.length > 0) {
                //ALTERAÇÃO AUNICA-TAGG
                //trackView('Imoveis - ' + nomeEmpreendimento + ' - Breve Lancamento - Enviado', '', 'Imoveis');
                trackOmni('Imoveis - ' + nomeEmpreendimento + ' - Breve Lancamento - Enviado', 'event4');
            }
        }
    }
}

function abrir() {
    document.getElementById('oQueRss').style.display = 'block';
    document.getElementById('transp').style.display = 'block';
}
function fechar() {
    document.getElementById('oQueRss').style.display = "none";
    document.getElementById('transp').style.display = 'none';
}

function abrirFormBusca() {
    document.getElementById('buscaFormulario').style.display = 'block';
    document.getElementById('blockAll').style.display = 'block';
}
function fecharFormBusca() {
    document.getElementById('buscaFormulario').style.display = "none";
    document.getElementById('blockAll').style.display = 'none';
}

function abrirDivConsultorOnLine() {
    document.getElementById('divConsultorOnLine').style.display = 'block';
    document.getElementById('divTranspConsultorOnLine').style.display = 'block';
}
function fecharDivConsultorOnLine() {
    document.getElementById('divConsultorOnLine').style.display = "none";   
}

function hideBuscaDrops() {
    document.getElementById('divSelectsBusca').style.display = "none";
}

function showDivConsultor(secs) {   
    if (readCookieFechaChat('fechaChat') != 'true') {
        setTimeout(function () {
            document.getElementById('chat').style.display = 'block';
        }, '40000');
    }
}

function readCookieFechaChat(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
}

//criar outro aqui para iphone

function showDivIPhone(secs) {
    setTimeout(function() {
    document.getElementById('floterIphone').style.display = 'block';
    }, secs);
}

/*function abrirDivConsultorOnLine() {
    document.getElementById('divConsultorOnLine').style.display = 'block';
    document.getElementById('divTranspConsultorOnLine').style.display = 'block';
}*/

function fecharDivIPhone() {
    document.getElementById('floterIphone').style.display = "none";    
}

function showDivReservaFloater() {
    /*setTimeout(function() {
        document.getElementById('floaterReserva').style.display = 'block';
    }, '20000');*/
}

function fecharDivReservaFloater() {   
    /*document.getElementById('floaterReserva').style.display = "none";*/
}

function showBuscaDrops() {
    document.getElementById('divSelectsBusca').style.display = "block";
}

function abrirVideo() {
    var element = document.getElementById('divSelectsBusca');

    if (element != null) {
        document.getElementById('divSelectsBusca').style.display = "none";   
    }    
    document.getElementById('ctl00_pnVideoHome').style.display = 'block';    
}
function fecharVideo() {
    var element = document.getElementById('divSelectsBusca');

    if (element != null) {
        document.getElementById('divSelectsBusca').style.display = "block";
    }        
    document.getElementById('ctl00_pnVideoHome').style.display = 'none';
}

/*Trabalhe Conosco*/
function trabalhePop() {
    var url = "/trabalheConosco.htm";

    window.open(url, 'popup', 'width = 1024, height = 580, location = no,toolbar = no,scrollbars = auto, status=no, menubar=no');
}

/*Ocultar Combos p/ IE6*/
function ocultarCombos(ocultar) {
    var versao = navigator.appVersion;
    if (versao.substr(versao.indexOf(';', 0) + 2, 8) == "MSIE 6.0") {
        if (navigator.appName != 'Netscape') {
            for (i = 0; i <= document.getElementsByTagName('SELECT').length - 1; i++) {
                document.getElementsByTagName('SELECT')[+i].style.visibility = ocultar
            }
        }
    }
}

function PegaParamtroViaQueryString(param) {
    var valParam = null,
                url = window.location.search.substring(1),
                urlSplit = url.split("&");
    for (i = 0; i < urlSplit.length; i++) {
        valParam = urlSplit[i].split("=");
        if (valParam[0] == param) {
            return valParam[1];
        }
    }
    return null;
}

function trackViewAnalytics(pageView) {
    if (typeof pageTracker != 'undefined') {
        //alert(pageView);
        pageTracker._trackPageview(pageView);
    }
}

function TrackClickRecebaNews() {
    var paramAnalyticsEmpreendimento = (nomeEmpreendimento.length == 0) ? "" : nomeEmpreendimento;

    var pageView = '/receba-novidades/links/topo/'+ nomeEmpreendimento;
    //alert(pageView);
    trackViewAnalytics(pageView);
}


