function afficheXmlDataParcelles() {
	var nbparcelle = 0;
	var typeAction = 1;
	var items = xmlHttpRequest.responseXML.getElementsByTagName("parcelle");

	videTable('tabparcelles');

	if (items.length > 0) {
		//Millesime 
		var node = items[0];
		var millesime=node.getElementsByTagName("millesime")[0].firstChild.nodeValue;
		var typedev="";
		var typecult="";
		var strlib="";
		
		var strOpt = node.getElementsByTagName("type")[0].firstChild.nodeValue;
		
		for (var i=0; i<items.length; i++) {
			var node = items[i];
			tabLigne = new Array();
			
			tabLigne[0]=document.createTextNode(node.getElementsByTagName("numilot")[0].firstChild.nodeValue);
			tabLigne[1]=document.createTextNode(node.getElementsByTagName("nomilot")[0].firstChild.nodeValue);
			tabLigne[2]=document.createTextNode(node.getElementsByTagName("nomparc")[0].firstChild.nodeValue);

			//Loupe d'affichage des parcelles
			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('idparc')[0].firstChild.nodeValue;
			objLinkNode.onclick= function () { loupeparcelle(this.id); }			
			objLinkNode.appendChild(objImgNode);

			tabLigne[3]=objLinkNode;
			tabLigne[3]=objImgNode;

			//information
			objImgNode=document.createElement("img");
			objImgNode.setAttribute("src", "/www/img/icone_info.gif");

			objLinkNode = document.createElement("a");
			objLinkNode.setAttribute("href", "#");
			objLinkNode.id=node.getElementsByTagName('idparc')[0].firstChild.nodeValue;
			objLinkNode.onclick= function () { tabulaireparcelle(this.id); }
			objLinkNode.appendChild(objImgNode);

			tabLigne[4]=objLinkNode;
			
			tabLigne[5]=document.createTextNode(node.getElementsByTagName("surface")[0].firstChild.nodeValue);
			
			//Vérification du mode parcelle cultural  ou prairie
			if (strOpt=="cultural"){
				//typedev=node.getElementsByTagName("devel")[0].firstChild.nodeValue;
				
				//Type de culture Colza ou non
				typecult=node.getElementsByTagName("typeppf")[0].firstChild.nodeValue; 
				
				//Affichage des infos des parcelles en cultural
				tabLigne[6]=document.createTextNode(node.getElementsByTagName("precedent")[0].firstChild.nodeValue);
				tabLigne[7]=document.createTextNode(node.getElementsByTagName("paille")[0].firstChild.nodeValue);
				strLib = node.getElementsByTagName("colza")[0].firstChild.nodeValue;
				strLib = strLib.replace('++','>');
				strLib = strLib.replace('--','<');	
				tabLigne[8]=document.createTextNode(strLib);
				tabLigne[9]=document.createTextNode(node.getElementsByTagName("prairie")[0].firstChild.nodeValue);
				tabLigne[10]=document.createTextNode(node.getElementsByTagName("apport ")[0].firstChild.nodeValue);
				

				//Zone Affecter
				//objTextNode = document.createTextNode(node.getElementsByTagName("libelle")[0].firstChild.nodeValue);
				if (node.getElementsByTagName("libelle")[0].firstChild.nodeValue=="Affecter"){
					//Zone objectif en affichage 
					tabLigne[11]=document.createTextNode(node.getElementsByTagName("objectif")[0].firstChild.nodeValue);
			
					objTextNode = document.createTextNode(node.getElementsByTagName("libelle")[0].firstChild.nodeValue);
					typeAction = 0;
				}else{	
					//Zone objectif en saisie
					objInputNode=document.createElement("input");
					if (node.getElementsByTagName("objectif")[0].firstChild.nodeValue!='-'){
						objInputNode.value=(node.getElementsByTagName("objectif")[0].firstChild.nodeValue);
					}else{objInputNode.value=''};
					objInputNode.id=node.getElementsByTagName('indice')[0].firstChild.nodeValue;
					objInputNode.onchange= function () { updateobjectif(this.id,this.value); }			
					tabLigne[11]=objInputNode;
					
					objTextNode=document.createElement("img");
					objTextNode.setAttribute("src", "/www/img/icone_gomme.gif");
					objTextNode.title="Effacer la ligne";
					
				}
				objLinkNode = document.createElement("a");
				objLinkNode.setAttribute("href", "#");
				objLinkNode.id=node.getElementsByTagName('indice')[0].firstChild.nodeValue;
				objLinkNode.value=(node.getElementsByTagName("libelle")[0].firstChild.nodeValue);
				objLinkNode.onclick= function () { updateparcelleCulture(this.id,this.value); }			
				objLinkNode.appendChild(objTextNode);
				tabLigne[12]=objLinkNode;
				
				//Ajout dans la table Parcelles				
				ajoutLigneCultures('tabparcelles', tabLigne);
				nbparcelle++;

			}else{
				//Affichage des infos en mode prairie
				//Recheche des caractères spéciaux 
				strLib = node.getElementsByTagName("modeexpl")[0].firstChild.nodeValue;
				strLib = strLib.replace('++','>');
				strLib = strLib.replace('--','<');
				//strLib = strLib.replace('&acirc;','â');					
				strLib = strLib.replace('+-99','â');					
				tabLigne[6]=document.createTextNode(strLib);
				
				tabLigne[7]=document.createTextNode(node.getElementsByTagName("apport ")[0].firstChild.nodeValue);
				//Zone Affecter
				if (node.getElementsByTagName("libelle")[0].firstChild.nodeValue=="Affecter"){
					objTextNode = document.createTextNode(node.getElementsByTagName("libelle")[0].firstChild.nodeValue);
				}else{	
					objTextNode=document.createElement("img");
					objTextNode.setAttribute("src", "/www/img/icone_gomme.gif");
					objTextNode.title="Effacer la ligne";
				}
				objLinkNode = document.createElement("a");
				objLinkNode.setAttribute("href", "#");
				objLinkNode.id=node.getElementsByTagName('indice')[0].firstChild.nodeValue;
				objLinkNode.value=(node.getElementsByTagName("libelle")[0].firstChild.nodeValue);
				objLinkNode.onclick= function () { updateprairie(this.id,this.value); }			
				objLinkNode.appendChild(objTextNode);
				tabLigne[8]=objLinkNode;
				
				//Ajout dans la table Parcelles				
				ajoutLigneTable('tabparcelles', tabLigne);
				nbparcelle++;

			}
/*			//Ajout dans la table Parcelles				
			ajoutLigneTable('tabparcelles', tabLigne);
			nbparcelle++;*/
		}
	}

	//Vérification chargement de la table
	if (nbparcelle > 0) {		
		document.getElementById("saisieculture").style.visibility = 'visible';
		//document.getElementById("msgCampagne").innerHTML="Liste des parcelles pour la campagne "+millesime;		
		
		//Affichage du bouton calcul
		document.getElementById("bt_calcul").style.visibility = 'visible';
		
		if (strOpt=='cultural'){
			//document.getElementById("libdev").innerHTML=typedev;	

			items = xmlHttpRequest.responseXML.getElementsByTagName("ligne");
			if (items.length>0){
				var node = items[0];
				var verifId=node.getElementsByTagName("id")[0].firstChild.nodeValue;
				if (verifId==0){
					videCombo('cboObjectif');
					document.getElementById("msgretour").className="succes";
					document.getElementById("msgretour").innerHTML="Attention, aucun objectif de rendement référencé."		
				}else{
					//Pour le mode cultural affichage de la combo 
					afficheXmlCombo('cboObjectif');
					
					typedev=node.getElementsByTagName("unite")[0].firstChild.nodeValue;
					document.getElementById("libdev").innerHTML=typedev;	
					
				}	
			}else{
				document.getElementById("msgretour").innerHTML=""
			}
				
			if (typecult=='C'){
				//Chargement de la combo de développement Colza				
				if (document.getElementById("cboColza").style>0){
                	videCombo('cboColza');
				}
				
				items = xmlHttpRequest.responseXML.getElementsByTagName("lignec");
				if (items.length>0){
				    videCombo('cboColza');
                    afficheXmlColza('');
                }	
				
				document.getElementById("libColza").style.visibility = 'visible';
				document.getElementById("cboColza").style.visibility = 'visible';
			}else{
				document.getElementById("libColza").style.visibility = 'hidden';
				document.getElementById("cboColza").style.visibility = 'hidden';	
			}	
		}
		if(typeAction == 1){
			document.getElementById('libaffec').firstChild.nodeValue='Effacer';
		}
		document.getElementById("msgbas").innerHTML="";
		
	}else {
		//Aucune culture
		document.getElementById("msgbas").innerHTML="Aucune parcelle ne correspond à vos critères de recherche.";
	}	
}

