function ajax(pSelect,tag_name)
{
    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,tag_name); };
    
    //on appelle le fichier reponse.php

//	progserveur = "http://127.0.0.1:8082/SiteFBC-BBR/FR/Introduction/RDLocalite.php?commune="+ pSelect.options[pSelect.selectedIndex].value;
	progserveur = "RDLocalite.php?commune="+ pSelect.options[pSelect.selectedIndex].value;
     xhr.open("GET", progserveur, true);
    xhr.send(null);
}

function alert_ajax(xhr, tag_name)
{
	var docXML= xhr.responseXML;
	var items = docXML.getElementsByTagName(tag_name); // ex: <Localite>  => Localite
	var itemsvalue = docXML.getElementsByTagName('ID'); // ex: <Localite>  => Localite
	//on fait juste une boucle sur chaque element "Localite" trouvé
	for (i=0;i<items.length;i++)
	{
		id = itemsvalue.item(i).firstChild.data;
		p = items.item(i).firstChild.data;
		j = ajouter(id,p,i);
	}
}
function ajouter(id,p,i) {
 		nouvel_element = new Option(p,p,false,true);
		document.IDENTMBR.IDLocalite.options[i+1] = nouvel_element;
document.IDENTMBR.IDLocalite.options[i+1].value = id; // Valeur de l'Id de la localité
document.IDENTMBR.IDLocalite.selectedIndex = 0; // Selection de la premiere Option ?
}


