// JavaScript Document


function Formatar() {
if ( document.nform.cnpj.value.length < 15 ) {
FormataCNPJ(document.nform,'cnpj');
} else {
FormataCNPJ(document.nform,'cnpj');
}
}
function Testar() {
if ( document.nform.cnpj.value.length < 15 ) {
TestaCNPJ();
} else {
TestaCNPJ();
}
}
function FormataCPF(nform,campo) {
if (event.keyCode < 45 || event.keyCode > 57) {
event.returnValue = false;
} else {
x = nform[campo].value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "-", "" );
t = x.length ;
if (t >= 3 && t < 6) { x = '' + x.substr(0,3) + '.' + x.substr(3) + ''; }
if (t >= 6 && t < 9) { x = '' + x.substr(0,3) + '.' + x.substr(3,3) + '.' + x.substr(6) + ''; }
if (t >= 9) { x = '' + x.substr(0,3) + '.' + x.substr(3,3) + '.' + x.substr(6,3) + '-' + x.substr(9) + ''; }
nform[campo].value = x;
}
}
function TestaCPF() {
x = document.nform.cnpj.value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "-", "" );
if (checaCPF(x)) {
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#000000';
//alert("Ok, o CPF ? valido.");
}
else {
errors="1";
if (errors)
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#FF0000';
if (document.nform.cnpj.value != '') {
alert('CNPJ ou CPF Incorreto!: ' + document.nform.cnpj.value + '');
document.all("cnpj").focus();

} else {
//alert('Digite um CNPJ ou CPF V?lido');
document.all("cnpj").focus();
}
document.MM_returnValue = (errors == '');
}
}
function checaCPF (CPF) {
CPF = CPF.toString().replace( ".", "" );
CPF = CPF.toString().replace( ".", "" );
CPF = CPF.toString().replace( "-", "" );
if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
CPF == "88888888888" || CPF == "99999999999")
return false;
soma = 0;
for (i=0; i < 9; i ++)
soma += parseInt(CPF.charAt(i)) * (10 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(9)))
return false;
soma = 0;
for (i = 0; i < 10; i ++)
soma += parseInt(CPF.charAt(i)) * (11 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(10)))
return false;
return true;
}
function FormataCNPJ(nform,campo) {
if (event.keyCode < 45 || event.keyCode > 57) {
event.returnValue = false;
} else {
x = nform[campo].value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "/", "" );
x = x.toString().replace( "-", "" );
t = x.length ;
if (t >= 2 && t < 5) { x = '' + x.substr(0,2) + '.' + x.substr(2) + ''; }
if (t >= 5 && t < 8) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5) + ''; }
if (t >= 8 && t < 12) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5,3) + '/' + x.substr(8) + ''; }
if (t >= 12) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5,3) + '/' + x.substr(8,4) + '-' + x.substr(12) + ''; }
nform[campo].value = x;
}
}
function TestaCNPJ() {
FORM = document.nform.cnpj.value;
FORM = FORM.toString().replace( ".", "" );
FORM = FORM.toString().replace( ".", "" );
FORM = FORM.toString().replace( "/", "" );
FORM = FORM.toString().replace( "-", "" );
CAMPO = "cnpj";
if(Verify(FORM, CAMPO))
{
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#000000';
//alert("Ok, o CNPJ ? valido.");
}
else
{
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#FF0000';
if (document.nform.cnpj.value != '') {
alert('CNPJ ou CPF Incorreto!: ' + document.nform.cnpj.value + '');
document.all("cnpj").focus();
} else {
//alert('Digite um CNPJ ou CPF V?lido');
document.all("cnpj").focus();
}
}
return;
}
function Verify(FORM,CAMPO)
{
if(FORM == 0)
{
return(false);
}
else
{
g=FORM.length-2;
if(TestDigit(FORM,CAMPO,g))
{
g=FORM.length-1;
if(TestDigit(FORM,CAMPO,g))
{	
return(true);
}
else
{
return(false);
}
}
else
{
return(false);
}
}
}
function TestDigit(FORM,CAMPO,g)
{
var dig=0;
var ind=2;
for(f=g;f>0;f--)
{
dig+=parseInt(FORM.charAt(f-1))*ind;
if (CAMPO=='cnpj')
{ if(ind>8) {ind=2} else {ind++} }
else
{ ind++ }
}
dig%=11;
if(dig<2)
{
dig=0;
}
else
{
dig=11-dig;
}
if(dig!=parseInt(FORM.charAt(g)))
{
return(false);
}
else
{
return(true);
}
}
window.status="";


