﻿function resolucaoObter(paginaPainelAltura, masterPainelAltura) {
    //Individual page panel
    var panel1 = document.getElementById('ctl00_ContentPlaceHolder1_Panel1');
    if (panel1 != null)
        panel1.style.height = screen.height - paginaPainelAltura;


    if (screen.width == 800 || screen.height == 600) {
        document.getElementById('ctl00_Panel1').style.height = "500px";
        if (panel1 != null)
            panel1.style.height = screen.height - paginaPainelAltura + 250;
    }
    else
        document.getElementById('ctl00_Panel1').style.height = screen.height - masterPainelAltura;


}
function municipiosInterior() {

    window.open("municipiosInterior.aspx", "JANELA", "height = 700, width = 500,left=300,top=50");
}
function ddlAcoesReset() {
    document.getElementById('ctl00_ContentPlaceHolder1_ddlAcoes').selectedIndex = 0;
}
function ddlReset(controlId) {
    document.getElementById('ctl00_ContentPlaceHolder1_' + controlId).selectedIndex = 0;
}
function checkBox(control1) {
    obj1 = control1;
    while (obj1.tagName != "TABLE")
        obj1 = obj1.parentNode;

    itemCol = obj1.getElementsByTagName("INPUT");
    for (var i = 0; i < itemCol.length; i++) {
        var item = itemCol[i];
        if (item.type == 'checkbox')
            item.checked = control1.checked
    }
}
function CheckBox(me) {

    for (i = 0; i < document.forms[0].length; i++) {
        var O = document.forms[0][i];
        if (O.type == 'checkbox') {
            if (O.id != me.id)
                O.checked = false;
        }
    }
}
function checkBox1(control1) {
    for (i = 0; i < document.forms[0].length; i++) {
        var ckb1 = document.forms[0][i];
        if (ckb1.type == 'checkbox') {
            if (ckb1.id != control1.id)
                ckb1.checked = false;
        }
    }

}
function checkBox2(control1) {
    for (i = 0; i < document.forms[0].length; i++) {
        var ckb1 = document.forms[0][i];
        if (ckb1.type == 'checkbox')
            ckb1.checked = control1.checked;
    }
}
function jcVeiculoSelecionar1(button1) {
    tabela1 = document.getElementById('ctl00_ContentPlaceHolder1_tabelaJornalConsultaTP');

    controlList = tabela1.getElementsByTagName("span");
    for (var i = 0; i < controlList.length; i++) {
        if (controlList[i].style.color != 'maroon')
            controlList[i].style.color = 'blue';

    }

    divVeiculos = document.getElementById('ctl00_ContentPlaceHolder1_divCkbVeiculos');
    controlList = divVeiculos.getElementsByTagName("input");
    for (var i = 0; i < controlList.length; i++)
        controlList[i].checked = false;

    button1.style.color = 'orange';
    document.getElementById('ctl00_ContentPlaceHolder1_' + button1.getAttribute('vetCodigo')).checked = true;
}

function a4() {

}
function menuVert1(td1, action1, posLeft1) {
    if (action1 == 0)
        td1.className = 'menu1';
    else
        td1.className = 'menu1Over';
}
function menuHorz1(td1, action1) {
    div1Id = 'div' + td1.id;
    div1 = document.getElementById(div1Id);

    if (action1 == 0) {

        td1.className = 'menuHorz1';
        if (div1 != null)
            div1.style.visibility = "hidden";
    }
    else {

        td1.className = 'menuHorz1Over';
        if (div1 != null)
            div1.style.visibility = "visible";
    }
}
function materiaisImpressao1(me) {
    if (me.id == 'ctl00_ContentPlaceHolder1_ckbMateriasImpressao_5') {
        for (i = 0; i < 5; i++) {
            document.getElementById('ctl00_ContentPlaceHolder1_ckbMateriasImpressao_' + i).checked = false;
        }
    }
    else {
        document.getElementById('ctl00_ContentPlaceHolder1_ckbMateriasImpressao_5').checked = false;
    }
}
function letrasImpedir(e) {
    var unicode = e.charCode ? e.charCode : e.keyCode
    if (unicode < 48 || unicode > 57) {
        if (unicode == 44 || unicode == 46 || unicode == 0)
            return true

        return false
    }
    return true
}
function numeroFormatar2(textBox1, dec1) {
    valor1 = textBox1.value;
    if (valor1.length == 0)
        return;
    bool1 = false;
    while (valor1.indexOf('.') >= 0)
    { valor1 = valor1.replace('.', ''); }
    if (valor1.indexOf(',') >= 0)
        bool1 = true;
    while (valor1.indexOf(',') >= 0)
    { valor1 = valor1.replace(',', ''); }

    if (valor1.length == 0) {
        textBox1.value = '';
        return;
    }

    if (bool1 == false)
        for (i = 0; i < dec1; i++)
        valor1 += '0';

    valorFinal1 = '';
    var j = 1;
    if (valor1.length > 0)
        for (i = valor1.length - 1; i >= 0; i--) {
        if (j == dec1 && i > 0)
            valorFinal1 = "," + valor1.substr(i, 1) + valorFinal1
        else if ((j - dec1) % 3 == 0 && i > 0)
            valorFinal1 = "." + valor1.substr(i, 1) + valorFinal1
        else
            valorFinal1 = valor1.substr(i, 1) + valorFinal1
        j++;
    }
    textBox1.value = valorFinal1;
}    
    