function ajaxInit(){
var xmlhttp ;
	try {
 		xmlhttp = new XMLHttpRequest ( ) ;
 	}catch (ee){
		try { 
		xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP") ;
 		}catch( e ) {
 			try {
 				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP" ) ;
 			}catch(E) {
 				xmlhttp= false ;
 			}
 		}
 	}
 return xmlhttp ;
}
function poupanca(){
	document.getElementById("DivPoupanca").innerHTML="/500";
}
function corrente(){
	document.getElementById("DivPoupanca").innerHTML="";
}
function carregaDados(id){
	ajax=ajaxInit();
	document.getElementById("DivDados").innerHTML="<div id=\"DivImgCarregando\"><img src=\"imagensFontte/carregando.gif\"></div>";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_dados&id='+id,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivDados").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function pagar(id,valor,vencimento){
	document.formBoleto.pedido.value=id;
	document.formBoleto.valor.value=valor;
	document.formBoleto.dataVencimento.value=vencimento;
	document.formBoleto.action='itau?tit=Pagamentos';
	document.formBoleto.submit();
}
function acessar2(valor,teclapres){
	 var tecla = 0;
   if(document.all){
        tecla = teclapres.keyCode;
    }
    else{
      tecla = teclapres.which;
      if(tecla==1){tecla=0}
    }
    if (tecla == 13 || tecla == 0){
		if(document.formLogin.txtCPF.value==''||document.formLogin.txtSenha.value==''){
			location.href="javascript:scroll(0,0)";
			document.getElementById("DivErro").style.visibility="visible";
			document.getElementById("DivErro").innerHTML="Informe seu ID e senha!";
			setTimeout ('escondeDiv("DivErro")',4000);
		}else{
			document.formLogin.action='acesso?ac=verificar_acesso&url=mf';
			document.formLogin.submit();
		}
	}     
}
function escondeDiv(div){
	document.getElementById(div).innerHTML="";
	document.getElementById(div).style.visibility="hidden";
}
function validarCPF(CPF){ 
	if (CPF != ''){ 
		if (!verificarCPF(CPF)){ 
			location.href="javascript:scroll(0,0)";
			document.getElementById("DivErro").style.visibility="visible";
			document.getElementById("DivErro").innerHTML="CPF inválido!";
			setTimeout ('escondeDiv("DivErro")',4000);
			document.form.txtCPF.value='';  
			document.form.txtCPF.focus(); 
		} 
	} 
} 
function validarCPF2(CPF){ 
	if (CPF != ''){ 
		if (!verificarCPF(CPF)){ 
			location.href="javascript:scroll(0,0)";
			document.getElementById("DivErro").style.visibility="visible";
			document.getElementById("DivErro").innerHTML="CPF inválido!";
			setTimeout ('escondeDiv("DivErro")',4000);
			document.form.txtCPF.value='';  
			document.form.txtCPF.focus(); 
		}else{
			ajax=ajaxInit();
			if(ajax){
				ajax.open('GET','mf?ac=verifica_cpf&cpf='+CPF,true);
				ajax.onreadystatechange=function(){
					if(ajax.readyState==4){
						if(ajax.status==200){
							if(ajax.responseText=='true'){
								location.href="javascript:scroll(0,0)";
								document.getElementById("DivErro").style.visibility="visible";
								document.getElementById("DivErro").innerHTML="CPF já existente em nossa base de dados!";
								setTimeout ('escondeDiv("DivErro")',4000);
								document.form.txtCPF.value='';  
								document.form.txtCPF.focus(); 
							} 
						}
					}
				}
			}
			ajax.send(null);
		} 
	} 
}
function verificarCPF(c){ 
	c = c.replace('.','');	
	c = c.replace('.','');	
	c = c.replace('-','');	
	var i;  
	s = c; 
	var c = s.substr(0,9);  
	var dv = s.substr(9,2);  
	var d1 = 0;  
	var v = false; 
	for (i = 0; i < 9; i++)  
	{  
		d1 += c.charAt(i)*(10-i);  
	}  
	if (d1 == 0){  
	v = true;  
	return false;  
	}  
	d1 = 11 - (d1 % 11);  
		if (d1 > 9) d1 = 0;  
			if (dv.charAt(0) != d1)  
			{  
		v = true; 
		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)  
	{  
	v = true; 
	return false;  
	}  
	if (!v) { 
	return true; 
	} 
}