/*****************************************************************************************/
/*Fonction pour la Calcul dose n Parcelle en culture */

//Mise à jour des informations d'une ligne parcelle culturale
function updateparcelleCulture(plngIndice,pstrTraitement) {
	var paille=0;
	var colza =0;
	var prairie=0;
	var apport = 0;
	var objectif =0;
	if (pstrTraitement=='Affecter'){
		var paille = document.forms['saisie_culture'].cboPaille.value;
		var colza = document.forms['saisie_culture'].cboColza.value;
		var prairie = document.forms['saisie_culture'].cboPrairie.value;
		var apport = document.forms['saisie_culture'].cboApport.value;
		var objectif = document.forms['saisie_culture'].cboObjectif.value;
	}
	/*alert('indice: ' + plngIndice);
	alert('paille: ' + paille);
	alert('colza: ' + colza);
	alert('prairie: ' + prairie);
	alert('apport: ' + apport);
	alert('objectif: ' + objectif);*/
	//window.open("/www/ppf/updateparcelle.php?indice="+plngIndice+"&paille="+paille+"&colza="+colza+"&prairie="+prairie+"&apport="+apport+"&objectif="+objectif+"&trt="+pstrTraitement,"parcelles");
	chargeXml("/www/ppf/updateparcelle.php?indice="+plngIndice+"&paille="+paille+"&colza="+colza+"&prairie="+prairie+"&apport="+apport+"&objectif="+objectif+"&trt="+pstrTraitement,"parcelles");
}

