﻿var nie = (navigator.appName.indexOf("Microsoft") == -1);
var gc = (navigator.userAgent.toLowerCase().indexOf("chrome") > -1);
var ie5 = document.all && !window.opera
var ns6 = document.getElementById

function getel(doc, id) {
    return doc.getElementById(id);
}

function el(id) {
    return getel(document, id);
}

function getElementsById(sId) {
    var outArray = new Array();

    if (typeof (sId) != 'string' || !sId) {
        return outArray;
    };

    if (document.evaluate) {
        var xpathString = "//*[@id='" + sId.toString() + "']"
        var xpathResult = document.evaluate(xpathString, document, null, 0, null);
        while ((outArray[outArray.length] = xpathResult.iterateNext())) { }
        outArray.pop();
    }
    else if (document.all) {

        if (document.all[sId])
            for (var i = 0, j = document.all[sId].length; i < j; i += 1) {
                outArray[i] = document.all[sId][i];
            }

    } else if (document.getElementsByTagName) {

        var aEl = document.getElementsByTagName('*');
        for (var i = 0, j = aEl.length; i < j; i += 1) {

            if (aEl[i].id == sId) {
                outArray.push(aEl[i]);
            };
        };

    };

    if ((outArray.length == 0) && (el(sId)))
        outArray[0] = el(sId);

    return outArray;
}

function escreve(s) {
    document.write(s);
}

function arr(n) {
    this.length = n
    for (var i = 0; i < n; i = i + 1) {
        this[i] = ''
    }
}

function element_top(el) {
    var et = 0
    while (el) {
        et += el.offsetTop
        el = el.offsetParent
    }
    return et
}


function element_left(el) {
    var et = 0
    while (el) {
        et += el.offsetLeft
        el = el.offsetParent
    }
    return et
}

function lstVai(lst, frame) {
    lnk = lst.options[lst.selectedIndex].value;
    if (lnk.length < 1)
        return;
    if (typeof(frame) == "undefined")
        window.location.href = lnk;
    else
        window.frames[frame].location.href = lnk;
    lst.selectedIndex = 0;
}

function mainDivCenter(divName, infinite, toRight) {
    d = document.documentElement.clientWidth;
    me = document.getElementById(divName);
    toRight = ((typeof (toRight) != 'undefined') && (toRight)) ? 1 : 0;
    if ((!me.lastD) || (me.lastD != d)) {
        me = document.getElementById(divName);
        x = me.offsetWidth;
        if (x < d) {
            dif = d - x;
            me.style.marginLeft = ((dif / 2) + (toRight ? dif % 2 : 0)) + 'px';
        }
        else
            me.style.marginLeft = '0px';
        me.lastD = d;
    }
    if (infinite)
        setTimeout('mainDivCenter(\'' + divName + '\', 1, ' + (toRight) + ')', 500);
}

