function FormataMaiuscula(objCampo) { 
        objCampo.value = objCampo.value.toUpperCase(); 
} 

function ValidaTeclaMoeda(objCampo) { 
        var strTecla = String.fromCharCode(event.keyCode); 
        var blnRetorno = ValidaDigitoMoeda(strTecla); 
        if (event.keyCode == 44 && objCampo.value.search(',') >= 0) 
                event.returnValue = false; 
        else 
        {         
                if (objCampo.value.search(',') < 0 && (objCampo.maxLength - 1) == objCampo.value.length && document.selection != null && document.selection.type != 'None') 
                        event.returnValue = false; 
                else 
                        event.returnValue = blnRetorno; 
        } 
} 

function ValidaDigitoMoeda(strCaracter) { 
    return ("0123456789,".indexOf(strCaracter)>=0); 
} 

function ValidaTeclaInteiro() { 
        var strTecla = String.fromCharCode(event.keyCode); 
        var blnRetorno = ValidaDigitoInteiro(strTecla); 
        event.returnValue = blnRetorno; 
} 

function ValidaDigitoInteiro(strCaracter) { 
    return ("0123456789".indexOf(strCaracter)>=0); 
} 

function FormataMoedaFoco(objCampo) 
{ 
        objCampo.value = SoNumeroMoeda(objCampo.value); 
        objCampo.select(); 
} 

function MontaStringIgual(strCaracter, intTamanho) 
{ 
        var intContador; 
        var strString = ''; 
        for (intContador = 1; intContador <= intTamanho; intContador++) 
                strString += strCaracter; 
        return strString; 
} 

function FormataMoeda(objCampo, intTamDecimal) 
{ 
        var strValor = objCampo.value; 
        var intVirgula = strValor.search(','); 
        var strValorFormat = ''; 
        var intDecimal = intContador = intPosicao = 0; 

        if (strValor != '') 
        { 
                if (intVirgula == -1) 
                        strValor += "," + MontaStringIgual("0", intTamDecimal); 
                else 
                { 
                        intDecimal = (strValor.substr(intVirgula + 1)).length; 
                        if (intDecimal <= intTamDecimal) 
                                strValor += MontaStringIgual("0", intTamDecimal - intDecimal); 
                        else 
                        { 
                                alert ('Número de casas decimais (' + intDecimal + ') maior do que o permitido (' + intTamDecimal + ') !'); 
                                objCampo.focus(); 
                                return false; 
                        } 
                } 
                if (strValor.length > objCampo.maxLength) 
                { 
                        if (intVirgula == -1) 
                                alert ('Parte inteira (' + (objCampo.value.length - intDecimal) + ') maior do que o permitido (' + (objCampo.maxLength - intTamDecimal - 1) + ') !'); 
                        else 
                                alert ('Parte inteira (' + (objCampo.value.length - intDecimal - 1) + ') maior do que o permitido (' + (objCampo.maxLength - intTamDecimal - 1) + ') !'); 
                        objCampo.focus(); 
                        return false; 
                } 
                else 
                        objCampo.value = strValor; 

                if (strValor.substr(0,1) == ",") 
                        strValor = '0' + strValor; 

                intVirgula = strValor.search(','); 
                strValorFormat = strValor.substr(intVirgula); 
                for (intContador = intVirgula - 1; intContador >= 0; intContador--) 
                { 
                        if (intPosicao == 3) 
                        { 
                                strValorFormat = '.' + strValorFormat; 
                                intPosicao = 0; 
                        } 
                        strValorFormat = strValor.substr(intContador, 1) + strValorFormat; 
                        intPosicao++; 
                } 
                objCampo.value = strValorFormat; 
        } 
} 

function RetornaClipBoard() 
{ 
        return (window.clipboardData.getData('Text')).replace(/\t/g,''); 
} 

function LimpaClipBoard() 
{ 
        return window.clipboardData.setData('Text',''); 
} 

function ValidaPasteTexto(fld) 
{ 
        var strTexto = RetornaClipBoard(); 
        LimpaClipBoard(); 
        if (strTexto != '') 
        { 
                if (fld.maxLength > 0) 
                { 
                        if (fld.maxLength >= strTexto.length) 
                                fld.value = strTexto; 
                        else 
                                fld.value = strTexto.substr(0,fld.maxLength); 
                } 
                else 
                        fld.value = strTexto; 
        } 
} 

