function ajax_traitement(valeur,nom_script_php,param_php,nom_id,nature,action)
{
    var xhr=null;
    
    if (window.XMLHttpRequest) { 
        xhr = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) 
    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //on définit l'appel de la fonction au retour serveur
    xhr.onreadystatechange = function() { 
	alert_ajax(xhr,nom_id,nom_script_php,param_php,nature,action); 
    };

	if (nom_script_php != '')
		xhr.open("GET", nom_script_php+'?param='+valeur+param_php, true);
    xhr.send(null);

	if (nom_script_php == 'ajax_refresh.php')
	    setTimeout("ajax_traitement('','ajax_refresh.php','','"+nom_id+"','','')", 1000);

}

function alert_ajax(xhr,nom_id,nom_script_php,param_php,nature,action)
{
    if (xhr.readyState==4) 
    {
    	var docXML= xhr.responseXML;
    	var items = docXML.getElementsByTagName("donnee")

	if (nom_script_php == 'ajax_communautes.php') {
		document.getElementById("id_service").className="nonaffiche";
		document.getElementById("id_fonction").className="nonaffiche";
		document.getElementById("id_influence").className="nonaffiche";
	}

	if (nom_script_php == 'ajax_services.php') {
		document.getElementById("id_service").className="affiche";
		document.getElementById("id_fonction").className="nonaffiche";
		document.getElementById("id_influence").className="nonaffiche";
	}

	if (nom_script_php == 'ajax_fonctions.php') {
		document.getElementById("id_fonction").className="affiche";
		document.getElementById("id_influence").className="nonaffiche";
	}

	if (nom_script_php == 'ajax_decideurs.php') {
		document.getElementById("id_influence").className="affiche";
	}
	
	if (action == 'suppr') {
		if ((nature == 'populations') || (nature == 'motscles') || (nature == 'themes') || (nature == 'rubriques') || (nature == 'sousrubriques') || (nature == 'typesdocuments'))
			document.getElementById("checkbox_"+nom_id).className="nonaffiche";
		document.getElementById("suppr_"+nom_id).className="nonaffiche";
		document.getElementById("reactive_"+nom_id).className="affiche";
	}
	else 
		if (action == 'reactive') {
			if ((nature == 'populations') || (nature == 'motscles') || (nature == 'themes') || (nature == 'rubriques') || (nature == 'sousrubriques') || (nature == 'typesdocuments'))
				document.getElementById("checkbox_"+nom_id).className="affiche";
			document.getElementById("suppr_"+nom_id).className="affiche";
			document.getElementById("reactive_"+nom_id).className="nonaffiche";
		}
		else
			if (action == 'affichage_simple') {
				document.getElementById(nom_id).className="affiche";
				document.getElementById(nom_id+"_on").className="nonaffiche";
			}

   	for (i=0;i<items.length;i++)
    	{
		if (i == 0)
			document.getElementById(nom_id).innerHTML =items.item(i).firstChild.data;
		else 
			if (nom_script_php == 'ajax_visu_membre.php') // Case + -
				document.getElementById("detail_"+nom_id).innerHTML =items.item(i).firstChild.data;
			else
			// seul cas où il y a plus de données renvoyées : maj de la zone de recherche ; mise à jour de la combo suivante ET de la zone de résultats de recherche
				document.getElementById("resultats_recherche").innerHTML =items.item(i).firstChild.data;
    	}
  }
}

function form_focus(nom_form,champ) {
	document.nom_form.champ.focus();
 }

var Timer=null;
var Pas=3;
function moveLayer(Sens,contenu,support) {

	if (contenu) { 
		varcontenu=contenu;
		varsupport=support;
	}

   var Objet=document.getElementById(varcontenu);
    if(parseInt(Objet.style.top) + (Pas*Sens)>0)  {
      clearTimeout(Timer);
   }
   else if(parseInt(Objet.style.top) + (Pas*Sens)<-(Objet.offsetHeight-document.getElementById(varsupport).offsetHeight)) {
      clearTimeout(Timer);
   }
    else {
        Objet.style.top = (parseInt(Objet.style.top) + (Pas*Sens)) + "px";
   }
   Timer = setTimeout("moveLayer(" + Sens + ");", 30);
}
