function afficheXmlDataIlots() {
	
	var items = xmlHttpRequest.responseXML.getElementsByTagName("ilot");
	
	videTable('tabilots');

	if (items.length > 0) {
		for (var i=0; i<items.length; i++) {
			var node = items[i];
			tabLigne = new Array();
			tabLigne[0]=document.createTextNode(node.getElementsByTagName("numero")[0].firstChild.nodeValue);
			tabLigne[1]=document.createTextNode(node.getElementsByTagName("nom")[0].firstChild.nodeValue);
			objImgNode=document.createElement("img");
			objImgNode.setAttribute("src", "/www/img/icone_loupe.gif");
			objImgNode.setAttribute("alt", "option indisponible");
			
			objLinkNode = document.createElement("a");
			objLinkNode.setAttribute("href", "#");
			objLinkNode.id=node.getElementsByTagName('idilot')[0].firstChild.nodeValue;
			objLinkNode.onclick= function () { loupeilot(this.id); }			
			objLinkNode.appendChild(objImgNode);
			
			tabLigne[2]=objLinkNode;
			
			tabLigne[2]=objImgNode;
			
			objImgNode=document.createElement("img");
			objImgNode.setAttribute("src", "/www/img/icone_info.gif");
			
			objLinkNode = document.createElement("a");
			objLinkNode.setAttribute("href", "#");
			objLinkNode.id=node.getElementsByTagName('idilot')[0].firstChild.nodeValue;
			objLinkNode.onclick= function () { tabulaireilot(this.id); }			
			objLinkNode.appendChild(objImgNode);		
			
			tabLigne[3]=objLinkNode;
			tabLigne[4]=document.createTextNode(node.getElementsByTagName("surfacetotale")[0].firstChild.nodeValue);
			
			// Remplissage des types de sol possibles pour chaque îlot
			objSelectNode = document.createElement("select");
			objSelectNode.id = node.getElementsByTagName("indice")[0].firstChild.nodeValue;
			objSelectNode.onchange = function ()  { updateilot(this.id, this.value); }
			
			// Ajout d'une ligne vide si le type n'est pas déterminé
			if (node.getElementsByTagName("typesolid")[0].firstChild.nodeValue==0) {
								objOptionNode=document.createElement("option");				
								objOptionNode.value = 0;
								objOptionNode.selected = true; 
								objOptionNode.appendChild(document.createTextNode(""));
								objSelectNode.appendChild(objOptionNode);
			}
			
			objTypesSol = node.getElementsByTagName("typesolpossible");
			for (var j=0; j<objTypesSol.length; j++) {
				var objTypeSol = objTypesSol[j];
				
				objOptionNode=document.createElement("option");
				objOptionNode.value = objTypeSol.getElementsByTagName("id")[0].firstChild.nodeValue;
							
				// Si c'est le type de sol attribué à cette parcelle, on positionne la combo à cette valeur
				if (node.getElementsByTagName("typesolid")[0].firstChild.nodeValue==objOptionNode.value) {
					 objOptionNode.selected = true; 
				}
				strLib = objTypeSol.getElementsByTagName("libelle")[0].firstChild.nodeValue;
				strLib = strLib.replace('++','>');
				strLib = strLib.replace('--','<');	
				
				var strEspace = " - ";
				objOptionNode.appendChild(document.createTextNode(strLib + strEspace + objTypeSol.getElementsByTagName("rendement")[0].firstChild.nodeValue));
				objSelectNode.appendChild(objOptionNode);
			}
			
			tabLigne[5]=objSelectNode;
			ajoutLigneTable('tabilots', tabLigne);
		}
		//affichage du bouton calculer
		document.getElementById("bouton_val").style.visibility="visible";
	}
	// Aucun ilot
	else {
		document.getElementById("msgbas").innerHTML="Aucun îlot à afficher."
	}
}

function updateilot(plngIdilot, plngIdtypesol) {
	chargeXml("/www/ppf/updateilot.php?id=" + plngIdilot + "&idtypesol=" + plngIdtypesol, "tabilots")
}

function loupeilot(plngIdilot) {
	window.open('/portail_base/index.php?rubrique=carte&page=cartelight&project=bdsollight&typecarte=ilot&idcarte='+plngIdilot,'LoupeIlot', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=800,height=600');
}

function tabulaireilot(plngIdilot) {
	window.open('./index.php?page=listeilotslight&id_ilot='+plngIdilot,'TabulaireIlot', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=800,height=600');
}


function valideilots() {
		
	// Vérification qu'une autre requête serveur n'existe pas
	if (document.getElementById("statusZone").style.visibility == 'hidden') {
		chargeXml("/www/ppf/valideilots.php","valide");
	}
}


