// JavaScript Document
function home_exibir()
{
	$("#acao_site").val('home');
	$("#dados").action = 'index.php';
	$("#dados").submit();
}

function eventos_listar()
{
	$.ajax({
		url: "ajax.php",
		type: 'post',
		cache: false,
		data: {acao: 'eventos_listar', palavra_chave: $("#palavra_chave").val(), data_evento_ini: $("#data_evento_ini").val(), data_evento_fim: $("#data_evento_fim").val(), pais: $("#pais").val(), id_estado: $("#id_estado").val(), id_cidade: $("#id_cidade").val()},
		dataType: 'html',
		success: function(retorno)
		{
			$("#td_tabela_eventos").html(decode(retorno));
			$("#tabela_eventos tbody tr:odd").addClass("tabela_linha_par");
			$("#tabela_eventos tbody tr:even").addClass("tabela_linha_impar");
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert(textStatus);
		}
	});	
}

function evento_exibir(id_evento)
{
	$('#validar'+id_evento).html('<img src="/imagens/loadinfo.gif" border="0" align="absmiddle" /> <font class="nome_campo"><b>Aguarde... Processando</b></font>');
	$("#acao_site").val("evento_exibir");
	$("#id_evento").val(id_evento);
	$("#dados").submit();
}

function monta_email()
{
	$.ajax({
		url: "ajax.php",
		type: 'post',
		cache: false,
		data: {acao: 'monta_email',id_evento: $("#id_evento").val()},
		dataType: 'json',
		success: function(retorno)
		{
			$("#div_dialog").html(decode(retorno.html));
			$("#div_dialog").dialog('destroy');
			$("#div_dialog").dialog({ 
					height: 400,
					show: 'slide',
					width: 500,
					hide: 'slide',
					modal: true,	
					resizable: false,
					draggable: false,
					title: 'Fale com a organização'
				});
			
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert(textStatus);
		}
	});		
}

/**
 * 
 * @return
 */
function contato_organizador()
{
	$.ajax({
		url: "eventos.php",
		type: 'post',
		cache: false,
		data: {
			acao_site: 'contato_organizador'
		},
		dataType: 'json',
		success: function(retorno)
		{
			$("#div_dialog").html(decode(retorno.html));
			$("#div_dialog").dialog('destroy');
			$("#div_dialog").dialog({ 
					height: 400,
					width: 500,
					modal: true,	
					resizable: true,
					draggable: true,
					title: 'Fale com a organização'
				});
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert(textStatus);
		}
	});		
}


/**
 * 
 * @return
 */

function atletas_listar()
{	
	id_evento = $("#id_evento").val();
		if (id_evento == '')
		{
			alert('Selecione o evento');
			return;
		}
	npeito      = $("#num_peito").val();
	nome        = $("#nome_atleta").val();
	nome_evento = $("#id_evento").text();
	

		if(npeito == '' && nome == '')
		{
		   alert('Nome ou Número de peito são obrigatórios'); 
		   return;
		}
		
	
	$.ajax({
		url: "fotos.php",
		type:'post',
		cache: false,
		data: {acao_site: 'atletas_listar', 
			id_evento: id_evento,
			numpeito: npeito,
			nome_atleta: nome,
			nomedoevento: nome_evento
		},
		dataType: 'html',
		success: function(retorno)
		{
			$("#div_fotos_evento").html(retorno);	
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert(textStatus);
		}

	});
	
}

function imagens_atleta(num_peito)
{
	$("#num_peito").val(num_peito);
	$("#acao_site").val("imagens_atleta");
	$("#dados").attr("action", "fotos.php");
	$("#dados").submit();	
}

function download(file)
{
	$("#acao_site").val('download');
	$("#dados").attr("action","fotos.php?arquivo=fotos/"+file);
	
	$("#dados").submit();		
}