/* 18/01/2010 */
function getFlash(id, src, width, height, align, salign, transparent, mozila, versao, onmouseover, onmouseout, flashVars, opaque) {
    s = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + (versao) + ',0,0,0" width="' +
        (width) + '" height="' + (height) + '" id="' +
        id + '" ' + (align != '' ? 'align="' + align + '"' : '') +
        ' bgcolor=#FFFFFF ' +
        (onmouseover != '' ? ' onmouseover="' + onmouseover + '"' : '') +
        (onmouseout != '' ? ' onmouseout="' + onmouseout + '"' : '') +
        '><param name="quality" value="high" />' +
        (src != '' ? '<param name="movie" value="' + src + '" />' : '') +
        (salign != '' ? '<param name="salign" value="' + salign + '" />' : '') +
        (transparent ? '<param name="wmode" value="transparent" />' : '') +
        (((typeof (opaque) != "undefined") && (opaque)) ? '<param name="wmode" value="opaque" />' : '') +
        (((typeof (flashVars) != "undefined") && (flashVars != '')) ? '<param name="flashVars" value="' + flashVars + '" />' : '') +
        '<param name="menu" value="false" /><param name="scale" value="noscale" />';
    if (mozila)
        s += '<embed ' +
            (src != '' ? 'src="' + src + '" ' : '') +
            'loop="false" menu="false" quality="high" scale="noscale" width="' +
            (width) + '" height="' + (height) + '" name="' + id + '" ' +
            (align != '' ? 'align="' + align + '" ' : '') +
            (salign != '' ? 'salign="' + salign + '" ' : '') +
            (onmouseover != '' ? 'onmouseover="' + onmouseover + '" ' : '') +
            (onmouseout != '' ? 'onmouseout="' + onmouseout + '" ' : '') +
            (transparent ? 'wmode="transparent" ' : '') +
            (((typeof (opaque) != "undefined") && (opaque)) ? 'wmode="opaque" ' : '') +
            (((typeof (flashVars) != "undefined") && (flashVars != '')) ? 'flashVars="' + flashVars + '" ' : '') +
            'allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swliveconnect="true" />';
    s += '</object>';
    return s;
}
function escreveFlash(id, src, width, height, align, salign, transparent, mozila, versao, onmouseover, onmouseout, flashVars, opaque) {
    s = getFlash(id, src, width, height, align, salign, transparent, mozila, versao, onmouseover, onmouseout, flashVars, opaque);
    escreve(s);
}

var moviesToLoad = [];

function loadFlashWithPreload3(id, src, preloadId) {
    preloaded = movieIsLoaded(mv(preloadId));

    if (preloaded) {
        cmd = 'loadMovie(\'' + id + '\', \'' + src + '\')';
        setTimeout(cmd, 1);
        return;
    }

    cmd = 'loadFlashWithPreload3(\'' + id + '\', \'' + src + '\', \'' + preloadId + '\')';
    setTimeout(cmd, 250);
}

function mv(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1)
        return document.all[movieName]
    else if (document[movieName])
        return document[movieName]
    else
        return el(movieName)
}
function loadMovie(id, movie, params) {
    mv(id).LoadMovie(0, movie);
    if (typeof(params) != 'undefined')
        for (p = 0; p < params.length; p += 2)
            mv(id).SetVariable(params[p], params[p + 1]);
}

function loadMovieWithDelay(id, movie, paramsStr) {
    cmd = 'loadMovie(\'' + id + '\', \'' + movie + '\', ' + paramsStr + ')';
    setTimeout(cmd, 500);
}

function movieIsLoaded(theMovie) {
    if (typeof (theMovie) != "undefined") {
        return ((typeof (theMovie.PercentLoaded) != "undefined") && (theMovie.PercentLoaded() == 100));
    } else {
        return false;
    }
}

function movieIsReady(theMovie) {
    return (typeof (theMovie.PercentLoaded) != "undefined");
}

function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function imprime() {
    window.focus();
    setTimeout("window.print()", 500);
}

var ie5 = document.all && !window.opera
var lastHeight = 0;
var autoHeight = 1;
var autoHSet = 0;
function adjustIFrameSize() {
    if (!el('divSize'))
        return;
    iframeElement = getel(window.parent.document, 'ifcontent');
    iframeWindow = window.parent.frames[name];

    ci = el('content-inner');
    cp = el('compartilhe');
    if (ci && cp) {
        if (ci.clientHeight < 225) {
            cp.style.paddingTop = '225px';
        }
    }
    
    if (nie)
        iframeElement.style.height = '';
    h = 0;
    hMin = 0;
    h = el('divSize').offsetHeight;
    h = h > alturaMinima ? h : alturaMinima;

    lastHeight = h;

    iframeElement.style.height = (h) + 'px';

    // window.parent.el('iframe-wrapper').style.height = (h) + 'px';

    if ((autoHeight) && (!autoHSet)) {
        autoHSet = 1;
        setTimeout('autoH()', 500);
    }
}