function SoNumeroMoeda(strTexto) 
{ 
        var intContador; 
        var strRetorno; 
        var blnVirgula = false; 
        strRetorno = ''; 
        for (intContador=0; intContador < strTexto.length; intContador++) 
        { 
                if ((!isNaN(strTexto.substr(intContador,1)) && strTexto.substr(intContador,1) != ' ') || strTexto.substr(intContador,1) == ',') 
                { 
                        if (strTexto.substr(intContador,1) == ',') 
                        { 
                                if (blnVirgula == false) 
                                { 
                                        blnVirgula = true; 
                                        strRetorno = strRetorno + strTexto.substr(intContador,1); 
                                } 
                        } 
                        else 
                                strRetorno = strRetorno + strTexto.substr(intContador,1); 
                } 
        } 
        return strRetorno; 
} 

function SoNumero(strTexto) 
{ 
        var intContador; 
        var strRetorno; 
        strRetorno = ''; 
        for (intContador=0; intContador < strTexto.length; intContador++) 
        { 
                if (!isNaN(strTexto.substr(intContador,1)) && strTexto.substr(intContador,1) != ' ') 
                        strRetorno = strRetorno + strTexto.substr(intContador,1); 
        } 
        return strRetorno; 
} 

function ValidaPasteData(fld) 
{ 
        var strTexto = RetornaClipBoard(); 
        LimpaClipBoard(); 
        if (strTexto != '') 
        { 
                strTexto = SoNumero(strTexto); 
                if (strTexto.length == 8) 
                        fld.value = strTexto.substr(0,2) + "/" + strTexto.substr(2,2) + "/" + strTexto.substr(4,4); 
                else 
                        fld.value = ''; 
        } 
} 

function ValidaPasteHora(fld) 
{ 
        var strTexto = RetornaClipBoard(); 
        LimpaClipBoard(); 
        if (strTexto != '') 
        { 
                strTexto = SoNumero(strTexto); 
                if (strTexto.length == 4) 
                        fld.value = strTexto.substr(0,2) + ":" + strTexto.substr(2,2); 
                else 
                        fld.value = ''; 
        } 
} 

function ValidaPasteMoeda(objCampo) 
{ 
        var strTexto = RetornaClipBoard(); 
        LimpaClipBoard(); 
        if (strTexto != '') 
        { 
                strTexto = SoNumeroMoeda(strTexto); 
                if (objCampo.maxLength > 0) 
                { 
                        if (objCampo.maxLength >= strTexto.length) 
                        { 
                                objCampo.value = strTexto; 
                        } 
                        else 
                        { 
                                objCampo.value = strTexto.substr(0, objCampo.maxLength); 
                        } 
                } 
                else 
                { 
                        objCampo.value = strTexto; 
                } 
        } 
} 

function ValidaPasteInteiro(objCampo) 
{ 
        var strTexto = RetornaClipBoard(); 
        LimpaClipBoard(); 
        if (strTexto != '') 
        { 
                strTexto = SoNumero(strTexto); 
                if (objCampo.maxLength > 0) 
                { 
                        if (objCampo.maxLength >= strTexto.length) 
                        { 
                                objCampo.value = strTexto; 
                        } 
                        else 
                        { 
                                objCampo.value = strTexto.substr(0, objCampo.maxLength); 
                        } 
                } 
                else 
                { 
                        objCampo.value = strTexto; 
                } 
        } 
} 

function ValidarCampos(strFRM) 
{ 
        var frm = eval("document." + strFRM);
        var blnOK = true; 
        var i; 
        for (i=0; i < frm.length; i++) 
        { 
                if (frm.item(i).required == 'true' || frm.item(i).required == 'verdadeiro') 
                { 
                        if (frm.item(i).value == "") 
                        { 
                                if (frm.item(i).NomeCampo == "") 
                                        alert("Preenchimento obrigatório deste campo !"); 
                                else 
                                        alert("O campo " + frm.item(i).NomeCampo + " é obrigatório !"); 
                                try 
                                {
									frm.item(i).focus(); 
								}
								catch (e){}
                                i = frm.length; 
                                blnOK = false; 
                        } 
                } 
        } 
        return blnOK; 
} 

