﻿/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
function css_browser_selector(u) { var ua = u.toLowerCase(), is = function(t) { return ua.indexOf(t) > -1; }, g = 'gecko', w = 'webkit', s = 'safari', o = 'opera', h = document.documentElement, b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + RegExp.$1) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.$1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.$2 : '')) : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.$1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js']; c = b.join(' '); h.className += ' ' + c; return c; }; css_browser_selector(navigator.userAgent);

var theForm = document.forms['form1'];
if (!theForm)
    theForm = document.form1;

function limparPadrao(campo) {
    if (campo.value == campo.defaultValue) {
        campo.value = "";
    }
}

function escreverPadrao(campo) {
    if (campo.value == "") {
        campo.value = campo.defaultValue;
    }
}
function verificaShowHide(elmnt, elmnt2) {
    if (document.getElementById(elmnt).style.display == "block") {
        hidemenu(elmnt);
        elmnt2.innerHTML = "> Clique aqui para visualizar todos os comentários";
    }
    else {
        showmenu(elmnt);
        elmnt2.innerHTML = "> Clique aqui para ocultar todos os comentários";
    }
}
function showhidemenu(elmnt) {
    if (document.getElementById(elmnt).style.display == "block")
        document.getElementById(elmnt).style.display = "none";
    else
        document.getElementById(elmnt).style.display = "block";
}

function showmenu(elmnt) {
    document.getElementById(elmnt).style.display = "block";
}

function hidemenu(elmnt) {
    document.getElementById(elmnt).style.display = "none";
}

function menuAtivacao(m, d, p, t) {
    for (i = 1; i <= t; i++) {
        div = p + i;
        divM = m + i;
        divS = p + d + "_" + i;
        if (document.getElementById(div) != null)
            document.getElementById(div).style.display = 'none';
        if (document.getElementById(divM) != null)
            document.getElementById(divM).className = "produto-informacao-inativo";
        if (document.getElementById(divS) != null)
            document.getElementById(divS).style.display = 'none';
        if (d == i) {
            if (document.getElementById(div) != null)
                document.getElementById(div).style.display = 'block';
            if (document.getElementById(divM) != null)
                document.getElementById(divM).className = "produto-informacao-ativo";
        }
    }
}
function subMenuAtivacao(m, d, t) {
    for (j = 1; j <= t; j++) {
        div = m + j;
        for (i = 1; i <= t; i++) {
            divS = m + j + "_" + i;
            if (document.getElementById(div) != null)
                document.getElementById(div).style.display = 'none';
            if (document.getElementById(divS) != null)
                document.getElementById(divS).style.display = 'none';
            if (d == i) {
                if (document.getElementById(div) != null)
                    document.getElementById(div).style.display = 'block';
            }
        }
    }
}
function onlynumber(myfield, e, tolerado) {
    if (myfield.length == 0)
        myfield.value = 0;

    var key;
    var keychar;

    if (window.event)
        key = window.event.keyCode;
    else if (e)
        key = e.which;
    else
        return true;

    keychar = String.fromCharCode(key);

    if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
        return true;
    else if ((("0123456789" + tolerado).indexOf(keychar) > -1)) {
        if (((myfield.value).indexOf(tolerado) > -1) && (keychar == tolerado))
            return false;
        else if ((myfield.value.length == 0) && (keychar == tolerado)) {
            myfield.value = "0";
            return true;
        }
        else
            return true;
    }
    else
        return false;
}
function clickButton(e, buttonid) {

    var evt = e ? e : window.event;

    var bt = document.getElementById(buttonid);

    if (bt) {

        if (evt.keyCode == 13) {

            bt.click();

            return false;
        }
    }
}
function Formato_CEP(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 5)
            input.value = input.value + '-';
    }
}
function Formato_Data(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 2 || input.value.length == 5)
            input.value = input.value + '/';
    }
}
function Formato_Hora3(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 4) {
        if (input.value.length == 2)
            input.value = input.value + ',';
    }
}
function Formato_CPF(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 3 || input.value.length == 7)
            input.value = input.value + '.';
        if (input.value.length == 11)
            input.value = input.value + '-';
    }
}
function Formato_Cnpj(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 2 || input.value.length == 6)
            input.value = input.value + '.';
        if (input.value.length == 10)
            input.value = input.value + '/';
        if (input.value.length == 15)
            input.value = input.value + '-';

    }
}
var galeriaPosition2 = 0;
var posicaoFinal2 = 0;
var galeriaHeight2 = 228;
var galeriaAtual2 = 0;
function moveProx2() {
    var ddh = document.getElementById("divGaleriaHidden");
    if (ddh.style.top != "0px")
        galeriaPosition2 += 10;
    ddh.style.top = galeriaPosition2 + 'px';

}
function moveAnt2() {
    var ddh = document.getElementById("divGaleriaHidden");
    if (galeriaPosition2 >= -posicaoFinal2)
        galeriaPosition2 -= 10;

    ddh.style.top = galeriaPosition2 + 'px';
}
var loopgaleria2;
function loopDestInterval2(f) {
    if (f == "topo") {
        galeriaAtual2++;
        loopgaleria2 = setInterval(moveProx2, 100);
    }
    else {

        if ((galeriaAtual2 * -1) < (posicaoFinal2 * 1)) {
            galeriaAtual2--;
            loopgaleria2 = setInterval(moveAnt2, 100);
        }
    }
}
function clearloopGal2() {
    clearInterval(loopgaleria2);
}