function autoH() {
    h = el('divSize').offsetHeight;
    h = h > alturaMinima ? h : alturaMinima;
    document.documentElement.scrollTop = 0;
    if (h != lastHeight) {
        scrollPos = window.parent.document.documentElement.scrollTop;
        adjustIFrameSize();
        window.parent.document.documentElement.scrollTop = scrollPos;
    }
    setTimeout('autoH()', 500);
}

function indica() {
    ifc = window.parent.frames['ifcontent'];
    iurl = 'indique.aspx?1=1';
    if (ifc) {
        if (ifc.idcontent)
            iurl += '&idContent=' + (ifc.idcontent);
        if (ifc.idcontentsection)
            iurl += '&idContentSection=' + (ifc.idcontentsection);
        ifc.location = htmlbase + iurl;
    }
    else
        window.location = iurl;
}

function amplia2(id, pw, ph, text) {
    wp = window.parent;
    wpd = wp.document;
    ov = getel(wpd, 'overlay');
    amp = getel(wpd, 'ampliacao');
    ampi = getel(wpd, 'ampliInner');
    img = getel(wpd, 'imgAmpliar2');
    txt = getel(wpd, 'ampliText');

    ampi.style.width = (pw + 12) + 'px';
    ov.style.height = (wpd.documentElement.scrollHeight > wpd.body.scrollHeight ? wpd.documentElement.scrollHeight : wpd.body.scrollHeight) + 'px';
    img.src = wp.htmlbase + 'images/blank.gif';
    txt.style.display = (text != '' ? 'block' : 'none');
    txt.innerHTML = text;

    th = wpd.documentElement.clientHeight;
    th = ((th - ph - 12 - 18 - 3) / 2) - 20;
    if (th < 0)
        th = 0;
    th = th + (window.parent.document.body.scrollTop > 0 ? window.parent.document.body.scrollTop : window.parent.document.documentElement.scrollTop);
    ampi.style.marginTop = (th) + 'px';

    ov.style.display = 'block';
    amp.style.display = 'block';

    img.src = wp.htmlbase + 'ModuleHandlers/Content/picture.aspx?idContentPicture=' +
        (id) + '&w=' + (pw) + '&h=' + (ph);
}

function fechaAmpliar2() {
    wp = window.parent;
    wpd = wp.document;
    img = getel(wpd, 'imgAmpliar2');
    txt = getel(wpd, 'ampliText');
    ov = getel(wpd, 'overlay');
    amp = getel(wpd, 'ampliacao');

    ov.style.display = 'none';
    amp.style.display = 'none';
    img.src = '';
    txt.innerHTML = '';
}

function umclique(base, sel) {
    val = sel.options[sel.selectedIndex].value;
    if (val != '')
        window.location = base + val;
}

function busca(ifc) {
    s = 'busca.aspx?p=' + document.forms['fbusca'].p.value;
    abre(s, ifc);
}

function abre(url, ifc) {
    if (ifc)
        window.parent.frames['ifcontent'].location = url;
    else
        window.location = 'padrao.aspx?' + url;
}


/* ----------------------------------------------- */

