// JavaScript Document
$(function(){
	$("#data_nascimento").mask("99/99/9999");
	$("#telefone_residencial").mask("(99)9999-9999");
	$("#telefone_celular").mask("(99)9999-9999");
	$("#cep").mask("99999-999");
	$("#data_realizacao").mask("99/99/9999");
	$("#data_termino_inscricao").mask("99/99/9999");
	$(".excluir").click(function(){
		var url = this.getAttribute("href");
		
		if(confirm("Deseja realmente excluir o registro?")){
			document.location = url;	
		}
		
		return false;
	});
});

function retorna_etapas_ajax(copa){
	$("#div_etapa").load("inscricao_buscas_ajax.php?busca=etapa&copa=" + copa);
}

function retorna_categorias_ajax(etapa){
	$("#div_categoria").load("inscricao_buscas_ajax.php?busca=categoria&etapa=" + etapa);	
}

function retorna_etapas_andamento_ajax(copa){
	$("#div_etapas").load("copa_andamento_busca_ajax.php?acao=etapa_lista&copa=" + copa);	
}

function retorna_etapa_detalhe_ajax(etapa){
	$("#div_detalhe").load("copa_andamento_busca_ajax.php?acao=etapa_detalhe&etapa=" + etapa);	
}

function lista_pilotos_ajax(etapa){
	$("#listagem_pilotos").load("etapa_pilotos_lista.php?etapa=" + etapa);	
}

function ValidaSemPreenchimento(form){
	for (i=0;i<form.length;i++){
		var obg = form[i].obrigatorio;
		if (obg==1){
			if (form[i].value == ""){
				var title = form[i].title
				alert("O campo [" + title + "] é obrigatório.")
				form[i].focus();
				return false
			}
		}
	}
	return true
}