var trm = "";
trm = trm + "<p class='info_7'>Leia o termo e selecione a opção</p>";
trm = trm + "<p>Eu declaro gozar de plena saúde, estar apto a praticar o esporte em questão, ter treinado apropriadamente para a prova e estar disputando o evento por minha livre e espontânea vontade, isentando os organizadores e patrocinadores do evento de qualquer responsabilidade.</p> <p>Autorizo, outrossim, o uso de minha imagem a título gratuito, em fotos, filmes ou outra gravação relativos ao evento.</p><p>Reconheço que, todo o material e equipamentos necessários para o desempenho nesta prova são de minha inteira responsabilidade, estando de pleno acordo o regulamento.</p><p>Assim também assumo, total e irrestrita, responsabilidade pelos atletas por mim inscritos no evento em questão.</p>";
trm = trm + "<table class='cond'>";
trm = trm + "<tr>";
trm = trm + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' value='1'/></td><td class='cell_condicoes'>Concordo com os termos e condi&ccedil;&otilde;es</td>";
trm = trm + "</tr>";
trm = trm + "<tr>";
trm = trm + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' value='2'/></td><td class='cell_condicoes'>Não Concordo</td>";
trm = trm + "</tr>";
trm = trm + "</table>";


var trm1 = "";
trm1 = trm1 + "<p class='info_7'>Leia o termo e selecione a opção</p>";
trm1 = trm1 + "<p>Eu declaro gozar de plena saúde, estar apto a praticar o esporte em questão, ter treinado apropriadamente para a prova e estar disputando o evento por minha livre e espontânea vontade, isentando os organizadores e patrocinadores do evento de qualquer responsabilidade.</p> <p>Autorizo, outrossim, o uso de minha imagem a título gratuito, em fotos, filmes ou outra gravação relativos ao evento.</p><p>Reconheço que, todo o material e equipamentos necessários para o desempenho nesta prova são de minha inteira responsabilidade, estando de pleno acordo o regulamento.</p><p>Assim também assumo, total e irrestrita, responsabilidade pelos atletas por mim inscritos no evento em questão.</p>";
trm1 = trm1 + "<table class='cond'>";
trm1 = trm1 + "<tr>";
trm1 = trm1 + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' checked value='1'/></td><td class='cell_condicoes'>Concordo com os termos e condi&ccedil;&otilde;es</td>";
trm1 = trm1 + "</tr>";
trm1 = trm1 + "<tr>";
trm1 = trm1 + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' value='2'/></td><td class='cell_condicoes'>Não Concordo</td>";
trm1 = trm1 + "</tr>";
trm1 = trm1 + "</table>";

var trm2 = "";
trm2 = trm2 + "<p class='info_7'>Leia o termo e selecione a opção</p>";
trm2 = trm2 + "<p>Eu declaro gozar de plena saúde, estar apto a praticar o esporte em questão, ter treinado apropriadamente para a prova e estar disputando o evento por minha livre e espontânea vontade, isentando os organizadores e patrocinadores do evento de qualquer responsabilidade.</p> <p>Autorizo, outrossim, o uso de minha imagem a título gratuito, em fotos, filmes ou outra gravação relativos ao evento.</p><p>Reconheço que, todo o material e equipamentos necessários para o desempenho nesta prova são de minha inteira responsabilidade, estando de pleno acordo o regulamento.</p><p>Assim também assumo, total e irrestrita, responsabilidade pelos atletas por mim inscritos no evento em questão.</p>";
trm2 = trm2 + "<table class='cond'>";
trm2 = trm2 + "<tr>";
trm2 = trm2 + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' value='1'/></td><td class='cell_condicoes'>Concordo com os termos e condi&ccedil;&otilde;es</td>";
trm2 = trm2 + "</tr>";
trm2 = trm2 + "<tr>";
trm2 = trm2 + "<td class='cell_radio'><input type='radio' id='id_termo1' class='sbord_bg' name='id_termo1' onclick='return MostraBotao();' checked value='2'/></td><td class='cell_condicoes'>Não Concordo</td>";
trm2 = trm2 + "</tr>";
trm2 = trm2 + "</table>"




var botao = "";
botao = botao + "<div id='botao'>";
botao = botao + "<input type='submit' id='id_cadastrar' name='submit' class='botao' value='Inscrever'/>";
botao = botao + "</div>";


function ValidaEquipe(){
	 if (TextoBranco(document.formulario_inscricao.id_eqip.value))
	{
		alert("Por favor, preencha o campo \"Nome da Equipe ou Patrocínio\".");
		document.formulario_inscricao.id_eqip.focus();
		return false;
	}
	
}

// VARIÁVEL DA FORMULAÇÃO DO FORMULÁRIO DE CADASTRO DE ATLETA (SIMPLES)



function Escolheu(id_categ){
	
var info = id_categ;
	str_1 = new String(info);
	str_2 = str_1.split("*");
	str_3 = str_2[0]; // -> QUANTIDADE DE ATLETA
	str_4 = str_2[1]; // -> ID DA CATEGORIA
	str_5 = str_2[2]; // -> SEXO PERMITIDO
	str_6 = str_2[3]; // -> TOTAL MASCULINO
	str_7 = str_2[4]; // -> TOTAL FEMININO	
	str_8 = str_2[5]; // -> ID DA INSCRIÇÃO 
	
	
	var q_atlet = str_3;
	var a_categ = str_4;
	var s_atlet = str_5;
	var t_mascu = str_6;
	var t_femin = str_7;
	var i_inscr = str_8;
	
	MontaPagamentos(a_categ);

	document.getElementById("formulario_inscricao").id_docc.focus();
	if(document.getElementById("formulario_inscricao").ID_CATEG.value!=""){
		alert("Ao selecionar outra categoria, os \natletas incluídos na lista serão apagados!");
		if(confirm('Confirma a troca de categoria,\n e a exclusão completa da lista?')){
		ApagaLista(""+str_8+"");
		}
		else{}	
		//return false;
	}
	
	alert("Informe um CPF e verifique");


document.getElementById("formulario_inscricao").ID_CATEG.value=a_categ;
document.getElementById("formulario_inscricao").MAXI_INS.value=q_atlet;	
document.getElementById("formulario_inscricao").SEXO_INS.value=s_atlet;
document.getElementById("formulario_inscricao").MIST_HOM.value=t_mascu;
document.getElementById("formulario_inscricao").MIST_MUL.value=t_femin;
}