function MultiLevelsMenu(varId, preloadId) {

    this.varid = varId;
    this.preloadid = preloadId;
    
    this.menuItens = new arr(0);
    this.menuComplete = 0;
    this.menuLoaded = 0;
    this.menuShowed = 0;

    this.addMenuItem = function (id, src) {
        this.menuItens.length++;
        i = this.menuItens.length - 1;
        this.menuItens[i] = [id, src];
    }

    this.menuDone = function () {
        this.menuComplete = 1;
    }
    
    this.mostraMenu = function () {
        preloaded = movieIsLoaded(mv(this.preloadid));

        if ((!this.menuComplete) || (!preloaded))
            setTimeout(this.varid + '.mostraMenu()', 100);
        else if (preloaded) {
            this.menuLoaded = 1;
            for (i = 0; i < this.menuItens.length; i++) {
                cmd = 'loadMovie(\'' + this.menuItens[i][0] + '\', \'' + this.menuItens[i][1] + '\')';
                setTimeout(cmd, i * 200);
            }
        }
    }

    this.activeMenu = 0;
    this.timeid = 0;
    this.isOverButton = 0;
    this.isOverMenu = 0;
    this.menuobj = 0;
    this.delayhide = 0;

    this.debugMenu = function(s) {
        // el('txtteste').value = s + '\n' + el('txtteste').value;
    }

    this.showmenu_src = 0;
    this.showmenu_id = 0;

    this.abreMenu = function (e, id) {

        // debugMenu('over ' + (id));

        this.isOverButton = id;
        this.isOverMenu = 0;

        this.showmenu_src = ie5 ? e.srcElement : e.target;
        this.showmenu_id = id;

        // debugMenu('hidemenu pela abremenu');

        this.hidemenu();
        this.clearhidemenu()

        clearTimeout(this.timeid);
        this.timeid = setTimeout(this.varid + '.showmenu()', 200);

        // debugMenu('abreMenu2');
    }
    
    this.fechaMenu = function (id) {

        // debugMenu('out ' + (id));

        if (id == this.isOverButton) {
            clearTimeout(this.timeid);
            this.timeid = setTimeout(this.varid + '.fechaMenu2()', 200);
        }
    }
    
    this.fechaMenu2 = function () {
        // debugMenu('fechaMenu2');
        this.isOverButton = 0;
        this.delayhidemenu();
    }

    this.showmenu = function() {

        // debugMenu('showmenu start');

        src = this.showmenu_src;
        id = this.showmenu_id;

        if (this.varid == 'menu1')
            this.mudaBotao(this.varid + '_m' + (id), 2);
        else if (this.varid == 'menu2')
            this.mudaBotao(this.varid + '_m' + (id), 9);

        this.activeMenu = id;
        this.clearhidemenu()

        this.menuobj = el(this.varid + '_ms' + (id));
        this.menuobj.style.left = (element_left(src)) + 'px';

        offsetTop = 0;

        if (this.varid == 'menu2') {
            fs = el('fsmenu2_ms' + (id));
            fsc = el('fscmenu2_ms' + (id));
            fsh = el('fshmenu2_ms' + (id));
            cr = el('crmenu2_ms' + (id));
            fs.style.height = (fsc.clientHeight + 3) + 'px';
            cr.style.height = (fsc.clientHeight - 3) + 'px';
            fsh.style.width = (163 - src.clientWidth) + 'px';
            offsetTop = -7;
        }

        this.menuobj.style.top = (element_top(src) + src.clientHeight + offsetTop) + 'px';

        return false;
    }

    this.subover = function(event) {
        this.clearhidemenu();
        this.isOverMenu = 1;
    }

    this.subout = function(event) {
        this.isOverMenu = 0; 
        this.dynamichide(event);
    }

    this.contains_ns6 = function (a, b) {
        while (b.parentNode)
            if ((b = b.parentNode) == a)
            return true;
        return false;
    }

    this.hidemenu = function () {
        if (this.menuobj) {
            if (this.varid == 'menu1')
                this.mudaBotao(this.varid + '_m' + (id), 1);
            else if (this.varid == 'menu2')
                this.mudaBotao(this.varid + '_m' + (id), 6);
            this.menuobj.style.top = '-5000px';
            this.activeMenu = 0;
            this.menuobj = 0;
        }
    }

    this.dynamichide = function(e) {
        if (!this.menuobj)
            return;
        if (!this.isOverButton) {
            if (ie5 && !this.menuobj.contains(e.toElement))
                this.hidemenu()
            else if (ns6 && e.currentTarget != e.relatedTarget && !this.contains_ns6(e.currentTarget, e.relatedTarget))
                this.hidemenu()
        }
    }

    this.delayhidemenu = function () {
        if (!this.isOverMenu)
            this.delayhide = setTimeout(this.varid + ".hidemenu()", 500)
    }

    this.clearhidemenu = function() {
        if (this.delayhide)
            clearTimeout(this.delayhide)
    }

    this.mudaBotao = function (id, estado) {
        if (!mv(id))
            return;

        // debugMenu('movie id ' + (id) + ' no estado ' + (estado));

        mv(id).SetVariable('fast', 'yes');

        if (estado != 2)
            mv(id).SetVariable('tipoBotao', estado);
            
        if (estado == 1) {
            mv(id).SetVariable('isOverSub', 'no');
            mv(id).GotoFrame(3);
        }
        else if (estado == 2) {
            mv(id).SetVariable('isOverSub', 'yes');
        }
        else if (estado == 6)
            mv(id).GotoFrame(8);
        else if (estado == 9)
            mv(id).GotoFrame(11);
    }
}

