function OnSubmitForm(acao){

    if(acao == 'nulo')
        document.frmDeliberativo.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoDeliberativoServlet?op=nulo";
    else if(acao == 'voto')
        document.frmDeliberativo.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoDeliberativoServlet?op=voto";
    else if(acao == 'branco')
        document.frmDeliberativo.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoDeliberativoServlet?op=branco";

    document.frmDeliberativo.submit();

}

function OnSubmitForm1(acao){

    if(acao == 'nulo')
        document.frmFiscal.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoFiscalServlet?op=nulo";
    else if(acao == 'voto')
        document.frmFiscal.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoFiscalServlet?op=voto";
    else if(acao == 'branco')
        document.frmFiscal.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/ConselhoFiscalServlet?op=branco";

    document.frmFiscal.submit();

}

function validarData(nomeCampo, valor) {

    var campo = document.getElementById(nomeCampo);
    var date = valor;
    var ardt = new Array;
    var ExpReg = new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");

    ardt = date.split("/");
    erro = false;

    if ( date.search(ExpReg)==-1){

        erro = true;

    }else if (((ardt[1]==4)||(ardt[1]==6)||(ardt[1]==9)||(ardt[1]==11))&&(ardt[0]>30)){

        erro = true;

    }else if ( ardt[1]==2) {

        if ((ardt[0]>28)&&((ardt[2]%4)!=0)){
            erro = true;
        }
        if ((ardt[0]>29)&&((ardt[2]%4)==0)){
            erro = true;
        }
    }

    if (erro) {

        alert("\"" + valor + "\" não é uma data válida, use dd/mm/aaaa!");
        return false;
    }
    return true
}

function formataMoeda(fld, milSep, decSep, e) {

    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = aux3 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;


    if (whichCode == 13)
        return true; // Enter

    if (whichCode == 0)
        return true; // TAB


    if (whichCode == 8) { // BackSpace

        len = fld.value.length;

        for(i=0; i < len; i++)
            if (strCheck.indexOf(fld.value.charAt(i))!=-1)
                aux += fld.value.charAt(i);

        len = aux.length;

        for( i=0; i<(len-1); i++ ) {
            aux2 += aux.charAt(i);
        }

        aux = aux2;
        len = aux.length;
    } else {

        key = String.fromCharCode(whichCode); // Get key value from key code

        if (strCheck.indexOf(key) == -1)
            return false; // Not a valid key

        len = fld.value.length;

        for(i = 0; i < len; i++)
            if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep))
                break;

        aux = '';

        for(; i < len; i++)
            if (strCheck.indexOf(fld.value.charAt(i))!=-1)
                aux += fld.value.charAt(i);

        aux += key;
        len = aux.length;
    }

    if (len == 0) fld.value = '';
    if (len == 1) fld.value = '0'+ decSep + '0' + aux;
    if (len == 2) fld.value = '0'+ decSep + aux;

    if (len > 2) {

        aux3 = '';

        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux3 += milSep;
                j = 0;
            }
            aux3 += aux.charAt(i);
            j++;
        }

        fld.value = '';
        len2 = aux3.length;

        for (i = len2 - 1; i >= 0; i--)
            fld.value += aux3.charAt(i);

        fld.value += decSep + aux.substr(len - 2, len);
    }
    return false;
}