function MontaPagamentos(id_c){
document.getElementById("pagamentos").innerHTML="<h3><img src='imgs/carregando.gif'> Aguarde . . .</h3>";
var id_cate = id_c;

ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"acoes_ajax.asp?mode=montapagamentos&id="+id_cate+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 	xmlhttp.onreadystatechange=function() {
 	if(xmlhttp.readyState == 4) {
		document.getElementById("pagamentos").innerHTML=xmlhttp.responseText;
	}
 
 }
 xmlhttp.send(null);	
 return false;
}



function ApagaLista(idd_i){
document.getElementById("inscricao_resposta").innerHTML="<h3><img src='imgs/carregando.gif'> Aguarde . . .</h3>";
ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"acoes_ajax.asp?mode=excluir_lista&id="+idd_i+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 xmlhttp.onreadystatechange=function() {

 	if(xmlhttp.readyState == 4) {
	texto = "<h2>Listagem para inscrição</h2>";
		var tx = xmlhttp.responseText;
			str_1 = new String(tx);
			str_2 = str_1.split("*");
			str_3 = str_2[0]; // -> IMAGENS E NOMES DOS ATLETAS
			str_4 = str_2[1]; // -> TOTAL DE ATLETAS NA LISTA
			str_5 = str_2[2]; // -> TOTAL DE HOMENS NA LISTA
			str_6 = str_2[3]; // -> TOTAL DE MULHERES NA LISTA
			str_7 = str_2[4]; // -> IDs DOS ATLETAS
		
		texto = texto + str_3;
		ins = new Number(str_4);
		per = new Number(document.getElementById("formulario_inscricao").MAXI_INS.value);
		dife = new Number(per) - new Number(ins); // -> DIFERENÇA TOTAL
				
		ins_m = new Number(str_5);
		per_m = new Number(document.getElementById("formulario_inscricao").MIST_HOM.value);
		dif_m = new Number(per_m) - new Number(ins_m); // -> DIFERENÇA MASCULINO
		
		ins_f = new Number(str_6);
		per_f = new Number(document.getElementById("formulario_inscricao").MIST_MUL.value);
		dif_f = new Number(per_f) - new Number(ins_f); // -> DIFERENÇA MASCULINO
		
		var atletas = str_7;
		
		document.getElementById("formulario_inscricao").ATLETAS_LIS.value=atletas;		
		document.getElementById("formulario_inscricao").TOTAL_LISTA.value=ins;
		document.getElementById("formulario_inscricao").TOTAL_HOMEM.value=ins_m;
		document.getElementById("formulario_inscricao").TOTAL_MULHE.value=ins_f;
		
		document.getElementById("inscricao_resposta").innerHTML="<p>Instruções</p>";
		
	  document.getElementById("inscricao_atletas_ck").innerHTML=texto;
	  
	  if (dife == 0){
			document.getElementById("termo").innerHTML=trm;
	  }
	  else{
			document.getElementById("termo").innerHTML="";
	  }
	

	}
 
 }
 xmlhttp.send(null);	
 return false;
}



function AjaxVerifica(pelo_cadastro){
if(pelo_cadastro==undefined){
pelo_cadastro = " ";	
}
else{
pelo_cadastro = "O Atleta: " + pelo_cadastro + " foi cadastrado(a) com sucesso, porém";
}

var cpf = document.getElementById("formulario_inscricao").id_docc.value;
var cat = document.getElementById("formulario_inscricao").ID_CATEG.value;
var idt = document.getElementById("formulario_inscricao").ID_TEMP_INSCRI.value;



	if (TextoBranco(cat)){
		alert("Selecione uma \"CATEGORIA\" antes de checar.");
		return false;
	}
	else if(TextoBranco(cpf)){
		alert("Informe um \"CPF\" válido.");
		document.getElementById("formulario_inscricao").id_docc.focus();
		return false;
	}
//------------------------------	VALIDAÇÃO MATEMÁTICA DO CPF ----------------------------------
		valor = true;
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		document.getElementById("formulario_inscricao").id_docc.focus();
		var nonNumbers = /\D/;
		
		if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";	
		if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			  erro += "Numero de CPF invalido!"
		}
		var a = [];
		var b = new Number;
		var c = 11;
		for (i=0; i<11; i++){
			a[i] = cpf.charAt(i);
			if (i < 9) b += (a[i] *  --c);
		}
		if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] *  c--); 
		if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
		if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro += "CPF inválido!";
		}
		if (erro.length > 0){
			alert(erro);
			document.getElementById("formulario_inscricao").id_docc.focus();
			return false;
		}
//-----------------------------	FINAL DA VALIDAÇÃO MATEMÁTICA DO CPF -----------------------

document.getElementById("inscricao_resposta").innerHTML="<h3><img src='imgs/carregando.gif'> Aguarde . . .</h3>";

o_sexo = document.getElementById("formulario_inscricao").SEXO_INS.value;

tt_ja_list = document.getElementById("formulario_inscricao").TOTAL_LISTA.value;
tt_list_ma = document.getElementById("formulario_inscricao").TOTAL_HOMEM.value;
tt_list_fe = document.getElementById("formulario_inscricao").TOTAL_MULHE.value;

per_total = document.getElementById("formulario_inscricao").MAXI_INS.value;	
per_mascu = document.getElementById("formulario_inscricao").MIST_HOM.value;
per_femin = document.getElementById("formulario_inscricao").MIST_MUL.value;