//Mise à jour de la zone Objectif sur une ligne parcelle
function updateobjectif(plngIndice,pintobjectif) {
	//Vérification valeur saisie
	var intnbObj =  document.forms['saisie_culture'].cboObjectif.length-1;
	if (intnbObj > 0){ 
		var intMinObj = document.forms['saisie_culture'].cboObjectif[0].value;
		var intMAxObj = document.forms['saisie_culture'].cboObjectif[intnbObj].value;
		//Vérification valeur saisi dans la fourchette
		if ((pintobjectif>=intMinObj) && (pintobjectif<=intMAxObj)){
			chargeXml("/www/ppf/updateparcelle.php?indice="+plngIndice+"&objectif="+pintobjectif+"&trt=Objectif", "parcelles");
		}else	{
			document.getElementById("msgretour").className="erreur";
			document.getElementById("msgretour").innerHTML="L'objectif de rendement doit être compris entre "+intMinObj+" et "+intMAxObj;	
		}
	}else{	
		document.getElementById("msgretour").className="succes";
		document.getElementById("msgretour").innerHTML="Impossible de calculer la dose N, référence objectif de rendement inconnu.";
	}
}

//Mise à jour de toutes les lignes parcelles - Culture
function updateListe(){
	//Affectation des données saisies dans toutes la liste
	var paille = document.forms['saisie_culture'].cboPaille.value;
	var colza = document.forms['saisie_culture'].cboColza.value;
	var prairie = document.forms['saisie_culture'].cboPrairie.value;
	var apport = document.forms['saisie_culture'].cboApport.value;
	var objectif = document.forms['saisie_culture'].cboObjectif.value;
	var trt=document.getElementById('libaffec').firstChild.nodeValue
	
	switch (document.getElementById('libaffec').firstChild.nodeValue){
		case "Affectation":
			trt="AffecterTout";
			document.getElementById('libaffec').firstChild.nodeValue='Effacer';
			break;
			
		case "Effacer":
			trt="EffacerTout";
			document.getElementById('libaffec').firstChild.nodeValue='Affectation';				
			break;
	}
	chargeXml("/www/ppf/updateparcelle.php?paille="+paille+"&colza="+colza+"&prairie="+prairie+"&apport="+apport+"&objectif="+objectif+"&trt="+trt, "parcelles");
}