function formatarCPF (campo,teclapres) { 
	var tecla = (window.event)?event.keyCode:teclapres.which;
	if ((tecla < 48) || (tecla > 57)) {
		return false;
	} 
	vr = campo.value;  
	vr = vr.replace( '-', '' );  
	vr = vr.replace( '.', '' );  
	vr = vr.replace( '.', '' );  
	tam = vr.length; 
	 
	if (tam < 11 && tecla != 8){ tam = vr.length + 1 ; }  
	if (tecla == 8 ){	tam = tam - 1 ; }  
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){  
		if ( tam <= 2 ){  
	 		campo.value = vr ; }  
	 	if ( (tam > 2) && (tam <= 5) ){  
	 		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }  
	 	if ( (tam >= 6) && (tam <= 8) ){  
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }  
	 	if ( (tam >= 9) && (tam <= 11) ){  
	 		campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }  
	}
}
function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

function validarCNPJ(CNPJ){ 
	if (CNPJ != ''){ 
		if (!verificarCNPJ(CNPJ)){ 
			location.href="javascript:scroll(0,0)";
			document.getElementById("DivErro").style.visibility="visible";
			document.getElementById("DivErro").innerHTML="CNPJ inválido!";
			setTimeout ('escondeDiv("DivErro")',4000); 
			document.form.txtCNPJ.value='';  
			document.form.txtCNPJ.focus(); 
		} 
	} 
}
function validarCNPJ2(CNPJ){ 
	if (CNPJ != ''){ 
		if (!verificarCNPJ(CNPJ)){ 
			location.href="javascript:scroll(0,0)";
			document.getElementById("DivErro").style.visibility="visible";
			document.getElementById("DivErro").innerHTML="CNPJ inválido!";
			setTimeout ('escondeDiv("DivErro")',4000); 
			document.form.txtCNPJ.value='';  
			document.form.txtCNPJ.focus(); 
		}else{
			ajax=ajaxInit();
			if(ajax){
				ajax.open('GET','mf?ac=verifica_cnpj&cnpj='+CNPJ,true);
				ajax.onreadystatechange=function(){
					if(ajax.readyState==4){
						if(ajax.status==200){
							if(ajax.responseText=='true'){
								location.href="javascript:scroll(0,0)";
								document.getElementById("DivErro").style.visibility="visible";
								document.getElementById("DivErro").innerHTML="CNPJ já existente em nossa base de dados!";
								setTimeout ('escondeDiv("DivErro")',4000);
								document.form.txtCNPJ.value='';  
								document.form.txtCNPJ.focus(); 
							} 
						}
					}
				}
			}
			ajax.send(null);
		}  
	} 
} 

function verificarCNPJ(c) { 
        CNPJ = c; 
        erro = new String; 
        if (CNPJ.length < 18) erro += "? necessarios preencher corretamente o numero do CNPJ!"; 
        if ((CNPJ.charAt(2) != '.') || (CNPJ.charAt(6) != '.') || (CNPJ.charAt(10) != '/') || (CNPJ.charAt(15) != '-')){ 
            if (erro.length == 0) erro += "E' necessarios preencher corretamente o numero do CNPJ!"; 
        } 
        //substituir os caracteres que nao sao numeros 
        if(document.layers && parseInt(navigator.appVersion) == 4){ 
            x = CNPJ.substring(0,2); 
            x += CNPJ.substring(3,6); 
            x += CNPJ.substring(7,10); 
            x += CNPJ.substring(11,15); 
            x += CNPJ.substring(16,18); 
            CNPJ = x; 
        } else { 
            CNPJ = CNPJ.replace('.',''); 
            CNPJ = CNPJ.replace('.',''); 
            CNPJ = CNPJ.replace('-',''); 
            CNPJ = CNPJ.replace('/',''); 
        } 
        var nonNumbers = /\+ D/; 
        if (nonNumbers.test(CNPJ)) erro += "A verificacao de CNPJ suporta apenas numeros!";     
        var a = []; 
        var b = new Number; 
        var c = [6,5,4,3,2,9,8,7,6,5,4,3,2]; 
        for (i=0; i<12; i++){ 
            a[i] = CNPJ.charAt(i); 
            b += a[i] * c[i+1]; 
        } 
        if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x } 
        b = 0; 
        for (y=0; y<13; y++) { 
            b += (a[y] * c[y]);  
        } 
        if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; } 
        if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){ 
            return false; 
        } 
        if (erro.length > 0){ 
            alert(erro); 
   		document.formulario.txtCNPJ.value=""; 
			document.formulario.txtCNPJ.focus(); 
            return false; 
        } else { 
        } 
        return true; 
} 