document.getElementById("formulario_inscricao").id_docc.value=""
document.getElementById("bt_checar").style.visibility="hidden";

ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"acoes_ajax.asp?mode=verificar_atleta&cpf="+cpf+"&cat="+cat+"&idt="+idt+"&o_sexo="+o_sexo+"&tt_perm="+per_total+"&tt_list="+tt_ja_list+"&tt_per_m="+per_mascu+"&tt_lis_m="+tt_list_ma+"&tt_per_f="+per_femin+"&tt_lis_f="+tt_list_fe+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 xmlhttp.onreadystatechange=function() {
 if(xmlhttp.readyState == 1){document.getElementById("bt_checar").style.visibility="hidden";}
 if(xmlhttp.readyState == 2){document.getElementById("bt_checar").style.visibility="hidden";}
 if(xmlhttp.readyState == 3){document.getElementById("bt_checar").style.visibility="hidden";}
 if(xmlhttp.readyState == 4) {
	
	var tx_do_erro = xmlhttp.responseText;
	str_e = new String(tx_do_erro);
	str_e1 = str_e.split("*");
	str_e2 = str_e1[1]; // -> ID DO ERRO  
	str_e3 = str_e1[0]; // -> IDADE DO ATLETA
	str_e4 = str_e1[2]; // -> IDADE MINIMA PERMITIDA
	str_e5 = str_e1[3]; // -> IDADE MÁXIMA PERMITIDA
	
	
var formu_atle = ""
formu_atle = formu_atle + "<h2>Formulario de Inclus&atilde;o de Atleta</h2>";
formu_atle = formu_atle + "<form id='incluir' name='incluir' onSubmit='return validaCPF()'>";
formu_atle = formu_atle + "<label id='lab_nome_n' for='id_nome'>Nome do Atleta:<input type='text' id='id_nome' name='id_nome' value='' maxlength='255'/></label>";
formu_atle = formu_atle + "<fieldset class='sexo_n'>";
formu_atle = formu_atle + "<legend>Sexo:</legend>";
formu_atle = formu_atle + "<label id='lab_masc' for='id_sexo1'>Masculino<input type='radio' id='id_sexo1' name='SEX_ATLE' value='M'/></label>";
formu_atle = formu_atle + "<label id='lab_femi' for='id_sexo2'>Feminino<input type='radio' id='id_sexo2' name='SEX_ATLE' value='F'/></label>";
formu_atle = formu_atle + "</fieldset>";
formu_atle = formu_atle + "<label id='lab_nasc_n' for='id_nasc'>Data do Nascimento:<input type='text' id='id_nasc' name='id_nasc' value='' onfocus='criaMascara(this,&quot;##/##/####&quot;);' size='19' onkeypress='criaMascara(this,&quot;##/##/####&quot;);' onkeyup='criaMascara(this,&quot;##/##/####&quot;);' onblur='criaMascara(this,&quot;##/##/####&quot;);'	/></label>";
formu_atle = formu_atle + "<label id='lab_docc_n' for='id_docc_n'>CPF:<input type='text' id='id_docc_n' name='id_docc_n' value='"+str_e2+"' /></label>";

formu_atle = formu_atle + "<label id='lab_dddf' for='id_dddf'>DDD:<input type='text' id='id_dddf' name='id_dddf' value='' maxlength='3' onfocus='criaMascara(this,&quot;###&quot;);' onkeypress='criaMascara(this,&quot;###&quot;);' 	onkeyup='criaMascara(this,&quot;###&quot;);' onblur='criaMascara(this,&quot;###&quot;);'  /></label>";
formu_atle = formu_atle + "<label id='lab_fone' for='id_fone'>Fone:<input type='text' id='id_fone' name='id_fone' value='' maxlength='9' onfocus='criaMascara(this,&quot;########&quot;);' onkeypress='criaMascara(this,&quot;########&quot;);' 	onkeyup='criaMascara(this,&quot;########&quot;);' onblur='criaMascara(this,&quot;########&quot;);' 	/></label>";
formu_atle = formu_atle + "<label id='lab_ema1' for='id_ema1'>E-mail 1:<input type='text' id='id_ema1' name='id_ema1' value='' maxlength='255'/></label>";
formu_atle = formu_atle + "<label id='lab_ema2' for='id_ema2'>E-mail 2:<input type='text' id='id_ema2' name='id_ema2' value='' maxlength='255'/></label>";
formu_atle = formu_atle + "<input type='hidden' name='O_CPF_A_CADASTRAR' value='"+str_e2+"' />";
formu_atle = formu_atle + "<div id='botao'>";
formu_atle = formu_atle + "<input type='submit' id='id_cadastrar' name='submit' class='botao' value='Gravar dados'/>";
formu_atle = formu_atle + "	</div>";
formu_atle = formu_atle + "</form>";
	
	
	
	if(str_e3=="x"){
	  document.getElementById("inscricao_resposta").innerHTML="<p>Usuário não registrado em nosso sistema!</p>";
	  document.getElementById("inscricao_atletas_ck").innerHTML=formu_atle;
	  document.getElementById("bt_checar").style.visibility="visible"
	}
	else if(str_e2=="idade_erro"){
		
		var dt = new Date();
        var str = dt.getUTCFullYear();
		var pre_cadastro = pelo_cadastro;
		document.getElementById("inscricao_resposta").innerHTML="<p>"+pre_cadastro+"</p><p>A idade do atleta indicado (em 31/12/"+str+") será "+str_e3+" anos.</p><p>Portanto incompatível com a faixa etária permitida na categoria (Entre "+str_e4+" e "+str_e5+" anos).</p>";
		ListarLista();
		
		
	}
	else if(xmlhttp.responseText=="y"){
	  
	  if(o_sexo=="M"){var s_p = "Masculino";var ssex = "Feminino";}
	  if(o_sexo=="F"){var s_p = "Feminino";var ssex = "Masculino";}
	  
	  	var pre_cadastro = pelo_cadastro;
		document.getElementById("inscricao_resposta").innerHTML="<p>"+pre_cadastro+"</p><p>O atleta em quest&atilde;o é do sexo: "+ssex+".</p><p>Para a categoria selecionada, é permitido apenas atletas do sexo "+s_p+"!</p>";
		ListarLista();
	}
	else if(xmlhttp.responseText=="tt_atingido"){
	  	var pre_cadastro = pelo_cadastro;
		document.getElementById("inscricao_resposta").innerHTML="<p>"+pre_cadastro+"</p><p>O limite máximo de atletas para a categoria selecionada foi atingido.</p>";
		ListarLista();
	}
	
	//else if(per_mascu!="99"){
	
			else if(xmlhttp.responseText=="tm_atingido"){
				var pre_cadastro = pelo_cadastro;
				document.getElementById("inscricao_resposta").innerHTML="<p>"+pre_cadastro+"</p>O limite máximo de atletas do sexo MASCULINO, para a categoria selecionada foi atingido.</p>";
				ListarLista("000");
			}
			else if(xmlhttp.responseText=="tf_atingido"){
				var pre_cadastro = pelo_cadastro;
				document.getElementById("inscricao_resposta").innerHTML="<p>"+pre_cadastro+"</p>O limite máximo de atletas do sexo FEMININO, para a categoria selecionada foi atingido.</p>";
				ListarLista();
			}
	//}
	
	
	else
	{
		texto = "<h2>Listagem para inscrição</h2>";
		var tx = xmlhttp.responseText;
			str_1 = new String(tx);
			str_2 = str_1.split("*");
			str_3 = str_2[0]; // -> IMAGENS E NOMES DOS ATLETAS
			str_4 = str_2[1]; // -> TOTAL DE ATLETAS NA LISTA
			str_5 = str_2[2]; // -> TOTAL DE HOMENS NA LISTA
			str_6 = str_2[3]; // -> TOTAL DE MULHERES NA LISTA
			str_7 = str_2[4]; // -> IDs DOS ATLETAS
		
		texto = texto + str_3;
		ins = new Number(str_4);
		per = new Number(document.getElementById("formulario_inscricao").MAXI_INS.value);
		dife = new Number(per) - new Number(ins); // -> DIFERENÇA TOTAL
				
		ins_m = new Number(str_5);
		per_m = new Number(document.getElementById("formulario_inscricao").MIST_HOM.value);
		dif_m = new Number(per_m) - new Number(ins_m); // -> DIFERENÇA MASCULINO
		
		ins_f = new Number(str_6);
		per_f = new Number(document.getElementById("formulario_inscricao").MIST_MUL.value);
		dif_f = new Number(per_f) - new Number(ins_f); // -> DIFERENÇA MASCULINO
		
		var atletas = str_7;
		
		document.getElementById("formulario_inscricao").ATLETAS_LIS.value=atletas;
		document.getElementById("formulario_inscricao").TOTAL_LISTA.value=ins;
		document.getElementById("formulario_inscricao").TOTAL_HOMEM.value=ins_m;
		document.getElementById("formulario_inscricao").TOTAL_MULHE.value=ins_f;

						
	  document.getElementById("inscricao_atletas_ck").innerHTML=texto;
		
		if (dife == 0){
			document.getElementById("termo").innerHTML=trm;
		}
		else{
			document.getElementById("termo").innerHTML="";
			
		}
	  document.getElementById("bt_checar").style.visibility="visible"
	  
	  if(o_sexo=="U"){
		  if(per_m!="99"){
			  document.getElementById("inscricao_resposta").innerHTML="<p>Inclusão efetuada com sucesso!</p><p>Faltam: "+dife+" atleta(s). "+dif_m+" homens e "+dif_f+" mulheres.";
		  }
		  else{
			  document.getElementById("inscricao_resposta").innerHTML="<p>Inclusão efetuada com sucesso!</p><p>Faltam: "+dife+" atleta(s).";
		  }
	  }
	  else if(o_sexo=="M"){
	  	  document.getElementById("inscricao_resposta").innerHTML="<p>Inclusão efetuada com sucesso!</p><p>Faltam: "+dife+" atleta(s) homens.";
	  }
	  else if(o_sexo=="F"){
	  	  document.getElementById("inscricao_resposta").innerHTML="<p>Inclusão efetuada com sucesso!</p><p>Faltam: "+dife+" atleta(s) mulheres.";
	  }
	}
	
 }
 
 }
 xmlhttp.send(null);

 return false;
	
}