// *********************************************************************************************************************


/* ********** */
var bannerIndex = -1;
var allBannersCreated = 0;
var bannerAutoChangeDelay = 20000;
var loadAllBannersIndex = 1;
var loadBannersCalled = 0;

function iniciaOutdoor() {
    if (banners.length == 0)
        return;

    if (!loadBannersCalled) {
        loadBanners();
        loadBannersCalled = 1;
    }
    else {
        vaiParaBanner(0);
    }
}

function loadBanners() {

    if (banners.length == 0)
        return;

    // el('button-left').style.display = banners.length > 1 ? 'block' : 'none';
    // el('button-right').style.display = banners.length > 1 ? 'block' : 'none';

    criaBanner(banners[0], 'banner0');

    setTimeout('loadAllBanners()', 500);

    trocaBanner(1, 1, -1);
}

function criaBanner(html, id) {
    el('bannerBanner').innerHTML += html;
}

function loadAllBanners() {

    if (bannerIsLoaded('banner0') || nie) {
        if (banners.length > 1) {
            criaBanner(banners[loadAllBannersIndex], 'banner' + (loadAllBannersIndex));
        }
        if (loadAllBannersIndex < banners.length - 1) {
            loadAllBannersIndex++;
            setTimeout('loadAllBanners()', 100);
        }
        else {
            el('bannerCarregando').style.display = 'none';
            allBannersCreated = 1;
        }
    }
    else
        setTimeout('loadAllBanners()', 500);
}


function bannerIsLoaded(id) {
    if ((mv(id).tagName == 'EMBED') || (mv(id).tagName == 'OBJECT'))
        return movieIsLoaded(mv(id));
    else if (mv(id).tagName == 'IMG')
        return el(id).complete;
}

var oldBannerIndex;
function trocaBanner(avanca, fast, novoIndice) {
    if ((!allBannersCreated) && (bannerIndex != -1))
        return;

    oldBannerIndex = bannerIndex;
    
    if (avanca > -1) {
        if (avanca)
            bannerIndex++;
        else
            bannerIndex--;

        if (bannerIndex == -1)
            bannerIndex = banners.length - 1;
        else if (bannerIndex >= banners.length)
            bannerIndex = 0;
    }
    else if (novoIndice > -1) {
        bannerIndex = novoIndice;
    }

    if (bannerIndex > -1) {
        if (!bannerIsLoaded('banner' + (bannerIndex)) && (oldBannerIndex > -1))
            el('divbanner' + (oldBannerIndex)).style.display = 'none';
    }

    mostraBanner(fast);
}

function avancaBanner(avanca) {
    trocaBanner(avanca, 0, -1);
}

function vaiParaBanner(indice) {
    trocaBanner(-1, 0, indice);
    el('bannerBanner').focus();
}

