// JavaScript Document

	function getXMLHttpRequest () {

	if (window.XMLHttpRequest) {
			
			var xmlHttpReq = new XMLHttpRequest ();
		
			if (xmlHttpReq.overrideMimeType) {
					xmlHttpReq.overrideMimeType("text/xml");
				}
			return xmlHttpReq;
		
		}
		
	else if (window.ActiveXObject) {
			try {
					return new ActiveXObject ("Msxml2.XMLHTTP");
				}
				
			catch (err) {}
			
			try {
					return new ActiveXObject ("Microsoft.XMLHTTP");
				}	
			catch (err) {}
		
		}
	throw new Error ("Impossible de créer l'objet XMLHttpRequest pour le navigateur");	
}

	
	
	
	function submitForm()
	{ 
		var req = null; 
		var html = new Array();

		document.getElementById("zone").innerHTML = "Initialisation...";
 
		if (window.XMLHttpRequest)
		{
 			req = new XMLHttpRequest();
			if (req.overrideMimeType) 
			{
				req.overrideMimeType('text/xml');
			}
		} 
		else if (window.ActiveXObject) 
		{
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e)
			{
				try {
					req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
	        	}



		req.onreadystatechange = function()
		{ 
			document.getElementById("zone").innerHTML = "";
			if(req.readyState == 4)
			{
				if(req.status == 200)
				{
				
				
				var doc 		= req.responseXML;                                             //  assigner le fichier XML à une variable
				var element 	= doc.getElementsByTagName('liste');			  //  lire le premier élément avec DOM
				
				
				var produits 		= element.item(0).getElementsByTagName('produit');
				var logoPath		= produits.item(0).getAttribute('logoPath');
				var iconePath		= produits.item(0).getAttribute('iconePath');		
				var getXML			= produits.item(0).getAttribute('destination');
				var imgPath			= produits.item(0).getAttribute('imgPath');
				var nbrelogoTech	= produits.item(0).getElementsByTagName("icone").length;
				var infos			= produits.item(0).getElementsByTagName("infos");			
				var couleur			= infos.item(0).getElementsByTagName('couleur').length;
				var reference		= infos.item(0).getElementsByTagName("reference").item(0).firstChild.data;
				var matiere			= infos.item(0).getElementsByTagName("matiere").item(0).firstChild.data;
				var taille			= infos.item(0).getElementsByTagName("taille").item(0).firstChild.data;
				var descripLength	= infos.item(0).getElementsByTagName('description').length;	
				var tailleComp			= produits.item(0).getElementsByTagName('tailleComplementaire').length;
				
				if (tailleComp!=0) {
				var taillecomplementaire = produits.item(0).getElementsByTagName('tailleComplementaire');
				}
				
				var produitsAssocies	= produits.item(0).getElementsByTagName("produitsAssocies");
				if(produitsAssocies.length!=0){
				var nbreFichesProduits	= produitsAssocies.item(0).getElementsByTagName("ficheProduit").length;
				var fichesProduits		= produitsAssocies.item(0).getElementsByTagName("ficheProduit");
				}
				var menuType	= JSExtraireParamType();
				
				
				html.push("<div style='margin-top:3px'>");
				html.push("<img src='"+logoPath+""+produits.item(0).getElementsByTagName('logoMarque').item(0).firstChild.data+"' border='0' height='36' vspace='1' hspace='2' ><br />" );
				
				
				for (i=0;i<nbrelogoTech;i++) {
					
					if (i==12) html.push("<br/>");
					html.push("<a href='javascript:fenetreGuide()'><img src='"+iconePath+""+produits.item(0).getElementsByTagName('icone').item(i).firstChild.data+"' border='0' vspace='1' hspace='2' width='40' height='40'></a>");
					
				}				
				
				html.push("<hr align='left' width='580' color='#ffffff' size='1' />");
				
				for (j=0;j<descripLength;j++) {
					
					html.push("<font color='#ffffff' style='font-family:Arial, Helvetica, sans-serif' size='-1'>"+infos.item(0).getElementsByTagName('description').item(j).firstChild.data+"</font><br />");
				
					
				}
				
				if(tailleComp!=0){
					
				for (i=0;i<tailleComp;i++) {

						
		var mesuresTaille		= taillecomplementaire.item(0).getElementsByTagName("mesuresTaille").item(0).firstChild.data;
		var poitrine			= taillecomplementaire.item(0).getElementsByTagName("poitrine").item(0).firstChild.data;
		var tourDeTaille		= taillecomplementaire.item(0).getElementsByTagName("tourDeTaille").item(0).firstChild.data;
		var longueurManche		= taillecomplementaire.item(0).getElementsByTagName("longueurManche").item(0).firstChild.data;
		var longueurCarrureDos	= taillecomplementaire.item(0).getElementsByTagName("longueurCarrureDos").item(0).firstChild.data;
		var longueurVeste		= taillecomplementaire.item(0).getElementsByTagName("longueurVeste").item(0).firstChild.data;
		var infoTaille			= taillecomplementaire.item(0).getElementsByTagName("infoTaille").item(0).firstChild.data;
					
					
		html.push("<br /><tr><td align='left' width='580'>");
		html.push ("<div style='margin-top:5px' >");
		html.push ("<font color='#ffffff' style='font-family:Arial, Helvetica, sans-serif' size='-1'><b>Mesures de la veste pour la taille "+mesuresTaille+" :</b><br /></font>");
		html.push ("<ul>");
		html.push ("<font color='#ffffff' style='font-family:Arial, Helvetica, sans-serif' size='-1'>- Tour de Poitrine				: "+poitrine+" cm<br />");
		html.push ("- Tour de Taille				: "+tourDeTaille+" cm<br />");	
		html.push ("- Longueur des manches (prise &agrave; partir de la couture de l&rsquo;&eacute;paule	: "+longueurManche+" cm<br />");
		
		html.push ("- Carrure dos	(prise au niveau des omoplates entre les deux &eacute;paules) : "+longueurCarrureDos+" cm<br />");
		html.push ("- Longueur du v&ecirc;tement : "+longueurVeste+" cm<br />");

		html.push ("</ul>");
		html.push (infoTaille);
		html.push ("<div class='informations'><div class='texte'>");
		html.push ("</div></div></font>");
		html.push ("</div></td></tr>");
		
		document.getElementById("zone").innerHTML  = html.join("");
		}
				}	
				
html.push("<br /><table height='20' cellSpacing='0' cellPadding='0' width='150' border='0'><tbody>");
				html.push ("</tr></tbody></table><br>");
				
				html.push("<div class='cadreTableau'>");
				
				html.push ("<div class='ligneRef'>R&eacute;f&eacute;rence</div>");
				
				html.push ("<div class='ligneMatiere'>Mati&egrave;re</div>");
				
				html.push ("<div class='ligneCouleurs'>Couleur(s) disponible(s)</div>");
																																																												
				html.push("<div class='ligneRef2'>"+reference+"</div>");
				
				html.push("<div class='ligneMatiere2'>"+matiere+"</div>");
								
				for (k=0;k<couleur;k++) {
				
				var logoPath	= produits.item(0).getAttribute('logoPath');
				
				html.push("<div class='ligneCouleurs2'><img src='"+logoPath+""+produits.item(0).getElementsByTagName('couleur').item(k).firstChild.data+"' alt='"+produits.item(0).getElementsByTagName('couleur').item(k).firstChild.data+"' border='0' vspace='1' hspace='10' width='28' height='28'></div>");
				}
								
				html.push("</div>");
				
				var fonctionJS = "fenetreTaille(\""+getXML+"\")";
				
				html.push ("<br /><br /><br /><br /><div style='margin-top:5px'>");
				if (menuType!="82" && menuType!="55" && menuType!="76")
				html.push ("<div style='float:left'><div style='margin-top:5px'><td width='200' height='20' cellSpacing='0' cellPadding='0' border='0' valign='middle'><a href='javascript:"+fonctionJS+"'><FONT color='#ffffff' style='font-family:Arial, Helvetica, sans-serif' size='-2'><b>Voir le guide des tailles</b></font></a></td></div></div>");
				if (menuType=="53" || menuType=="80" || menuType=="81" || menuType=="54" || menuType=="95" || menuType=="82" || menuType=="55" || menuType =="76") html.push ("<div style='float:right'><div style='margin-right:17px'><div style='margin-top:5px'><td width='200'><a href='javascript:fenetreGuide()'><FONT color='#ffffff' style='font-family:Arial, Helvetica, sans-serif' size='-2'><b>Guide Technique</b></font></a></td></div></div></div>");
				html.push ("</div></div><br />");
				
								//if (nbreFichesProduits != 0) {
					//html.push ("<table cellSpacing='0' cellPadding='0' width='580' border='0' height='336' align='left' style='background:url(img/fondArticlesAssocies.jpg) center no-repeat'><tbody><tr align='left' height='20' ><td align='middle' colspan='"+nbreFichesProduits+"'></td></tr>");
	
					//html.push("<tr align='center' height='150' valign='center'>");
				
					//for (k=0;k<nbreFichesProduits;k++) {
							//var destinationProduit	= fichesProduits.item(0).getAttribute("destination");
							//var menuDestination		= fichesProduits.item(0).getAttribute("menuType");
							//var ref					= fichesProduits.item(0).getAttribute("ref");
							//var titreProduit		= fichesProduits.item(0).getElementsByTagName("titreProduit").item(0).firstChild.data;
							//var marqueProduit 		= fichesProduits.item(0).getElementsByTagName("marqueProduit").item(0).firstChild.data;
							//var referenceProduit	= fichesProduits.item(0).getElementsByTagName("referenceProduit").item(0).firstChild.data;	
							//var prixProduit			= fichesProduits.item(0).getElementsByTagName("prixProduit").item(0).firstChild.data;
							//var photoProduit		= fichesProduits.item(0).getElementsByTagName("photoProduit").item(0).firstChild.data;
							
							
							
							//html.push ("<td align='middle'><a href='fiche_produit.cfm?ref="+ref+"&code_lg=lg_fr&type="+menuDestination+"'><br /><br /><br /><img src='"+imgPath+photoProduit+".jpg' width='150' height='245' border='0'><br /><FONT color='#000000' style='font-family:Arial, Helvetica, sans-serif' size='-1'><font style='font-weight:bold'>"+titreProduit+"</font></font><br /><FONT color='#cc0000' style='font-family:Arial, Helvetica, sans-serif' size='5'><font style='font-weight:bold'>"+prixProduit+"</font></font></a></td>");
						//}
					//html.push ("</tr></tbody><br /><br /></table>");
					//}
				
				document.getElementById("zone").innerHTML  = html.join("");	
				
				
				}	
				else	
				{
					//document.getElementById("zone").innerHTML="Error: returned status code " + req.status + " " + req.statusText;
				}	
			} 
		}; 
		var get = TJSExtraireParam();
		req.open("GET", "produits/"+get+".xml", true); 
		req.send(null); 
	} 


function TJSExtraireParam()
 {
   url = window.location.href;
   var tabNom=url.split("\?");
   var tabParam=new Array();
   
   if (tabNom!=null) 
   {
	   if (tabNom[1].indexOf("&") == -1) {
       
	   		var tabTemp=tabNom[1].split("=");
       		tabParam=tabTemp[1];
	   }
	   
	   else  {
		   var tabTemp1 =tabNom[1].split("&");
		   
		   for (i=0;i<tabTemp1.length;i++) {
		   		var tabTemp2 = tabTemp1[i].split("=");
				
				if(tabTemp2[0]=='ref') {
			   		tabParam=tabTemp2[1];
		   		}
		   }
		   
		   
		   
		   
		   
	   }
   }
   else {

   }
   return tabParam;
 }

function fenetreTaille(getXML) {
 monURL 		= "guideTaille"+getXML+".cfm";
 monNomFenetre	= "Guide des Tailles";
 if (getXML=="homme_femme") mafenetre = window.open(monURL, "_blank",'menubar=no,status=no,scrollbars=yes, width=598, height=550');
 else mafenetre = window.open(monURL, "_blank",'menubar=no,status=no,scrollbars=yes, width=597, height=550');
 mafenetre.focus();
}

function fenetreGuide() {
 monURL 		= "guideTechnique.cfm";
 monNomFenetre	= "Guide des icônes";
 mafenetre = window.open(monURL, "_blank",'menubar=no,status=no,scrollbars=yes, width=900, height=550');
 mafenetre.focus();
}


