function $(id){
	return document.getElementById(id);
}

function change_hauteur(id,hauteur){
	$(id).style.height=hauteur+"px";
}

//Envoie une requête ajax au fichier "fichier", retourne un objet xhr_object
function ajax(fichier){
	var xhr_object = null;
	if(window.XMLHttpRequest) // Firefox
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}

	xhr_object.open("GET", fichier, true);
	return xhr_object;
}

//Envoie une commande
function commande(cmd,cmd_second,arg){
	if(!cmd_second)
		cmd_second="";
	if(!arg)
		arg="";
	$(cmd).innerHTML="<center><img src=\"images/ajax-loader.gif\" alt=\"ajax loader\"/></center>";
	var xhr_object=ajax("commandes.php?commande="+cmd+cmd_second+"&arg="+arg);
	xhr_object.onreadystatechange = function() {
		if(xhr_object.readyState == 4){
			$(cmd).innerHTML=xhr_object.responseText;
		}
	}
	xhr_object.send(null);
}

//Change un quart d'heure d'une horloge
function change_horloge(td,numhorloge,heure){
	if(td.className=="hoff"){
		td.className="hon";
		etat=1;
	}else{
		td.className="hoff";
		etat=0;
	}
	var xhr_object=ajax("commandes.php?commande=horloge&numhorloge="+numhorloge+"&heure="+heure+"&etat="+etat);
	xhr_object.send(null);
	
}