function LimpaTela(strFRM) 
{ 
        var frm = eval('document.' + strFRM); 
        for (i=0;i<frm.length;i++) 
        { 
                if (frm.item(i).name.substring(0,3) == "txt") 
                        frm.item(i).value = ""; 
                if (frm.item(i).name.substring(0,3) == "lst" || frm.item(i).name.substring(0,3) == "cbo") 
                        frm.item(i).selectedIndex = -1; 
                if (frm.item(i).name.substring(0,3) == "chk") 
                        frm.item(i).checked = false; 
        } 
} 

function SubmetePagina(strFRM, strPagina) 
{ 
        var frm = eval("document." + strFRM); 
        frm.action = strPagina; 
        frm.submit(); 
} 

function ValidaCNPJ(objCampo) 
{ 
        objCampo.value = DesformataCNPJ_CPF(objCampo.value); 
        if (objCampo.value.length > 0) 
        { 
                if (objCampo.value.length != 14) 
                { 
                        alert("CNPJ inválido !"); 
                        objCampo.focus(); 
                        objCampo.select(); 
                        return false; 
                } 
                else 
                { 
                        if (ConsistirCNPJ_CPF(objCampo.value) != 0) 
                        { 
                                objCampo.value = FormataCNPJ(objCampo.value); 
                        } 
                        else 
                        { 
                                alert("CNPJ inválido !") 
                                objCampo.focus(); 
                                objCampo.select(); 
                                return false; 
                        } 
                } 
        } 
} 

function FormataCNPJ(strCNPJ) 
{ 
        if (strCNPJ.length == 0) 
        { 
                return ""; 
        } 
        var bytAuxCont; 
        var bytTamStr; 
        var strResultado = ''; 
        if (strCNPJ.length > 14) 
        { 
                strCNPJ = strCNPJ.substr(0,14); 
        } 
        else 
        { 
                if (strCNPJ.length < 14) 
                { 
                        bytTamStr = 14 - strCNPJ.length; 
                        for (bytAuxCont = 1; bytAuxCont <= bytTamStr; bytAuxCont++) 
                        { 
                                strCNPJ = '0' + strCNPJ; 
                        } 
                } 
        } 
        for (bytAuxCont = 0; bytAuxCont <= 13; bytAuxCont++) 
        { 
                if (bytAuxCont == 2 | bytAuxCont==5) 
                { 
                        strResultado = strResultado + '.'; 
                } 
                if (bytAuxCont == 8) 
                { 
                        strResultado = strResultado + '/'; 
                } 
                if (bytAuxCont == 12) 
                { 
                   strResultado = strResultado + '-'; 
                } 
                strResultado = strResultado + strCNPJ.substr(bytAuxCont,1); 
        } 
        return strResultado; 
} 

function DesformataCNPJ_CPF(strDocumento) 
{ 
        var lngTamString; 
        var bytAuxCont; 
        strDocumento = strDocumento.replace(".",""); 
        strDocumento = strDocumento.replace(".",""); 
        strDocumento = strDocumento.replace("/",""); 
        strDocumento = strDocumento.replace("-",""); 
        return strDocumento; 
} 

function cpf(cpfNum)
{

if(cpfNum.length!=11){return false;}

Digitos = cpfNum.substring(9);
cpfNum = cpfNum.substring(0, 9);

cpfDig1=cpfNum.slice(8);   a1=eval(cpfDig1);
cpfDig2=cpfNum.slice(7,8); a2=eval(cpfDig2);
cpfDig3=cpfNum.slice(6,7); a3=eval(cpfDig3);
cpfDig4=cpfNum.slice(5,6); a4=eval(cpfDig4);
cpfDig5=cpfNum.slice(4,5); a5=eval(cpfDig5);
cpfDig6=cpfNum.slice(3,4); a6=eval(cpfDig6);
cpfDig7=cpfNum.slice(2,3); a7=eval(cpfDig7);
cpfDig8=cpfNum.slice(1,2); a8=eval(cpfDig8);
cpfDig9=cpfNum.slice(0,1); a9=eval(cpfDig9);

cpfPriDig=(a1*9+a2*8+a3*7+a4*6+a5*5+a6*4+a7*3+a8*2+a9)%11;
if(cpfPriDig==10){cpfPriDig=0;}
cpfSegDig=(cpfPriDig*9+a1*8+a2*7+a3*6+a4*5+a5*4+a6*3+a7*2+a8)%11;
if(cpfSegDig==10){cpfSegDig=0;}
cpfDV=cpfPriDig*10+cpfSegDig;
if(cpfDV==0){cpfDV="00";}
if(cpfDV>0&&cpfDV<10){cpfDV="0"+cpfDV;}

return (Digitos==cpfDV);
}