var timeoutid;
var timeoutid2;
function mostraBanner(fast) {
    if (bannerIsLoaded('banner' + (bannerIndex))) {
        // el('bannerBanner').style.backgroundColor = 'white';
        // clearTimeout(timeoutid2);
        if ((!nie) && (!fast)) {
            oDiv = el('bannerBanner');
            oDiv.style.filter = "blendTrans(duration=1.0)";
            oDiv.filters.blendTrans.apply();
            oDiv.filters.blendTrans.play();
        }
        if (oldBannerIndex > -1)
            el('divbanner' + (oldBannerIndex)).style.display = 'none';
        el('divbanner' + (bannerIndex)).style.display = 'block';
        // timeoutid2 = setTimeout('el(\'bannerBanner\').style.backgroundColor = \'\'', 3000);
        acertaBullets(oldBannerIndex, bannerIndex);
        if (timeoutid)
            clearTimeout(timeoutid);
        timeoutid = setTimeout('trocaBanner(1, 0, -1)', bannerAutoChangeDelay);
    }
    else {
        if (nie) {
            if (oldBannerIndex > -1)
                el('divbanner' + (oldBannerIndex)).style.display = 'none';
            el('divbanner' + (bannerIndex)).style.display = 'block';
            acertaBullets(oldBannerIndex, bannerIndex);
            if (timeoutid)
                clearTimeout(timeoutid);
            timeoutid = setTimeout('trocaBanner(1, 0, -1)', bannerAutoChangeDelay);
        }
        else
            setTimeout('mostraBanner(' + (fast) + ')', 100);
    }
}

function acertaBullets(oldindex, newindex) {
    if (el('bl' + (oldindex)))
        el('bl' + (oldindex)).className = 'but-circle';
    if (el('bl' + (newindex)))
        el('bl' + (newindex)).className = 'selected';
}

/* ----------------------------------------------- */

function getAjax() {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            // set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            // http_request.overrideMimeType("text/html; charset=windows-1252");
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!http_request) {
        alert('Desculpe, seu navegador é incompatível com este recurso.');
        return false;
    }
    return http_request;
}

var lastD = 0;
function mainBg() {
    d = document.documentElement.clientWidth;
    if (lastD != d) {
        w_fundo = 9;
        j = Math.ceil((d / 2.0) - (w_fundo / 2));   // o browser usaria math.floor; nós usamos ceil para ficar igual ao alinhamento por margem negativa
        j -= 2; // deloca -2 para encaixar com o fundo do menu e do copo

        el('wrapper').style.backgroundPosition = (j) + 'px center';
        el('bg2').style.backgroundPosition = (j) + 'px center';
        lastD = d;
    }
    setTimeout('mainBg()', 500);
}

function showdesc(id) {
    d = document.documentElement.scrollWidth;
    bgv = el('bgvermelho');
    bgv.style.width = (d) + 'px';
    bgv.style.display = 'block';
    bgv.style.top = (element_top(el('mi' + (id))) + 22) + 'px';
    if (el('id' + (id)))
        el('id' + (id)).style.visibility = 'visible';   // para IE6
}

function hidedesc(id) {
    el('bgvermelho').style.display = 'none';
    if (el('id' + (id)))
        el('id' + (id)).style.visibility = 'hidden';   // para IE6
}

function ajustaFrameLogin(extended) {
    name = 'iflogin';
    iframeElement = window.parent.document.getElementById(name);
    iframeElement.style.height = (extended ? 92 : 50) + 'px';
}

