/****************************************************************
*	Criado em: 09/11/2007			Por: CARLOS MONTEIRO
****************************************************************/

/*# IMAGE CHANGER #*/
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//-->

/*# CONTA CARACTER #*/
function contaCaracter(caracter, limite, campo) 
{
	if (document.getElementById(campo).value.length > limite) 
	{
		document.getElementById(campo).value = document.getElementById(campo).value.substring(0, limite);
	} 
	else 
	{
		document.getElementById(caracter).value	= limite - document.getElementById(campo).value.length;
	}
}

/*# FORMATAR MOEDA*/
function formataMoeda(mnt) 
{
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
	
    return (mnt == Math.floor(mnt)) ? mnt + '.00' : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);
}

function imagemRandomica()
{
	var imagens = new Array ("banner_01", "banner_02", "banner_03", "banner_04", "banner_05");
	var indice	= Math.round(Math.random() * (imagens.length - 1));
	var imagem 	= imagens[indice];
	var topo = ''
	
	topo = 	'<a href="default.asp?actA=0"><img src="imagens/layout/logo_01.gif" class="im_logo" alt="Latin Sports"/></a>';
	topo +=	'<img src="imagens/layout/'+imagem+'.jpg" class="im_banner"/>';
	topo +=	'<a href="default.asp?actA=2&act=1"><img src="imagens/layout/bt_04.gif" class="im_cadastro" alt="Meu Cadastro"/></a>'
	topo +=	'<a href="default.asp?actA=3&act=1"><img src="imagens/layout/bt_05.gif" class="im_inscricao" alt="Minhas Inscrições"/></a>'

	document.getElementById("area_banner").innerHTML = topo;
}

/*# VALIDA E-MAIL [expressão regular] */
function verificaEmail(campo) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo)) 
	{
		return	'';
	}
	return 'O E-MAIL digitado é inválido.\n';
}