function cnpj(cgcNum)
{
if(cgcNum.length!=14){return false;}

Digitos = cgcNum.substring(12);
cgcNum = cgcNum.substring(0, 12);

cgcDig1=cgcNum.slice(11);    b1=eval(cgcDig1);
cgcDig2=cgcNum.slice(10,11); b2=eval(cgcDig2);
cgcDig3=cgcNum.slice(9,10);  b3=eval(cgcDig3);
cgcDig4=cgcNum.slice(8,9);   b4=eval(cgcDig4);
cgcDig5=cgcNum.slice(7,8);   b5=eval(cgcDig5);
cgcDig6=cgcNum.slice(6,7);   b6=eval(cgcDig6);
cgcDig7=cgcNum.slice(5,6);   b7=eval(cgcDig7);
cgcDig8=cgcNum.slice(4,5);   b8=eval(cgcDig8);
cgcDig9=cgcNum.slice(3,4);   b9=eval(cgcDig9);
cgcDig10=cgcNum.slice(2,3);  b10=eval(cgcDig10);
cgcDig11=cgcNum.slice(1,2);  b11=eval(cgcDig11);
cgcDig12=cgcNum.slice(0,1);  b12=eval(cgcDig12);


//cgcPriDig=(b1*9+b2*8+b3*7+b4*6+b5*5+b6*4+b7*3+b8*2+b9*9+b10*8+b11*7+b12*6)%11;
d1=(b1*2+b2*3+b3*4+b4*5+b5*6+b6*7+b7*8+b8*9+b9*2+b10*3+b11*4+b12*5)
d1=11 - (d1 % 11);
if (d1>=10) d1 = 0;
d2 = d1*2+b1*3+b2*4+b3*5+b4*6+b5*7+b6*8+b7*9+b8*2+b9*3+b10*4+b11*5+b12*6;
d2 = 11 - ( d2 % 11 );
if (d2>=10) d2 = 0;
cgcDV = new String(d1) + new String(d2);
return (Digitos==cgcDV);
}

function ConsistirCNPJ_CPF(strDocumento)
{
	if(strDocumento.length <= 11)
	{
		return cpf(strDocumento);
	}else{
		return cnpj(strDocumento);
	}
}

