//	code commun à tous les scripts
//	GW 05/2010


	<!--  	Affichage du parcours GPX à l'aide du service s2s_gm.php
	//-->
	function rech_parc_gpx (parc,div){
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='s2s_gm.php?parc='+parc+'&tm='+timestamp;
		var oUl=document.getElementById(div);
		var oImg=document.getElementById('img_wait');
		var value=4;
		oUl.style.opacity = value/10;
		oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
		oImg.style.visibility = 'visible';

		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				oUl.innerHTML = xhr.responseText;
				value=10;
				oUl.style.opacity = value/10;
				oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
				oImg.style.visibility = 'hidden';
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}


	<!--  	Affichage et Mise à jour du co voiturage à l'aide du service s2s_co_voit.php
	//-->
	function maj_co_voit (uid,act,besoin,part_uid,div,nbplaces){
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_co_voit.php?evt=sortie&act='+act+'&bes='+besoin+'&uid='+uid+'&part_uid='+part_uid+'&nbp='+nbplaces+'?'+timestamp;
		var oUl=document.getElementById(div);
		var oImg=document.getElementById('img_wait');
		var value=4;
		oUl.style.opacity = value/10;
		oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
		oImg.style.visibility = 'visible';

		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				oUl.innerHTML = xhr.responseText;
				value=10;
				oUl.style.opacity = value/10;
				oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
				oImg.style.visibility = 'hidden';
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}


	<!--  	Affichage de la liste des passagers d'un chauffeur du co voiturage à l'aide du service s2s_co_voit.php
	//-->
	function aff_co_voit (uid,act,besoin,part_uid,div,event){
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_co_voit.php?evt=sortie&act='+act+'&bes='+besoin+'&uid='+uid+'&part_uid='+part_uid+'&nbp=0&rnd='+timestamp;
		var oUl=document.getElementById(div);

		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				oUl.innerHTML = xhr.responseText;
				oUl.style.visibility = 'visible';
				var fct='masque_co_voit(\''+div+'\')';
				setTimeout (fct,5000);
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}
	function masque_co_voit(div){
		var oUl=document.getElementById(div);
		oUl.style.visibility = 'hidden';
	}

//	lib/aff-parc.php
	function aff_parc_enter(onglet){
		a=document.formsel.parcours.value+document.formsel.AR.value+document.formsel.HE.value;
		document.formsel.parc.value=a;
		if (onglet){document.formsel.o.value=onglet;}
		document.formsel.submit();
	}

//	lib/inscr_sortie.php
	<!--  Accès au service par XMLHTTPREQUEST
	//-->
	function getXhr(url){
		var xhr=null;
		
		if(window.XMLHttpRequest) // Firefox et autres
			xhr = new XMLHttpRequest();
		else if(window.ActiveXObject){ // Internet Explorer
		try {
			xhr = new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e) {
		try {
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e1) {
		xhr = null;
		}
		}
		}
		else { // XMLHttpRequest non supporté par le navigateur
		alert('Le navigateur ne supporte pas les objets XMLHTTPRequest - installer la dernière version du navigateur...');
		}
		return xhr;
	}

	function change_value(bt){
		textOk="Annuler";textKo="S'incrire";
		if (bt.value==textOk){
			return textKo;
		}else{
			return textOk; 
		}
	}


	<!--  	Création dynamique du contenu à l aide du service s2s_inscr.php
	<!--	index= destination du code (ixx inscrits, bxx bouton)
	//-->
	function inscr_sortie_aff_insc(act,besoin,uid,index,nbplaces){
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_inscr_sortie.php?evt=sortie&act='+act+'&bes='+besoin+'&uid='+uid+'&nbp='+nbplaces+'?'+timestamp;
		var oUl=document.getElementById('i'+index);
		var value=4;
		oUl.style.opacity = value/10;
		oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			oUl.innerHTML = xhr.responseText;
			var value=10;
			oUl.style.opacity = value/10;
			oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
				if (act=='can'){
					document.getElementById('bti'+index).style.visibility='visible';
					document.getElementById('bta'+index).style.visibility='hidden';
					if (!(document.getElementById('btco'+index) == null)){document.getElementById('btco'+index).style.visibility='hidden';}
				}
				if (act=='reg'){
					document.getElementById('bti'+index).style.visibility='hidden';
					document.getElementById('bta'+index).style.visibility='visible';
					if (!(document.getElementById('btco'+index) == null)){document.getElementById('btco'+index).style.visibility='visible';}
				}
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}

