function OnSubmitForm(acao){

    if(acao == 'imprimir')
        document.frmResultado.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/SimuladorImprimirServlet?dataHoraSimulacao=" + document.getElementById("dataHoraSimulacao").value;
    else if(acao == 'contato')
        document.frmResultado.action ="http://www.quanta-previdencia.com.br/qjsp/servlet/SimuladorContatoServlet?dataHoraSimulacao=" + document.getElementById("dataHoraSimulacao").value;

    document.frmResultado.submit();

}

function abrirPopup() {
    window.open('http://www.quanta-previdencia.com.br/admin/sos/usuario_entrar.asp','mywindow','width=455,height=400');
}
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;
}

function init() {

    if (TransMenu.isSupported()) {
        TransMenu.initialize();

        //para os itens que tem sublink
        menu1.onactivate = function() {
            document.getElementById("quem_somos").className = "hover";
        };
        menu1.ondeactivate = function() { 
            document.getElementById("quem_somos").className = "";
        };

        menu2.onactivate = function() {
            document.getElementById("o_que_e_previdencia").className = "hover";
        };
        menu2.ondeactivate = function() { 
            document.getElementById("o_que_e_previdencia").className = "";
        };

        menu3.onactivate = function() {
            document.getElementById("plano_precaver").className = "hover";
        };
        menu3.ondeactivate = function() { 
            document.getElementById("plano_precaver").className = "";
        };

        menu4.onactivate = function() {
            document.getElementById("investimentos").className = "hover";
        };
        menu4.ondeactivate = function() { 
            document.getElementById("investimentos").className = "";
        };

        menu5.onactivate = function() {
            document.getElementById("simulador").className = "hover";
        };
        menu5.ondeactivate = function() { 
            document.getElementById("simulador").className = "";
        };

        menu6.onactivate = function() {
            document.getElementById("artigos_e_noticias").className = "hover";
        };
        menu6.ondeactivate = function() { 
            document.getElementById("artigos_e_noticias").className = "";
        };

        //para os links que nao tem sublink
        document.getElementById("pagina_inicial").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("pagina_inicial").onmouseout = function() { 
            this.className = "";
        }

        document.getElementById("participante_precaver").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("participante_precaver").onmouseout = function() { 
            this.className = "";
        }

        document.getElementById("demonstrativos").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("demonstrativos").onmouseout = function() { 
            this.className = "";
        }

        document.getElementById("informativos_precaver").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("informativos_precaver").onmouseout = function() { 
            this.className = "";
        }

        document.getElementById("fale_conosco").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("fale_conosco").onmouseout = function() { 
            this.className = "";
        }
    }
}

function initRestrita() {

    if (TransMenu.isSupported()) {
        TransMenu.initialize();

        //para os links que nao tem sublink
        document.getElementById("dados_do_plano").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("dados_do_plano").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("dados_cadastrais").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("dados_cadastrais").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("dados_financeiros").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("dados_financeiros").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("parcelas_em_aberto").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("parcelas_em_aberto").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("atas_normativas").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("atas_normativas").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("demonstrativos").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("demonstrativos").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("informe_rendimentos").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("informe_rendimentos").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("guia_do_participante").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("guia_do_participante").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("alterar_senha").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("alterar_senha").onmouseout = function() {
            this.className = "";
        }

        document.getElementById("sair").onmouseover = function() {
            ms.hideCurrent();
            this.className = "hover";
        }
        document.getElementById("sair").onmouseout = function() {
            this.className = "";
        }
    }
}