﻿window.onload = function () {
    VerificarCategorias();
    VerificarOfertas();
}
function VerificarCategorias() {
    if (document.getElementById('categoriasnull') && document.getElementById('baseBuscaCategorias')) {
        document.getElementById('baseBuscaCategorias').style.visibility = "hidden";
        document.getElementById('baseBuscaCategorias').style.height = "0px";
    }
}
function VerificarOfertas() {
    if ((document.getElementById('ofertasNovosNull') || document.getElementById('ofertasSemiNull')) && document.getElementById('baseOfertas')) {
        document.getElementById('baseOfertas').style.visibility = "hidden";
        document.getElementById('baseOfertas').style.height = "0px";
    }
}

function VerificarOfertasHotSite() {
    if (document.getElementById('ofertasSimplesSemiNull') && document.getElementById('baseHotSiteOfertas')) {
        document.getElementById('baseHotSiteOfertas').style.display = "none";
    }
}


//Função que redimenvciona o background que envolve algumas paginas internas do portal - Vinicius Benzi 06/10/2011
// Adicionei o tratamento de exceção - Joabe - 19/10/2011
window.onload = function () {
    var url = window.location.toString();
    var ExisteBgDinamico = 'dgruposinal|novoResultadosBusca|VisualizarVeiculo';
    var finalUrl = (url.length).valueOf();
    var primeiraBarra = (url.lastIndexOf('/') + 1).valueOf();

    if (url.match(ExisteBgDinamico) || primeiraBarra == finalUrl) {
        var homeBgDinamico = 'dgruposinal';
        var novoResultadoBgDinamico = 'novoResultadosBusca';
        var VicualizarBgDinamico = 'VisualizarVeiculo';

        if (url.match(homeBgDinamico) || primeiraBarra == finalUrl) {
            if (document.getElementById('bgDinamicoPaginas')) {
                document.getElementById('bgDinamicoPaginas').style.display = 'block';
                document.getElementById('bgDinamicoPaginas').style.height = '550px';
            }
        }
        if (url.match(novoResultadoBgDinamico)) {
            if (document.getElementById('bgDinamicoPaginas')) {
                document.getElementById('bgDinamicoPaginas').style.display = 'block';
                document.getElementById('bgDinamicoPaginas').style.height = '3900px';
            }
        }
        if (url.match(VicualizarBgDinamico)) {
            if (document.getElementById('bgDinamicoPaginas')) {
                document.getElementById('bgDinamicoPaginas').style.display = 'block';
                document.getElementById('bgDinamicoPaginas').style.height = '480px';
            }
        }
    }
}
//FIM Função redimenvciona background


/*FUNÇÂO ABAS OFERTAS*/
function OcultarDivOfertasCcv() {

    if (document.getElementById('ofertasNovosNull') && document.getElementById('ofertasSemiNull') && document.getElementById('ofertasProdutosNull')) {
        if (document.getElementById('promocoes')) { document.getElementById('promocoes').style.display = "none"; }
    }
    else {
        if (document.getElementById('ofertasNovosNull')) {
            ExibirOfertaDiv('2');
        }
        else { ExibirOfertaDiv('1'); }
    }

    if (document.getElementById('ofertasNovosNull') != null) { OcultarOfertaLinkTitle('1'); }
    if (document.getElementById('ofertasSemiNull') != null) { OcultarOfertaLinkTitle('2'); }
    if (document.getElementById('ofertasProdutosNull') != null) { OcultarOfertaLinkTitle('3'); }

    function OcultarOfertaLinkTitle(divIdOc) {
        if (document.getElementById('link' + divIdOc) != null) { document.getElementById('link' + divIdOc).style.visibility = "hidden"; }
    }
}

function ExibirOfertaDiv(divId) {
    for (var iJs = 0; iJs < 5; iJs++) {

        if (document.getElementById('dvOf' + iJs) != null) {
            document.getElementById('dvOf' + iJs).style.visibility = "hidden";
        }
        if (document.getElementById('link' + iJs)) {
            window.document.getElementById('link' + iJs).className = "bt" + iJs;
        }
    }
    if (divId != null) {
        if (document.getElementById('dvOf' + divId)) {
            document.getElementById('dvOf' + divId).style.visibility = "visible";
        }

        if (document.getElementById('link' + divId)) {
            window.document.getElementById('link' + divId).className = "bt" + divId + "_active";
        }
    }
}
/*FUNÇÂO ABAS OFERTAS*/
