
var ajax_obj = new sack();
var retourAjax;

// parametre global permettant de differencier les cookies pour reutilisation du jeu de fonction en vue d'autre application
strCatalogueCookie = "Elec";

// FDA : 04/05/2009
// permet de mettre à jour l'affichage du nombre de reference dans le panier
function updateNbReferenceView(){
	
	// recuperation du nombre de reference dans le panier
	nbRefPanier = countRefPanier();
	
	if (nbRefPanier > 1)
	{
		document.getElementById("viewNbRefPanier").innerHTML = nbRefPanier + " références";
	}
	else
	{
		document.getElementById("viewNbRefPanier").innerHTML = nbRefPanier + " référence";
	}
}

// FDA : 04/05/2009
// permet de compter le nombre de reference stocké dans le panier
function countRefPanier()
{
	contenuPanier =lirePanier();
	if ( contenuPanier != null){
		listeReference = contenuPanier.split("#");
		
		if ( listeReference.length == 0 ){
			return 0
		}
		else
		{
			return listeReference.length - 1;
		}
	}
	else
	{
		return 0;	
	}	
}

// FDA : 27/10/2006
// permet de lire le cookie Panier ( lire pour Greg!!!! )
function lirePanier()	// Ajout d'une référence au panier sous la forme qté$ref$
{
	val = getCookie("Panier" + strCatalogueCookie);
	return val
}

// FDA : 27/10/2006
// permet de lire le cookie Signet ( lire pour Greg!!!! )
function lireSignet()	// Ajout d'une référence au panier sous la forme qté$ref$
{
	getCookie("Signet" + strCatalogueCookie);
}

// FDA : 27/10/2006
// permet d'ajouter un signet
// param = 
//	page : numero de page ( ex:A60 )
//	libelle : libelle du signet (ex:disj CC)
function addSignet( page, libelle )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	if (ajoutCookie("Signet"+strCatalogueCookie) != null)
	{
		val = page + "|" + libelle + "#";
		val = (getCookie("Signet"+strCatalogueCookie)) + val;
	}
	ajoutCookie("Signet"+strCatalogueCookie,val,5);
}

// FDA : 27/10/2006
// permet d'ajouter une reference dans le panier

function addPanier( qte, reference , source )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	designation = "test libellé de reézeesfdsfd";
	delai = "2";
	prix = "500,14";
	page = "A20";
	val = "";
	
	// appel ajax pour recuperation de l'ensemble des info d'une reference
	getInfoReference(reference,qte,source);
}

// FDA :
// permet d'importer une liste de reference dans le panier
function addPanierList ( listReference ) {
	var url = "getInfoReferenceList.asp?referenceList="+ listReference;
	ajax_obj.requestFile = url;	
	ajax_obj.onCompletion = function(){traiteInfoReferenceList(listReference);};	
	ajax_obj.runAJAX();
}

function addPanierDatasheet( qte, reference , source )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	designation = "test libellé de reézeesfdsfd";
	delai = "2";
	prix = "500,14";
	page = "A20";
	val = "";
	
	qte = document.getElementById("qte").value;
	
	// appel ajax pour recuperation de l'ensemble des info d'une reference
	getInfoReference(reference,qte,source);
	
}

// FDA : 13/11/2006
// permet de supprimer une reference dans le panier en donnant son index
// contexte d'utilisation = dans panier
function suppRefPanier( position )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	valCookie = lirePanier();
	listeReference = contenuPanier.split("#");
	valDest = "";
	for (i=0;i<listeReference.length-1;i++){
		if ( i!= position ){
			valDest = valDest + listeReference[i] + "#";
		}
	}
	
	ajoutCookie("Panier"+strCatalogueCookie,valDest,5);
	initPanier();
	
	updateNbReferenceView();
}