function FormatarCampoCPF() {
if ( document.nform.cpf.value.length < 15 ) {
FormataCPF(document.nform,'cpf');
} else {
FormataCNPJ(document.nform,'cnpj');
}
}
function TestarCampoCPF() {
if ( document.nform.cpf.value.length < 15 ) {
TestaCPF();
} else {
TestaCNPJ();
}
}
function FormataCPF(nform,campo) {
if (event.keyCode < 45 || event.keyCode > 57) {
event.returnValue = false;
} else {
x = nform[campo].value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "-", "" );
t = x.length ;
if (t >= 3 && t < 6) { x = '' + x.substr(0,3) + '.' + x.substr(3) + ''; }
if (t >= 6 && t < 9) { x = '' + x.substr(0,3) + '.' + x.substr(3,3) + '.' + x.substr(6) + ''; }
if (t >= 9) { x = '' + x.substr(0,3) + '.' + x.substr(3,3) + '.' + x.substr(6,3) + '-' + x.substr(9) + ''; }
nform[campo].value = x;
}
}
function TestaCPF() {
x = document.nform.cpf.value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "-", "" );
if (checaCPF(x)) {
document.nform.cpf.style.backgroundColor='#FFFFFF';
document.nform.cpf.style.color='#000000';
//alert("Ok, o CPF ? valido.");
}
else {
errors="1";
if (errors)
document.nform.cpf.style.backgroundColor='#FFFFFF';
document.nform.cpf.style.color='#FF0000';
if (document.nform.cpf.value != '') {
alert('CPF Incorreto!: ' + document.nform.cpf.value + '');
document.all("cpf").focus();

} else {
//alert('Digite um CNPJ ou CPF V?lido');
//document.all("cpf").focus();
}
document.MM_returnValue = (errors == '');
}
}
function checaCPF (CPF) {
CPF = CPF.toString().replace( ".", "" );
CPF = CPF.toString().replace( ".", "" );
CPF = CPF.toString().replace( "-", "" );
if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
CPF == "88888888888" || CPF == "99999999999")
return false;
soma = 0;
for (i=0; i < 9; i ++)
soma += parseInt(CPF.charAt(i)) * (10 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(9)))
return false;
soma = 0;
for (i = 0; i < 10; i ++)
soma += parseInt(CPF.charAt(i)) * (11 - i);
resto = 11 - (soma % 11);
if (resto == 10 || resto == 11)
resto = 0;
if (resto != parseInt(CPF.charAt(10)))
return false;
return true;
}
function FormataCNPJ(nform,campo) {
if (event.keyCode < 45 || event.keyCode > 57) {
event.returnValue = false;
} else {
x = nform[campo].value;
x = x.toString().replace( ".", "" );
x = x.toString().replace( ".", "" );
x = x.toString().replace( "/", "" );
x = x.toString().replace( "-", "" );
t = x.length ;
if (t >= 2 && t < 5) { x = '' + x.substr(0,2) + '.' + x.substr(2) + ''; }
if (t >= 5 && t < 8) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5) + ''; }
if (t >= 8 && t < 12) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5,3) + '/' + x.substr(8) + ''; }
if (t >= 12) { x = '' + x.substr(0,2) + '.' + x.substr(2,3) + '.' + x.substr(5,3) + '/' + x.substr(8,4) + '-' + x.substr(12) + ''; }
nform[campo].value = x;
}
}
function TestaCNPJ() {
FORM = document.nform.cnpj.value;
FORM = FORM.toString().replace( ".", "" );
FORM = FORM.toString().replace( ".", "" );
FORM = FORM.toString().replace( "/", "" );
FORM = FORM.toString().replace( "-", "" );
CAMPO = "cnpj";
if(Verify(FORM, CAMPO))
{
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#000000';
//alert("Ok, o CNPJ ? valido.");
}
else
{
document.nform.cnpj.style.backgroundColor='#FFFFFF';
document.nform.cnpj.style.color='#FF0000';
if (document.nform.cnpj.value != '') {
alert('CNPJ Incorreto!: ' + document.nform.cnpj.value + '');
document.all("cnpj").focus();
} else {
//alert('Digite um CNPJ ou CPF V?lido');
//document.all("cnpj").focus();
}
}
return;
}
function Verify(FORM,CAMPO)
{
if(FORM == 0)
{
return(false);
}
else
{
g=FORM.length-2;
if(TestDigit(FORM,CAMPO,g))
{
g=FORM.length-1;
if(TestDigit(FORM,CAMPO,g))
{	
return(true);
}
else
{
return(false);
}
}
else
{
return(false);
}
}
}
function TestDigit(FORM,CAMPO,g)
{
var dig=0;
var ind=2;
for(f=g;f>0;f--)
{
dig+=parseInt(FORM.charAt(f-1))*ind;
if (CAMPO=='cnpj')
{ if(ind>8) {ind=2} else {ind++} }
else
{ ind++ }
}
dig%=11;
if(dig<2)
{
dig=0;
}
else
{
dig=11-dig;
}
if(dig!=parseInt(FORM.charAt(g)))
{
return(false);
}
else
{
return(true);
}
}
window.status="";




