    function pulacampo(tammax,campo1,campo2) {
        if (document.getElementById(campo1).value.length == tammax) {
            document.getElementById(campo2).focus();
        }
    }
    function mascaradata(data,campo){
        var mdata = '';
        mdata = mdata + data;
        if (mdata.length == 2){
            mdata = mdata + '/';
            campo.value = mdata;
        }
        if (mdata.length == 5){
            mdata = mdata + '/';
            campo.value = mdata;
        }
        if (mdata.length == 10){
            return true;
        }
    }
    function mascaraCep(cep,campo){
        var mdata = '';
        mdata = mdata + cep;
        if (mdata.length == 2){
            mdata = mdata + '.';
            campo.value = mdata;
        }
        if (mdata.length == 6){
            mdata = mdata + '-';
            campo.value = mdata;
        }
        if (mdata.length == 10){
            return true;
        }
    }
    function mascaraFone(fone,campo){
        var mdata = '';
        mdata = mdata + fone;
        if (mdata.length == 4){
            mdata = mdata + '-';
            campo.value = mdata;
        }
        if (mdata.length == 9){
            return true;
        }
    }
    function isCpf(cpf){
        var i;
        s = cpf;
        var c = s.substr(0,9);
        var dv = s.substr(9,2);
        var d1 = 0;
        for (i = 0; i < 9; i++){
            d1 += c.charAt(i)*(10-i);
        }
        if (d1 == 0){
            alert("CPF inválido")
            return false;
        }
        d1 = 11 - (d1 % 11);
        if (d1 > 9) d1 = 0;
        if (dv.charAt(0) != d1) {
            alert("CPF inválido")
            return false;
        }
        d1 *= 2;
        for (i = 0; i < 9; i++) {
                d1 += c.charAt(i)*(11-i);
        }
        d1 = 11 - (d1 % 11);
        if (d1 > 9) d1 = 0;
        if (dv.charAt(1) != d1){
            alert("CPF inválido")
            return false;
        }
        return true;
    }
    // Função para retirar os espaços em branco do início e do fim da string.
    function trim(strTexto){
        // Substitúi os espaços vazios no inicio e no fim da string por vazio.
        return strTexto.replace(/^\s+|\s+$/g, '');
    }

    // Função para validação de CEP.
    function isCep(strCEP){
        // Caso o CEP não esteja nesse formato ele é inválido!
        var objER = /^[0-9]{2}\.[0-9]{3}-[0-9]{3}$/;
        strCEP = trim(strCEP)
        if(strCEP.length > 0){
            if(objER.test(strCEP))
                return true;
            else
                return false;
        }
    }
    function isNumber(evt) {
        var charCode = (evt.which) ? evt.which : event.keyCode
        if (charCode > 31 && (charCode < 48 || charCode > 57)){
            return false;
        }
        return true;
    }

    function reais(obj,event){
        var whichCode = (window.Event) ? event.which : event.keyCode;
        /*Executa a formatação após o backspace nos navegadores !document.all*/
        if (whichCode == 8 && !documentall) {
            if (event.preventDefault){ //standart browsers
                event.preventDefault();
            }else{ // internet explorer
                event.returnValue = false;
            }
            var valor = obj.value;
            var x = valor.substring(0,valor.length-1);
            obj.value= demaskvalue(x,true).formatCurrency();
            return false;
        }
        /*Executa o Formata Reais e faz o format currency novamente após o backspace*/
        FormataReais(obj,'.',',',event);
    }


    function backspace(obj,event){
        var whichCode = (window.Event) ? event.which : event.keyCode;
        if (whichCode == 8 && documentall) {
            var valor = obj.value;
            var x = valor.substring(0,valor.length-1);
            var y = demaskvalue(x,true).formatCurrency();

            obj.value =""; //necessário para o opera
            obj.value += y;

            if (event.preventDefault){ //standart browsers
                event.preventDefault();
            }else{ // internet explorer
                event.returnValue = false;
            }
            return false;

        }// end if
    }// end backspace
    function FormataReais(fld, milSep, decSep, e) {
        var sep = 0;
        var key = '';
        var i = j = 0;
        var len = len2 = 0;
        var strCheck = '0123456789';
        var aux = aux2 = '';
        var whichCode = (window.Event) ? e.which : e.keyCode;

        //if (whichCode == 8 ) return true; //backspace - estamos tratando disso em outra função no keydown
        if (whichCode == 0 ) return true;
        if (whichCode == 9 ) return true; //tecla tab
        if (whichCode == 13) return true; //tecla enter
        if (whichCode == 16) return true; //shift internet explorer
        if (whichCode == 17) return true; //control no internet explorer
        if (whichCode == 27 ) return true; //tecla esc
        if (whichCode == 34 ) return true; //tecla end
        if (whichCode == 35 ) return true;//tecla end
        if (whichCode == 36 ) return true; //tecla home

        /*
     O trecho abaixo previne a ação padrão nos navegadores. Não estamos inserindo o caractere normalmente, mas via script
     */

        if (e.preventDefault){ //standart browsers
            e.preventDefault()
        }else{ // internet explorer
            e.returnValue = false
        }

        var key = String.fromCharCode(whichCode);  // Valor para o código da Chave
        if (strCheck.indexOf(key) == -1) return false;  // Chave inválida

        /*
     Concatenamos ao value o keycode de key, se esse for um número
     */
        fld.value += key;

        var len = fld.value.length;
        var bodeaux = demaskvalue(fld.value,true).formatCurrency();
        fld.value=bodeaux;

        /*
     Essa parte da função tão somente move o cursor para o final no opera. Atualmente não existe como movê-lo no konqueror.
     */
        if (fld.createTextRange) {
            var range = fld.createTextRange();
            range.collapse(false);
            range.select();
        }
        else if (fld.setSelectionRange) {
            fld.focus();
            var length = fld.value.length;
            fld.setSelectionRange(length, length);
        }
        return false;

    }