//****************************************************************
//* Calcul Dose N - Autre que Prairie                            *
//* VérifSaisie : Véficiation des critères de recherche          *
//**************************************************************** 
function verifsaisie(pintIdExploit){
	//Vérification des informations saisies pour la recherche des parcelles
	if ((document.forms['saisie_culture'].cboCult.value!=0)&&(document.forms['saisie_culture'].cboSol.value!=0)){
		document.getElementById("msgretour").innerHTML=""
		// Affichage du sablier
		document.getElementById("statusZone").style.visibility = 'visible';

		var param = "&mode=cultural"	
		param = param + '&idculture='+document.forms['saisie_culture'].cboCult.value;
		param = param + '&idsol='+document.forms['saisie_culture'].cboSol.value;
		param = param + '&idprec='+document.forms['saisie_culture'].cboPrec.value;
		param = param + '&idparc='+document.forms['saisie_culture'].cboParc.value;
		param = param + '&idilot='+document.forms['saisie_culture'].cboIlot.value;
		param = param + '&newrech=1';
		
	//Suppression d'un éventuel message
	document.getElementById("msgbas").innerHTML=""
	
	// Vidage de l'éventuel  combo des colza
    /*if (document.getElementById("cboColza")){
		videCombo('cboColza');
	} */
		
		//Appel du traitement d'affichage de la liste des parcelles
		afficheListe('numilot','parcelles',param);
		
	}else{	
		document.getElementById("msgretour").className="erreur";
		document.getElementById("msgretour").innerHTML="Sélection d'une culture et d'un type de sol obligatoire!"	
	}
}
//****************************************************************
/*****************************************************************************************/