function MostraBotao(){
var escolha = document.formulario_inscricao["id_termo1"];
	if (escolha[0].checked){
		//alert("escolheu: "+escolha[0].value+"");
		document.getElementById("termo").innerHTML=trm1+botao;

	}
	else if (escolha[1].checked){
		//alert("escolheu: "+escolha[1].value+"");
		document.getElementById("termo").innerHTML=trm2;

	}

return false;
	
}



function ExcluiDaLista(id_lista){
document.getElementById("bt_checar").style.visibility="visible";	
var idt = document.getElementById("formulario_inscricao").ID_TEMP_INSCRI.value;
	
document.getElementById("inscricao_resposta").innerHTML="<h3><img src='imgs/carregando.gif'> Aguarde . . .</h3>";
ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"acoes_ajax.asp?mode=excluir_atleta&id="+id_lista+"&idt="+idt+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 xmlhttp.onreadystatechange=function() {

 	if(xmlhttp.readyState == 4) {
	texto = "<h2>Listagem para inscrição</h2>";
		var tx = xmlhttp.responseText;
			str_1 = new String(tx);
			str_2 = str_1.split("*");
			str_3 = str_2[0]; // -> IMAGENS E NOMES DOS ATLETAS
			str_4 = str_2[1]; // -> TOTAL DE ATLETAS NA LISTA
			str_5 = str_2[2]; // -> TOTAL DE HOMENS NA LISTA
			str_6 = str_2[3]; // -> TOTAL DE MULHERES NA LISTA
			str_7 = str_2[4]; // -> IDs DOS ATLETAS
		
		texto = texto + str_3;
		ins = new Number(str_4);
		per = new Number(document.getElementById("formulario_inscricao").MAXI_INS.value);
		dife = new Number(per) - new Number(ins); // -> DIFERENÇA TOTAL
				
		ins_m = new Number(str_5);
		per_m = new Number(document.getElementById("formulario_inscricao").MIST_HOM.value);
		dif_m = new Number(per_m) - new Number(ins_m); // -> DIFERENÇA MASCULINO
		
		ins_f = new Number(str_6);
		per_f = new Number(document.getElementById("formulario_inscricao").MIST_MUL.value);
		dif_f = new Number(per_f) - new Number(ins_f); // -> DIFERENÇA MASCULINO
		
		
		
		var atletas = str_7;
		
		document.getElementById("formulario_inscricao").ATLETAS_LIS.value=atletas;
		document.getElementById("formulario_inscricao").TOTAL_LISTA.value=ins;
		document.getElementById("formulario_inscricao").TOTAL_HOMEM.value=ins_m;
		document.getElementById("formulario_inscricao").TOTAL_MULHE.value=ins_f;

		
	  document.getElementById("inscricao_atletas_ck").innerHTML=texto;
	  
	  if (dife == 0){
			document.getElementById("termo").innerHTML=trm;
	  }
	  else{
			document.getElementById("termo").innerHTML="";
	  }
	
	
	  if(o_sexo=="U"){
		  if(per_m!="99"){
			  document.getElementById("inscricao_resposta").innerHTML="<p>Atleta excluído com êxito da posição da listagem.</p><p>Faltam: "+dife+" atleta(s). "+dif_m+" homens e "+dif_f+" mulheres.";		  }
		  else{
			  document.getElementById("inscricao_resposta").innerHTML="<p>Atleta excluído com êxito da posição da listagem.</p><p>Faltam: "+dife+" atleta(s).";
		  }
	  	  
	  }
	  if(o_sexo=="M"){
	  	  document.getElementById("inscricao_resposta").innerHTML="<p>Atleta excluído com êxito da posição da listagem.</p><p>Faltam: "+dife+" atleta(s) homens.";
	  }
	  if(o_sexo=="F"){
	  	  document.getElementById("inscricao_resposta").innerHTML="<p>Atleta excluído com êxito da posição da listagem.</p><p>Faltam: "+dife+" atleta(s) mulheres.";
	  }

	}
 
 }
 xmlhttp.send(null);
 return false;
	
	
}