// FDA : 13/11/2006
// permet de supprimer toute les references contenu dans le panier
// contexte d'utilisation = dans panier
function suppAllRefPanier( )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	valDest = ""
	ajoutCookie("Panier"+strCatalogueCookie,valDest,5);
	initPanier();
}

// FDA : 13/11/2006
// permet de supprimer toute les references contenu dans le panier
// contexte d'utilisation = dans panier
function modifieQuantiteRef( position )	// Ajout d'une référence au panier sous la forme qté$ref$
{
	valCookie = lirePanier();
	listeReference = contenuPanier.split("#");
	valDest = "";
	maRef = listeReference[position];
	detailReference = maRef.split("|");
	
	listeReference[position] = document.getElementById("qte" + position).value + "|" + detailReference[1]  + "|" + detailReference[2]  + "|" + detailReference[3]  + "|" + detailReference[4]  + "|" + detailReference[5]; 

	for (i=0;i<listeReference.length-1;i++){
		valDest = valDest + listeReference[i] + "#";
	}
	
	ajoutCookie("Panier"+strCatalogueCookie,valDest,5);
	initPanier();
	
}

// FDA : 20/11/2006
// fonction qui transforme le prix pour un affichage ecran conforme
function formatPrix(prix)
{
	if ( isNaN(parseFloat(prix)) ) 
	{
		monPrixString = "Hors tarif";
	}
	else
	{
		monPrix = parseFloat(prix);
		monPrix = monPrix / 100;
		var monPrixString = new String(monPrix);
		monPrixString = monPrixString.replace(".",",");	
		posVirgule = monPrixString.indexOf(",");
		
		if ( posVirgule < 0 )
		{
			monPrixString = monPrixString + ",00";	
		}
		else
		{
			//alert(monPrixString + " / " + posVirgule + " / " + monPrixString.length);
			
			if ( ( posVirgule + 2 - monPrixString.length ) == 0 )
				monPrixString = monPrixString.substring(0,posVirgule) + "," + monPrixString.substring(posVirgule+1,posVirgule+3) + "0";
			else
				monPrixString = monPrixString.substring(0,posVirgule) + "," + monPrixString.substring(posVirgule+1,posVirgule+3);
		}
	}	
	return monPrixString
}

function formatPrixPanier(prix)
{	
	if ( isNaN(parseFloat(prix)) ) 
	{
		monPrixString = "Hors tarif";
	}
	else
	{
		monPrixString = prix;
		posVirgule = monPrixString.indexOf(",");
		if ( posVirgule < 0 )
		{
			monPrixString = monPrixString + ",00";	
		}
		else
		{
			//alert(monPrixString + " / " + posVirgule + " / " + monPrixString.length);
			
			if ( ( posVirgule + 2 - monPrixString.length ) == 0 )
				monPrixString = monPrixString.substring(0,posVirgule) + "," + monPrixString.substring(posVirgule+1,posVirgule+3) + "0";
			else
				monPrixString = monPrixString.substring(0,posVirgule) + "," + monPrixString.substring(posVirgule+1,posVirgule+3);
		
		}
	}
	return monPrixString
}

// **********************************************************************************
// FONCTION GENERIQUE D'acces AU COOKIES
// **********************************************************************************

// FDA : 27/10/2006
// permet de récuperer la valeur du cookie passé en parametre
function getCookie(Name) { 
// Récupération de la valeur du cookie
          var search = Name + "=" 
          if (document.cookie.length > 0) { // si il existe au moins un cookie 
                    offset = document.cookie.indexOf(search) 
					if (offset != -1) { // si le cookie recherché existe 
                              offset += search.length ; 
                              //détermine la position de début de la valeur du cookie. 
                              end = document.cookie.indexOf(";", offset) 
                              // détermine la position de la fin de la valeur du cookie 
                              if (end == -1) 
                                        end = document.cookie.length 
                              return unescape(document.cookie.substring(offset, end)) 
					} 
          } 
}

