function getHTTPObject() {
	// Native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		try { connexion = new XMLHttpRequest(); } catch(e) { connexion = false; }
	// IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		try { connexion = new ActiveXObject("Msxml2.XMLHTTP"); } 
		catch(e) { 
			try { connexion = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { connexion = false; }
		}
	}

	if (connexion) {
		connexion.onreadystatechange = function() {
		if ( connexion.readyState == 4 && connexion.status == 200) {
			// récupère les données envoyées
			elements = connexion.responseText.split('@@');
			var tabResultat = new Array();
			for (var i = 0; i < elements.length; i++) {
				temp = elements[i].split("=");
				tabResultat[i] = new Array(temp[0], unescape(temp[1]));
				};
			comboCourse = document.getElementById("manche");
			comboCla = document.getElementById("class");
			comboCourse.options.length = 0;
			// aucun classement dispo
			if ( tabResultat.length == 1 ) {
				comboCourse.options[comboCourse.options.length] = new Option("---Pas de courses pour " + comboCla.options[comboCla.selectedIndex].text + "---",0);
				comboCourse.options[0].style.color = "#FF0000";
				}
			// 1 seul classement : choix automatique
			if ( tabResultat.length == 2 ) {
				comboCourse.options[comboCourse.options.length] = new Option(tabResultat[0][0],tabResultat[0][1]);
				}
			// plusieurs classements : liste
			if ( tabResultat.length > 2 ) {
				// remise à zéro combo
				if ( comboCla.value > 0 )
					comboCourse.options[comboCourse.options.length] = new Option("---Choix course pour " + comboCla.options[comboCla.selectedIndex].text + "---",0);
					else
					comboCourse.options[comboCourse.options.length] = new Option("---Courses disponibles---",0);
				for (var i = 0; i < tabResultat.length-1; i++) {					
					comboCourse.options[comboCourse.options.length] = new Option(tabResultat[i][0],tabResultat[i][1]);
					}
				};
			}
		}
	}
	return connexion;
};

// changement de la combo des classements
function testClass(course) {
	comboClass = document.getElementById("class");
	if ( comboClass.value > 0 )
		return !sendData("ajax_classements.php","course=" + course + "&class=" + comboClass.value);

	};

 
 function sendData(url, data) {
	var connexion = getHTTPObject();
	if ( !connexion ) {
	        alert("Erreur object AJAX");
	        return false;	        
		}
		else
		{
		connexion.open("POST", url, true); //ouverture asynchrone
		connexion.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		connexion.send(data);
		};	
	return true;
	};