function afficheXmlDataParcellesDetSol() {
	var items = xmlHttpRequest.responseXML.getElementsByTagName("parcelle");
	
	videTable('tabparcellesdetsol');

	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("numilot")[0].firstChild.nodeValue);
			tabLigne[1]=document.createTextNode(node.getElementsByTagName("nomparc")[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('idparc')[0].firstChild.nodeValue;
			//objLinkNode.onclick= function () { loupeparcelle(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('idparc')[0].firstChild.nodeValue;
			objLinkNode.onclick= function () { tabulaireparcelle(this.id); }
			objLinkNode.appendChild(objImgNode);

			tabLigne[3]=objLinkNode;

			tabLigne[4]=document.createTextNode(node.getElementsByTagName("surface")[0].firstChild.nodeValue);

			// Remplissage des types de sol possibles pour chaque parcelle
			objSelectNode = document.createElement("select");
			objSelectNode.id = node.getElementsByTagName("indice")[0].firstChild.nodeValue;
			objSelectNode.onchange = function ()  { updateparcelle(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('tabparcellesdetsol', tabLigne);
		}
		//affichage du bouton calculer
		document.getElementById("bouton_val").style.visibility="visible";
	}	
	// Aucune parcelle 
	else {
		document.getElementById("msgbas").innerHTML="Aucune parcelle à afficher."
	}
}

function updateparcelle(plngIdparcelle, plngIdtypesol) {
	chargeXml("/www/ppf/updateparcelledetsol.php?id=" + plngIdparcelle + "&idtypesol=" + plngIdtypesol, "tabparcelles")
}

function loupeparcelle(plngIdParcelle) {
	window.open('index.php?rubrique=carte&page=cartelight&project=bdsollight&typecarte=parcelle&idcarte='+plngIdParcelle,'LoupeIlot', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=900,height=600');
}

function tabulaireparcelle(plngIdparcelle) {
	//window.open('./index.php?page=listeparcelleslight&idcarte='+plngIdParcelle,'TabulaireParcelle', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=800,height=600');
  window.open('index.php?page=ficheParcellelight&idParcelle='+plngIdparcelle,'TabulaireParcelle', 'directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=800,height=600');	
}

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

/*********************************************************************************************
/* Traitement pour calcul Dose N sur les prairies */
//Affectation des zones de saisie Prairie pour UNE ligne
function updateprairie(plngIndice,pstrTraitement){
	var modeexpl=0;
	var apport = 0;

	if (pstrTraitement=='Affecter'){
		var modeexpl = document.forms['saisie_culture'].cboMode.value;
		var apport = document.forms['saisie_culture'].cboApport.value;
		if ((modeexpl==0) || (apport==0)){
			document.getElementById("msgretour").className="erreur";
			document.getElementById("msgretour").innerHTML="Les informations 'mode exploitation' et 'apport effluent' sont obligatoires. "
		}else{
			document.getElementById("msgretour").innerHTML=" ";
			
			chargeXml("/www/ppf/updateprairie.php?indice="+plngIndice+"&modeexpl="+modeexpl+"&apport="+apport+"&trt="+pstrTraitement,"parcelles");			
			//window.open("/www/ppf/updateprairie.php?indice="+plngIndice+"&modeexpl="+modeexpl+"&apport="+apport+"&trt="+pstrTraitement,"parcelles");			
		}
	}else{	
		chargeXml("/www/ppf/updateprairie.php?indice="+plngIndice+"&modeexpl="+modeexpl+"&apport="+apport+"&trt="+pstrTraitement,"parcelles");				
		//window.open("/www/ppf/updateprairie.php?indice="+plngIndice+"&modeexpl="+modeexpl+"&apport="+apport+"&trt="+pstrTraitement,"parcelles");				
	}
}

//Mise à jour de toutes les lignes prairies
function updateListeP(){
	//Affectation des données saisies dans toutes la liste
	var modeexpl = document.forms['saisie_culture'].cboMode.value;
	var apport = document.forms['saisie_culture'].cboApport.value;
	var trt=document.getElementById('libaffec').firstChild.nodeValue
	
	switch (document.getElementById('libaffec').firstChild.nodeValue){
		case "Affectation":
			trt="AffecterTout";
			lib='Effacer';
			break;
			
		case "Effacer":
			trt="EffacerTout";
			lib='Affectation';
			break;
	}
	if (trt== "AffecterTout"){
		if ((modeexpl==0) || (apport==0)){
			document.getElementById("msgretour").className="erreur";
			document.getElementById("msgretour").innerHTML="Les informations 'mode exploitation' et 'apport effluent' sont obligatoires. ";
							
		}else{
			document.getElementById("msgretour").innerHTML=" ";
			document.getElementById('libaffec').firstChild.nodeValue=lib;
			chargeXml("/www/ppf/updateprairie.php?indice=0&modeexpl="+modeexpl+"&apport="+apport+"&trt="+trt,"parcelles");	
		}
	}else{
			document.getElementById("msgretour").innerHTML=" ";
			document.getElementById('libaffec').firstChild.nodeValue=lib;
			chargeXml("/www/ppf/updateprairie.php?indice=0&modeexpl="+modeexpl+"&apport="+apport+"&trt="+trt,"parcelles");	
				
	}
	
}

function valideparcelles(pstrmode) {
	//chargeXml("/www/ppf/valideparcelles.php?mode="+pstrmode,"validecalcul");
	chargeXml("/www/ppf/valideparcelles.php?mode="+pstrmode,"valide");
	//window.open("/www/ppf/valideparcelles.php?mode="+pstrmode,"valide");
}

/*function afficheXmlDataValideCalcul() {
	
	var statut = xmlHttpRequest.responseXML.getElementsByTagName("statut")[0].firstChild.nodeValue;
	var message = xmlHttpRequest.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue;
	var messagetech = xmlHttpRequest.responseXML.getElementsByTagName("messagetech")[0].firstChild.nodeValue;
	
	switch (statut) {
		
		// Erreur technique
		case '-1':
			document.getElementById("msgretour").className="erreur";
			document.getElementById("msgretour").innerHTML= "Erreur serveur : " + message;
			document.getElementById("msgretour").title=messagetech;
			break;
		
		// Erreur utilisateur
		case '0':
			document.getElementById("msgretour").className="erreur";
			document.getElementById("msgretour").innerHTML=message;
			break;

		// Pas de modification
		case '2':
			//document.getElementById("msgretour").className="erreur";
			//document.getElementById("msgretour").innerHTML=message;
			break;

		// Succès	
		case '1':
			//window.location='/www/ppf/index.php?option=tabsynth.php';
			//window.location='./index.php?rubrique=geofertilanet&page=gf_calculnliste&option=tabsynth.php';
			document.getElementById("msgretour").className="succes";
			document.getElementById("msgretour").innerHTML=message;
			break;
	}
}*/

//************************* Traitement des combo - Calcul Dose n ******************************************/
function chargcombo(pstrTrt){
	if (pstrTrt=='cult'){
		//Chargement des combos à partir de l'id culture uniquement
		param = 'idcult='+document.getElementById("cboCult").value+'&idsol=0';
	}else{
		param = 'idcult='+document.getElementById("cboCult").value+'&idsol='+document.getElementById("cboSol").value;
	}		

	// Affichage du sablier
	document.getElementById("statusZone").style.visibility = 'visible';
	
	//Chargement de la combo des précédents culturals
	var file = "/www/ppf/getcombocult.php?"+param; 
    chargeXml(file,'combocult','cbocult');
}

function afficheXmlComboCult(pstrCombo){	
	//Chargement de la combo précédent		
	var items = xmlHttpRequest.responseXML.getElementsByTagName("ligneprecedent");
	videCombo('cboPrec');
	var objcombo=document.getElementById('cboPrec');
	if (items.length > 0) {				
		for (var i=0; i<items.length; i++) {
			var node = items[i];
			objOptionNode=document.createElement("option");
			objOptionNode.value = node.getElementsByTagName("id")[0].firstChild.nodeValue;
			objOptionNode.appendChild(document.createTextNode(node.getElementsByTagName("valeur")[0].firstChild.nodeValue));			
			objcombo.appendChild(objOptionNode);
		}
	}
	
	//Chargement de la combo parcelles
	var items = xmlHttpRequest.responseXML.getElementsByTagName("ligneparcelle");
	videCombo('cboParc');
	var objcombo=document.getElementById('cboParc');
	if (items.length > 0) {				
		for (var i=0; i<items.length; i++) {
			var node = items[i];
			objOptionNode=document.createElement("option");
			objOptionNode.value = node.getElementsByTagName("id")[0].firstChild.nodeValue;
			objOptionNode.appendChild(document.createTextNode(node.getElementsByTagName("valeur")[0].firstChild.nodeValue));			
			objcombo.appendChild(objOptionNode);
		}
	}

	//Chargement de la combo Ilots
	var items = xmlHttpRequest.responseXML.getElementsByTagName("ligneilot");
	videCombo('cboIlot');
	var objcombo=document.getElementById('cboIlot');
	if (items.length > 0) {				
		for (var i=0; i<items.length; i++) {
			var node = items[i];
			objOptionNode=document.createElement("option");
			objOptionNode.value = node.getElementsByTagName("id")[0].firstChild.nodeValue;
			objOptionNode.appendChild(document.createTextNode(node.getElementsByTagName("valeur")[0].firstChild.nodeValue));			
			objcombo.appendChild(objOptionNode);
		}
	}
	
	//Chargement de la combo type de sol
	var items = xmlHttpRequest.responseXML.getElementsByTagName("lignesol");
	if (items.length > 0) {				
		videCombo('cbosol');
		var objcombo=document.getElementById('cbosol');

		for (var i=0; i<items.length; i++) {
			var node = items[i];
			objOptionNode=document.createElement("option");
			objOptionNode.value = node.getElementsByTagName("id")[0].firstChild.nodeValue;
				var strLib = node.getElementsByTagName("valeur")[0].firstChild.nodeValue;
				strLib = strLib.replace('++','>');
				strLib = strLib.replace('--','<');	

			objOptionNode.appendChild(document.createTextNode(strLib));			
			objcombo.appendChild(objOptionNode);
		}
	}
	
}
	
function selectCombo(pidcult,pidsol){	
	//Sélection des combos cultures et types de sols par rapport à la parcelle du tableau de synthèse
	if (pidcult!=0){document.getElementById('cboCult').value = pidcult;}		
	if (pidsol!=0) {document.getElementById('cboSol').value = pidsol;}		
}

//Affichage de la combo des colza
function afficheXmlColza(){
	var items = xmlHttpRequest.responseXML.getElementsByTagName("lignec");
	var objcombo=document.getElementById("cboColza");
	if (items.length > 0) {				
		for (var i=0; i<items.length; i++) { 
			var node = items[i];
			objOptionNode=document.createElement("option");
			objOptionNode.value = node.getElementsByTagName("id")[0].firstChild.nodeValue;
			var strvaleur = node.getElementsByTagName("valeur")[0].firstChild.nodeValue
			strvaleur = strvaleur.replace('++','>');
			strvaleur = strvaleur.replace('--','<');	
			objOptionNode.appendChild(document.createTextNode(strvaleur));			
			objcombo.appendChild(objOptionNode);

		}	
	}
}

// Ajout d'une ligne à une table
function ajoutLigneCultures(pstrTableId, ptabLigne) {
	var objTable = document.getElementById(pstrTableId);
	var intLastRow = objTable.rows.length;
	var objRow = objTable.insertRow(intLastRow);
	if (objTable.rows.length != 1) {
		// Pour alterner la couleur des lignes
		if (objTable.rows[intLastRow-1].className=="d2") {
			objRow.className = "d3";
		}
		else {
			objRow.className = "d2";
		}
	}
	else {
		objRow.className = "d2";
	}
	
	
	tabobjCell = new Array ();
		
	for (i=0; i<ptabLigne.length; i++) {
		tabobjCell[i] = objRow.insertCell(i);
		tabobjCell[i].appendChild(ptabLigne[i]);
	} 		
}