// FDA : 27/10/2006
// permet d'ajouter une valeur passer en parametre dans le cookie specifié
function ajoutCookie(name, value, expire) { 
	if (expire != null) { 
		  var today = new Date() 
		  var expires = new Date() 
		  expires.setTime(today.getTime() + 60*60*24*1000*expire) 
		  expire = expires

	} 
	document.cookie = name + "=" + escape(value) + ((expires==null) ? "" : ("; expires="+expires.toGMTString()));
}

// **********************************************************************************
// FONCTION GENERIQUE D'appel AJAX
// **********************************************************************************
function getInfoReference( reference , qte, source ){
	
	var url = "getInfoReference.asp?reference="+ reference;
	ajax_obj.requestFile = url;	
	ajax_obj.onCompletion = function(){traiteInfoReference(reference, qte, source);};	
	ajax_obj.runAJAX();
}

function traiteInfoReference(reference, qte, source){

		retourAjax = ajax_obj.response;	
		ChargerXMLData(retourAjax);

		try{
	
		if (window.ActiveXObject) { // implementation for IE
			var nav = xmlDoc.documentElement;
	
			if (nav)
			{
				var result = nav.selectNodes("//result");
				
					
				if ( result.length > 0 ){
						
					// recuperation du noeud de substitution
					var substitution = result.item(0).selectNodes("substitution");
					
					if ( substitution.length > 0 ){
						// type de substitution
						var typeSubstitution = substitution.item(0).selectNodes("@type").item(0).text
						
						chaineSubstitution = "<table width=\"500\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#EAEAEA\" style=\" border-bottom:solid 1px #808080;\">";
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" height=\"30\" class=\"texteGreen14px\"><img src=\"images/infoSubstitution.gif\" border=\"0\" usemap=\"#MapSubstitution\"></TD></TR>";
						
						chaineSubstitution = chaineSubstitution + "</TD></TR>";
						
						var referenceXml = result.item(0).selectNodes("reference");
						designation  = referenceXml.item(0).selectNodes("@label").item(0).text;
						delai = referenceXml.item(0).selectNodes("@delai").item(0).text;
						prix = referenceXml.item(0).selectNodes("@prix").item(0).text;
						finCom = referenceXml.item(0).selectNodes("@finCom").item(0).text;
						
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" width=\"750\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080; padding-left: 10px;\"><br>Ancienne référence<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"600\" height=\"3\" align=\"absmiddle\"></TD></TR>";
						chaineSubstitution = chaineSubstitution + "<TR><TD>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD class=\"texteGris11px\" height=\"30\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">" + reference + "<img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\"><a href=\"javascript:openDatasheet('" + reference + "')\"><img src=\"images/ficheProduit.gif\" align=\"absmiddle\" border=\"0\"></a><img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Libellé</B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + designation + "&nbsp;" + prix + "&nbsp;" + delai + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Fin de com. </B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + finCom + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"></TD></TR>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">Type<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"685\" height=\"3\" align=\"absmiddle\"></TD></TR>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" height=\"30\" class=\"texteGris11px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">";
						
						typeSubstitution = typeSubstitution * 1;
						
						switch(typeSubstitution){
							case 1:
								chaineSubstitution = chaineSubstitution + "une référence pour une référence";
								break;
							case 2:
								chaineSubstitution = chaineSubstitution + "une référence pour un lot";
								break;
							case 3:
								chaineSubstitution = chaineSubstitution + "une référence pour un des lots ci-dessous";
								break;
						}
					
						chaineSubstitution = chaineSubstitution + "<TR><TD width=\"750\" colspan=\"2\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">Nouvelle référence<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"605\" height=\"3\" align=\"absmiddle\"></TD></TR>";
						chaineSubstitution = chaineSubstitution + "<TR><TD width=\"750\" height=\"30\" colspan=\"2\" class=\"texteGris11px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080; padding-left: 10px;\">";
						
						var lot = substitution.item(0).selectNodes("lot");
						
						if ( lot.length != 0 ){
							for ( nbLot=0; nbLot<lot.length; nbLot++ ){
								
								if ( lot.length > 1 ){
									chaineSubstitution = chaineSubstitution + "<B>Lot " + lot.item(nbLot).selectNodes("@name").item(0).text + "</B><BR>";
								}
								
								var referenceSubsti = lot.item(nbLot).selectNodes("referenceSubsti");
							
								lienMultiRef = ""
							
								for ( i=0; i<referenceSubsti.length; i++ ){
								
									referenceSubstiID = referenceSubsti.item(i).selectNodes("@ID").item(0).text;
									referenceSubstiLabel = referenceSubsti.item(i).selectNodes("@libelle").item(0).text;
									referenceSubstiPrix = referenceSubsti.item(i).selectNodes("@prix").item(0).text;
									referenceSubstiDelai = referenceSubsti.item(i).selectNodes("@delai").item(0).text;
									lienMultiRef = lienMultiRef + "1:" + referenceSubstiID + "|";
									chaineSubstitution = chaineSubstitution + referenceSubstiID + "<img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\"><a href=\"javascript:openDatasheet('" + referenceSubstiID + "')\"><img src=\"images/ficheProduit.gif\" align=\"absmiddle\" border=\"0\"></a><img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Libellé</B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + referenceSubstiLabel.toLowerCase() + "<img src=\"images/1pixTrans.gif\" width=\"15\" height=\"3\"><b>Prix</b><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + formatPrix(referenceSubstiPrix) + "&euro;<img src=\"images/1pixTrans.gif\" width=\"15\" height=\"3\"><b>Delai</b><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + referenceSubstiDelai + "jrs<br>";
								}
								
								lienMultiRef = lienMultiRef.substring(0,lienMultiRef.length-1);
								
								chaineSubstitution = chaineSubstitution.substring(0,chaineSubstitution.length-4);
								
								// chaine d'ajout au panier
								if ( referenceSubsti.length > 1 ){
									chaineSubstitution = chaineSubstitution + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><a href=\"javascript:addPanierList('" + lienMultiRef + "');hideSubstitution();\" class=\"lienVert11px\">> ajouter au panier</a><BR>";
								}
								else
								{
									chaineSubstitution = chaineSubstitution + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><a href=\"javascript:addPanier('1','" + referenceSubsti.item(0).selectNodes("@ID").item(0).text + "',4);hideSubstitution();\" class=\"lienVert11px\">> ajouter au panier</a><BR>";
								}
							}
						}
						
						chaineSubstitution = chaineSubstitution + "<BR><BR></TD></TR>";
						chaineSubstitution = chaineSubstitution + "</TABLE>";
						// recuperation du ou des lots de substitution
						
						document.getElementById("SubstitutionBox").innerHTML = chaineSubstitution;
						document.getElementById("SubstitutionBox").style.zIndex = 100;
						document.getElementById("SubstitutionBox").style.visibility = "visible";
					}
					
					else
					{
						
						// recuperation des informations références
						var referenceXml = result.item(0).selectNodes("reference");
						if ( referenceXml.length > 0 ){
							designation  = referenceXml.item(0).selectNodes("@label").item(0).text;
							delai = referenceXml.item(0).selectNodes("@delai").item(0).text;
							prix = referenceXml.item(0).selectNodes("@prix").item(0).text;
							page = ""
							
							if ( designation == ""){
								designation = "Réference hors tarif Schneider Electric France";
							}
							if ( delai == ""){
								delai = "NC";
							}						
							if ( prix == ""){
								prix = "NC";
							}		
																
							if (getCookie("Panier"+strCatalogueCookie) != null)
							{
								val = qte + "|" + reference + "|" + designation + "|" + delai + "|" + prix + "|" + page + "#";
								val = (getCookie("Panier"+strCatalogueCookie)) + val;
							}
							else
							{
								val = qte + "|" + reference + "|" + designation + "|" + delai + "|" + prix + "|" + page + "#";
							}
							
							// mise à jour du cookie				
							ajoutCookie("Panier"+strCatalogueCookie,val,5);
							
							if ( source == "0" ){
								initPanier();
								document.getElementById("directReference").value="";
								document.getElementById("directReference").focus();
							}
							
							if ( source == "1" ){
								parent.initPanier();
								parent.document.getElementById("directReference").focus();
							}
							
							if ( source == "2" ){
								parent.document.getElementById("panier_conteneur").contentWindow.initPanier();
								parent.document.getElementById("directReference").focus();
							}
		
							if ( source == "4" ){
								initPanier();
							}
						}
					
					}
				}
			}		
		}

		else	//implementation pour firefox
		{
				
				var xpeContent = new XPathEvaluator();
				
				var resultGroup = xpeContent.evaluate("//result",xmlDoc,null,XPathResult.ANY_TYPE, null);
				var result = resultGroup.iterateNext();
				
				if ( result != null ){
					
					// recuperation du noeud de substitution
					var substitutionGroup = xpeContent.evaluate("substitution",result,null,XPathResult.ANY_TYPE, null);
					var substitution = substitutionGroup.iterateNext();
					
					if ( substitution != null ){
						// type de substitution
						var typeSubstitution = substitution.getAttribute("type");
						
						chaineSubstitution = "<table width=\"500\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#EAEAEA\" style=\" border-bottom:solid 1px #808080;\">";
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" height=\"30\" class=\"texteGreen14px\"><img src=\"images/infoSubstitution.gif\" border=\"0\" usemap=\"#MapSubstitution\"></TD></TR>";
						
						chaineSubstitution = chaineSubstitution + "</TD></TR>";

						var referenceXmlGroup = xpeContent.evaluate("reference",result,null,XPathResult.ANY_TYPE, null);
						var referenceXml = referenceXmlGroup.iterateNext();			

						designation  = referenceXml.getAttribute("label");
						delai = referenceXml.getAttribute("delai");
						prix = referenceXml.getAttribute("prix");
						finCom = referenceXml.getAttribute("finCom");
						
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" width=\"750\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080; padding-left: 10px;\"><br>Ancienne référence<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"600\" height=\"3\" align=\"absmiddle\"></TD></TR>";
						chaineSubstitution = chaineSubstitution + "<TR><TD>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD class=\"texteGris11px\" height=\"30\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">" + reference + "<img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\"><a href=\"javascript:openDatasheet('" + reference + "')\"><img src=\"images/ficheProduit.gif\" align=\"absmiddle\" border=\"0\"></a><img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Libellé</B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + designation + "&nbsp;" + prix + "&nbsp;" + delai + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Fin de com. </B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + finCom + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"></TD></TR>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">Type<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"685\" height=\"3\" align=\"absmiddle\"></TD></TR>";
	
						chaineSubstitution = chaineSubstitution + "<TR><TD colspan=\"2\" height=\"30\" class=\"texteGris11px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">";
						
						typeSubstitution = typeSubstitution * 1;
						
						switch(typeSubstitution){
							case 1:
								chaineSubstitution = chaineSubstitution + "une référence pour une référence";
								break;
							case 2:
								chaineSubstitution = chaineSubstitution + "une référence pour un lot";
								break;
							case 3:
								chaineSubstitution = chaineSubstitution + "une référence pour un des lots ci-dessous";
								break;
						}
					
						chaineSubstitution = chaineSubstitution + "<TR><TD width=\"750\" colspan=\"2\" class=\"texteGreenLight12px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080;padding-left: 10px;\">Nouvelle référence<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><img src=\"images/filetVert.gif\" width=\"605\" height=\"3\" align=\"absmiddle\"></TD></TR>";
						chaineSubstitution = chaineSubstitution + "<TR><TD width=\"750\" height=\"30\" colspan=\"2\" class=\"texteGris11px\" style=\"border-left: solid 1px #808080;border-right: solid 1px #808080; padding-left: 10px;\">";
						
						var lot = substitution.item(0).selectNodes("lot");
						
						if ( lot.length != 0 ){
							for ( nbLot=0; nbLot<lot.length; nbLot++ ){
								
								if ( lot.length > 1 ){
									chaineSubstitution = chaineSubstitution + "<B>Lot " + lot.item(nbLot).selectNodes("@name").item(0).text + "</B><BR>";
								}
								
								var referenceSubsti = lot.item(nbLot).selectNodes("referenceSubsti");
							
								lienMultiRef = ""
							
								for ( i=0; i<referenceSubsti.length; i++ ){
								
									referenceSubstiID = referenceSubsti.item(i).selectNodes("@ID").item(0).text;
									referenceSubstiLabel = referenceSubsti.item(i).selectNodes("@libelle").item(0).text;
									referenceSubstiPrix = referenceSubsti.item(i).selectNodes("@prix").item(0).text;
									referenceSubstiDelai = referenceSubsti.item(i).selectNodes("@delai").item(0).text;
									lienMultiRef = lienMultiRef + "1:" + referenceSubstiID + "|";
									chaineSubstitution = chaineSubstitution + referenceSubstiID + "<img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\"><a href=\"javascript:openDatasheet('" + referenceSubstiID + "')\"><img src=\"images/ficheProduit.gif\" align=\"absmiddle\" border=\"0\"></a><img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><B>Libellé</B><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + referenceSubstiLabel.toLowerCase() + "<img src=\"images/1pixTrans.gif\" width=\"15\" height=\"3\"><b>Prix</b><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + formatPrix(referenceSubstiPrix) + "&euro;<img src=\"images/1pixTrans.gif\" width=\"15\" height=\"3\"><b>Delai</b><img src=\"images/1pixTrans.gif\" width=\"5\" height=\"3\">" + referenceSubstiDelai + "jrs<br>";
								}
								
								lienMultiRef = lienMultiRef.substring(0,lienMultiRef.length-1);
								
								chaineSubstitution = chaineSubstitution.substring(0,chaineSubstitution.length-4);
								
								// chaine d'ajout au panier
								if ( referenceSubsti.length > 1 ){
									chaineSubstitution = chaineSubstitution + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><a href=\"javascript:addPanierList('" + lienMultiRef + "');hideSubstitution();\" class=\"lienVert11px\">> ajouter au panier</a><BR>";
								}
								else
								{
									chaineSubstitution = chaineSubstitution + "<img src=\"images/1pixTrans.gif\" width=\"10\" height=\"3\"><a href=\"javascript:addPanier('1','" + referenceSubsti.item(0).selectNodes("@ID").item(0).text + "',4);hideSubstitution();\" class=\"lienVert11px\">> ajouter au panier</a><BR>";
								}
							}
						}
						
						chaineSubstitution = chaineSubstitution + "<BR><BR></TD></TR>";
						chaineSubstitution = chaineSubstitution + "</TABLE>";
						// recuperation du ou des lots de substitution
						
						document.getElementById("SubstitutionBox").innerHTML = chaineSubstitution;
						document.getElementById("SubstitutionBox").style.zIndex = 10;
						document.getElementById("SubstitutionBox").style.visibility = "visible";
					}
					
					else
					{
						
						
						// recuperation des informations références
						
						var referenceXmlGroup = xpeContent.evaluate("reference",result,null,XPathResult.ANY_TYPE, null);
						var referenceXml = referenceXmlGroup.iterateNext();			
						
						if ( referenceXml!= null ){
							
							referenceXml.getAttribute("label");
							designation  = referenceXml.getAttribute("label");
							delai = referenceXml.getAttribute("delai");
							prix = referenceXml.getAttribute("prix");
							page = ""
							
							if ( designation == ""){
								designation = "Réference hors tarif Schneider Electric France";
							}
							if ( delai == ""){
								delai = "NC";
							}						
							if ( prix == ""){
								prix = "NC";
							}		
																
							if (getCookie("Panier"+strCatalogueCookie) != null)
							{
								val = qte + "|" + reference + "|" + designation + "|" + delai + "|" + prix + "|" + page + "#";
								val = (getCookie("Panier"+strCatalogueCookie)) + val;
							}
							else
							{
								val = qte + "|" + reference + "|" + designation + "|" + delai + "|" + prix + "|" + page + "#";
							}
							
							// mise à jour du cookie				
							ajoutCookie("Panier"+strCatalogueCookie,val,5);
							
							if ( source == "0" ){
								initPanier();
								document.getElementById("directReference").value="";
								document.getElementById("directReference").focus();
							}
							
							if ( source == "1" ){
								parent.initPanier();
								parent.document.getElementById("directReference").focus();
							}
							
							if ( source == "2" ){
								parent.document.getElementById("panier_conteneur").contentWindow.initPanier();
								parent.document.getElementById("directReference").focus();
							}
		
							if ( source == "4" ){
								initPanier();
							}
						}
					
					}
				}
		}
	
		// mise à jour de l'info nombre de référence	
		updateNbReferenceView();
	}catch(err){
		updateNbReferenceView();
	}
}