function formatarCNPJ (campo,teclapres) { 
	vr = campo.value;  
	vr = vr.replace( '-', '' );  
	vr = vr.replace( '/', '' );  
	vr = vr.replace( '.', '' );  
	vr = vr.replace( '.', '' );  
	tam = vr.length;  
		if ( tam <= 2 ){  
	 		campo.value = vr ; }  
	 	if ( (tam > 2) && (tam <= 5) ){  
	 		campo.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, tam ) ; }  
	 	if ( (tam >= 6) && (tam <= 8) ){  
	 		campo.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, tam ) ; }  
	 	if ( (tam >= 9) && (tam <= 12) ){  
	 		campo.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, tam ) ; }  
	 	if ( (tam >= 13) && (tam <= 14) ){  
	 		campo.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, 4 ) + '-' + vr.substr( 12, tam ) ; }  
}    
function salvar(){
	if(document.form.txtNome.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um nome!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtNome.focus();
	}
	else if(!document.form.rdOpcao[0].checked&&!document.form.rdOpcao[1].checked){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Selecione Pessoa Física ou Pessoa Jurídica!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.rdOpcao[0].checked&&document.form.txtCPF.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um CPF!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtCPF.focus();
	}
	else if(document.form.rdOpcao[1].checked&&document.form.txtCNPJ.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um CNPJ!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtCNPJ.focus();
	}
	else if(document.form.txtEmail.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um email!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEmail.focus();
	}
	else if(validaEmail(document.form.txtEmail.value)==false){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Email inválido!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEmail.focus();
	}
	else if(document.form.txtTel.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um telefone!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtTel.focus();
	}
	else if(document.form.cboPais.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um País!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboPais.focus();
	}
	else if(document.form.cboEstado.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Estado!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboEstado.focus();
	}
	else if(document.form.cboLocalidade.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe uma Localidade!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboLocalidade.focus();
	}
	else if(document.form.cboBairro.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Bairro!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboBairro.focus();
	}
	else if(document.form.cboLogradouro.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Logradouro!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboLogradouro.focus();
	}
	else if(document.form.txtEndereco.value == ''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Complemento!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEndereco.focus();
	}
	else{
		document.form.action='mf?ac=salvar';
		document.form.submit();
	}
}
function finalizar(id){
	document.form.action='mf?ac=finalizar&id='+id;
	document.form.submit();
}