function myClient() {
    var cep;
    var endereco;
    var bairro;
    var cidade;
    var uf;

}

function LocalizaCEP() {
	var cep=document.nform.CEP.value;
	var endereco=document.nform.Endereco.value;
	var cidade=document.nform.Cidade.value;
	var uf=document.nform.uf.value;
	var strURL;

	strURL="BuscaCep.asp?cep=" + cep + "&endereco=" + endereco + "&cidade=" + cidade + "&uf=" + uf;

	if (showModalDialog(strURL, myClient,"dialogWidth:60em;dialogHeight:30em;center:1;resizable:0;status:No;")==false)
		return;    // user canceled search
	else {
		// search for the string
		if (myClient.cep!="" && myClient.cep!="undefined" && myClient.cep!=null) {
			document.nform.CEP.value=myClient.cep;
			document.nform.Endereco.value=myClient.endereco;
			document.nform.Bairro.value=myClient.bairro;
			document.nform.Cidade.value=myClient.cidade;
			document.nform.uf.value=myClient.uf;
			document.all("Numero").focus();
		}
	}
}

function BuscaCartao() {
	var cartao="";
	var strURL;

	strURL="BuscaCartao.asp";

	if (showModalDialog(strURL, BC,"dialogWidth:15em;dialogHeight:25em;center:1;resizable:0;status:No;")==false)
		return;    // user canceled search
	else {
		// search for the string
		if (BC.cartao!="" && BC.cartao!="undefined" && BC.cartao!=null) {
			document.nform.cartao.value=BC.cartao;
			document.all("Nome").focus();
		}
		else
			document.all("cartao").focus();
	}
}

function BC() {
    var cartao;
}


function checa(nform) {			
	
	
	
	if (nform.Nome.value == "") {
		alert("Informe o seu Nome.");
		nform.Nome.focus();
		nform.Nome.select();
		return false;
	}
	
	if (nform.rg.value == "") {
		alert("Informe o RG.");
		nform.rg.focus();
		nform.rg.select();
		return false;
	}	
	
	if (nform.cpf.value == "") {
		alert("Informe o CPF.");
		nform.cpf.focus();
		nform.cpf.select();
		return false;
	}
	
	if (nform.fone.value == "") {
		alert("Informe seu telefone.");
		nform.fone.focus();
		nform.fone.select();
		return false;
	}	
		
	if (nform.email.value == "") {
		alert("Informe seu e-mail.");
		nform.email.focus();
		nform.email.select();
		return false;
	} else {
		prim = nform.email.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		if(nform.email.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			nform.email.focus();
			nform.email.select();
			return false;
		}
		
		
	   if (nform.email.value != nform.email2.value) {
       alert("Os campos E-mail e CONFIRMAR E-mail, DEVEM ser iguais!");
       nform.email2.focus();
       return false;
	   }
		
		if (nform.cep.value == "") {
			alert("Informe seu CEP.");
			nform.cep.focus();
			nform.cep.select();
			return false;
		}
		
		if (nform.Login.value == "") {
			alert("Informe seu login.");
			nform.Login.focus();
			nform.Login.select();
			return false;
		}
		
		if (nform.senha.value == "") {
			alert("Informe sua senha.");
			nform.senha.focus();
			nform.senha.select();
			return false;
		}
		
	   if (nform.senha.value != nform.senha2.value) {
       alert("Os campos SENHA e CONFIRMAR SENHA, DEVEM ser iguais!");
       nform.senha2.focus();
       return false;
	   }

	}
		return true;
}