function traiteInfoReferenceList (listReference ){
	retourAjax = ajax_obj.response;
	
	ChargerXMLData(retourAjax);

	if (window.ActiveXObject) { // implementation for IE
		var nav = xmlDoc.documentElement;
		
		if (nav)
		{
			var referenceList = nav.selectNodes("//reference");
			
			if ( referenceList.length != 0 ){
				val = ""
				
				for ( nbReference = 0; nbReference < referenceList.length; nbReference++ ){
					
						qte = referenceList.item(nbReference).selectNodes("@qte").item(0).text;
						reference = referenceList.item(nbReference).selectNodes("@ID").item(0).text;
						designation = referenceList.item(nbReference).selectNodes("@label").item(0).text;
						delai = referenceList.item(nbReference).selectNodes("@delai").item(0).text;
						prix = referenceList.item(nbReference).selectNodes("@prix").item(0).text;
						page = "";
						
						val = val + qte + "|" + reference + "|" + designation + "|" + delai + "|" + prix + "|" + page + "#";
				}
				
				if (getCookie("Panier"+strCatalogueCookie) != null)
				{
					val = (getCookie("Panier"+strCatalogueCookie)) + val;
				}
				
				ajoutCookie("Panier"+strCatalogueCookie,val,5);
				parent.initPanier();
				
				parent.updateNbReferenceView();
			}
		}
			
	}
}


function traiteListRefPanierAjax(){
	retour = ajax_listRef.response;
	
	document.getElementById("listRefAjax").innerHTML = retour;
}

// **********************************************************************************
// FONCTION DE TRIATEMENT DES FLUX XML
// **********************************************************************************	
function ChargerXMLData(url) {
	if (window.ActiveXObject) {
	  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async="false";
		xmlDoc.onreadystatechange = Verification;
		xmlDoc.setProperty("SelectionLanguage", "XPath"); // On paramètre le Xpath comme language pour utiliser contains() et autres méthodes
		xmlDoc.loadXML(url);
	}
	else
	{
		parser=new DOMParser();
	  xmlDoc=parser.parseFromString(url,"application/xml");
	}
}

function Verification() { 
	if(xmlDoc.readyState!=4)
		return false; 
}

function hideSubstitution(){
	document.getElementById("SubstitutionBox").style.zIndex = 0;
	document.getElementById("SubstitutionBox").style.visibility = "hidden";
}