var elementosFonte = '';
function fonte(aumenta) {
    // default
    dif = Number(readCookie('fonte'));

    els = elementosFonte.split(',');

    for (i = 0; i < els.length; i++) {

        if (els[i].substr(0, 1) == '_') {
            dfs = getElementsById(els[i].substr(1, els[i].length - 1));
        }
        else
            dfs = [el(els[i])];

        for (xx = 0; xx < dfs.length; xx++) {
            df = dfs[xx];
            if (!df)
                continue;
            def = Number(df.getAttribute('default-font', 0));
            if (aumenta > -1) {
                size = Number(df.style.fontSize.substr(0, df.style.fontSize.length - 2));
                dif = size - def;
            }
            else {
                dif = Number(readCookie('fonte'));
                size = def + dif;
            }
            //alert(els[i] + ' default: ' + (def) + ' atual: ' + (size));

            if (aumenta > -1) {
                if ((dif <= 0) && !aumenta) {
                    alert(fonteMinTxt);
                    return;
                }
                if ((dif >= 4) && aumenta) {
                    alert(fonteMaxTxt);
                    return;
                }
                if (aumenta)
                    size++;
                else
                    size--;
            }

            dif = size - def;

            df.style.fontSize = (size) + "px";
        }
    }

    var expire = new Date();
    expire.setTime(new Date().getTime() + 3600000 * 24 * 5000);
    document.cookie = 'fonte' + "=" + escape((dif) + '') + ";expires=" + expire.toGMTString() + ";path=/";

    adjustIFrameSize();
}

function readCookie(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);
    }
    return null;
}

homeAtiva = 0;
function adjust1(home, reloadLogin, mostrarLogin) {

    el('iflogin').style.display = mostrarLogin ? 'block' : 'none';

    if ((reloadLogin) && (window.frames['iflogin']))
        window.frames['iflogin'].window.location = htmlbase + 'controles/cxLogin.aspx?rnd=' + (Math.random()) + '&interna=1';

    homeAtiva = home;

    if (el('iframe-wrapper'))
        el('iframe-wrapper').className = homeAtiva ? '' : 'interna';
}

function mostraDialogo(html, width, height) {
    wp = window.parent;
    wpd = wp.document;

    ov = getel(wpd, 'overlay');
    amp = getel(wpd, 'dialogo');
    ampi = getel(wpd, 'dialogoInner');
    ct = getel(wpd, 'dialogoContent');

    ct.innerHTML = '';

    ct.style.height = (height) + 'px';
    ct.style.width = (width) + 'px';
    ampi.style.width = (width) + 'px';

    ov.style.height = (wpd.documentElement.scrollHeight > wpd.body.scrollHeight ? wpd.documentElement.scrollHeight : wpd.body.scrollHeight) + 'px';

    th = wpd.body.clientHeight;
    th = ((th - height - 12 - 18 - 3) / 2) - 20;
    if (th < 0)
        th = 0;
    th = th + (wpd.body.scrollTop > 0 ? wpd.body.scrollTop : wpd.documentElement.scrollTop);
    ampi.style.marginTop = (th) + 'px';

    ov.style.display = 'block';
    amp.style.display = 'block';

    ct.innerHTML = html;
}

function mostraDialogoFrame(src, width, height) {
    mostraDialogo('<iframe width=' + (width) + ' height=' + (height) + ' frameborder=0 src="' + src + '" scrolling=auto></iframe>', width, height);
}

function fechaDialogo() {
    wp = window.parent;
    wpd = wp.document;
    ov = getel(wpd, 'overlay');
    amp = getel(wpd, 'dialogo');

    ov.style.display = 'none';
    amp.style.display = 'none';

    document.body.style.overflow = '';
}

function clickLink(linkId) {
    eval(el(linkId).href);
}

function validaCep(oSrc, args) {
    args.IsValid = args.Value.length == 8;
}

function trajecta(id) {
    cmd = 'newImage(\'http://www.trajecta.com.br/customertrends/site.php?emp=abc71&pag=' + id + '\')';
    setTimeout(cmd, 1000);
}

function abreFone() {

    w = 350;
    h = 430;

    janela = window.open(htmlbase + 'atendimento/atendimento.aspx', 'abc71_atendimento', 'toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,menubar=no,width=' + (w) + ',height=' + (h) + ',top=' + (((screen.height - h) / 2) - 30) + ',left=' + (((screen.width - w) / 2) - 10))
    janela.focus()
}