function ms(v){
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{2})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1/$2")       //Coloca um ponto entre o terceiro e o quarto dígitos	
	v=v.replace(/(\d{4})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
	return v
	}
	
	function FormatMesAno(val)
{
   	var strPass = val.value;
	var mikExp = /[0123456789]/;

	for(i=0; i<strPass.length; i++){
		// charAt -> retorna o caractere posicionado no ?ndice especificado
		var lchar = val.value.charAt(i);
		var nchar = val.value.charAt(i+1);

		if(i==0){
		   // search -> retorna um valor inteiro, indicando a posi??o do inicio da primeira
		   // ocorr?ncia de expReg dentro de instStr. Se nenhuma ocorrencia for encontrada o m?todo retornara -1
		   // instStr.search(expReg);
		   if ((lchar.search(mikExp) != 0) || (lchar>3)){
			  val.value = "";
		   }

		}else if(i==1){

			   if(lchar.search(mikExp) != 0){
				  // substring(indice1,indice2)
				  // indice1, indice2 -> ser? usado para delimitar a string
				  var tst1 = val.value.substring(0,(i));
				  val.value = tst1;
 				  continue;
			   }

			   if ((nchar != '/') && (nchar != '')){
				 	var tst1 = val.value.substring(0, (i)+1);

					if(nchar.search(mikExp) != 0)
						var tst2 = val.value.substring(i+2, strPass.length);
					else
						var tst2 = val.value.substring(i+1, strPass.length);

					val.value = tst1 + '/' + tst2;
			   }

		 }else if(i==4){

				if(lchar.search(mikExp) != 0){
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;
					continue;
				}

				if	((nchar != '/') && (nchar != '')){
					var tst1 = val.value.substring(0, (i)+1);

					if(nchar.search(mikExp) != 0)
						var tst2 = val.value.substring(i+2, strPass.length);
					else
						var tst2 = val.value.substring(i+1, strPass.length);

					val.value = tst1 + '/' + tst2;
				}
   		  }

		  if(i>=6){
			  if(lchar.search(mikExp) != 0) {
					var tst1 = val.value.substring(0, (i));
					val.value = tst1;
			  }
		  }
	 }

     if(strPass.length>10)
		val.value = val.value.substring(0, 10);
	 	return true;
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}



function ms(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1-$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	  
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}


function FormataCellphoneBr(obj,e)
{
	if (navigator.userAgent.indexOf("IE") != -1)
	{
		var keypress = window.event.keyCode;
		if (keypress > 47 && keypress < 58 && obj.value.length < 13)
			{
			if (obj.value.length == 0)
			   obj.value = "(" + obj.value;
			if (obj.value.length == 3)
			   obj.value = obj.value + ")";
			if (obj.value.length == 8)
			   obj.value = obj.value + "-";
			}
		else
			event.returnValue = false;
	}
	else
	{
		lineaux = obj.value;
		var keypress = e.which;
		if (keypress == 8)
			return true;
		if ((keypress < 48 || keypress > 57) || obj.value.length >= 13)
			return false;
		if (lineaux.length == 0)
			lineaux = "(";
		if (lineaux.length == 3)
			lineaux = lineaux + ")";
		if (lineaux.length == 8)
			lineaux = lineaux + "-";
		lineaux = lineaux + (keypress - 48);
		obj.value = lineaux;
		return false;
	}
	return true;
} 