function ListarLista(){
document.getElementById("bt_checar").style.visibility="visible";	
var idt = document.getElementById("formulario_inscricao").ID_TEMP_INSCRI.value;

ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"acoes_ajax.asp?mode=listar&idt="+idt+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 xmlhttp.onreadystatechange=function() {

 	if(xmlhttp.readyState == 4) {
	texto = "<h2>Listagem para inscrição</h2>";
		var tx = xmlhttp.responseText;
			str_1 = new String(tx);
			str_2 = str_1.split("*");
			str_3 = str_2[0]; // -> IMAGENS E NOMES DOS ATLETAS
			str_4 = str_2[1]; // -> TOTAL DE ATLETAS NA LISTA
			str_5 = str_2[2]; // -> TOTAL DE HOMENS NA LISTA
			str_6 = str_2[3]; // -> TOTAL DE MULHERES NA LISTA
			str_7 = str_2[4]; // -> IDs DOS ATLETAS
		
		texto = texto + str_3;
		ins = new Number(str_4);
		per = new Number(document.getElementById("formulario_inscricao").MAXI_INS.value);
		dife = new Number(per) - new Number(ins); // -> DIFERENÇA TOTAL
				
		ins_m = new Number(str_5);
		per_m = new Number(document.getElementById("formulario_inscricao").MIST_HOM.value);
		dif_m = new Number(per_m) - new Number(ins_m); // -> DIFERENÇA MASCULINO
		
		ins_f = new Number(str_6);
		per_f = new Number(document.getElementById("formulario_inscricao").MIST_MUL.value);
		dif_f = new Number(per_f) - new Number(ins_f); // -> DIFERENÇA MASCULINO
		
		
		
		var atletas = str_7;
		
		document.getElementById("formulario_inscricao").ATLETAS_LIS.value=atletas;
		document.getElementById("formulario_inscricao").TOTAL_LISTA.value=ins;
		document.getElementById("formulario_inscricao").TOTAL_HOMEM.value=ins_m;
		document.getElementById("formulario_inscricao").TOTAL_MULHE.value=ins_f;

		
	  document.getElementById("inscricao_atletas_ck").innerHTML=texto;
	  
	  if (dife == 0){
			document.getElementById("termo").innerHTML=trm;
	  }
	  else{
			document.getElementById("termo").innerHTML="";
	  }


	}
 
 }
 xmlhttp.send(null);
 return false;
	
	
}




function getHTTPObject() {
var xmlhttp;
// Mozilla, Firefox, Safari, e Netscape
if (window.XMLHttpRequest) {
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
xmlhttp = false;
}
return xmlhttp;
}

// Internet Explorer
if (window.ActiveXObject) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
} catch(e) {
xmlhttp = false;

}
}
}
}

return xmlhttp;
}
alert("Objeto XMLHTTP nao e suportado pelo navegador.");
}




function getMetodo() {
var metoto;
// Mozilla, Firefox, Safari, e Netscape
if (window.XMLHttpRequest) {
try {
metodo = "GET";
} catch(e) {
xmlhttp = false;
}
return metodo;
}

// Internet Explorer
if (window.ActiveXObject) {
try {
metodo = "POST"; 
} catch(e) {
try {
metodo = "POST"; 
} catch(e) {
try {
metodo = "POST";
} catch(e) {
try {
metodo = "POST"; 
} catch(e) {
metodo = false;

}
}
}
}

return metodo;
}
alert("Objeto XMLHTTP nao e suportado pelo navegador.");
}


// TERMINA AJAX /////////////////////////////////////////////////



// cria mascara 
function criaMascara(_RefObjeto, _Modelo){

var valorAtual = _RefObjeto.value;
var valorNumerico = '';
var nIndexModelo = 0;
var nIndexString = 0;
var valorFinal = '';
var adicionarValor = true;
 

// limpa a string valor atual para verificar
// se todos os caracteres são números
for (i=0;i<_Modelo.length;i++){
  if (_Modelo.substr(i,1) != '#'){
    valorAtual = valorAtual.replace(_Modelo.substr(i,1),'');
}}
 
// verifica se todos os caracteres são números
for (i=0;i<valorAtual.length;i++){
  if (!isNaN(parseFloat(valorAtual.substr(i,1)))){
    valorNumerico = valorNumerico + valorAtual.substr(i,1);
}}
 
// aplica a máscara ao campo informado usando
// o modelo de máscara informado no script
for (i=0;i<_Modelo.length;i++){
 
  if (_Modelo.substr(i,1) == '#'){
    if (valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + valorNumerico.substr(nIndexModelo,1);
      nIndexModelo++;nIndexString++;
    }
      else {
        adicionarValor = false;
  }}
 
    else {
      if (adicionarValor && valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + _Modelo.substr(nIndexString,1)
      nIndexString++;
    }}
}
 
_RefObjeto.value = valorFinal
 
}

function TextoBranco(Campo)
{ 
	if (Campo.length == 0)
		return true;
			
	for (i = 0; i < Campo.length; i++)
	{
	   if (Campo.charCodeAt(i) != 32 && Campo.charCodeAt(i) != 13 && Campo.charCodeAt(i) != 10)
	       return false;
	}
	return true;
}