/*
function ConsistirCNPJ_CPF(strDocumento) 
{ 
        var va_digito; 
        var numero = new Array(15); 
        var va_resto; 
        var va_resultado; 
        var as_somadigito10; 
        va_cnpj_cpf = strDocumento; 
        if (strDocumento.length != 14) 
        { 
                var tam_cgc_cpf = strDocumento.length; 
                for (tam_cgc_cpf; tam_cgc_cpf < 14; tam_cgc_cpf++) 
                { 
                        va_cnpj_cpf = '0' + va_cnpj_cpf; 
                } 
        } 
        va_digito = va_cnpj_cpf.substring(13,2); 
        numero[1] = parseInt(va_cnpj_cpf.substr(0,1)); 
        numero[2] = parseInt(va_cnpj_cpf.substr(1,1)); 
        numero[3] = parseInt(va_cnpj_cpf.substr(2,1)); 
        numero[4] = parseInt(va_cnpj_cpf.substr(3,1)); 
        numero[5] = parseInt(va_cnpj_cpf.substr(4,1)); 
        numero[6] = parseInt(va_cnpj_cpf.substr(5,1)); 
        numero[7] = parseInt(va_cnpj_cpf.substr(6,1)); 
        numero[8] = parseInt(va_cnpj_cpf.substr(7,1)); 
        numero[9] = parseInt(va_cnpj_cpf.substr(8,1)); 
        numero[10] = parseInt(va_cnpj_cpf.substr(9,1)); 
        numero[11] = parseInt(va_cnpj_cpf.substr(10,1)); 
        numero[12] = parseInt(va_cnpj_cpf.substr(11,1)); 
        numero[13] = parseInt(va_cnpj_cpf.substr(12,1)); 
        numero[14] = parseInt(va_cnpj_cpf.substr(13,1)); 
stop;
        if (strDocumento.length > 11) 
        { 
                if (parseInt(va_cnpj_cpf.substr(0,8)) == 0 || parseInt(va_cnpj_cpf.substr(8,4)) == 0) 
                { 
                        return false; 
                } 
                va_resultado = (numero[1]*5) + (numero[2]*4) + (numero[3]*3) + (numero[4]*2) + (numero[5]*9) + (numero[6]*8) + (numero[7]*7) + (numero[8]*6) + (numero[9]*5) + (numero[10]*4) + (numero[11]*3) + (numero[12]*2); 
        } 
        else 
        { 
                if (parseFloat(va_cnpj_cpf.substr(0,9)) == 0) 
                { 
                        return false; 
                } 
                va_resultado = (numero[4]*10) + (numero[5]*9) + (numero[6]*8) + (numero[7]*7) + (numero[8]*6) + (numero[9]*5) + (numero[10]*4) + (numero[11]*3) + (numero[12]*2); 
        } 
        va_resto = 11 - (va_resultado % 11); 
        if (va_resto > 9) 
        { 
           va_resto = 0; 
        } 
        if (va_resto != numero[13]) 
        { 
           return false; 
        } 
        if (strDocumento.length > 11) 
        { 
                va_resultado = (numero[1]*6) + (numero[2]*5) + (numero[3]*4) + (numero[4]*3) + (numero[5]*2) + (numero[6]*9) + (numero[7]*8) + (numero[8]*7) + (numero[9]*6) + (numero[10]*5) + (numero[11]*4) + (numero[12]*3) + (numero[13]*2); 
        } 
        else 
        { 
            va_resultado = (numero[4]*11) + (numero[5]*10) + (numero[6]*9) + (numero[7]*8) + (numero[8]*7) + (numero[9]*6) + (numero[10]*5) + (numero[11]*4) + (numero[12]*3) + (numero[13]*2); 
        } 
        va_resto = 11 - (va_resultado % 11); 
        if (va_resto > 9) 
        { 
           va_resto = 0; 
        } 
        if (va_resto != numero[14]) 
        { 
           return false; 
        } 
        if (strDocumento.length > 11) 
        { 
                return 1; 
        } 
        else 
        { 
            return 2; 
        } 
} 
*/

/*function ValidaCPF(objCampo) 
{ 
		
        objCampo.value = DesformataCNPJ_CPF(objCampo.value);
        if (objCampo.value.length > 0) 
        { 
                if (objCampo.value.length != 11) 
                { 
                        alert("CPF inválido !"); 
                        objCampo.focus(); 
                        objCampo.select(); 
                        return false; 
                } 
                else 
                { 
                        if (ConsistirCNPJ_CPF(objCampo.value) != 0) 
                        { 
                                objCampo.value = FormataCPF(objCampo.value); 
                        } 
                        else 
                        { 
                                alert("CPF inválido !") 
                                objCampo.focus(); 
                                objCampo.select(); 
                                return false; 
                        } 
                } 
        } 
} */

function FormataCPF(strCPF) 
{ 
        if (strCPF.length == 0) 
        { 
                return ""; 
        } 
        var bytAuxCont; 
        var bytTamStr; 
        var strResultado =''; 
        if (strCPF.length > 11) 
        { 
                strCPF = strCPF.substr(0,11); 
        } 
        else 
        { 
                if (strCPF.length < 11) 
                { 
                        bytTamStr = 11 - strCPF.length; 
                        for (bytAuxCont = 1; bytAuxCont <= bytTamStr; bytAuxCont++) 
                        { 
                                strCPF = '0' + strCPF; 
                        } 
                } 
        } 
        for (bytAuxCont = 0; bytAuxCont <= 12; bytAuxCont++) 
        { 
                if (bytAuxCont == 3 | bytAuxCont == 6) 
                { 
                   strResultado = strResultado + '.'; 
                } 
                if (bytAuxCont == 9) 
                { 
                   strResultado = strResultado + '-'; 
                } 
            strResultado = strResultado + strCPF.substr(bytAuxCont,1); 
        } 
        return strResultado; 
} 