// JavaScript Document
	function SomenteNumeros(input)
	{
			
		var keypress = window.event.keyCode
		
		if ((keypress<48)||(keypress>57))
			event.returnValue = false;
	}
	
	//****Usar essa função! - A função acima foi mantida por ainda ser usada em outros programas:
	function vSomenteNum(evt, bAceitaVirgula_)
    {
        var key_code = evt.keyCode  ? evt.keyCode  :
                       evt.charCode ? evt.charCode :
                       evt.which    ? evt.which    : void 0;
		
		//Aceita a virgula para informar numeros decimais:
		if( bAceitaVirgula_ && key_code == 44 )
            return true 
			
		//key_code == 46
		
        // Habilita teclas <DEL>, <TAB>, <ENTER>, <ESC> e <BACKSPACE>
        if ( key_code == 46 || key_code == 8  ||  key_code == 9  ||  key_code == 13  ||  key_code == 27 )
        {
            return true;
        }

        // Habilita teclas <HOME>, <END>, mais as quatros setas de navegação (cima, baixo, direta, esquerda)
        else if ( key_code >= 35 && key_code <= 40 )
        {
            return true
        }

        // Habilita números de 0 a 9
        else if ((key_code >= 48)  &&  (key_code <= 57))
        {
            return true
        }

        return false;
    }	
	
	function mascara(o,f){
	v_obj=o
	v_fun=f
	setTimeout("execmascara()",1)
	}
	
	function execmascara(){
	v_obj.value=v_fun(v_obj.value)
	}
	
	function leech(v){
	v=v.replace(/o/gi,"0")
	v=v.replace(/i/gi,"1")
	v=v.replace(/z/gi,"2")
	v=v.replace(/e/gi,"3")
	v=v.replace(/a/gi,"4")
	v=v.replace(/s/gi,"5")
	v=v.replace(/t/gi,"7")
	return v
	}
	
	
	function ms(v){
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1-$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	
	v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
	return v
	}
	
	function VerificaData(digData) 
	{
	var bissexto = 0;
	var data = digData; 
	var tam = data.length;
	if (tam == 5) 
	{
	var dia = data.substr(0,2)
	var mes = data.substr(3,2)
	//var ano = data.substr(6,4)
	//if ((ano > 1900)||(ano < 2100))
	{
	switch (mes) 
	{
	case '01':
	case '03':
	case '05':
	case '07':
	case '08':
	case '10':
	case '12':
	if  (dia <= 31) 
	{
	return true;
	}
	break
	
	case '04':        
	case '06':
	case '09':
	case '11':
	if  (dia <= 30) 
	{
	return true;
	}
	break
	case '02':
	/* Validando ano Bissexto / fevereiro / dia */ 
	if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) 
	{ 
	bissexto = 1; 
	} 
	if ((bissexto == 1) && (dia <= 29)) 
	{ 
	return true;                 
	} 
	if ((bissexto != 1) && (dia <= 28)) 
	{ 
	return true; 
	}            
	break                        
	}
	}
	}    
	alert("A Data "+data+" incorreta!");
	document.Data_EventoInicio.focus
	return false;
	}
	
	function Verifica_CPF(nform) {
	//var CPF = document.nform.CPF.value; // Recebe o valor digitado no campo
	var CPF = document.getElementById('CPF').value;
	
	CPF = CPF.toString().replace( ".", "" );
	CPF = CPF.toString().replace( ".", "" );
	CPF = CPF.toString().replace( "-", "" );	
	
	// Verifica se o campo é nulo
	if (CPF == '') {
	alert('Este campo é de preenchimento obrigatório!');
	return false;
	}
	
	// Aqui começa a checagem do CPF
	var POSICAO, I, SOMA, DV, DV_INFORMADO;
	var DIGITO = new Array(10);
	DV_INFORMADO = CPF.substr(9, 2); // Retira os dois últimos dígitos do número informado
	
	// Desemembra o número do CPF na array DIGITO
	for (I=0; I<=8; I++) {
	DIGITO[I] = CPF.substr( I, 1);
	}
	
	// Calcula o valor do 10º dígito da verificação
	POSICAO = 10;
	SOMA = 0;
	for (I=0; I<=8; I++) {
	SOMA = SOMA + DIGITO[I] * POSICAO;
	POSICAO = POSICAO - 1;
	}
	DIGITO[9] = SOMA % 11;
	if (DIGITO[9] < 2) {
	DIGITO[9] = 0;
	}
	else{
	DIGITO[9] = 11 - DIGITO[9];
	}
	
	// Calcula o valor do 11º dígito da verificação
	POSICAO = 11;
	SOMA = 0;
	for (I=0; I<=9; I++) {
	SOMA = SOMA + DIGITO[I] * POSICAO;
	POSICAO = POSICAO - 1;
	}
	DIGITO[10] = SOMA % 11;
	if (DIGITO[10] < 2) {
	DIGITO[10] = 0;
	}
	else {
	DIGITO[10] = 11 - DIGITO[10];
	}
	
	// Verifica se os valores dos dígitos verificadores conferem
	DV = DIGITO[9] * 10 + DIGITO[10];
	if (DV != DV_INFORMADO) {
	alert('CPF Incorreto!');
	//nform.CPF.value = '';
	document.getElementById('CPF').value ='';
	document.getElementById('CPF').focus();
	
	
	return false;
	} 
	}