function validar_logar_usuario()
{
	if (TextoBranco(document.form_logar.id_login.value))
	{
		alert("Por favor, informe seu \"LOGIN\".");
		document.form_logar.id_login.focus();
		return false;
	}
	else if (TextoBranco(document.form_logar.id_senha.value))
	{
		alert("Por favor, informe sua \"SENHA\".");
		document.form_logar.id_senha.focus();
		return false;
	}

}




function cep(){

	if (TextoBranco(document.form_cadastro_usuario.id_ceep.value))
	{
		alert("Por favor, preencha o campo \"CEP\" antes de fazer a busca.");
		document.form_cadastro_usuario.id_ceep.focus();
		return false;
	}
	else
	{
     		window.open("localiza_endereco.asp?id=" + document.form_cadastro_usuario.id_ceep.value + "","Cadastro","top= 10,left= 10,width= 700,height= 400,scrollbar=No,status=yes,resize=No");
     		return false;
	}
}








function validar_lembrar_senha()
{
	if (TextoBranco(document.form_lembrar_senha.id_mail.value))
	{
		alert("Por favor, informe seu \"E-MAIL\".");
		document.form_lembrar_senha.id_mail.focus();
		return false;
	}
	else if (document.form_lembrar_senha.id_mail.value.indexOf('@', 0) == -1 ||document.form_lembrar_senha.id_mail.value.indexOf('.', 0) == -1){ 
    	alert("Desculpe mas este E-Mail não tem um formato válido, verifique novamente!");
	document.form_lembrar_senha.id_mail.focus();
	return false
	}

}


function lembrete(){


		document.forms['form_logar'].style.visibility = 'hidden';
		document.forms['form_logar'].style.margin =  '-150px';

		document.forms['form_lembrar_senha'].style.visibility = 'visible';
		document.forms['form_lembrar_senha'].style.margin =  '5px 5px 5px 0;';

		return false;

}

function volta_login () {

		document.forms['form_logar'].style.visibility = 'visible';
		document.forms['form_logar'].style.margin =  '5px 5px 5px 0;';

		document.forms['form_lembrar_senha'].style.visibility = 'hidden';
		document.forms['form_lembrar_senha'].style.margin =  '-150px';
		document.form_lembrar_senha.id_mail.value = '';
		return false;

}





var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
var reDate = reDate4;


function validar_form_cadastro_usuario() {

pFmt = "5";
pStr = document.form_cadastro_usuario.id_nasc.value;

eval("reDate = reDate" + pFmt);
if (reDate.test(pStr)) {

} else if (pStr != null && pStr != "") {
alert(pStr + " não é uma data válida.");
document.form_cadastro_usuario.id_nasc.focus();
return false;
}


cpf = document.form_cadastro_usuario.id_docc.value;
		valor = true;
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		document.form_cadastro_usuario.id_docc.focus();
		var nonNumbers = /\D/;
		
		if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";	
		if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			  erro += "Numero de CPF invalido!"
		}
		var a = [];
		var b = new Number;
		var c = 11;
		for (i=0; i<11; i++){
			a[i] = cpf.charAt(i);
			if (i < 9) b += (a[i] *  --c);
		}
		if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] *  c--); 
		if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
		if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro +="CPF inválido!";
		}
		

		
		if (erro.length > 0){
			alert(erro);
			document.form_cadastro_usuario.id_docc.focus();
			return false;
		}





if (!document.form_cadastro_usuario.id_tipo[0].checked &&
    !document.form_cadastro_usuario.id_tipo[1].checked)
     {
     alert("O Tipo de inscrição deve ser informado!");
     document.form_cadastro_usuario.id_tipo[0].focus();
     return false; }

else if (TextoBranco(document.form_cadastro_usuario.id_nome.value))
	{
		alert("Por favor, preencha o campo \"NOME\".");
		document.form_cadastro_usuario.id_nome.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_nasc.value))
	{
		alert("Por favor, preencha o campo \"DATA DE NASCIMENTO\".");
		document.form_cadastro_usuario.id_nasc.focus();
		return false;
	}



else if (!document.form_cadastro_usuario.id_sexo[0].checked &&
    !document.form_cadastro_usuario.id_sexo[1].checked)
     {
     alert("O Sexo do usuário deve ser informado!");
     document.form_cadastro_usuario.id_sexo[0].focus();
     return false; }


else if (TextoBranco(document.form_cadastro_usuario.id_ceep.value))
	{
		alert("Por favor, preencha o campo \"CEP\".");
		document.form_cadastro_usuario.id_ceep.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_ende.value))
	{
		alert("Por favor, preencha o campo \"ENDEREÇO\".");
		document.form_cadastro_usuario.id_ende.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_nume.value))
	{
		alert("Por favor, preencha o campo \"NÚMERO\".");
		document.form_cadastro_usuario.id_nume.focus();
		return false;
	}
//else if (TextoBranco(document.form_cadastro_usuario.id_comp.value))
//	{
//		alert("Por favor, preencha o campo \"COMPLEMENTO\".");
//		document.form_cadastro_usuario.id_comp.focus();
//		return false;
//	}
else if (TextoBranco(document.form_cadastro_usuario.id_bair.value))
	{
		alert("Por favor, preencha o campo \"BAIRRO\".");
		document.form_cadastro_usuario.id_bair.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_cida.value))
	{
		alert("Por favor, preencha o campo \"CIDADE\".");
		document.form_cadastro_usuario.id_cida.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_esta.value))
	{
		alert("Por favor, preencha o campo \"ESTADO\".");
		document.form_cadastro_usuario.id_esta.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_dddf.value))
	{
		alert("Por favor, preencha o campo \"DDD FONE\".");
		document.form_cadastro_usuario.id_dddf.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_fone.value))
	{
		alert("Por favor, preencha o campo \"FONE\".");
		document.form_cadastro_usuario.id_fone.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_dddc.value))
	{
		alert("Por favor, preencha o campo \"DDD CELULAR\".");
		document.form_cadastro_usuario.id_dddc.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_celu.value))
	{
		alert("Por favor, preencha o campo \"CELULAR\".");
		document.form_cadastro_usuario.id_celu.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_ema1.value))
	{
		alert("Por favor, preencha o campo \"E-MAIL\".");
		document.form_cadastro_usuario.id_ema1.focus();
		return false;
	}