function CaixaBaixa(fsValor, foForm, foNome) { 
	if (window.event.keyCode >= 65 && window.event.keyCode <= 90){
		x = new String(document.forms[foForm].elements[foNome].value);
		document.forms[foForm].elements[foNome].value = x.toLowerCase();
	}
} 
function validaEmail(Email){
	var filter = /^(([a-zA-Z0-9_-])+(([\.\])+([a-zA-Z0-9_-]{0,1})))+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 
	var arrayEmail = Email.split(";"); //Separa os email 
	for (var i=0;i < arrayEmail.length; i++){ //varre a lista de emails 
		if ( !filter.test(arrayEmail[i]) ){ 
			return false; //se tiver erro sai com false 
		}
		else{ 
			return true; // se nao achou erro retorrna verdadeiro 
		}
	}
}
function atualizarestado(valor){
	ajax=ajaxInit();
	document.getElementById("div_estado").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_estado&idpais='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_estado").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}

function atualizarlocalidade(valor){
	ajax=ajaxInit();
	document.getElementById("div_localidade").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_localidade&idestado='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_localidade").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}


function atualizarbairro(valor){
	
	ajax=ajaxInit();
	document.getElementById("div_bairro").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_bairro&idlocalidade='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_bairro").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
		
}
function atualizarlogradouro(valor){
	
	ajax=ajaxInit();
	document.getElementById("div_logradouro").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_logradouro&idbairro='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("div_logradouro").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
	
}
function atualizarCombosCEP(){
	if(document.form.txtCEP.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um CEP!";
		setTimeout ('escondeDiv("DivErro")',4000);
        document.form.txtCEP.focus();
	}else{
		ajax=ajaxInit();
		document.getElementById("DivCarregando").src="imagensFontte/carregando_end.gif";
		if(ajax){
			ajax.open('GET','mf?ac=carregar_Combos_CEP&CEP='+document.form.txtCEP.value,true);
			ajax.onreadystatechange=function(){
				if(ajax.readyState==4){
					if(ajax.status==200){
						if(ajax.responseText!="null"){
							var vRetorno = ajax.responseText.split("|");
							document.getElementById("div_pais").innerHTML=vRetorno[0];
							document.getElementById("div_estado").innerHTML=vRetorno[1];	
							document.getElementById("div_localidade").innerHTML=vRetorno[2];	
							document.getElementById("div_bairro").innerHTML=vRetorno[3];	
							document.getElementById("div_logradouro").innerHTML=vRetorno[4];
							document.getElementById("DivCarregando").src="imagensFontte/mini_lupa.png";
						}
						else{
							location.href="javascript:scroll(0,0)";
							document.getElementById("DivErro").style.visibility="visible";
							document.getElementById("DivErro").innerHTML="CEP não encontrado em nossa base de dados!";
							setTimeout ('escondeDiv("DivErro")',4000);
       						document.form.txtCEP.focus();
       						document.getElementById("DivCarregando").src="imagensFontte/mini_lupa.png";
						}	
					}
				}
			}
		}
		ajax.send(null);
	}
}
function atualizarCEP(valor){
	ajax=ajaxInit();
	//document.getElementById("txtCEP").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_CEP&idlogradouro='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("txtCEP").value=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function atualizaDiv(valor){
	ajax=ajaxInit();
	document.getElementById("campo").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_campo&radio='+valor,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("campo").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function mostraPlano(id){
	ajax=ajaxInit();
	if(document.form.idAnterior.value!=''){
		document.getElementById(document.form.idAnterior.value).innerHTML="";
	}
	document.getElementById(id).innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_plano&id='+id,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(id).innerHTML=ajax.responseText;
					document.form.idAnterior.value=id;
				}
			}
		}
	}
	ajax.send(null);
}
function Valida(id) {
	preencheu = false;
	botoes = document.form.rdPlano.length;
	for (i=0;i<botoes;i++) {
		if (document.form.rdPlano[i].checked) {
		preencheu = true;
		break; 
		}
	}
	if (preencheu) {
		location.href='mf?ac=cadastro&idAnterior='+document.form.idAnterior.value+(id=='null'?'':'&id='+id); 
	}
	else {
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Selecione uma opção!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
}
function CaixaAlta(fsValor, foForm, foNome) { 
	if (window.event.keyCode >= 65 && window.event.keyCode <= 90){
		x = new String(document.forms[foForm].elements[foNome].value);
		document.forms[foForm].elements[foNome].value = x.toUpperCase();
	}
}
function validaData(pValor,nome){
	if(document.form.elements[nome].value!='' && validarDataYYYY(pValor)=='F'){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Data Incorreta!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.elements[nome].value='';
		document.form.elements[nome].focus();
	}
}
function formatarDataYYYY(campo, teclapres) { 
	var tecla = teclapres.keyCode;  
	vr = campo.value;  
	vr = vr.replace( '/', '' );  
	vr = vr.replace( '/', '' );  
	tam = vr.length + 1;  
	if ( tecla != 9 && tecla != 8 ) {  
	   if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {  
		   if ( tam <= 2 ) campo.value = vr ;  
		   if ( tam > 2 && tam < 5 ) campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam );  
		   if ( tam >= 5 && tam <= 10 ) campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, tam );   
      }  
   }  
}
function validarDataYYYY(vValor){ 
    var checkStr = ''; 
	checkStr = vValor; 
	var err=0; 
    var psj=0; 
	var dia = 0; 
	var mes = 0; 
	var ano = 0; 
	var barra1 = ''; 
	var barra2 = ''; 
       	dia = checkStr.substring(0, 2); 
       	barra1 = checkStr.substring(2, 3); 
       	mes = checkStr.substring(3, 5); 
       	barra2 = checkStr.substring(5, 6); 
	    ano = checkStr.substring(6, 10); 
    	    //verifica??es b?sicas 
    	    if (checkStr.length != 10) 
				err = 1; 
    	    if (mes<1 || mes>12) 
				err = 1; 
    	    if (barra1 != '/') 
				err = 1; 
    	    if (dia<1 || dia>31) 
				err = 1; 
    	    if (barra2 != '/') 
				err = 1; 
    	    if (ano<1900 || ano>2900) 
				err = 1; 
    	    //verifica??es avan?adas 
    	    // m?s com 30 dias 
    	    if (mes==4 || mes==6 || mes==9 || mes==11){ 
    		   if (dia==31) 
			   		err=1; 
    	    } 
    	    // fevereiro e ano bissexto 
    	    if (mes==2){ 
    		    var g = parseInt(ano/4); 
    		    if (isNaN(g)) { 
    			    err=1; 
    		    } 
    		    if (dia>29) 
					err=1; 
    		    if (dia==29 && ((ano/4)!=parseInt(ano/4))) 
					err=1; 
    	    } 
    if (err==1) 
       return 'F'; 
	else 
	   return 'T'; 
} 
function esqueciSenha(){
	if(document.form.txtCPF.value==''&&document.form.txtId.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe seu ID ou CPF!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else{
		document.form.action='acesso?ac=reenviar_senha&url=mf';
		document.form.submit();
	}
}
function alterarSenha(){
	if(document.form.txtSenhaNova.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe sua senha nova!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtSenhaConfirma.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe sua senha novamente para confirmação!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtSenhaNova.value!=document.form.txtSenhaConfirma.value){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Nova senha não confere com a confirmação!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else{
		document.form.action='acesso?ac=alterar_senha&url=mf';
		document.form.submit();
	}
}
function cadastroIndicador(){
	location.href="http://www.fontte.com.br/fontte/mf?ac=pre_cadastro&id="+document.form.txtIdIndicador.value;
}
function enviarEmail(){
	if(document.form.txtDe.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um remetente!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtPara.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um destinatário!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtAssunto.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um assunto!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else{
		document.form.action='mf?ac=enviar_email';
		document.form.submit();
	}
}
function habilitaBotao(){
	if(document.form.botaoTermosUso.disabled){
		document.form.botaoTermosUso.disabled = false;
	}else{
		document.form.botaoTermosUso.disabled = true;
	}
}
function montaXMLHTTP() { 
	try { 
		myObj = new XMLHttpRequest() 
	} 
	catch(e) { 
		myObj = new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	return myObj; 
} 
function mudaPlano(idPlano){
	ajax=ajaxInit();
	document.getElementById("DivDescPlano").innerHTML="Carregando...";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_plano2&id='+idPlano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivDescPlano").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function confirmaPlano(idPlano,idAssociado){
	location.href='mf?ac=seta_plano&idPlano='+idPlano+'&idAssociado='+idAssociado;	
}
function carregaBonificacao(id,idPlano){
	ajax=ajaxInit();
	document.getElementById("DivValor").innerHTML="<div id=\"DivImgCarregando\"><img src=\"imagensFontte/carregando.gif\"></div>";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_bonificacao&id='+id+'&idPlano='+idPlano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivValor").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function carregaHistorico(id,ano){
	ajax=ajaxInit();
	document.getElementById("DivHistorico").innerHTML="<div id=\"DivImgCarregando\"><img src=\"imagensFontte/carregando.gif\"></div>";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_historico&id='+id+'&ano='+ano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivHistorico").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function carregaTabelas(id,mes,ano){
	ajax=ajaxInit();
	//document.getElementById("DivTB12").innerHTML="<div id=\"DivImgCarregando\">Bônus 12<br><img src=\"imagensFontte/carregando.gif\"></div>";
	document.getElementById("DivTBStart").innerHTML="<div id=\"DivImgCarregando\">Bônus Start<br><img src=\"imagensFontte/carregando.gif\"></div>";
	document.getElementById("DivTBSponsor").innerHTML="<div id=\"DivImgCarregando\">Bônus Sponsor<br><img src=\"imagensFontte/carregando.gif\"></div>";
	if(ajax){
		ajax.open('GET','mf?ac=carregar_tbStart&id='+id+'&mes='+mes+'&ano='+ano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivTBStart").innerHTML=ajax.responseText;
					carregaBsponsor(id,mes,ano);
				}
			}
		}
	}
	ajax.send(null);
}
function carregaBstart(id,mes,ano){
	ajax=ajaxInit();
	if(ajax){
		ajax.open('GET','mf?ac=carregar_tbStart&id='+id+'&mes='+mes+'&ano='+ano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivTBStart").innerHTML=ajax.responseText;
					carregaBsponsor(id,mes,ano);
				}
			}
		}
	}
	ajax.send(null);
}
function carregaBsponsor(id,mes,ano){
	ajax=ajaxInit();
	if(ajax){
		ajax.open('GET','mf?ac=carregar_tbSponsor&id='+id+'&mes='+mes+'&ano='+ano,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById("DivTBSponsor").innerHTML=ajax.responseText;
				}
			}
		}
	}
	ajax.send(null);
}
function extratoBonus(){
	document.form.action='rel?nome_arq=acesso.jasper';
	document.form.submit();
}
function enviarEmailContato(){
	if(document.form.txtNome.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe seu nome!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtNome.focus();
	}
	else if(document.form.txtEmail.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe seu Email!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEmail.focus();
	}
	else if(validaEmail(document.form.txtEmail.value)==false){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Email inválido!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEmail.value = '';
	}
	else if(document.form.txtAssunto.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um assunto!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtAssunto.focus();
	}
	else if(document.form.txtMsg.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Digite uma mensagem!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtMsg.focus();
	}
	else{
		document.form.action='mf?ac=contato';
		document.form.submit();
	}
}
function alteraDados(){
	if(document.form.txtEmail.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um email!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtDDD.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um DDD!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.txtTelefone.value==''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um telefone!";
		setTimeout ('escondeDiv("DivErro")',4000);
	}
	else if(document.form.cboPais.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um País!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboPais.focus();
	}
	else if(document.form.cboEstado.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Estado!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboEstado.focus();
	}
	else if(document.form.cboLocalidade.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe uma Localidade!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboLocalidade.focus();
	}
	else if(document.form.cboBairro.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Bairro!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboBairro.focus();
	}
	else if(document.form.cboLogradouro.value == 0){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Logradouro!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.cboLogradouro.focus();
	}
	else if(document.form.txtEndereco.value == ''){
		location.href="javascript:scroll(0,0)";
		document.getElementById("DivErro").style.visibility="visible";
		document.getElementById("DivErro").innerHTML="Informe um Complemento!";
		setTimeout ('escondeDiv("DivErro")',4000);
		document.form.txtEndereco.focus();
	}
	else{
		document.form.action='mf?ac=altera_dados';
		document.form.submit();
	}
}
function dadosClientes(id){
	if(document.getElementById("Div"+id).style.display=="block"){
		document.getElementById("Div"+id).style.display="none";
	}else{
		document.getElementById("Div"+id).style.display="block";
	}
}