// JavaScript Document
// Ici viennent les scripts javascripts
<!-- FONCTION QUI REGLE LES CONFLITS DE window.onload -->
funconload = new Array(); 

function replaceonload(Obj) { 
    funconload[funconload.length] = Obj; 
} 
     
// Execution des scripts au chargement de la page 
window.onload = function() {   
	for(i=0; i<funconload.length; i++){
		funconload[i]();
	} 
}
//-->
<!-- PRELOAD IMAGE -->
if (document.images)
{
  preload_image_object = new Image();
  // set image url
  image_url = new Array();
  image_url[0] = "../images/menugauchesurvoldt.png";
  image_url[1] = "../images/menugauchesurvolli.png";
  image_url[2] = "../images/menudroitesurvoldt.png";
  image_url[3] = "../images/menudroitesurvolli.png";
  image_url[4] = "../images/loader.gif";
  image_url[5] = "../images/loader2.gif";

   var i = 0;
   for(i=0; i<=6; i++) 
	 preload_image_object.src = image_url[i];
}
//-->
<!-- MENU DEROULANT AVEC REDIRECTION -->
function ChangeUrl(formulaire)
	{
	if (formulaire.ListeUrl.selectedIndex != 0)
		{
		location.href = formulaire.ListeUrl.options[formulaire.ListeUrl.selectedIndex].value;
	 	}
	}