var galeriaPosition1 = 0;
var posicaoFinal1 = 0;
var galeriaHeight1 = 228;
var galeriaAtual1 = 0;
function moveProx1() {
    var ddh = document.getElementById("divGaleriaHiddenDetalhe");
    if (ddh.style.top != "0px")
        galeriaPosition1 += 10;
    ddh.style.top = galeriaPosition1 + 'px';

}
function moveAnt1() {
    var ddh = document.getElementById("divGaleriaHiddenDetalhe");
    if (galeriaPosition1 >= -posicaoFinal1)
        galeriaPosition1 -= 10;

    ddh.style.top = galeriaPosition1 + 'px';
}
var loopgaleria1;
function loopDestInterval1(f) {
    if (f == "topo") {
        galeriaAtual1++;
        loopgaleria1 = setInterval(moveProx1, 100);
    }
    else {

        if ((galeriaAtual1 * -1) < (posicaoFinal1 * 1)) {
            galeriaAtual1--;
            loopgaleria1 = setInterval(moveAnt1, 100);
        }
    }
}
function clearloopGal1() {
    clearInterval(loopgaleria1);
}

var galeriaPosition = 0;
var posicaoFinal = 0;
var galeriaHeight = 228;
var galeriaAtual = 0;
function moveProx() {

    var ddh = document.getElementById("divGaleriaCabine");
    if (ddh.style.top != "0px")
        galeriaPosition += 10;
    ddh.style.top = galeriaPosition + 'px';
}
function moveAnt() {
    var ddh = document.getElementById("divGaleriaCabine");
    if (galeriaPosition >= -posicaoFinal)
        galeriaPosition -= 10;
    ddh.style.top = galeriaPosition + 'px';
}
var loopgaleria;
function loopDestInterval(f) {
    if (f == "topo") {
        galeriaAtual++;
        loopgaleria = setInterval(moveProx, 100);
    }
    else {
        if ((galeriaAtual * -1) < (posicaoFinal * 1)) {
            galeriaAtual--;
            loopgaleria = setInterval(moveAnt, 100);
        }
    }
}
function clearloopGal() {
    clearInterval(loopgaleria);
}
function mudaImagem(id, img, idFonte, fonte) {
    document.getElementById(id).src = img;
    document.getElementById(idFonte).style.display = "block";
    if (fonte == "")
        document.getElementById(idFonte).style.display = "none";
    document.getElementById(idFonte).innerHTML = fonte;
}
function verificaBusca() {
    liberado = true;

   
    //if (!document.getElementById("ctl00_ContentPlaceHolder1_buscahorizontal_chkSomenteHS").checked && Trim(document.getElementById("ctl00_ContentPlaceHolder1_buscahorizontal_txtOrigem").value) == "") {
    if (Trim(document.getElementById("ctl00_ContentPlaceHolder1_buscahorizontal_txtOrigem").value) == "") {
        document.getElementById("lblErroOrigem").style.display = "block";
        liberado = false;
    }
    else
        document.getElementById("lblErroOrigem").style.display = "none";
    if (Trim(document.getElementById("ctl00_ContentPlaceHolder1_buscahorizontal_txtDestino").value) == "") {
        document.getElementById("lblErroDestino").style.display = "block";
        liberado = false;
    }
    else
        document.getElementById("lblErroDestino").style.display = "none";
   
    if (liberado) {
        theForm.action = "/telas/busca/Default.aspx";
        theForm.submit();
    }
    

    return liberado;
}
function verificaBuscaInterno() {
    liberado = true;
    if (Trim(document.getElementById("ctl00_ContentPlaceHolder1_buscavertical_txtOrigem").value) == "") {
        document.getElementById("lblErroOrigem").style.display = "block";
        liberado = false;
    }
    else
        document.getElementById("lblErroOrigem").style.display = "none";
    if (Trim(document.getElementById("ctl00_ContentPlaceHolder1_buscavertical_txtDestino").value) == "") {
        document.getElementById("lblErroDestino").style.display = "block";
        liberado = false;
    }
    else
        document.getElementById("lblErroDestino").style.display = "none";   
    if (liberado) {
        theForm.action = "/telas/busca/Default.aspx";
        theForm.submit();
    }
    return liberado;
}
function Trim(str) { return str.replace(/^\s+|\s+$/g, ""); }
function checaRdo(ctrl, autoP) {
    if (document.getElementById(ctrl).checked == false) {
        document.getElementById(ctrl).checked = true;
        if (autoP)
            setTimeout('__doPostBack(\'' + ctrl + '\',\'\')', 0)
    }
}
function FormataCPF(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 3 || input.value.length == 7)
            input.value = input.value + '.';
        if (input.value.length == 11)
            input.value = input.value + '-';

    }
}
function FormataTel(input, e) {
    var keyCode;

    if (window.event)
        keyCode = window.event.keyCode;
    else if (e)
        keyCode = e.which;

    if (keyCode != 8) {
        if (input.value.length == 4)
            input.value = input.value + '-';

    }
}
function clickBotao(c) {
    document.getElementById(c).click();
}
