function listeCompetition(p_organisation, p_langue, p_div)
{
    jQuery.ajax({
		type: "GET",
		url : "gestion/triath_ajax.php",
		data : "liste=competition" + "&organisation=" + p_organisation + "&langue=" + p_langue,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivCompetition").html(data);
		}
	});
	
}

function insertChrono(p_operation, p_entite, p_dossard, p_competition, p_correction)
{
    jQuery.ajax({
		type: "GET",
		url : "triath_insert_chrono.php",
		data : "p_operation=" + p_operation + "&p_entite=" + p_entite + "&p_dossard=" + p_dossard + "&p_competition=" + p_competition + "&p_correction=" + p_correction,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivListe").html(data);
		}
	});
	
}

function afficheChoixInscriptionListe(p_langue, p_affichage)
{
    jQuery.ajax({
		type: "GET",
		url : "spip.php",
		data : "page=inc_choix_inscription_liste" + "&p_langue=" + p_langue + "&p_affichage=" + p_affichage ,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivChoixInscriptionListe").html(data);
		}
	});
}

function afficheListeInscrits(p_langue, p_tri, p_nom, p_organisation, p_competition, p_club, p_action, p_athlete, p_connecte)
{
	effaceDiv('DivErreur');
	afficheEnCours('DivListeInscrits');
    jQuery.ajax({
		type: "GET",
		url : "gestion/inscriptions/triath_liste_inscrits_site.php",
		data : "p_langue=" + p_langue + "&p_tri=" + p_tri + "&p_nom=" + p_nom +
				"&p_organisation=" + p_organisation + "&p_competition=" + p_competition + "&p_club=" + p_club +
				"&p_action=" + p_action + "&p_athlete=" + p_athlete + "&p_connecte=" + p_connecte ,
		error: function(data) {
			$("#DivListeInscrits").html(data);
		},
		success: function(data) {
			$("#DivListeInscrits").html(data);
		}
	});
}

function listeInscription(action, codeAthlete, tri, thisNameField, organisation, thisCompetitionField, thisClubField)
{
    jQuery.ajax({
		type: "GET",
		url : "triath_liste_inscrits2.php",
		data : "lg=fr&action=" + action + "&codeAthlete=" + codeAthlete + "&tri=" + tri + "&organisation=" + organisation + "&thisCompetitionField=" + thisCompetitionField + "&thisNameField=" + thisNameField,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivListe").html(data);
		}
	});
	
}

function updateInscription(action, codeInscription, organisation, competition, licence, nom, prenom, sexe, dateNaissance, adresse, codePostal, localite, pays, email, tel, club, licence, commentaire, paye)
{
    jQuery.ajax({
		type: "GET",
		url : "triath_update_inscrits.php",
		data : "lg=fr&action=" + action + "&codeInscription=" + codeInscription + "&organisation=" + organisation + "&competition=" + competition + "&nom=" + nom +
					"&prenom=" + prenom + "&sexe=" + sexe + "&dateNaissance=" + dateNaissance + "&adresse=" + adresse + "&codePostal=" + codePostal + 
					"&localite=" + localite + "&pays=" + pays + "&email=" + email + "&telephone=" + tel + "&club=" + escape(club) + "&licence=" + licence + "&commentaire=" + commentaire + 
					"&paye=" + paye ,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivListe").html(data);
		}
	});
}

function afficheMiseAJour(p_code_inscription, p_action)
{
    jQuery.ajax({
		type: "GET",
		url : "spip.php",
		data : "page=triath_update_inscription&lg=fr&p_code_inscription=" + p_code_inscription + "&p_action=" + p_action ,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivFormulaireInscription").html(data);
		}
	});
}



function afficheTempsIntermediaire(p_tri)
{
    jQuery.ajax({
		type: "GET",
		url : "triath_temps_intermediaire.php",
		data : "p_tri=" + p_tri,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			$("#DivTempsIntermediaire").html(data); document.forms[0].champ1.select();
		}
	});
	
}


function updateEnregistrement(p_entite, p_operation, p_code, p_master, p_suiteValeur, p_ligneParPage, p_numeroPage, p_typeMembre, p_typeDepartement)
{
  var test=true;
  if (p_operation == 'delete')
  {
    test = confirm("Voulez-vous confirmer la suppression ?");
  }

  if (p_operation == 'stop')
  {
    dateFin = prompt('Date de fin');
    if (dateFin == null) { alert(dateFin); }
    if (dateFin == null || dateFin == '') { test = false; } else { p_suiteValeur = dateFin; }
  }

  if (test) {
    
    jQuery.ajax({
		  type: "GET",
		  url : "spip.php",
		  data : "page=lbftd_update_enregistrement" +
						  "&p_entite=" + p_entite +
						  "&p_operation=" + p_operation +
						  "&p_code=" + p_code +
						  "&p_master=" + p_master +
						  "&p_suiteValeur=" + p_suiteValeur +
						  "&p_ligneParPage=" + p_ligneParPage +
						  "&p_numeroPage=" + p_numeroPage +
						  "&p_typeMembre=" + p_typeMembre +
						  "&p_typeDepartement=" + p_typeDepartement ,
		  error: function() {
  			alert('erreur update enregistrement');
		  },
		  success: function(data) {
  			$("#DivListe").html(data);
		  }
	  });
  }
}

function afficheEnCours(contenu)
{
	document.getElementById(contenu).innerHTML = '<div width="100%" align="center"><img src="gestion/img/searching.gif" /></div>';
}

function afficheErreur(erreur)
{
	document.getElementById('DivErreur').innerHTML = erreur;
}

function afficheTitre(titre)
{
	document.getElementById('DivTitre').innerHTML = titre;
}

function effaceDiv(div)
{
	document.getElementById(div).innerHTML="";
}

function controleLicenceLbftd(p_licence)
{
    jQuery.ajax({
		type: "GET",
		url : "triath_licence_lbftd.php",
		data : "p_licence=" + p_licence,
		error: function(msg) {
			alert('erreur' + msg);
		},
		success: function(data) {
			alert(data);
			$("#DivTempsIntermediaire").html(data);
		}
	});
}
