function afficheXmlDataSynthese() {
	var items = xmlHttpRequest.responseXML.getElementsByTagName("parcelle");
	videTable('tabsynth');
	if (items.length > 0) {
		//Millesime 
		var node = items[0];
		var millesime=node.getElementsByTagName("millesime")[0].firstChild.nodeValue;

		//Dernière campagne	
		var camp=millesime;
		if (document.getElementById("TxtType").value=="histo"){
			camp=document.getElementById("cboMille")[0].value;
		}

		for (var i=0; i<items.length; i++) {
			var node = items[i];
			tabLigne = new Array();
			tabLigne[0]=document.createTextNode(node.getElementsByTagName("numlot")[0].firstChild.nodeValue);
			strLib = node.getElementsByTagName("typsol")[0].firstChild.nodeValue;
			strLib = strLib.replace('++','>');
			strLib = strLib.replace('--','<');	
			tabLigne[1]=document.createTextNode(strLib);
			
			//Identifiant de la parcelle - Information pour renvoi vers le calcul de la dose
			var lngIdgf = node.getElementsByTagName("idgfparcelle")[0].firstChild.nodeValue;
			
			//Lien pour ouvrir la page de calcul si pas de dose calculée
			if (((node.getElementsByTagName("dosec")[0].firstChild.nodeValue=="-")||(node.getElementsByTagName("dosec")[0].firstChild.nodeValue=="0")) && (camp==node.getElementsByTagName("millesime")[0].firstChild.nodeValue)){
				objTextNode = document.createTextNode(node.getElementsByTagName("nomparc")[0].firstChild.nodeValue);
				objLinkNode = document.createElement("a");
				if (node.getElementsByTagName("type")[0].firstChild.nodeValue=='P'){
					objLinkNode.setAttribute("href", "./index.php?rubrique=geofertilanet&page=gf_calculnliste&typesaisie=prairie&option=calculdose.php&idgfparcelle="+lngIdgf);
				}else{
					var lngIdCul = node.getElementsByTagName("idculture")[0].firstChild.nodeValue;
					var lngIdTpSol = node.getElementsByTagName("idtypesol")[0].firstChild.nodeValue;
					objLinkNode.setAttribute("href", "./index.php?rubrique=geofertilanet&page=gf_calculnliste&option=calculdose.php&newcombo=1&typesaisie=cultural&idgfparcelle="+lngIdgf+"&idculture="+lngIdCul+"&idsol="+lngIdTpSol);	
				}	
				objLinkNode.id=node.getElementsByTagName("indice")[0].firstChild.nodeValue;
				objLinkNode.value=(node.getElementsByTagName("type")[0].firstChild.nodeValue);
				objLinkNode.appendChild(objTextNode);
				tabLigne[2]=objLinkNode;
			}else{	
				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;

			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 () { tabulaireilot(this.id); }			
			objLinkNode.appendChild(objImgNode);

			tabLigne[4]=objLinkNode;
			
			tabLigne[5]=document.createTextNode(node.getElementsByTagName("surface")[0].firstChild.nodeValue);
			tabLigne[6]=document.createTextNode(node.getElementsByTagName("culture")[0].firstChild.nodeValue);
			tabLigne[7]=document.createTextNode(node.getElementsByTagName("objectif")[0].firstChild.nodeValue);
			tabLigne[8]=document.createTextNode(node.getElementsByTagName("dosec")[0].firstChild.nodeValue);
			
			//Modification de la dose uniquement pour la campagne en cours
			if (camp==node.getElementsByTagName("millesime")[0].firstChild.nodeValue){
				//Zone de saisie pour la dose Retenue
				objInputNode=document.createElement("input");
				if (node.getElementsByTagName("doser")[0].firstChild.nodeValue!='-'){
					objInputNode.value=(node.getElementsByTagName("doser")[0].firstChild.nodeValue);
				}else{objInputNode.value=''};
				objInputNode.id=node.getElementsByTagName('indice')[0].firstChild.nodeValue;
				objInputNode.onchange= function () { updateSynthese(this.id,this.value,'','dose'); }			
				objInputNode.onblur= function () { updateSynthese(this.id,this.value,'','dose'); }			
				tabLigne[9]=objInputNode;
				//Zone de saisie pour les commentaires
				objInputNode=document.createElement("input");
				if (node.getElementsByTagName("commentaire")[0].firstChild.nodeValue!='-'){
					objInputNode.value=(node.getElementsByTagName("commentaire")[0].firstChild.nodeValue);
				}else{objInputNode.value=''};
				objInputNode.id=node.getElementsByTagName('indice')[0].firstChild.nodeValue;
				objInputNode.onchange= function () { updateSynthese(this.id,'',this.value,'commentaire'); }			
				objInputNode.onblur= function () { updateSynthese(this.id,'',this.value,'commentaire'); }			
				tabLigne[10]=objInputNode;
			}else{
				tabLigne[9]=document.createTextNode(node.getElementsByTagName("doser")[0].firstChild.nodeValue);
				tabLigne[10]=document.createTextNode(node.getElementsByTagName("commentaire")[0].firstChild.nodeValue);
			}	
				
			//Ajout dans la table Parcelles				
			ajoutLigneTable('tabsynth', tabLigne);
		}
		
		if ((document.getElementById("TxtType").value=="annee")||(camp==node.getElementsByTagName("millesime")[0].firstChild.nodeValue)){
			var mill=millesime-1;
			//document.getElementById("msgCampagne").innerHTML="Campagne du 1 août  "+mill+" au 31 juillet "+millesime+" - Récolte "+millesime;		
			//Affichage du bouton calcul
			document.getElementById("bt_calcul").style.visibility = 'visible';

		}
	}else{	
		//document.getElementById("msgCampagne").innerHTML="Historique Calcul dose azote"		
		document.getElementById("msgbas").innerHTML="Aucun historique pour votre exploitation";		
	}
	//document.getElementById("msgretour").innerHTML="";			
}

//Mise à jour de la zone dose Retenue ou zone Commentaire
function updateSynthese(plngIndice,pintdose,pstrcommentaire,pstrtrt) {
	switch (pstrtrt){	
		case 'dose'	:
			//Vérification saisi dose en numérique
			if (isNaN(pintdose)){
				document.getElementById("msgretour").className="erreur";		
				document.getElementById("msgretour").innerHTML="La dose retenue doit être une valeur numérique.";			
				chargeXml("/www/ppf/updatesynthese.php?indice="+plngIndice+"&dose=0&trt=Dose", "synthese");
			}else{
				if (pintdose>=0){
					chargeXml("/www/ppf/updatesynthese.php?indice="+plngIndice+"&dose="+pintdose+"&trt=Dose", "saisie");
				}
			}	
			break;
		case 'commentaire' :
			
			chargeXml("/www/ppf/updatesynthese.php?indice="+plngIndice+"&commentaire="+pstrcommentaire+"&trt=Commentaire", "saisie");
			break;
	}
}

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

function valideBase() {
	chargeXml("/www/ppf/validesynthese.php","valide");
}


function rechhisto(){
	document.getElementById("msgretour").innerHTML="";			
	var lngMille = document.getElementById("cboMille").value;
	//Recherche des historique 
	afficheListe('nomlot', 'synthese','&mode=histo&millesime='+lngMille+'&newrech=1');
}