else if (document.form_cadastro_usuario.id_ema1.value.indexOf('@', 0) == -1 ||document.form_cadastro_usuario.id_ema1.value.indexOf('.', 0) == -1){ 
    	alert("Desculpe mas este E-Mail não tem um formato válido, verifique novamente!");
	document.form_cadastro_usuario.id_ema1.focus();
	return false
	}

else if (TextoBranco(document.form_cadastro_usuario.id_logi.value))
	{
		alert("Por favor, preencha o campo \"LOGIN\".");
		document.form_cadastro_usuario.id_logi.focus();
		return false;
	}
else if (TextoBranco(document.form_cadastro_usuario.id_senh.value))
	{
		alert("Por favor, preencha o campo \"SENHA\".");
		document.form_cadastro_usuario.id_senh.focus();
		return false;
	}


}





function criaMascara(_RefObjeto, _Modelo){

var valorAtual = _RefObjeto.value;
var valorNumerico = '';
var nIndexModelo = 0;
var nIndexString = 0;
var valorFinal = '';
var adicionarValor = true;
 

// limpa a string valor atual para verificar
// se todos os caracteres são números
for (i=0;i<_Modelo.length;i++){
  if (_Modelo.substr(i,1) != '#'){
    valorAtual = valorAtual.replace(_Modelo.substr(i,1),'');
}}
 
// verifica se todos os caracteres são números
for (i=0;i<valorAtual.length;i++){
  if (!isNaN(parseFloat(valorAtual.substr(i,1)))){
    valorNumerico = valorNumerico + valorAtual.substr(i,1);
}}
 
// aplica a máscara ao campo informado usando
// o modelo de máscara informado no script
for (i=0;i<_Modelo.length;i++){
 
  if (_Modelo.substr(i,1) == '#'){
    if (valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + valorNumerico.substr(nIndexModelo,1);
      nIndexModelo++;nIndexString++;
    }
      else {
        adicionarValor = false;
  }}
 
    else {
      if (adicionarValor && valorNumerico.substr(nIndexModelo,1) != ''){
      valorFinal = valorFinal + _Modelo.substr(nIndexString,1)
      nIndexString++;
    }}
}
 
_RefObjeto.value = valorFinal
 
}

function SohNumeros(valor)
    {
     chars= "0123456789,.";
     e = String.fromCharCode(window.event.keyCode);
     if (e == "")
     {
     if (valor.indexOf(e)==-1)
     {
     return;
     }
     window.event.keyCode=0;
     }
     if(chars.indexOf(e)==-1)
     {
     window.event.keyCode=0;
     }
    }



function validaCPF() {

pFmt = "5";
pStr = document.incluir.id_nasc.value;

eval("reDate = reDate" + pFmt);
if (reDate.test(pStr)) {

} else if (pStr != null && pStr != "") {
alert(pStr + " não é uma data válida.");
document.incluir.id_nasc.focus();
return false;
}


		cpf = document.incluir.id_docc_n.value;
		valor = true;
		erro = new String;
		if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
		document.incluir.id_docc_n.focus();
		var nonNumbers = /\D/;
		
		if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";	
		if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			  erro += "Numero de CPF invalido!"
		}
		var a = [];
		var b = new Number;
		var c = 11;
		for (i=0; i<11; i++){
			a[i] = cpf.charAt(i);
			if (i < 9) b += (a[i] *  --c);
		}
		if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
		b = 0;
		c = 11;
		for (y=0; y<10; y++) b += (a[y] *  c--); 
		if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
		if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
			erro = erro + "CPF inválido!";
		}
		
		if (erro.length > 0){
			alert(erro);
			document.incluir.id_docc_n.focus();
			return false;
		}


if (TextoBranco(document.incluir.id_nome.value))
	{
		alert("Por favor, preencha o campo \"NOME\".");
		document.incluir.id_nome.focus();
		return false;
	}
else if (TextoBranco(document.incluir.id_nasc.value))
	{
		alert("Por favor, preencha o campo \"DATA DE NASCIMENTO\".");
		document.incluir.id_nasc.focus();
		return false;
	}
else if (!document.incluir.SEX_ATLE[0].checked &&
    !document.incluir.SEX_ATLE[1].checked)
     {
     alert("O Sexo do usuário deve ser informado!");
     document.incluir.SEX_ATLE[0].focus();
     return false; }
else if (TextoBranco(document.incluir.id_dddf.value))
	{
		alert("Por favor, preencha o campo \"DDD FONE\".");
		document.incluir.id_dddf.focus();
		return false;
	}
else if (TextoBranco(document.incluir.id_fone.value))
	{
		alert("Por favor, preencha o campo \"FONE\".");
		document.incluir.id_fone.focus();
		return false;
	}
else if (TextoBranco(document.incluir.id_ema1.value))
	{
		alert("Por favor, preencha o campo \"E-MAIL 1\".");
		document.incluir.id_ema1.focus();
		return false;
	}

else if (document.incluir.id_ema1.value.indexOf('@', 0) == -1 ||document.incluir.id_ema1.value.indexOf('.', 0) == -1){ 
    	alert("Desculpe mas este endereço de \"E-Mail\" não tem um formato válido, verifique novamente!");
	document.incluir.id_ema1.focus();
	return false
	}
	
	
// AJAX PARA GRAVAR USUÁRIO	
// VARIÁVEIS GET

myOption = -1;
for (i=document.incluir.SEX_ATLE.length-1; i > -1; i--) {
	if (document.incluir.SEX_ATLE[i].checked) {
	myOption = i;
	}
}
if (myOption == -1) {
return false;
}

 



var n_at = document.incluir.id_nome.value;
var sexa = document.incluir.SEX_ATLE[myOption].value;
var nasc = document.incluir.id_nasc.value;
var cpfa = document.incluir.O_CPF_A_CADASTRAR.value;
var dddf = document.incluir.id_dddf.value;
var nufo = document.incluir.id_fone.value;
var ema1 = document.incluir.id_ema1.value;
var ema2 = document.incluir.id_ema2.value;