//-->
<!-- NOUVEAU LIEU -->
function choisirlieu() {
	if (document.getElementById("selectlocation").value == "newlocation") {
	var html = "<table width='100%' border='0' cellspacing='0'>";
	html += "<tr>";
	html += "<td width='32%' align='right' valign='top' for:'nomlieu'>Nom du lieu:</td>";
	html += "<td width='1%'>&nbsp;</td>";
	html += "<td width='67%'><input name='nomlieu' type='text' id='nomlieu' size='30' class=\"champobligatoire {validate:{required:true, messages:{required:'<br />Veuillez entrer un nom de lieu!'}}}\" /><br /><span class='xxsmall'>(S'il s'agit de l'adresse d'un club, veuillez entrer le nom du club dans ce champ)</span></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align='right' valign='top' for='adresse'>Adresse:</td>";
	html += "<td>&nbsp;</td>";
	html += "<td><input name='adresse' type='text' id='adresse' class=\"champobligatoire {validate:{required:true, messages:{required:'<br />Veuillez entrer une adresse!'}}}\" size='50' /><br /><span class='xxsmall'>L'adresse sera automatiquement convertie en une adresse Google Maps (c)</span></td>";
	html += "</tr>";
	html += "</table>";

	document.getElementById("divnewlocation").innerHTML = html;
	} else {
	document.getElementById("divnewlocation").innerHTML = "";	
	}
}
//-->
<!-- NOUVEAU PROFIL -->
function choisirprofil(vnom,vprenom,vemail) {
	if (document.getElementById("selectprofil").value == "newprofil") {

	var html = "<table width='100%' border='0' cellspacing='0'>";
	html += "<tr>";
	html += "<td width='15%' align='right' valign='top'>Nom:</td>";
	html += "<td width='1%'>&nbsp;</td>";
	html += "<td width='84%'><input name='nom' type='text' class='champobligatoire' id='nom' size='30' value='"+vnom+"' /></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align='right' valign='top'>Prénom:</td>";
	html += "<td>&nbsp;</td>";
	html += "<td><input name='prenom' type='text' class='champobligatoire' id='prenom' size='30' value='"+vprenom+"' /></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align='right' valign='top'>Email:</td>";
	html += "<td>&nbsp;</td>";
	html += "<td><input name='email' type='text' class='champobligatoire' id='email' size='30' value='"+vemail+"' /></td>";
	html += "</tr>";
	html += "<tr>";
	html += "<td align='right'>&nbsp;</td>";
	html += "<td>&nbsp;</td>";
	html += "<td class='xxsmall'>Une fois inscrit, vous aurez l'occasion d'ajouter plus d'infos vous concernant.</td>";
	html += "</tr>";
	html += "</table>";

	document.getElementById("divnewprofil").innerHTML = html;
	} else {
	document.getElementById("divnewprofil").innerHTML = "";	
	}
}
//-->
<!-- COCHE/DECOCHE MANAGER SI COACH COCHE -->
/*function managercoach()
{
	if (document.getElementById("coach").checked == true) {
	document.getElementById("divmanagercoach").innerHTML = "<input name=\"manager\" type=\"checkbox\" id=\"manager\" value=\"yes\" checked=\"checked\" /> Manager <span class=\"xxsmall\">(Attention! Si vous cochez cette case, cette personne pourra éditer les infos)</span><br />";
	} else {
	document.getElementById("divmanagercoach").innerHTML = "<input name=\"manager\" type=\"checkbox\" id=\"manager\" value=\"yes\" /> Manager <span class=\"xxsmall\">(Attention! Si vous cochez cette case, cette personne pourra éditer les infos)</span><br />";
	}

}*/
//-->
<!-- CHANGE LE STATUT D'UN JOUEUR DANS LA CONVOCATION -->
function changedispo2(idevent,idequipe,idcontact,statut,i,nbcontacts){ 

	if ((statut== "") || (statut == "adeterminer")) { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"present\" /><img src=\"images/present.jpg\" alt=\"Pr&eacute;sent\" title=\"Pr&eacute;sent\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','present', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	} else if (statut == "present") { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"absent\" /><img src=\"images/absent.jpg\" alt=\"Absent\" title=\"Absent\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','absent', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	} else if (statut == "absent") { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"blesse\" /><img src=\"images/blesse.jpg\" alt=\"Bless&eacute;\" title=\"Bless&eacute;\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','blesse', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	} else if (statut == "blesse") { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"suspendu\" /><img src=\"images/suspendu.jpg\" alt=\"Suspendu\" title=\"Suspendu\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','suspendu', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	} else if (statut == "suspendu") { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"bye\" /><img src=\"images/bye.jpg\" alt=\"Bye\" title=\"Bye\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','bye', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	} else if (statut == "bye") { 
	var html = "<input type=\"hidden\" name=\"dispo-"+idcontact+"\" id=\"dispo-"+i+"\" value=\"adeterminer\" /><img src=\"images/blanc.jpg\" alt=\"A d&eacute;terminer\" title=\"A d&eacute;terminer\" width=\"21\" height=\"21\" onclick=\"changedispo2('"+idevent+"','"+idequipe+"','"+idcontact+"','adeterminer', '"+i+"', '"+nbcontacts+"'), countdispo('"+nbcontacts+"')\" class=\"pointimage\" />";
	}

	document.getElementById("divchangedispo2-"+idcontact+"").innerHTML = html;
}
//-->
function countdispo(nbcontacts) {
	
	var totaldispo = 0;
	
	var i=0;
	while(i<nbcontacts) {
		
		if(document.getElementById("dispo-"+i).value == "present") {
			totaldispo++;
		}
	i++;
	}
	
	document.getElementById("divnbpresents").innerHTML = totaldispo;
}
<!-- VERIFIE LA DATE DANS LA FICHE MATCH -->
function checkdatematch(idmatch, idequipe){ 
	
	var getdatematch = document.getElementById("datematch").value;
	
	var explode = getdatematch.split('/');

	var datematch = explode[2]+"-"+explode[1]+"-"+explode[0];
	
	var hour = document.getElementById("coupenvoiheure").value;
	var minute = document.getElementById("coupenvoiminute").value;
	
	var heurematch = hour+":"+minute+":00";
	
	var ajd = new Date();
	var thisday = ajd.getDate();
	if (thisday < 10) { var thisday = "0"+thisday; }
	var thismonth = (ajd.getMonth()+1);
	if (thismonth < 10) { var thismonth = "0"+thismonth; }
    var datetoday = ajd.getFullYear() + "-" + thismonth + "-" + thisday;
	
	var heuretoday = ajd.getHours()+":"+ajd.getMinutes()+":00";
		
	if ((datematch > datetoday) || ((datematch == datetoday) && (heuretoday < heurematch))) {
		
		document.getElementById("resulthome").disabled = true;
		document.getElementById("resulthome").value = "";
		
		document.getElementById("resultaway").disabled = true;
		document.getElementById("resultaway").value = "";
		
		document.getElementById("commentaire").disabled = true;
		document.getElementById("commentaire").value = "";
		
		document.getElementById("pcoo").disabled = true;
		document.getElementById("pcoo").value = "";
		
		document.getElementById("pcoc").disabled = true;
		document.getElementById("pcoc").value = "";
		
		document.getElementById("pcdc").disabled = true;
		document.getElementById("pcdc").value = "";
		
		document.getElementById("pcds").disabled = true;
		document.getElementById("pcds").value = "";
		
		document.getElementById("divbuteurs").style.display = "none";
		document.getElementById("divassists").style.display = "none";
		
		document.getElementById("divmaillons").style.display = "none";
		document.getElementById("divfloche").style.display = "none";
		
		arbitragebeforeafter(idmatch, idequipe, 'before');
	
	} else {

		// On prépare les variables		
		document.getElementById("resulthome").disabled = false;
		document.getElementById("resultaway").disabled = false;
		document.getElementById("commentaire").disabled = false;
		document.getElementById("pcoo").disabled = false;
		document.getElementById("pcoc").disabled = false;
		document.getElementById("pcdc").disabled = false;
		document.getElementById("pcds").disabled = false;
		
		document.getElementById("divbuteurs").style.display = "block";
		document.getElementById("divassists").style.display = "block";
		
		document.getElementById("divmaillons").style.display = "block";
		document.getElementById("divfloche").style.display = "block";
		
		arbitragebeforeafter(idmatch, idequipe, 'after');
	}

}
//-->
<!-- CHANGE L'OPACITE (DISPONIBILITES)-->
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
<!-- AFFICHE UN TEXTAREA POUR DETAILLER FONCTION D'UN CONTACT -->
function detailsfonction(statut) {
	
	var html="";
	
	if (statut == "open") {
	html+="<textarea name='details' rows='4' style='width: 300px;' id='details'></textarea><br />";
	html += "<label onclick=\"detailsfonction('close')\">Annuler</label>";
	} else if (statut == "close") {
	html += "<label onclick=\"detailsfonction('open')\">Plus de détails sur la fonction</label>";
	}

	document.getElementById("divdetailsfonction").innerHTML = html;
}
<!-- CHANGE L'ACCES AU CHANGEMENT DU MENU DEROULANT -->
function changeaccespage() {
	
	var html = "";
	var categorie = document.getElementById("categorie").value;
	
	if (categorie == "menupublic") {
	html+= "Cette page est visible pour tous";
	} else if (categorie == "myclub") {
	html += "Cette page est visible pour les membres du club uniquement";
	} else if (categorie == "admingenerale") {
	html += "Cette page est visible pour les administrateurs du club uniquement";
	} else {
	html += "Cette page n'est pas affichée";
	}

	document.getElementById("acces").value = html;
}
<!-- OUVRE UNE POPUP STYLISEE -->
function alertpopup(url){	

	if((url != "cancel") && (url != undefined)) {
		window.location=url;
	}
}
<!-- MONTRE LE BOUTON EDITER AU SURVOL D'UNE PHOTO DE PROFIL -->
function showboutonprofil(status){	
	
	if(status == "show") {
	document.getElementById("editphotoprofil").style.display = "block";
	} else if(status == "hide") {
	document.getElementById("editphotoprofil").style.display = "none";
	}
}
<!-- ENABLE/DISABLE PROFESSION -->
function enbableprofession(status){	
	
	if(status == "student") {
	document.getElementById("divmaprofession").style.display = "none";
	document.getElementById("divprofessionparents").style.display = "block";
	} else if (status == "autre") {
	document.getElementById("divmaprofession").style.display = "block";
	document.getElementById("divprofessionparents").style.display = "none";
	}
}
<!-- AFFICHE/CACHE LES CATEGORIES DU MODULE COMMUNICATION -->
function showhidecatcommu(show, hideorid, type){	

	if(type == "radio") {
		if(hideorid) {
		document.getElementById(hideorid).style.display = "none";
		}
		if(show) {
		document.getElementById(show).style.display = "block";
		}
	} else if (type == "checkbox") {
		if (document.getElementById(hideorid).checked == true) {
			document.getElementById(show).style.display = "block";
		} else {
			document.getElementById(show).style.display = "none";
		}	
	}
}
<!-- AFFICHE/CACHE LES TABS -->
function showhidetabs(show, nbtabs, idtabs){	

	for(i=1; i<=nbtabs; i++) {
		document.getElementById(idtabs+"-"+i).style.display = "none";
	}
	
	document.getElementById(idtabs+"-"+show).style.display = "block";
}
<!-- AFFICHE/CACHE -->
function showhide(id){	

	if(document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
		document.getElementById(id+"-buttonshow").style.display = "none";
		document.getElementById(id+"-buttonhide").style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
		document.getElementById(id+"-buttonshow").style.display = "block";
		document.getElementById(id+"-buttonhide").style.display = "none";
	}
	
}
function opentoutadresse(param) {
	
	if(param == "voirtout") {
		document.getElementById("nbemailssup").style.display = "block";
		document.getElementById("divopentoutadresse").innerHTML = "<label onclick=\"opentoutadresse('voirmoins')\" id=\"opentoutadresse\">Voir moins</label>";	
	} else if (param == "voirmoins") {
		document.getElementById("nbemailssup").style.display = "none";
		document.getElementById("divopentoutadresse").innerHTML = "<label onclick=\"opentoutadresse('voirtout')\" id=\"opentoutadresse\">Voir tout</label>";	
	}
}
/* EDIT IMAGE: Modifie l'échelle */
function defineechelle(sizepic) {
	
	var longueurorig = document.getElementById("longueurimageorig").value;
	var hauteurorig = document.getElementById("hauteurimageorig").value;
		
	if(sizepic == "miniature") {
		var newwidth = 150;
	} else if (sizepic == "moyenne") {
		var newwidth = 300;
	} else if (sizepic == "grande") {
		var newwidth = 1024;
	} else if (sizepic == "originale") {
		var newwidth = longueurorig;
	}
	
	var rapport = newwidth/longueurorig;
	var newheight = Math.round(hauteurorig*rapport);
	
	document.getElementById("longueurimage").value = newwidth;
	document.getElementById("hauteurimage").value = newheight;
}
function confirmformbycheck(){
	document.getElementById("submit").disabled = !document.getElementById("checkvalidate").checked;
}
<!-- ENABLE/DISABLE ARBITRAGE -->
function givenewarbitre(status, i){	

	if(status == "yes") {
	document.getElementById("newarbitre-"+i).style.display = "none";
	document.getElementById("recherchearbitre-"+i).value = "";
	document.getElementById("divrecherchearbitre-"+i).style.display = "none";
	document.getElementById("resultnewarbitre-"+i).style.display = "none";
	} else if (status == "no") {
	document.getElementById("idnewarbitre-"+i).value = 0;
	document.getElementById("newarbitre-"+i).style.display = "block";
	document.getElementById("recherchearbitre-"+i).value = "";
	document.getElementById("divrecherchearbitre-"+i).style.display = "none";
	document.getElementById("resultnewarbitre-"+i).style.display = "none";
	}
}
<!-- ENABLE/DISABLE ARBITRAGE -->
function arbitrepresent(status, i){	
	
	if(status == "yes") {
	document.getElementById("arbitrepresentnon-"+i).style.display = "none";
	document.getElementById("arbitrepresentoui-"+i).style.margin = "10px 0 0 0";
	} else if (status == "no") {
	document.getElementById("arbitrepresentnon-"+i).style.display = "block";
	document.getElementById("arbitrepresentoui-"+i).style.margin = "10px 0 0 25px";
	}
}