/*# aceita só números digitados num campo */
function soNumero(evtKeyPress) 
{
	var nTecla;
	
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if ((nTecla > 47 && nTecla < 58) || nTecla == 8 || nTecla == 9)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/*# aceita só números digitados num campo */
function soNumeroHifen(evtKeyPress) 
{
	var nTecla;
	
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if ((nTecla > 47 && nTecla < 58) || nTecla == 8 || nTecla == 9 || nTecla == 45)
	{
		return true;
	}
	else
	{
		return false;
	}
}


/*# MASCARA */
function mascarar(vc_campo, vc_mascara) 
{
	var i		= vc_campo.value.length;
	var x		= vc_mascara.substring(0,1);
	var y		= vc_mascara.substring(i);
	
	if (y.substring(0,1) != x) 
	{
		vc_campo.value += y.substring(0,1);
	}
}

/*# VERIFICA DATA #*/
function verificaData(vc_campo) 
{ 
	if (vc_campo.value.length > 0) 
	{  
		it_dia		= (vc_campo.value.substring(0,2)); 
		it_mes		= (vc_campo.value.substring(3,5)); 
		it_ano		= (vc_campo.value.substring(6,10)); 
		it_erro		= 0; 
		
		if ((it_dia < 01) || (it_dia < 01 || it_dia > 30) && (it_mes == 04 || it_mes == 06 || it_mes == 09 || it_mes == 11 ) || it_dia > 31) 
		{ 
			it_erro	= 1; 
		} 

		if (it_mes < 01 || it_mes > 12 ) 
		{ 
			it_erro	= 1; 
		} 

		if (it_mes == 2 && (it_dia < 01 || it_dia > 29 || (it_dia > 28 && (parseInt(it_ano / 4) != it_ano / 4)))) 
		{ 
			it_erro	= 1; 
		} 

		if ((it_ano < 1900) || (it_ano>2078))
		{
			it_erro	= 1;
		}
		
		if (it_erro == 1) 
		{ 
			alert("Por favor, preencha uma data válida!"); 
			vc_campo.value	= '';
			vc_campo.focus(); 
		}
	} 
}

/*# iFrame virtual [ crossBrowser ] #*/
function iframe_virtual(vc_url) 
{
	// pega iframeVirtual pelo ID ou cria um iframeVirtual caso ñ exista
	var tempIFrame	= (document.getElementById('iframe_virtual')) ? document.getElementById('iframe_virtual') : document.createElement('iframe');
	
	with (tempIFrame) 
	{
		style.border	= '0px';
		style.width		= '0px';
		style.height	= '0px';
	
		setAttribute('id','iframe_virtual');
		setAttribute('name','iframe_virtual');
		setAttribute('src',vc_url);
	}
	
	IFrameObj = document.body.appendChild(tempIFrame);
}

/*# Alternativa ao getElementsByName [ apenas p/ o IE ] */
function getElementsByNameIE(vc_tag, vc_name) 
{
	var ar_elem		= document.getElementsByTagName(vc_tag);
	var ar_retorno	= new Array();
	var vc_atributo	= new String();
	
	for(i = 0, iarr = 0; i < ar_elem.length; i++) 
	{
		vc_atributo = ar_elem[i].getAttribute('name');
		
		if(vc_atributo == vc_name) 
		{
			ar_retorno[iarr] = ar_elem[i];
			iarr++;
		}
	}
	
	return ar_retorno;
}

//MascaraMoeda CROSSBROWSER	- Exemplo de chamada:		mascaraMoeda(this.value, this.id, event);
function mascaraMoeda(valor, cx, evtKeyPress) 
{
	if (valor) 
	{
		var doc     = eval('document.getElementById("'+cx+'")');
		var nTecla	= (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
		
		if (nTecla == 110 || nTecla == 188 || nTecla == 190 || nTecla == 194) 
		{
			return false;
		} 
		else 
		{
			valor = mascararCentavo(valor);
		
			if (mascararCentavo(valor).length > 2) 
			{
				str			= valor.replace(".", "");
				doc.value	= str.substr(0,(str.length-2)) + "." + str.substr((str.length-2),str.length);
			} 
			else 
			{
				valor		= mascararCentavo(valor);
				
				if (valor.length == 1) 
				{
					doc.value	= "0.0" + valor;
				} 
				else 
				{
					doc.value	= "0." + valor;
				}
			}
		}
	}
}
	
function mascararCentavo(mn_valor) 
{
	if (mn_valor.indexOf('0') == 0) 
	{
		mn_valor = mn_valor.replace('0.','');
		mn_valor = mn_valor.replace('0.0','');
	}
	
	mn_valor = mn_valor.replace('.','');
	
	return mn_valor;
}

function $elemento(name)
{
	var obj = document.getElementsByName(name)[0];
	return obj;
}

function verificarCadastro()
{
	if ($elemento("vc_cliente").value == '')
	{
		alert("Por favor, preencha o campo NOME.");
		$elemento("vc_cliente").focus();
		return;
	}

	if ($elemento("it_sexo").value == 0)
	{
		alert("Por favor, preencha o campo SEXO.");
		$elemento("it_sexo").focus();
		return;
	}

	if ($elemento("vc_apelido").value == '')
	{
		alert("Por favor, preencha o campo APELIDO.");
		$elemento("vc_apelido").focus();
		return;
	}

	if ($elemento("id_doc_tipo").value == 0)
	{
		alert("Por favor, preencha o campo TIPO DE DOCUMENTO.");
		$elemento("id_doc_tipo").focus();
		return;
	}

	if ($elemento("id_doc_tipo").value == 1)
	{
		var vc_doc_1 	= $elemento("vc_cpf").value
		var tipoDoc		= "CPF"
	}
	else
	{
		var vc_doc_1 	= $elemento("vc_passaporte").value
		var tipoDoc		= "PASSAPORTE"
	}

	if (vc_doc_1 == '')
	{
		alert("Por favor, preencha o " + tipoDoc + ".");
		$elemento("vc_" + tipoDoc.toLowerCase()).focus();
		return;
	}
	
	if ($elemento("id_nacionalidade").value == 0)
	{
		alert("Por favor, preencha o campo NACIONALIDADE.");
		$elemento("id_nacionalidade").focus();
		return;
	}
	
	if ($elemento("id_pais").value == 0)
	{
		alert("Por favor, preencha o campo PAÍS.");
		$elemento("id_pais").focus();
		return;
	}

	if ($elemento("dt_nascimento").value == '')
	{
		alert("Por favor, preencha o campo DATA DE NASCIMENTO.");
		$elemento("dt_nascimento").focus();
		return;
	}
	
	if ($elemento("id_estado").value == 0)
	{
		alert("Por favor, selecione um ESTADO.");
		$elemento("id_estado").focus();
		return;
	}

	if ($elemento("id_cidade").value == 0)
	{
		alert("Por favor, selecione uma CIDADE.");
		$elemento("id_cidade").focus();
		return;
	}
	
	if ($elemento("vc_email").value == '')
	{
		alert("Por favor, preencha o campo E-MAIL.");
		$elemento("vc_email").focus();
		return;
	}

	if (verificaEmail($elemento("vc_email").value) != '')
	{
		alert(verificaEmail($elemento("vc_email").value))
		$elemento("vc_email").focus();
		return;
	}
	
	if ($elemento("vc_senha").value == '')
	{
		alert("Por favor, preencha uma SENHA.");
		$elemento("vc_senha").focus();
		return;
	}
	
	if ($elemento("vc_confirma_senha").value == '')
	{
		alert("Por favor, preencha uma CONFIRMAÇÃO DE SENHA.");
		$elemento("vc_confirma_senha").focus();
		return;
	}	

	if ($elemento("vc_senha").value != $elemento("vc_confirma_senha").value)
	{
		alert("A SENHA digitada não coincide com a CONFIRMAÇÃO.");
		$elemento("vc_confirma_senha").focus();
		return;
	}
	
	$elemento("bt_submeter").disabled = true;
	$elemento("bt_submeter").value = "AGUARDE...";
	
	parent.codigo.location.href = 'temp/dados_cadastrados.asp?vc_email=' + $elemento("vc_email").value + '&vc_doc_1=' + vc_doc_1 + '&id_doc_tipo=' + $elemento("id_doc_tipo").value + '&id_cliente=' + $elemento("id_cliente").value;
}

function desbloquearBotao()
{
	$elemento("bt_submeter").disabled 	= false;
	$elemento("bt_submeter").value 		= "CONFIRMAR";
}

function submeterCadastro()
{
	$elemento("frm").submit();
}

function verificaPais(pais)
{
	//Pais 12 - Brasil
	if (pais == 12)
	{
		document.getElementById("td_cep").innerHTML = '<input type="text" name="vc_cep" maxlength="9" value="" class="bx_01" onKeyUp="return contar_cep(event);" onKeyPress="return soNumero(event);" style="width:70px;">&nbsp;<input type="text" name="vc_status" class="bx_03" style="width:175px;" readonly>';

		iframe_virtual('temp/busca_estado.asp?id_pais='+pais);

		var selec = $elemento("id_estado");
		
		selec.options[0] = new Option('Pesquisando...', '0');
	}
	else
	{
		document.getElementById("td_cep").innerHTML = '<input type="text" name="vc_cep" maxlength="9" class="bx_01" onKeyPress="return soNumero(event);" style="width:70px;">';

		iframe_virtual('temp/busca_estado.asp?id_pais=0');
	}
	
}

function verificaDoc(doc)
{
	//Doc 1 - CPF
	if (doc == 1)
	{
		document.getElementById("td_rotulo_doc").innerHTML 		= '<b>CPF</b>';
		document.getElementById("tb_cpf").style.display 		= "block";
		document.getElementById("tb_passaporte").style.display 	= "none";
	}
	else if (doc == 2)
	{
		document.getElementById("td_rotulo_doc").innerHTML 		= '<b>Passaporte</b>';
		document.getElementById("tb_cpf").style.display 		= "none";
		document.getElementById("tb_passaporte").style.display 	= "block";
	}
}

function verificaDocInscricao(doc)
{
	//Doc 1 - CPF
	if (doc == 1)
	{
		document.getElementById("td_doc_inscricao").innerHTML 	= '<b>CPF</b>';
		document.getElementById("td_documento").innerHTML 		= '<input type="text" name="vc_doc"  maxlength="14" class="bx_01" style="width:226px" onKeyPress="MascaraCPF(this.name); return soNumero(event);" onBlur="if(this.value.length>=14){ok = valida_CPF(this.value);if(ok!=true){alert(\'CPF inválido\');this.focus();}}">';
	}
	else if (doc == 2)
	{
		document.getElementById("td_doc_inscricao").innerHTML 	= '<b>Passaporte</b>';
		document.getElementById("td_documento").innerHTML 		= '<input type="text" name="vc_doc"  maxlength="30" class="bx_01" style="width:226px">';
	}
	else
	{
		document.getElementById("td_doc_inscricao").innerHTML 	= '<b>Documento</b>';
		document.getElementById("td_documento").innerHTML 		= '<input type="text" name="vc_doc"  maxlength="30" class="bx_01" style="width:226px">';
	}
}

/* MÁSCARA PARA CPF */
function MascaraCPF(campo) 
{
	var doc = $elemento(campo);

	if (doc.value.length == 3) 
	{
		doc.value = doc.value + '.';
	} 
	else if (doc.value.length == 7) 
	{
		doc.value = doc.value + '.';	
	} 
	else if (doc.value.length == 11) 
	{
		doc.value = doc.value + '-';	
	}	
}

/* VALIDAR CPF */
function valida_CPF(s)    
{
    var i;
    s = limpa_string(s);
    var c = s.substr(0,9);
    var dv = s.substr(9,2);
    var d1 = 0;
	
    	for (i = 0; i < 9; i++){
        	d1 += c.charAt(i)*(10-i);
    	}
		if (d1 == 0) return false;
    
		d1 = 11 - (d1 % 11);
    
		if (d1 > 9) d1 = 0;
	    
		if (dv.charAt(0) != d1){
	        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){
	        return false;
	    }
		
	return true;
}

function limpa_string(S)
{
    // Deixa só os digitos no numero
    var Digitos = "0123456789";
    var temp = "";
    var digito = "";

    for (var i=0; i<S.length; i++)    {
        digito = S.charAt(i);
        if (Digitos.indexOf(digito)>=0)    {
            temp=temp+digito    }
    } 

    return temp
}

// preenche o combo das linhas com os estados encontrados. * @param object: recordset com os dados encontrados no select 
function preencheEstado(object) 
{
	var selec 	= $elemento("id_estado");
	var pais 	= $elemento("id_pais").value;

	for (i = selec.length; i > 0; i--)
	{
		selec.options[i] = null;
	}

	selec.options[0] = new Option('Selecione uma opção', '0');
	
	if (pais > 1)
	{
		var j = 1;
	}
	else
	{
		selec.options[1] = new Option('Outros', '1');
		var j = 2;
	}
	
	for (i = 0; i <object.rows.length; i++) 
	{
		selec.options[j] = new Option(object.rows[i].vc_estado.replace(/´/g,"'"), object.rows[i].id_estado);
		
		j++;
	}
	
}

function buscaCidade(estado)
{
	iframe_virtual('temp/busca_cidade.asp?id_estado='+estado);
}

//preenche o combo das linhas com as cidades encontradas. @param object: recordset com os dados encontrados no select 
function preencheCidade(object) 
{
	var selec 	= $elemento("id_cidade");
	var estado 	= $elemento("id_estado").value;

	for (i = selec.length; i > 0; i--)
	{
		selec.options[i] = null;
	}

	selec.options[0] = new Option('Selecione uma opção', '0');
	
	if (estado > 1)
	{
		selec.options[1] = new Option('Outros', '1');
		var j = 2;
	}
	else
	{
		var j = 1;
	}
	
	for (i = 0; i <object.rows.length; i++) 
	{
		selec.options[j] = new Option(object.rows[i].vc_cidade.replace(/´/g,"'"), object.rows[i].id_cidade);
		
		j++;
	}
	
}

function exibeEstado(estado)
{
	if (estado == 1)
	{
		if (document.all)
		{
			document.getElementById("tr_estado").style.display = "block";
		}
		else
		{
			document.getElementById("tr_estado").style.display = "table-row";
		}
	}
	else
	{
		document.getElementById("tr_estado").style.display = "none";
	}
}

function exibeCidade(cidade)
{
	if (cidade == 1)
	{
		if (document.all)
		{
			document.getElementById("tr_cidade").style.display = "block";
		}
		else
		{
			document.getElementById("tr_cidade").style.display = "table-row";
		}
	}
	else
	{
		document.getElementById("tr_cidade").style.display = "none";
	}	
}

function mudaCorFundo(id, tipo)
{
	if (tipo == 1)
	{
		document.getElementById(id).className = "dv_eventos_on";
	}
	else
	{
		document.getElementById(id).className = "dv_eventos_off";
	}
}

function prosseguir(obj)
{
	if (obj.checked == true)
	{
		$elemento("bt_prosseguir").disabled = false;
	}
	else
	{
		$elemento("bt_prosseguir").disabled = true;
	}
}

function redirect(url)
{
	parent.location.href = url;
}

function verificaClienteInscrito(evento, integrantes, categoria, descricaoCategoria)
{
	parent.codigo.location.href = 'temp/verifica_cadastro_cliente.asp?id_evento='+evento+'&it_integrantes='+integrantes+'&id_categoria='+categoria+'&vc_categoria='+descricaoCategoria;
}

function verificaDocumento(evento, integrantes, categoria, descricaoCategoria)
{
	var tipo 	= $elemento("id_doc_tipo").value;
	var doc 	= $elemento("vc_doc").value;

	if (tipo == 0)
	{
		alert("Por favor, preencha um tipo de documento para verificar.");
		$elemento("id_doc_tipo").focus();
		return;
	}
	
	if (doc == '')
	{
		alert("Por favor, preencha um número de documento para verificar.");
		$elemento("vc_doc").focus();
		return;
	}
	
	parent.codigo.location.href = 'temp/verifica_cadastro.asp?vc_doc_1='+doc+'&id_doc_tipo='+tipo+'&id_evento='+evento+'&it_integrantes='+integrantes+'&id_categoria='+categoria+'&vc_categoria='+descricaoCategoria;
}

function respostaDocumento(acao, tipo, integrantes, evento, doc, categoria, descricaoCategoria, cliente)
{
	switch (parseInt(acao))
	{
		case 1:
			//Meu Cadastro
			redirect('../default.asp?actA=2&actB=4&act=1&id_doc_tipo='+tipo+'&it_integrantes='+integrantes+'&id_evento='+evento+'&vc_doc_1='+doc+'&id_categoria='+categoria+'&vc_categoria='+descricaoCategoria);
			break;
		case 2:
			//Minhas Inscrições
			redirect('../default.asp?actA=4&actB=4&id_evento='+evento+'&id_cliente='+cliente+'&vc_doc='+doc);
			break;
		case 3:
			//Passo 2
			redirect('../default.asp?actA=4&actB=2&id_cliente='+cliente+'&id_evento='+evento+'&id_categoria='+categoria+'&vc_categoria='+descricaoCategoria+'&it_integrantes='+integrantes+'&it_terceiro=1');
			break;
		case 4:
			//Minhas Inscrições
			redirect('../default.asp?actA=4&actB=5&id_evento='+evento);
			break;			
	}
}

function exibirProcuraAtleta()
{
	document.getElementById("tb_opcao_atleta").style.display 	= "none";
	document.getElementById("tb_procura_atleta").style.display 	= "block";
}

function termoUnicoIntegrante()
{
	if ($elemento("chk_termo").checked)
	{
		document.getElementById("tb_termo").style.display 				= "none";
		document.getElementById("tb_unico_integrante").style.display 	= "block";
	}
}

function verificaInscricao()
{
	var integrantes = $elemento("it_integrantes").value;
	
	if (integrantes == 1)
	{
		if ($elemento("id_faixa_etaria").value == 0)
		{
			alert("ERRO 001 - Problemas no processo de inscrição - Nenhuma faixa etária cadastrada.\nPor favor, entre em contato com a Latin Sports.");
			return;
		}

		if ($elemento("id_modalidade").value == '')
		{
			alert("ERRO 002 - Problemas no processo de inscrição - Nenhuma modalidade cadastrada.\nPor favor, entre em contato com a Latin Sports.");
			return;
		}
		
		$elemento("bt_concluir").disabled 	= true;
		$elemento("bt_concluir").value 		= "AGUARDE...";
		
		$elemento("frm").submit();

	}
	else
	{
		var itModalidade = 0;

		if ($elemento("vc_equipe").value == '')
		{
			alert("Por favor, preencha o nome da equipe.");
			$elemento("vc_equipe").focus();
			return;			
		}

		//Percorre todos os campos de cada integrante
		for (i=1; i<=integrantes; i++)
		{
			if (document.getElementById("it_qtde_modalidade_"+i).value > 0)
			{
				itVerificacao = 1;
				
				if (document.getElementById("vc_atleta_"+i).value == '')
				{
					alert("Por favor, preencha o nome de todos os atletas.");
					document.getElementById("vc_atleta_"+i).focus();
					return;
					break;
				}
	
				if (document.getElementById("vc_apelido_"+i).value == '')
				{
					alert("Por favor, preencha o apelido de todos os atletas.");
					document.getElementById("vc_apelido_"+i).focus();
					return;
					break;
				}
	
				if (document.getElementById("dt_nascimento_"+i).value == '')
				{
					alert("Por favor, preencha a data de nascimento de todos os atletas.");
					document.getElementById("dt_nascimento_"+i).focus();
					return;
					break;
				}
	
				if (document.getElementById("it_sexo_"+i).value == 0 || document.getElementById("it_sexo_"+i).value == '')
				{
					alert("Por favor, informe o sexo de todos os atletas.");
					document.getElementById("it_sexo_"+i).focus();
					return;
					break; 
				}
	
				if (document.getElementById("vc_email_"+i).value == '')
				{
					alert("Por favor, preencha o e-mail de todos os atletas.");
					document.getElementById("vc_email_"+i).focus();
					return;
					break;
				}
	
				if (verificaEmail(document.getElementById("vc_email_"+i).value) != '')
				{
					alert(verificaEmail(document.getElementById("vc_email_"+i).value));
					document.getElementById("vc_email_"+i).focus();
					return;
					break;
				}
	
				if (document.getElementById("id_faixa_etaria_"+i).value == 0 || document.getElementById("id_faixa_etaria_"+i).value == '')
				{
					alert("ERRO 001 - Problemas no processo de inscrição - Nenhuma faixa etária cadastrada.\nPor favor, entre em contato com a Latin Sports.");
					return;
					break;
				}

				//Conta a qtde de modalidades selecionadas
				for (j=0; j<document.getElementsByName("id_modalidade_"+i).length; j++)
				{
					if (document.getElementsByName("id_modalidade_"+i)[j].disabled == false)
					{
						if (document.getElementsByName("id_modalidade_"+i)[j].checked)
						{
							itModalidade += 1;
						}
					}
				}
			}
		}
		
		if (parseInt(itModalidade) != $elemento("it_modalidades").value)
		{
			alert("Por favor, selecione corretamente as modalidades para cada atleta.");
			return;
		}
		
		$elemento("bt_concluir").disabled 	= true;
		$elemento("bt_concluir").value 		= "AGUARDE...";	
		
		$elemento("frm").submit();
	}
}

function loginVerificar()
{
	email 	= document.getElementById("vc_email").value;
	url		= document.getElementById("vc_url").value.replace(/=/g,"|").replace(/&/g, "$");
	origem	= $elemento("it_origem").value;
	
	if (document.getElementById("it_logon_1").checked)
	{
		redirect('default.asp?actA=2&actB=0&act=1&vc_email='+email+'&it_origem='+origem+'&vc_url='+url);
	}
	else
	{
		$elemento("bt_continuar").disabled 	= true;
		$elemento("bt_continuar").value		= 'AGUARDE...';
		
		$elemento("loginFRM").submit();
	}
}

function esqueciSenha()
{
	parent.codigo.location.href = 'temp/esqueci_senha.asp?vc_email=' + $elemento("vc_login").value;
}

function selecionaLogon()
{
	document.getElementById("it_logon_3").checked = true;
}

function insereClienteAtleta()
{
	if ($elemento("it_indice_cliente").value == 0)
	{
		var integrantes = $elemento("it_integrantes").value;
		var indice		= 1;
		
		//Percorre uma posição livre para inserir o cliente
		for (i=1; i<=integrantes; i++)
		{
			if (document.getElementById("vc_atleta_"+i).value == '')
			{
				indice = i;
				break;
			}
		}
		
		//Guarda o índice utilizado pelo cliente, caso o mesmo venha a ser retirado
		$elemento("it_indice_cliente").value = indice;
		
		document.getElementById("tb_atleta_"+indice).className 		= "tb_02";
		document.getElementById("it_caracter_"+indice).className 	= "bx_06";
	
		document.getElementById("id_cliente_equipe_"+indice).value	= $elemento("id_cliente_atleta").value;
		document.getElementById("vc_atleta_"+indice).value			= $elemento("vc_cliente_atleta").value;
		document.getElementById("vc_apelido_"+indice).value			= $elemento("vc_cliente_apelido").value;
		document.getElementById("dt_nascimento_"+indice).value		= $elemento("dt_cliente_nascimento").value;
		document.getElementById("vc_email_"+indice).value			= $elemento("vc_cliente_email").value;
		document.getElementById("it_sexo_"+indice).value			= $elemento("it_cliente_sexo").value;
		document.getElementById("it_sexo_atleta_"+indice).value		= $elemento("it_cliente_sexo").value;
	
		document.getElementById("vc_atleta_"+indice).readOnly		= true;
		document.getElementById("vc_apelido_"+indice).readOnly		= true;
		document.getElementById("dt_nascimento_"+indice).readOnly	= true;
		document.getElementById("vc_email_"+indice).readOnly		= true;
		document.getElementById("it_sexo_"+indice).disabled			= true;
		
		document.getElementById("id_faixa_etaria_"+indice).value	= $elemento("id_cliente_faixa_etaria").value;
	}
}

function retiraClienteAtleta()
{
	indice = $elemento("it_indice_cliente").value;
	
	if (indice > 0)
	{
		document.getElementById("tb_atleta_"+indice).className 		= "tb_03";
		document.getElementById("it_caracter_"+indice).className 	= "bx_05";
		
		document.getElementById("id_cliente_equipe_"+indice).value	= 0;
		document.getElementById("vc_atleta_"+indice).value			= '';
		document.getElementById("vc_apelido_"+indice).value			= '';
		document.getElementById("dt_nascimento_"+indice).value		= '';
		document.getElementById("vc_email_"+indice).value			= '';
		document.getElementById("it_sexo_"+indice).value			= 0;
		document.getElementById("it_sexo_atleta_"+indice).value		= 0;
		
		document.getElementById("vc_atleta_"+indice).readOnly		= false;
		document.getElementById("vc_apelido_"+indice).readOnly		= false;
		document.getElementById("dt_nascimento_"+indice).readOnly	= false;
		document.getElementById("vc_email_"+indice).readOnly		= false;
		document.getElementById("it_sexo_"+indice).disabled			= false;
		
		for (i=document.getElementById("id_faixa_etaria_"+indice).length; i>=0; i--)
		{
			document.getElementById("id_faixa_etaria_"+indice).options[i] = null;
		}
		
		$elemento("it_indice_cliente").value = 0;
	}
}

function buscaFaixaEtaria(indice, categoria, evento)
{
	var nascimento 	= document.getElementById("dt_nascimento_"+indice).value;
	var sexo		= document.getElementById("it_sexo_"+indice).value;
	
	if (nascimento.length == 10 && sexo > 0)
	{
		parent.codigo.location.href = 'temp/busca_faixa_etaria.asp?id_evento='+evento+'&id_categoria='+categoria+'&dt_nascimento='+nascimento+'&it_sexo='+sexo+'&indice='+indice;
	}
}

function preencheFaixaEtaria(faixaEtaria, indice)
{
	document.getElementById("id_faixa_etaria_"+indice).value = faixaEtaria;
}

function bloquearLiberarModalidades(i, x)
{
	var integrantes = $elemento("it_atletas").value;
	
	//Se a modalidade for checada, bloquear a de todos os outros atletas
	if (document.getElementById("id_modalidade_"+i+"_"+x).checked == true)
	{
		for (j=1; j<=integrantes; j++)
		{
			if (j!=i)
			{
				document.getElementById("id_modalidade_"+j+"_"+x).disabled = true;
			}
		}
		
		document.getElementById("it_qtde_modalidade_"+i).value = parseInt(document.getElementById("it_qtde_modalidade_"+i).value) + 1;
	}
	else
	{
		for (j=1; j<=integrantes; j++)
		{
			if (j!=i)
			{
				document.getElementById("id_modalidade_"+j+"_"+x).disabled = false;
			}
		}
		
		document.getElementById("it_qtde_modalidade_"+i).value = parseInt(document.getElementById("it_qtde_modalidade_"+i).value) - 1;
	}
}

function ocultarExiberModalidades(i, x, integrantes)
{
	var ocultar	= 0;

	//Se a modalidade for checada, bloquear a de todos os outros atletas
	if (document.getElementById("id_modalidade_"+i+"_"+x).checked == true)
	{
		for (j=1; j<integrantes+1; j++)
		{
			if (j!=i)
			{
				document.getElementById("id_modalidade_"+j+"_"+x).disabled = true;
			}
		}
		
		document.getElementById("it_qtde_modalidade_"+i).value = parseInt(document.getElementById("it_qtde_modalidade_"+i).value) + 1;
	}
	else
	{
		for (j=1; j<integrantes+1; j++)
		{
			if (j!=i)
			{
				document.getElementById("id_modalidade_"+j+"_"+x).disabled = false;
			}
		}
		
		document.getElementById("it_qtde_modalidade_"+i).value = parseInt(document.getElementById("it_qtde_modalidade_"+i).value) - 1;
	}

	for (k=1; k<=integrantes; k++)
	{
		ocultar = 1
		
		for (y=1; y<=document.getElementsByName("id_modalidade_"+k).length; y++)
		{
			if (document.getElementById("id_modalidade_"+k+"_"+y).disabled == false)
			{
				ocultar = 0;
				break;
			}
		}
		
		if (ocultar == 1)
		{
			document.getElementById("tr_"+k).style.display = "none";
		}
		else
		{
			if (document.all)
			{
				document.getElementById("tr_"+k).style.display = "block";
			}
			else
			{
				document.getElementById("tr_"+k).style.display = "table-row";
			}
		}
	}
}

function armazenaSexo(sexo, indice)
{
	document.getElementById("it_sexo_atleta_"+indice).value = sexo;
}

function abrir(actA, evento, equipe)
{
	redirect('default.asp?actA='+actA+'&id_evento='+evento+'&id_equipe='+equipe);
}

function visualizaPagamentos(evento, equipe)
{
	redirect('default.asp?actA=12&eventoID='+evento+'&equipeID='+equipe);
}

function verificaAlteracaoAtleta(integrantes)
{
	var itModalidade = 0;
	
	//Percorre todos os campos de cada integrante
	for (i=1; i<=integrantes; i++)
	{
		if (document.getElementById("vc_atleta_"+i).value == '')
		{
			alert("Por favor, preencha o nome de todos os atletas.");
			document.getElementById("vc_atleta_"+i).focus();
			return;
			break;
		}

		if (document.getElementById("vc_apelido_"+i).value == '')
		{
			alert("Por favor, preencha o apelido de todos os atletas.");
			document.getElementById("vc_apelido_"+i).focus();
			return;
			break;
		}

		if (document.getElementById("dt_nascimento_"+i).value == '')
		{
			alert("Por favor, preencha a data de nascimento de todos os atletas.");
			document.getElementById("dt_nascimento_"+i).focus();
			return;
			break;
		}

		if (document.getElementById("vc_email_"+i).value == '')
		{
			alert("Por favor, preencha o e-mail de todos os atletas.");
			document.getElementById("vc_email_"+i).focus();
			return;
			break;
		}

		if (verificaEmail(document.getElementById("vc_email_"+i).value) != '')
		{
			alert(verificaEmail(document.getElementById("vc_email_"+i).value));
			document.getElementById("vc_email_"+i).focus();
			return;
			break;
		}

		if (document.getElementById("id_faixa_etaria_"+i).value == 0 || document.getElementById("id_faixa_etaria_"+i).value == '')
		{
			alert("ERRO 001 - Problemas no processo de inscrição - Nenhuma faixa etária cadastrada.\nPor favor, entre em contato com a Latin Sports.");
			return;
			break;
		}
		
		if (document.getElementById("it_qtde_modalidade_"+i).value == 0)
		{
			alert("Por favor, escolha pelo menos uma modalidade para cada atleta.");
			return;
			break;
		}

		itModalidade += parseInt(document.getElementById("it_qtde_modalidade_"+i).value)
		
	}
	
	if (parseInt(itModalidade) != parseInt($elemento("it_modalidades").value))
	{
		alert("Por favor, selecione corretamente as modalidades para cada atleta.");
		return;
	}	
	
	$elemento("bt_concluir").disabled 	= true;
	$elemento("bt_concluir").value		= "AGUARDE...";
	$elemento("frm").submit();
}

function verificaQuestionario()
{
	var idPerguta 		= 0;
	var itTipoPergunta 	= 0;
	var itSubmeter		= 1;
	
	for (i=0; i<document.getElementsByName("id_pergunta").length; i++)
	{
		idPergunta 		= document.getElementsByName("id_pergunta")[i].value;
		itTipoPergunta 	= document.getElementsByName("it_tipo_pergunta")[i].value;
		
		document.getElementsByName("it_respondida")[i].value = 0;
		
		if (parseInt(itTipoPergunta) != 3)
		{
			for (j=0; j<document.getElementsByName("id_resposta_"+idPergunta).length; j++)
			{
				if (document.getElementsByName("id_resposta_"+idPergunta)[j].checked)
				{
					document.getElementsByName("it_respondida")[i].value = 1;
					break;
				}
			}
		}
		else
		{
			if ($elemento("vc_resposta_"+idPergunta).value != '')
			{
				document.getElementsByName("it_respondida")[i].value = 1;
			}
		}
	}
	
	for (i=0; i<document.getElementsByName("it_respondida").length; i++)
	{
		if (document.getElementsByName("it_respondida")[i].value == 0)
		{
			alert("Por favor, responda todas as questões.");
			return;			
		}
	}
	
	$elemento("bt_concluir").disabled = true;
	$elemento("bt_concluir").value = "AGUARDE...";
	$elemento("frm").submit();
}

function linkEvento(evento)
{
	parent.location.href = 'default.asp?actA=7&id_evento=' + evento;
}


/***********************************************************************
*		B A N N E R S 
***********************************************************************/

/*# BANNER #*/
function bannerCount(bannerID) {
	codigo.location.href='codigos/banner.asp?bannerID='+bannerID;
}