var NOME_ATLETA = n_at;
NOME_ATLETA = NOME_ATLETA.replace("ç","c");
NOME_ATLETA = NOME_ATLETA.replace("Ç","C");
NOME_ATLETA = NOME_ATLETA.replace("ê","e");
NOME_ATLETA = NOME_ATLETA.replace("Ê","E");
NOME_ATLETA = NOME_ATLETA.replace("ê","e");
NOME_ATLETA = NOME_ATLETA.replace("ê","e");
NOME_ATLETA = NOME_ATLETA.replace("é","e");
NOME_ATLETA = NOME_ATLETA.replace("É","E");
NOME_ATLETA = NOME_ATLETA.replace("á","a");
NOME_ATLETA = NOME_ATLETA.replace("Á","A");
NOME_ATLETA = NOME_ATLETA.replace("à","a");
NOME_ATLETA = NOME_ATLETA.replace("À","A");
NOME_ATLETA = NOME_ATLETA.replace("â","a");
NOME_ATLETA = NOME_ATLETA.replace("Â","A");
NOME_ATLETA = NOME_ATLETA.replace("ã","a");
NOME_ATLETA = NOME_ATLETA.replace("Ã","A");
NOME_ATLETA = NOME_ATLETA.replace("ê","e;");
NOME_ATLETA = NOME_ATLETA.replace("ê","e");
NOME_ATLETA = NOME_ATLETA.replace("é","e");
NOME_ATLETA = NOME_ATLETA.replace("É","E");
NOME_ATLETA = NOME_ATLETA.replace("í","i");
NOME_ATLETA = NOME_ATLETA.replace("Í","I");
NOME_ATLETA = NOME_ATLETA.replace("õ","o");
NOME_ATLETA = NOME_ATLETA.replace("Õ","O");
NOME_ATLETA = NOME_ATLETA.replace("ó","o");
NOME_ATLETA = NOME_ATLETA.replace("Ó","O");
NOME_ATLETA = NOME_ATLETA.replace("ô","o");
NOME_ATLETA = NOME_ATLETA.replace("Ô","O");
NOME_ATLETA = NOME_ATLETA.replace("ú","u");
NOME_ATLETA = NOME_ATLETA.replace("Ú","U");
NOME_ATLETA = NOME_ATLETA.replace("ü","u");
NOME_ATLETA = NOME_ATLETA.replace("Ü","U");
						
if(ema2==""){
	var email_2 = ema1;
}
else{
	var email_2 = ema2;
}


document.getElementById("inscricao_resposta").innerHTML="<h3><img src='imgs/carregando.gif'> Aguarde . . .</h3>";
document.getElementById("inscricao_atletas_ck").innerHTML="<p><img src='imgs/carregando.gif'> Aguarde . . .</p>";
ometodo = getMetodo();
xmlhttp = getHTTPObject();
xmlhttp.open(ometodo,"../inclusao.asp?mode=atleta&n_at="+NOME_ATLETA+"&sexa="+sexa+"&nasc="+nasc+"&cpfa="+cpf+"&dddf="+dddf+"&nufo="+nufo+"&ema1="+ema1+"&ema2="+email_2+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
 xmlhttp.onreadystatechange=function() {

 	if(xmlhttp.readyState == 4) {
		
		
	texto = "<h2>Listagem para inscrição</h2>";
	document.getElementById("inscricao_resposta").innerHTML="<p>Atleta cadastrado com sucesso!</p>";
	document.getElementById("inscricao_atletas_ck").innerHTML="<p><img src='imgs/carregando.gif'> Aguarde . . . Indexando informações!</p>";
	document.getElementById("formulario_inscricao").id_docc.value=xmlhttp.responseText;
	//alert(xmlhttp.responseText);
	AjaxVerifica(""+NOME_ATLETA+"");
	}
 }
 xmlhttp.send(null);	
 return false;

}















  function GetExtension(Filename) {
    var I = Filename.lastIndexOf(".");
    return (I > -1) ? Filename.substring(I + 1, Filename.length).toLowerCase() : "";
  }

function ValidarMp3() {
var form = document.upload;

var Ext = "";

if ( form.blob.value == "")
     {
      alert("Selecione um arquivo de imagem: \"*.jpg, *.png ou *.bmp \".");
      form.blob.focus();
      return false;
     }
     
if (form.blob.value != "") {
     Ext = GetExtension(form.blob.value);
      if (Ext != "jpg" && Ext != "png" && Ext != "bmp")
          {
          alert("O arquivo selecionado não é um arquivo válido");
          form.reset();
          form.blob.focus();
          return false;
          }
      else{
      
      return true;}
      }
}

function DoShow(objDiv, visibility){
   document.getElementById(objDiv).style.visibility = visibility;
}




function getHTTPObject() {
var xmlhttp;
// Mozilla, Firefox, Safari, e Netscape
if (window.XMLHttpRequest) {
try {
xmlhttp = new XMLHttpRequest();
} catch(e) {
xmlhttp = false;
}
return xmlhttp;
}

// Internet Explorer
if (window.ActiveXObject) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
} catch(e) {
xmlhttp = false;

}
}
}
}

return xmlhttp;
}
alert("Objeto XMLHTTP nao e suportado pelo navegador.");
}




function getMetodo() {
var metoto;
// Mozilla, Firefox, Safari, e Netscape
if (window.XMLHttpRequest) {
try {
metodo = "GET";
} catch(e) {
xmlhttp = false;
}
return metodo;
}

// Internet Explorer
if (window.ActiveXObject) {
try {
metodo = "POST"; 
} catch(e) {
try {
metodo = "POST"; 
} catch(e) {
try {
metodo = "POST";
} catch(e) {
try {
metodo = "POST"; 
} catch(e) {
metodo = false;

}
}
}
}

return metodo;
}
alert("Objeto XMLHTTP nao e suportado pelo navegador.");
}



function ApagarTemporario(id){
	
	ometodo = getMetodo();
	xmlhttp = getHTTPObject();
	xmlhttp.open(ometodo,"acoes_ajax.asp?mode=apagatemporario&id_temp="+id+"",true);
	if(ometodo=="POST"){
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlhttp.setRequestHeader("Pragma", "no-cache");
	}	
	 xmlhttp.onreadystatechange=function() {
		 if(xmlhttp.readyState == 4) {
			
			 
		 }
	}
	 xmlhttp.send(null);
	 return false;	
}