//	lib/inscr_sortie_coll.php

	<!--  	Création dynamique du contenu à l aide du service s2s_inscr.php
	<!--	index= destination du code (ixx inscrits, bxx bouton)
	//-->
	function inscr_sortie_coll_aff_insc(act,besoin,index){
		if (document.getElementById("m_uid").innerHTML=='x'){
			alert ('Sélectionnez d abord un membre');
			exit;
		}
		
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_inscr_sortie.php?evt=sortie&act='+act+'&bes='+besoin+'&uid='+document.getElementById("m_uid").innerHTML+'&nbp=999?'+timestamp;
		var oUl=document.getElementById('i'+index);
		var value=4;
		oUl.style.opacity = value/10;
		oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			oUl.innerHTML = xhr.responseText;
			var value=10;
			oUl.style.opacity = value/10;
			oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}
	

	<!--  	Mise à jour de la table programme à l'aide du service s2s_maj_prog.php
	<!--	index= id de la destination des informations retournées
	//-->
	function inscr_sortie_coll_maj_prog(act,value,uid,index, user){
		
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_maj_prog.php?evt=sortie&act='+act+'&uid='+uid+'&value='+value+'&user='+user+'&nbp='+timestamp;
		var oUl=document.getElementById('aff_'+act);
		var opacity=4;
		oUl.style.opacity = opacity/10;
		oUl.style.filter = 'alpha(opacity=' + opacity*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			var opacity=10;
			oUl.innerHTML = value;
			alert(xhr.responseText);
			oUl.style.opacity = opacity/10;
			oUl.style.filter = 'alpha(opacity=' + opacity*10 + ')';
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}
	
	function inscr_sortie_coll_sel(nom,prenom,uid){
		document.getElementById("m_nom").innerHTML=nom;
		document.getElementById("m_pre").innerHTML=prenom;
		document.getElementById("m_uid").innerHTML=uid;
		
	}



	<!--  	Envoi d'un SMS en cas de création et d'annulation d'inscription à un atelier technique
	<!--	atelier/s2s_inscr.php
	function atelier_send_sms(sentTo,act,evt,besoin,nom, prenom){
	}


	<!--  	Création dynamique du contenu à l aide du service
	<!--	atelier/s2s_inscr.php
	<!--	inscription ou désinscription à un atelier technique
	//-->
	function atelier_aff_insc(act,evt,besoin,uid,index,nbplaces){
		var s2s='club/atelier/s2s_inscr.php?evt='+evt+'&act='+act+'&bes='+besoin+'&uid='+uid+'&nbp='+nbplaces +'&nocache='+Math.random();
		var oUl=document.getElementById('i'+index);
		var value=4;
		oUl.style.opacity = value/10;
		oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			oUl.innerHTML = xhr.responseText;
			var value=10;
			oUl.style.opacity = value/10;
			oUl.style.filter = 'alpha(opacity=' + value*10 + ')';
				if (act=='can'){
					document.getElementById('bti'+index).style.visibility='visible';
					document.getElementById('bta'+index).style.visibility='hidden';
				}
				if (act=='reg'){
					document.getElementById('bti'+index).style.visibility='hidden';
					document.getElementById('bta'+index).style.visibility='visible';
				}
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}

	

	<!--  	Mise à jour de la table votes_resultats à l'aide du service s2s_vote.php
	<!--	retour= nombre de votes pour le choix
	//-->
	function vote_go(evt,choix,uid){
		
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var check=document.getElementById('check_'+choix);
		var act=(check.checked)?"reg":"can";
		var s2s='lib/s2s_vote.php?evt='+evt+'&uid='+uid+'&choix='+choix+'&act='+act+'&nbp='+timestamp;
		var votes_choix=document.getElementById('nb_voix_'+choix);
		var mes_choix=document.getElementById('mes_choix');
		var nb_votants=document.getElementById('nb_votants');
		var nb_votes=document.getElementById('nb_votes');
		var opacity=4;
		check.style.opacity = opacity/10;
		check.style.filter = 'alpha(opacity=' + opacity*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			var opacity=10;
			var resultat=xhr.responseText.split('&');
			votes_choix.innerHTML = resultat[0];
			mes_choix.innerHTML = 'Mes choix (<font color=red>'+resultat[1]+'</font>)';
			nb_votants.innerHTML = resultat[2];
			nb_votes.innerHTML = resultat[3];
			check.style.opacity = opacity/10;
			check.style.filter = 'alpha(opacity=' + opacity*10 + ')';
			votes_choix.style.fontWeight='bold';
			votes_choix.style.color='red';
			nb_votants.style.color='red';
			nb_votants.style.fontWeight='bold';
			nb_votes.style.color='red';
			nb_votes.style.fontWeight='bold';
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}
	

	<!--  	Founit la liste des électeurs d'une sortieà l'aide du service s2s_vote.php
	<!--	retour= nombre de votes pour le choix
	//-->
	function vote_qui(evt,choix){
	
		var timestamp = Math.floor((new Date()).getTime() / 1000);
		var s2s='lib/s2s_vote.php?evt='+evt+'&choix='+choix+'&act=qui&nbp='+timestamp;
		var table_choix=document.getElementById('table_choix');
		var opacity=4;
		table_choix.style.opacity = opacity/10;
		table_choix.style.filter = 'alpha(opacity=' + opacity*10 + ')';
		
		var xhr = getXhr()
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){

			var opacity=10;
			table_choix.style.opacity = opacity/10;
			table_choix.style.filter = 'alpha(opacity=' + opacity*10 + ')';
			alert(xhr.responseText);
			}
		}
		xhr.open('GET',s2s,true);
		xhr.send(null);
		return false;
	}