function FormataCEP(strCEP) 
{ 
        if (strCEP.length == 0) 
        { 
                return ""; 
        } 
        var bytAuxCont; 
        var bytTamStr; 
        var strResultado =''; 
        if (strCEP.length < 8) 
        { 
                bytTamStr = 8 - strCEP.length; 
                for (bytAuxCont = 1; bytAuxCont <= bytTamStr; bytAuxCont++) 
                { 
                        strCEP = '0' + strCEP; 
                } 
        } 
        for (bytAuxCont = 0; bytAuxCont <= 7; bytAuxCont++) 
        { 
                if (bytAuxCont == 5) 
                { 
                   strResultado = strResultado + '-'; 
                } 
            strResultado = strResultado + strCEP.substr(bytAuxCont,1); 
        } 
        return strResultado; 
} 

function DesformataCEP(strCEP) 
{ 
        var lngTamString; 
        var bytAuxCont; 
        strCEP = strCEP.replace("-",""); 
        return strCEP; 
} 

function ValidaCEP(objCampo) 
{ 
        var strCEP = DesformataCEP(objCampo.value); 
        if (strCEP.length > 0) 
        { 
                var va_cep = objCampo.value; 
                if (strCEP.length != 8) 
                { 
                        var tam_cep = strCEP.length; 
                        for (tam_cep; tam_cep < 8; tam_cep++) 
                        { 
                                va_cep = '0' + va_cep; 
                        } 
                } 
                if (parseFloat(va_cep.substr(0,5)) != 0 && parseFloat(va_cep.value) != 0) 
                { 
                        objCampo.value = FormataCEP(objCampo.value); 
                } 
                else 
                { 
                        alert("CEP inválido !") 
                        objCampo.focus(); 
                        objCampo.select(); 
                        return false; 
                } 
        } 
} 

function DesformataFone(strFone) 
{ 
        var lngTamString; 
        var bytAuxCont; 
        strFone = strFone.replace("(0",""); 
        strFone = strFone.replace(")",""); 
        strFone = strFone.replace("xx",""); 
        strFone = strFone.replace("-",""); 
        strFone = strFone.replace("_","0"); 
        return strFone; 
} 

function FormataFone(strFone) 
{ 
        if (strFone.length == 0) 
        { 
                return ""; 
        } 
        var bytAuxCont; 
        var bytTamStr; 
        var strResultado =''; 
        if (strFone.length < 8) 
        { 
                bytTamStr = 8 - strFone.length; 
                for (bytAuxCont = 1; bytAuxCont <= bytTamStr; bytAuxCont++) 
                { 
                        strFone = '0' + strFone; 
                } 
        } 
        for (bytAuxCont = 0; bytAuxCont <= 7; bytAuxCont++) 
        { 
                if (bytAuxCont == 4) 
                { 
                   strResultado = strResultado + '-'; 
                } 
                if (bytAuxCont == 0 && strFone.substr(bytAuxCont,1) == '0') 
                { 
                   strResultado = strResultado + '_'; 
                } 
                else 
                { 
                        strResultado = strResultado + strFone.substr(bytAuxCont,1); 
                } 
        } 
        return strResultado; 
} 

function ValidaFone(objCampo) 
{ 
        var strFone = DesformataFone(objCampo.value); 
        if (strFone.length > 0) 
        { 
                var va_fone = objCampo.value; 
                if (strFone.length != 8) 
                { 
                        var tam_fone = strFone.length; 
                        for (tam_fone; tam_fone < 8; tam_fone++) 
                        { 
                                va_fone = '0' + va_fone; 
                        } 
                } 
                if (parseInt(va_fone.substr(0,4)) != 0 && 
                        parseInt(va_fone.substr(1,3)) != 0 && 
                        parseInt(va_fone.substr(1,2)) != 0 && 
                        //parseInt(va_fone.substr(1,1)) != 0 && 
                        parseInt(va_fone.value) != 0) 
                {
						
                        objCampo.value = FormataFone(objCampo.value); 
                } 
                else 
                { 
                        alert("Telefone inválido !") 
                        objCampo.focus(); 
                        objCampo.select(); 
                        return false; 
                } 
        } 
} 

function ValidaFoneDDD(objCampo) 
{ 
	
        var strFone = DesformataFone(objCampo.value); 
        if (strFone.length > 0) 
        { 
                var va_fone = objCampo.value; 
                if (strFone.length != 10) 
                { 
                        var tam_fone = strFone.length; 
                        for (tam_fone; tam_fone < 9; tam_fone++) 
                        { 
                                va_fone = '0' + va_fone; 
                        } 
                } 
                //alert(va_fone.substr(0,2));
                if (parseInt(va_fone.substr(0,0)) != 0 && 
                        parseInt(va_fone.substr(0,2)) != 0 && 
						parseInt(va_fone.substr(2,2)) != 0 && 
						parseInt(va_fone.value) != 0) 
                { 
						//alert ("aqui" + va_fone.substr(0,3));
                        objCampo.value = FormataFoneDDD(objCampo.value); 
                } 
                else 
                { 
                        alert("Telefone inválido !") 
                        objCampo.focus(); 
                        objCampo.select(); 
                        return false; 
                } 
        } 
} 

function FormataFoneDDD(strFone) 
{ 
        if (strFone.length == 0) 
        { 
                return ""; 
        } 
        var bytAuxCont; 
        var bytTamStr; 
        var strResultado =''; 
        if (strFone.length < 9) 
        { 
                bytTamStr = 9 - strFone.length; 
                for (bytAuxCont = 1; bytAuxCont <= bytTamStr; bytAuxCont++) 
                { 
                        strFone = '0' + strFone; 
                } 
        } 
        for (bytAuxCont = 0; bytAuxCont <= 9; bytAuxCont++) 
        { 
                if (bytAuxCont == 0) 
                { 
                   strResultado = strResultado + '(0xx'; 
                } 
                if (bytAuxCont == 2) 
                { 
                   strResultado = strResultado + ')'; 
                } 
                if ((bytAuxCont == 6 && strFone.length == 10) || (bytAuxCont == 5 && strFone.length == 9))
                { 
                   strResultado = strResultado + '-'; 
                } 
                if (bytAuxCont == 2 && strFone.substr(bytAuxCont,1) == '0') 
                { 
                        strResultado = strResultado + '_'; 
                } 
                else 
                { 
                        strResultado = strResultado + strFone.substr(bytAuxCont,1); 
                } 
        } 
        return strResultado; 
}

function FormataTextArea(objCampo)
{
	if (objCampo.value.length > objCampo.maxlength)
	{
		objCampo.value = (objCampo.value).substr(0,objCampo.maxlength);
	}
}

function validaemail(email) {
  //var objRegExp  = /^[A-Za-z]([\w\.]*)@([A-Za-z0-9\.]*)\.(([A-Za-z]{3}\.[A-Za-z]{2}$)|([A-Za-z]{3}$)|([a-z]{2}$))/i;
  
  var objRegExp = /^[a-z0-9._-]+\@[a-z0-9._-]+\.[a-z]{2,4}$/;
  return objRegExp.test(email);   
  
}


function ValidaCPF(objCampo)
{  
    var i; 
    
    var s = objCampo.value;  
    
    
    if (objCampo.value.length > 0) 
    {    
        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 Invalido") 
            objCampo.focus(); 
            objCampo.select(); 
            return false;   

        } 
      
        d1 = 11 - (d1 % 11);   
        
        if (d1 > 9) d1 = 0;   
        
        if (dv.charAt(0) != d1)   
        {   
            alert("CPF Invalido")   
            objCampo.focus(); 
            objCampo.select(); 
            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 Invalido")            
            objCampo.focus(); 
            objCampo.select(); 
            return false;    
        } 
        
        objCampo.value = FormataCPF(objCampo.value);      
        return true; 
    }  
} 
