// Fonction AJAX

//var xhr = null; 
function Get_Xhr(url,variable) 
	{
	//var xhr = null; 
	xhr = null;
	if (window.XMLHttpRequest) 
		{ 
		// Mozilla, Safari, ...
        xhr = new XMLHttpRequest();
		if (xhr.overrideMimeType) 
			{
            xhr.overrideMimeType('text/xml');
            // See note below about this line
           	}
        } else if (window.ActiveXObject) 
				{
				// IE
            	try {
                	xhr = new ActiveXObject("Msxml2.XMLHTTP");
            		} 
            		catch (e) {
               			try {
                    	xhr = new ActiveXObject("Microsoft.XMLHTTP");
                		} 
                		catch (e) {}
            	}
        }

        if (!xhr) {
            alert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');
            return false;
        }
				//alert(variable);
        xhr.open('POST', url, true);
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(variable);
		//xhr.send(variable);
		
		return xhr;
    }


// ---> Fonction permettant de faire des XMLHttpRequest multiples et simultanées
// On passe en paramêtres l'url à apeller et l'objet qui recevra la réponse (exemple div)
function ajaxClass(ActionTag,url, refObj,variable)
{	
	//var xhr_object = null;
	//var mUrl = url;
	//var mObj = refObj;
	var xhr_object = null;
	var mUrl = url;
	var mObj = refObj;
	this.execute = function()
	{
		this.SendGetRequestSearch(url,mObj);
	}
	
	this.SendGetRequestSearch = function(URL,objectID)
	{
	if (window.XMLHttpRequest) 
		{ 
		// Mozilla, Safari, ...
        xhr_object = new XMLHttpRequest();
		//var xhr = getUnObjetXMLhttpRequest();

		if (xhr_object.overrideMimeType) 
			{
            xhr_object.overrideMimeType('text/xml');
            // See note below about this line
           	}
        } else if (window.ActiveXObject) 
				{
				// IE
            	try {
                	xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
            		} 
            		catch (e) {
               			try {
                    	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
                		} 
                		catch (e) {}
            	}
        }

        if (!xhr_object) {
            alert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');
            return false;
        }
        xhr_object.open('POST', URL, true);
		xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		//
		if (mObj != "")
			{
			xhr_object.onreadystatechange = this.CallBackRequest;
		  	xhr_object.WaitForResponse;
			}	  
		//
		xhr_object.send(variable);
	}
	
	this.CallBackRequest = function(){
		if (xhr_object.readyState == 4)
		{
		//document.getElementById(mObj).src = xhr_object.responseText;
		ajaxClassAction(ActionTag,mObj,xhr_object.responseText,variable);
		}
	}
}

function ajaxClassAction(ActionTag,mObj,ActionResponseText,variable)
	{
	//document.getElementById(mObj).src = action;
	//alert(ActionElement);
	//eval(ActionElement) = ActionResponseText;
	if(ActionTag == '1')
		{
		//alert(ActionResponseText);	
		document.getElementById(mObj).src = ActionResponseText;
		}
	if(ActionTag == '2')
		{
		//alert("tarif");
		Ext_HT_TTC = Extention_HT_TTC(variable);
		// On affiche le tarif dans le tableau (avec Euro) et dans le hidden (sans Euro)
		//document.getElementById(mObj).innerHTML = ActionResponseText + " &euro; HT";
		document.getElementById(mObj).innerHTML = ActionResponseText + " " + Ext_HT_TTC;
		document.getElementById("hid_"+mObj+"").value = ActionResponseText;
		/*
		//alert(variable);
		// On récupère lme type de client
		var id_client_tmp = Extract_balise(variable,"client=","&");
		if(id_client_tmp != "-1")
			{
			// PRO	
			Ext_HT_TTC = "&euro; HT";
			} else {
					// PAS CONNECTE
					Ext_HT_TTC = "&euro; TTC";
					}
		*/			
		//alert(id_client_tmp);
		}
	if(ActionTag == '3')
		{
		//alert("tarif : " + ActionResponseText);
		document.getElementById(mObj).innerHTML = ActionResponseText;
		}
	if(ActionTag == '4')
		{
		//alert(ActionResponseText);	
		//alert("tarif");
		//alert(variable);
		// On affiche le tarif dans le tableau (avec Euro) et dans le hidden (sans Euro)
		Ext_HT_TTC = Extention_HT_TTC(variable);
		document.getElementById(mObj).innerHTML = ActionResponseText + " " + Ext_HT_TTC;
		//document.getElementById(mObj).innerHTML = ActionResponseText + " &euro; HT";
		//document.getElementById("hid_"+mObj+"").value = ActionResponseText;
		}	
	}

function HTMLentities(texte)
	{
	texte = texte.replace(/"/g,'&quot;'); // 34 22
	texte = texte.replace(/&/g,'&amp;'); // 38 26
	texte = texte.replace(/\'/g,'&#39;'); // 39 27
	texte = texte.replace(/</g,'&lt;'); // 60 3C
	texte = texte.replace(/>/g,'&gt;'); // 62 3E
	texte = texte.replace(/\^/g,'&circ;'); // 94 5E
	texte = texte.replace(/‘/g,'&lsquo;'); // 145 91
	texte = texte.replace(/’/g,'&rsquo;'); // 146 92
	texte = texte.replace(/“/g,'&ldquo;'); // 147 93
	texte = texte.replace(/”/g,'&rdquo;'); // 148 94
	texte = texte.replace(/•/g,'&bull;'); // 149 95
	texte = texte.replace(/–/g,'&ndash;'); // 150 96
	texte = texte.replace(/—/g,'&mdash;'); // 151 97
	texte = texte.replace(/˜/g,'&tilde;'); // 152 98
	texte = texte.replace(/™/g,'&trade;'); // 153 99
	texte = texte.replace(/š/g,'&scaron;'); // 154 9A
	texte = texte.replace(/›/g,'&rsaquo;'); // 155 9B
	texte = texte.replace(/œ/g,'&oelig;'); // 156 9C
	texte = texte.replace(//g,'&#357;'); // 157 9D
	texte = texte.replace(/ž/g,'&#382;'); // 158 9E
	texte = texte.replace(/Ÿ/g,'&Yuml;'); // 159 9F
	// texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
	texte = texte.replace(/¡/g,'&iexcl;'); // 161 A1
	texte = texte.replace(/¢/g,'&cent;'); // 162 A2
	texte = texte.replace(/£/g,'&pound;'); // 163 A3
	//texte = texte.replace(/ /g,'&curren;'); // 164 A4
	texte = texte.replace(/¥/g,'&yen;'); // 165 A5
	texte = texte.replace(/¦/g,'&brvbar;'); // 166 A6
	texte = texte.replace(/§/g,'&sect;'); // 167 A7
	texte = texte.replace(/¨/g,'&uml;'); // 168 A8
	texte = texte.replace(/©/g,'&copy;'); // 169 A9
	texte = texte.replace(/ª/g,'&ordf;'); // 170 AA
	texte = texte.replace(/«/g,'&laquo;'); // 171 AB
	texte = texte.replace(/¬/g,'&not;'); // 172 AC
	texte = texte.replace(/­/g,'&shy;'); // 173 AD
	texte = texte.replace(/®/g,'&reg;'); // 174 AE
	texte = texte.replace(/¯/g,'&macr;'); // 175 AF
	texte = texte.replace(/°/g,'&deg;'); // 176 B0
	texte = texte.replace(/±/g,'&plusmn;'); // 177 B1
	texte = texte.replace(/²/g,'&sup2;'); // 178 B2
	texte = texte.replace(/³/g,'&sup3;'); // 179 B3
	texte = texte.replace(/´/g,'&acute;'); // 180 B4
	texte = texte.replace(/µ/g,'&micro;'); // 181 B5
	texte = texte.replace(/¶/g,'&para'); // 182 B6
	texte = texte.replace(/·/g,'&middot;'); // 183 B7
	texte = texte.replace(/¸/g,'&cedil;'); // 184 B8
	texte = texte.replace(/¹/g,'&sup1;'); // 185 B9
	texte = texte.replace(/º/g,'&ordm;'); // 186 BA
	texte = texte.replace(/»/g,'&raquo;'); // 187 BB
	texte = texte.replace(/¼/g,'&frac14;'); // 188 BC
	texte = texte.replace(/½/g,'&frac12;'); // 189 BD
	texte = texte.replace(/¾/g,'&frac34;'); // 190 BE
	texte = texte.replace(/¿/g,'&iquest;'); // 191 BF
	texte = texte.replace(/À/g,'&Agrave;'); // 192 C0
	texte = texte.replace(/Á/g,'&Aacute;'); // 193 C1
	texte = texte.replace(/Â/g,'&Acirc;'); // 194 C2
	texte = texte.replace(/Ã/g,'&Atilde;'); // 195 C3
	texte = texte.replace(/Ä/g,'&Auml;'); // 196 C4
	texte = texte.replace(/Å/g,'&Aring;'); // 197 C5
	texte = texte.replace(/Æ/g,'&AElig;'); // 198 C6
	texte = texte.replace(/Ç/g,'&Ccedil;'); // 199 C7
	texte = texte.replace(/È/g,'&Egrave;'); // 200 C8
	texte = texte.replace(/É/g,'&Eacute;'); // 201 C9
	texte = texte.replace(/Ê/g,'&Ecirc;'); // 202 CA
	texte = texte.replace(/Ë/g,'&Euml;'); // 203 CB
	texte = texte.replace(/Ì/g,'&Igrave;'); // 204 CC
	texte = texte.replace(/Í/g,'&Iacute;'); // 205 CD
	texte = texte.replace(/Î/g,'&Icirc;'); // 206 CE
	texte = texte.replace(/Ï/g,'&Iuml;'); // 207 CF
	texte = texte.replace(/Ð/g,'&ETH;'); // 208 D0
	texte = texte.replace(/Ñ/g,'&Ntilde;'); // 209 D1
	texte = texte.replace(/Ò/g,'&Ograve;'); // 210 D2
	texte = texte.replace(/Ó/g,'&Oacute;'); // 211 D3
	texte = texte.replace(/Ô/g,'&Ocirc;'); // 212 D4
	texte = texte.replace(/Õ/g,'&Otilde;'); // 213 D5
	texte = texte.replace(/Ö/g,'&Ouml;'); // 214 D6
	texte = texte.replace(/×/g,'&times;'); // 215 D7
	texte = texte.replace(/Ø/g,'&Oslash;'); // 216 D8
	texte = texte.replace(/Ù/g,'&Ugrave;'); // 217 D9
	texte = texte.replace(/Ú/g,'&Uacute;'); // 218 DA
	texte = texte.replace(/Û/g,'&Ucirc;'); // 219 DB
	texte = texte.replace(/Ü/g,'&Uuml;'); // 220 DC
	texte = texte.replace(/Ý/g,'&Yacute;'); // 221 DD
	texte = texte.replace(/Þ/g,'&THORN;'); // 222 DE
	texte = texte.replace(/ß/g,'&szlig;'); // 223 DF
	texte = texte.replace(/à/g,'&agrave;'); // 224 E0
	texte = texte.replace(/á/g,'&aacute;'); // 225 E1
	texte = texte.replace(/â/g,'&acirc;'); // 226 E2
	texte = texte.replace(/ã/g,'&atilde;'); // 227 E3
	texte = texte.replace(/ä/g,'&auml;'); // 228 E4
	texte = texte.replace(/å/g,'&aring;'); // 229 E5
	texte = texte.replace(/æ/g,'&aelig;'); // 230 E6
	texte = texte.replace(/ç/g,'&ccedil;'); // 231 E7
	texte = texte.replace(/è/g,'&egrave;'); // 232 E8
	texte = texte.replace(/é/g,'&eacute;'); // 233 E9
	texte = texte.replace(/ê/g,'&ecirc;'); // 234 EA
	texte = texte.replace(/ë/g,'&euml;'); // 235 EB
	texte = texte.replace(/ì/g,'&igrave;'); // 236 EC
	texte = texte.replace(/í/g,'&iacute;'); // 237 ED
	texte = texte.replace(/î/g,'&icirc;'); // 238 EE
	texte = texte.replace(/ï/g,'&iuml;'); // 239 EF
	texte = texte.replace(/ð/g,'&eth;'); // 240 F0
	texte = texte.replace(/ñ/g,'&ntilde;'); // 241 F1
	texte = texte.replace(/ò/g,'&ograve;'); // 242 F2
	texte = texte.replace(/ó/g,'&oacute;'); // 243 F3
	texte = texte.replace(/ô/g,'&ocirc;'); // 244 F4
	texte = texte.replace(/õ/g,'&otilde;'); // 245 F5
	texte = texte.replace(/ö/g,'&ouml;'); // 246 F6
	texte = texte.replace(/÷/g,'&divide;'); // 247 F7
	texte = texte.replace(/ø/g,'&oslash;'); // 248 F8
	texte = texte.replace(/ù/g,'&ugrave;'); // 249 F9
	texte = texte.replace(/ú/g,'&uacute;'); // 250 FA
	texte = texte.replace(/û/g,'&ucirc;'); // 251 FB
	texte = texte.replace(/ü/g,'&uuml;'); // 252 FC
	texte = texte.replace(/ý/g,'&yacute;'); // 253 FD
	texte = texte.replace(/þ/g,'&thorn;'); // 254 FE
	texte = texte.replace(/ÿ/g,'&yuml;'); // 255 FF
	return texte;	
	}
// ------------------------------------------------------------------------------------------------- //
	
// Fonction permettant d'afficher la famille d'une gamme
function Ajax_Affiche_gamme(id_fam)
	{
	//alert(id_fam);
	
	// On affiche le calque du sous_menu
	//Affiche_element("bulle");
	//Calibre_Calque("bulle");
	
	document.getElementById('div_gamme').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	//document.getElementById('bulle').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	variable = "id_fam="+id_fam;
	//alert(variable);
	var xhr = Get_Xhr("js/recherche_gam.php",variable);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//alert(xhr.responseText);
					document.getElementById('div_gamme').innerHTML = xhr.responseText;
					
					// On affiche le titre de cette rubrique
					Ajax_Affiche_Titre_gamme(id_fam,'','');
            		//document.getElementById('bulle').innerHTML = xhr.responseText;
					} else {
                			/////////////////////// alert('Erreur AJAX');
            				}
        		}
			}
	}

// Fonction permettant d'afficher le titre de la rubrique
function Ajax_Affiche_Titre_gamme(id_fam,id_client,client_type)
	{
	document.getElementById('div_titre_gamme').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	variable = "id_fam="+id_fam;
	var xhr = Get_Xhr("js/recherche_titre_gam.php",variable);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					document.getElementById('div_titre_gamme').innerHTML = xhr.responseText;
					// On test d'afficher les prix
					//var tmp = document.getElementById('hiden_produit').value;
					//alert(document.getElementById('hiden_produit').value);
					//alert(document.getElementById('hiden_div_tarif').value);
					//alert(tmp);
					// On affiche les prix des produits
					if(id_client != "")
						{
						Ajax_Tarif_Produit(document.getElementById('hiden_produit').value,document.getElementById('hiden_div_tarif').value,id_client,client_type)
						}
					} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}


// Fonction permettant d'afficher la gamme d'une famille
function Ajax_Affiche_produit(id_gam,id_client,client_type)
	{
	//alert(id_client);	
	//alert(id_gam);
	//document.getElementById('div_pro').innerHTML = "veuillez patienter...";
	document.getElementById('div_pro').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	variable = "id_gam="+id_gam;
	//alert(variable);
	var xhr = Get_Xhr("js/recherche_pro.php",variable);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					document.getElementById('div_pro').innerHTML = xhr.responseText;
					
					// On affiche le titre de cette rubrique
					Ajax_Affiche_Titre_gamme(id_gam,id_client,client_type);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}

// Fonction permettant d'allumer le bouton du menu du haut
function Menu_Haut(num_btn)
	{
	// On met les boutons par defaut
	document.getElementById('btn_01').src = "./images/skin/v2/contact.jpg";
	document.getElementById('btn_02').src = "./images/skin/v2/catalogue.jpg";
	document.getElementById('btn_03').src = "./images/skin/v2/panier.jpg";
	document.getElementById('btn_04').src = "./images/skin/v2/cmd_enreg.jpg";
	document.getElementById('btn_05').src = "./images/skin/v2/cmd_suivi.jpg";
	document.getElementById('btn_06').src = "./images/skin/v2/client.jpg";
	document.getElementById('btn_07').src = "./images/skin/v2/download.jpg";
	
	// On allume le bon bouton
	switch (num_btn) 
		{
		case "1":
			document.getElementById('btn_01').src = "./images/skin/v2/contact_on.jpg";
			break;
		case "2":
			document.getElementById('btn_02').src = "./images/skin/v2/catalogue_on.jpg";
			break;
		case "3":
			document.getElementById('btn_03').src = "./images/skin/v2/panier_on.jpg";
			break;
		case "4":
			document.getElementById('btn_04').src = "./images/skin/v2/cmd_enreg_on.jpg";
			break;
		case "5":
			document.getElementById('btn_05').src = "./images/skin/v2/cmd_suivi_on.jpg";
			break;
		case "6":
			document.getElementById('btn_06').src = "./images/skin/v2/client_on.jpg";
			break;	
		case "7":
			document.getElementById('btn_07').src = "./images/skin/v2/download_on.jpg";
			break;	
		}
	
	}

// Fonction permettant de calibrer la taille de la bulle
function Calibre_Calque(MyElement)
	{
	//document.getElementById(MyElement).style.left = "0";
	}
// Fonction permettant d'afficher un élément
function Affiche_element(MyElement)
	{
	//alert(MyElement);
	//alert(document.getElementById(MyElement).style.display);
	document.getElementById(MyElement).style.display = "block";
	document.getElementById(MyElement).style.visibility = "visible";
	}

function Masque_element(MyElement)
	{
	//alert(MyElement);
	document.getElementById(MyElement).style.display = "none";
	document.getElementById(MyElement).style.visibility = "hidden";
	}
	
function Masque_element_all(nb_tot_element,prefix)
	{
	//alert(prefix);
	//alert("nb_tot_element : " + nb_tot_element);
	for(i=0 ; i < nb_tot_element; i++)
		{
		MyElement = (prefix + "" + i);
		Masque_element(MyElement)
		}
	}
	

// Fonction permettant d'afficher les images picto
function Ajax_images_open_picto(Id_produit)
	{
	var xhr = Get_Xhr("html/affiche_image_picto.php","Id_produit="+Id_produit);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					//alert("A"+xhr.responseText+"A");
					if(xhr.responseText == " " || xhr.responseText == "")
						{
						//alert("pas d'images");
						// Il n'y a pas de picto donc on supprime les flêche de scrolling
						document.getElementById("fleche_picto_1").innerHTML = "";
						document.getElementById("fleche_picto_2").innerHTML = "";
						}
					document.getElementById("picto").innerHTML = (xhr.responseText);
					//Ajax_images_open_s(Id_produit,'2','schema');
					//Ajax_images_open_normal(Id_produit,'');
					Ajax_images_open_m(Id_produit)
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
// Fonction permettant d'afficher les images marketing
function Ajax_images_open_m(Id_produit)
	{
	var xhr = Get_Xhr("html/affiche_image_mkt.php","Id_produit="+Id_produit);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById("images_m").innerHTML = (xhr.responseText);
					//alert(xhr.responseText);
					var test_img = parseFloat(xhr.responseText.indexOf('<img border='));
					//alert(test_img);
					if (test_img == "-1")
						{
						//alert("go");	
						//alert("efface : A" + xhr.responseText.indexOf('<img border=')+"A");	
						// Il n'y a pas d'image à afficher
						document.getElementById("fleche_mkt_1").innerHTML = "";
						document.getElementById("fleche_mkt_2").innerHTML = "";
						} else {
								//alert("laisse");
								}
					
					//Ajax_images_open_s(Id_produit,'2','schema');
					//Ajax_images_open_normal(Id_produit,'');
					//Ajax_images_open_normal(Id_produit,'');
					Ajax_images_open_f(Id_produit);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
// Fonction permettant d'afficher les images fournisseur
function Ajax_images_open_f(Id_produit)
	{
	var xhr = Get_Xhr("html/affiche_image_four.php","Id_produit="+Id_produit);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById("images_f").innerHTML = (xhr.responseText);
					//Ajax_images_open_s(Id_produit,'2','schema');
					//Ajax_images_open_normal(Id_produit,'');
					//Ajax_images_open_normal(Id_produit,'');
					Ajax_images_open_normal(Id_produit,'');
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
// Fonction permettant d'afficher les images normal
function Ajax_images_open_normal(Id_produit,Id_Image)
	{
	document.getElementById('image').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	var xhr = Get_Xhr("html/affiche_image_normal.php","Id_produit="+Id_produit+"&Id_Image="+Id_Image);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById("image").innerHTML = (xhr.responseText);
					//alert(xhr.responseText);
					//Ajax_images_open_s(Id_produit,'2','schema');
					//Ajax_images_open_normal(Id_produit);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
	


/*	
// Fonction permettant d'afficher les images du produit progressivement
function Ajax_images_open_i(Id_produit,Type,Emplacement)
	{
	//alert(Id_produit);	
		
	Get_Xhr("html/affiche_image.php","Id_produit="+Id_produit+"&img_type="+Type);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById(Emplacement).innerHTML = (xhr.responseText);
					Ajax_images_open_s(Id_produit,'2','schema');
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
			
	}
	
// Fonction permettant d'afficher les images du produit progressivement
function Ajax_images_open_s(Id_produit,Type,Emplacement)
	{
	Get_Xhr("html/affiche_image.php","Id_produit="+Id_produit+"&img_type="+Type);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById(Emplacement).innerHTML = (xhr.responseText);
					Ajax_images_open_m(Id_produit,'3','images_m');
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}	
// Fonction permettant d'afficher les images du produit progressivement
function Ajax_images_open_m(Id_produit,Type,Emplacement)
	{
	Get_Xhr("html/affiche_image.php","Id_produit="+Id_produit+"&img_type="+Type);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById(Emplacement).innerHTML = (xhr.responseText);
					Ajax_images_open_m(Id_produit,'4','images_f');
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
// Fonction permettant d'afficher les images du produit progressivement
function Ajax_images_open_f(Id_produit,Type,Emplacement)
	{
	Get_Xhr("html/affiche_image.php","Id_produit="+Id_produit+"&img_type="+Type);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					document.getElementById(Emplacement).innerHTML = (xhr.responseText);
					//Ajax_images_open_m(Id_produit,'4','images_f');
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}	

*/
// Fonction permettant d'afficher une image en grand
function ShowPicture(chemin)
	{
		
	// On met le fond grisé
	Resize_element("Div_Fond_Voile",document.body.clientWidth,document.body.clientHeight);
	document.getElementById('Div_Fond_Voile').className = "Div_Background_on";
	
	Create_Window(500,300,"Chargement en cours...");
	//alert("test");
	//centre_div_v2('Div_Bulle_Info');
	centre_div('Div_Bulle_Info');
	//alert("test fin");
	//var div_new_hauteur = 300;
	//var div_new_longeur = 300;
	//document.getElementById('calque_img').style.width = div_new_longeur + "px";
	//document.getElementById('calque_img').style.height = div_new_hauteur + "px";	
	

	// On désactive l'ascenseur
	//var htmlElement = document.getElementsByTagName('html')[0];	
	//htmlElement.style.overflow = 'hidden'
	//var new_top = (htmlElement.clientHeight / 2) - (div_new_hauteur / 2);
	//var new_left = (htmlElement.clientWidth / 2) - (div_new_longeur / 2);

	// On centre le div  de l'image
	//document.getElementById('calque_img').style.top = new_top + "px";
	//document.getElementById('calque_img').style.left = new_left + "px";
	//document.getElementById('calque_fond').style.visibility="visible";
	//document.getElementById('calque_img').style.visibility="visible";
	//document.getElementById('calque_img').innerHTML = "chargement en cour...";
	var xhr = Get_Xhr("html/img_big.php","chemin="+chemin);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('calque_img').innerHTML = xhr.responseText;
					document.getElementById('Bulle_Info_Txt').innerHTML = xhr.responseText;
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}
	
// Fonction permettant de fermer une image
function HiddenPicture()
	{
	// On réactive l'asensceur
	var htmlElement = document.getElementsByTagName('html')[0];
	htmlElement.style.overflow = "";
	
	document.getElementById('calque_img').innerHTML = " ";
	document.getElementById('calque_img').style.visibility="hidden";
	document.getElementById('calque_fond').style.visibility="hidden";
	}
	
function tmp()
	{
	alert("TEST");	
	}
	



	
function Ajax_Famille_Img(js_TAB_div,js_TAB_id)
	{
	for(var i=0; i < js_TAB_div.length; i++)
		{
		var nom_div = js_TAB_div[i];
		var image_id = js_TAB_id[i];
		var ActionTag = "1";
		//ActionElement = "document.getElementById("+image_id+").src";
		//ActionElement = nom_div;
		var mAjax = new ajaxClass(ActionTag,"html/affiche_img_fam.php", nom_div,"image_id="+image_id);
		mAjax.execute();	
		}	
	}
	

// Fonction permettant de calculer le tarif d'un article
function Ajax_Tarif_Ref(TAB_div,TAB_ref,client,client_type)
	{
	//alert(client);
	//alert(TAB_div.length);
	
	
	for(var i=0; i < TAB_div.length; i++)
		{
		var nom_div = TAB_div[i];
		var ref_produit = TAB_ref[i];
		
		var ActionTag = "2";
		var mAjax = new ajaxClass(ActionTag,"html/affiche_tarif_ref.php", nom_div,"ref_produit="+ref_produit+"&client="+client+"&client_type="+client_type+"");
		mAjax.execute();
		
		//alert('nom_div => ' + nom_div + 'ref_produit => ' + ref_produit + 'client => ' + client + 'client_type => ' + client_type);
		}
		
	}
	
// Fonction permettant de calculer le tarif d'un article
function Ajax_Tarif_Ref_Nouveaute(TAB_div,TAB_ref,client,client_type)
	{
	//alert(client);
	//alert(TAB_div.length);
	
	
	for(var i=0; i < TAB_div.length; i++)
		{
		var nom_div = TAB_div[i];
		var ref_produit = TAB_ref[i];
		
		var ActionTag = "4";
		var mAjax = new ajaxClass(ActionTag,"html/affiche_tarif_ref.php", nom_div,"ref_produit="+ref_produit+"&client="+client+"&client_type="+client_type+"");
		mAjax.execute();
		
		//alert('nom_div => ' + nom_div + 'ref_produit => ' + ref_produit + 'client => ' + client + 'client_type => ' + client_type);
		}
		
	}

function Ajax_session_open(tag_user,tag_passwd,cookie_active)
//function Ajax_session_open()
	{
	var user = document.getElementById('user').value;
	var passwd = document.getElementById('passwd').value;

	//var client_type = "0";
	/*
	// Par defaut on en peut se connecter qu'avec un compte PRO
	if(document.getElementById('client_pro').checked)
		{
		client_type = "1";
		}
	if(document.getElementById('client_part').checked)
		{
		client_type = "2";
		}
	*/
	
	btn_cookies_user = "0";
	if(tag_user=="0" && cookie_active=="true")
		{
		if(document.getElementById('btn_cookies_user').checked == true)
				{
				btn_cookies_user = "1";
				}
		//alert(btn_cookies_user);			
		}
		
	btn_cookies_passwd = "0";
	if(tag_passwd=="0" && cookie_active=="true")
		{
		if(document.getElementById('btn_cookies_passwd').checked == true)
				{
				btn_cookies_passwd = "1";	
				}	
		}
	
	client_type = "1";
	
	//alert(user+" => "+passwd+" => "+client_type);
	document.getElementById('info_login').innerHTML = "connection en cours...";
	//variable = "client_type="+client_type+"&user="+user+"&passwd="+passwd+"&cookie_active="+cookie_active;
	variable = "client_type="+client_type+"&user="+user+"&passwd="+passwd+"&btn_cookies_user="+btn_cookies_user+"&btn_cookies_passwd="+btn_cookies_passwd+"&cookie_active="+cookie_active;
	// var xhr = Get_Xhr("html/affiche_image_normal.php","Id_produit="+Id_produit+"&Id_Image="+Id_Image);
	
	var xhr = Get_Xhr("js/session_open.php",variable);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var result_login = xhr.responseText;
					//alert("TEST" + result_login + "TEST");
					//document.getElementById('info_login').innerHTML = result_login;

					
					if(result_login == "ok")
						{
						// On rafraichi la page en cours en vidant le cache car si on est sur le catalogue les prix ne sont plus bon
						//Ajax_login_2();
						//window.location.reload(true);
						//window.location = "catalogue.php";
						window.location.reload();
						//alert("ok suite...");
						}
					if(result_login == "erreur_10")
						{
						//alert("date depasse et mot de passe inchange => compte desactive");
						contenu = HTMLentities("Cher client,");
						contenu += ("<br><br><br>");
						contenu += HTMLentities("Votre mot de passe temporaire aurait dû être modifié avant le 15/02/2011.");
						contenu += ("<br><br>");
						contenu += HTMLentities("Par sécurité votre compte a été désactivé.");
						contenu += ("<br><br>");
						contenu += HTMLentities("Veuillez nous contacter au 04-76-33-31-89 pour le réactiver.");
						contenu += ("<br><br>");
						contenu += ("<p align=\"right\">");
						contenu += HTMLentities("Merci de votre compréhension.");
						contenu += ("</p>");
						Create_Window(500,300,contenu);
						document.getElementById('info_login').innerHTML = HTMLentities("compte désactivé");
						}
					if(result_login == "erreur_11")
						{
						contenu = HTMLentities("Veuillez entrer votre identifiant et mot de passe.");
						Create_Window(500,300,contenu);
						document.getElementById('info_login').innerHTML = HTMLentities("Veuillez entrer votre identifiant et mot de passe.");
						}
					if(result_login == "erreur_12")
						{
						contenu = HTMLentities("Utilisateur ou mot de passe invalide.");
						Create_Window(500,300,contenu);
						document.getElementById('info_login').innerHTML = HTMLentities("Utilisateur ou mot de passe invalide.");
						}
					if(result_login == "erreur_13")
						{
						contenu = ("<br>");
						contenu += HTMLentities("Bienvenue sur le site internet de GERARD ET PEYSSON.");
						contenu += ("<br><br>");
						contenu += HTMLentities("Le mot de passe que vous venez de saisir est TEMPORAIRE.");
						contenu += ("<br><br>");
						contenu += ("Pour activer votre compte-client, veuillez vous rendre dans votre espace client et ");
						contenu += ("<a href='espace_client.php?p=if'>");
						contenu += HTMLentities("changez votre mot de passe.");
						contenu += ("</a>");
						contenu += ("<br><br>");
						contenu += HTMLentities("Au delà du 15/02/2011, votre mot de passe temporaire ne sera plus valide.");
						Create_Window(500,300,contenu);
						document.getElementById('Btn_close').innerHTML = "<a href=\"#\" onclick=\"Close_Window();window.location.reload();return false;\" class=\"txt_del_red\">[X] Fermer</a>";
						//window.location.reload();
						//document.getElementById('info_login').innerHTML = "Utilisateur ou mot de passe invalide.";
						}	
						
						//else {
								//alert("pas ok");
								//document.getElementById('info_login').innerHTML = result_login;
								
								//}
            		//alert("xhr.responseText : " + xhr.responseText);
            		} else {
                			alert('Erreur de connection');
            				}
        		}
			}		
	}


// ---------------------------------- Gestion des sessions ----------------------------------------------- //
// Fonction permettant d'include le module login2.php à la place de login.php
function Ajax_login_2()
	{
	//alert("test");
	//getXhr();
	
	var xhr = Get_Xhr("templates/login_2.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					document.getElementById('module_login').innerHTML = xhr.responseText;
            		//alert(xhr.responseText);
					} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	//document.getElementById('module_login').innerHTML = "<?php include('../html/test.html') ?>";	
	
	}
	
// Fonction permettant d'include le module login.php à la place de login_2.php
function Ajax_login()
	{
	//getXhr();
	var xhr = Get_Xhr("templates/login.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('info_login').innerHTML = xhr.responseText;
            		//alert("xhr.responseText : " + xhr.responseText);
					//alert(xhr.responseText);
					document.getElementById('module_login').innerHTML = xhr.responseText;
					// On rafraichi la page en cours en vidant le cache car si on est sur le catalogue les prix ne sont plus bon
					window.location.reload(true);  
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	//document.getElementById('module_login').innerHTML = "<?php include('../html/test.html') ?>";	
	}
	

// On ferme la session et les variables de session en cours
function Ajax_session_close()
	{
	//alert("affichage login");
	/*
	//getXhr();
  	xhr.onreadystatechange = function()
   		{
    	if(xhr.readyState == 4 && xhr.status == 200)
    		{
    		// Nous recuperons ce coup ci le retour dans une variable
    		var chaine = xhr.responseText;
			//alert("contenu panier "+chaine);
			alert(chaine);
			}
   		}
  		xhr.open("POST",'js/session_close.php',true);
  		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(null);
	*/
	
		//alert(Id_produit);
	//alert("test : " + Id_produit);
	//getXhr();
	//alert("test");
	//alert("close");
	document.getElementById('info_login').innerHTML = "Veuillez patienter..."
	//document.getElementById('info_login').innerHTML = "connection en cours...";
	var xhr = Get_Xhr("js/session_close.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//window.location.reload(true);
					window.location = "catalogue.php";
					//alert(xhr.responseText);
					//document.getElementById('images').innerHTML = xhr.responseText
					//window.location.reload(true);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	
	}
	
// ---------------------------------- Gestion des sessions ----------------------------------------------- //	



// ---------------------------------- Gestion du Panier    ----------------------------------------------- //	
// Fonction permettant d'ajouter un article au panier
function Panier_add_article(reference_produit,div_tarif,id_produit,client)
	{
	//alert(reference_produit);
	//alert(div_tarif);
	//alert(id_produit);
	//alert(client);
	if(client == "-1")
		{
		alert("Vous devez vous identifier pour commander un produit");	
		
		}else {	
				//alert("test");	
				//alert(reference_produit + " => " + div_tarif);
				//alert(document.getElementById(div_tarif).innerHTML);
				panier_info("ajout en cours...");
				
				var article_tarif = document.getElementById("hid_"+div_tarif).value;
				var article_qte = document.getElementById("qte_"+div_tarif).value;
				Create_Window(500,300,"Ajout du produit "+reference_produit+" dans votre commande. Veuillez patienter...")
				//alert("A"+article_tarif+"A");
				//alert(isFinite(article_tarif));
				// On test si le tarif de l'article est bien un chiffre
				//alert(reference_produit);
				//alert(article_tarif+" qte : "+article_qte);
				if((isFinite(article_tarif) == false) || (isFinite(article_qte) == false) || (article_qte == "0" ) || (parseFloat(article_qte) < 0 ) || (article_qte == "NC" ) || article_tarif == "0" || isNaN(reference_produit)==true || article_tarif == "")
					{
					//alert("Le tarif ou la quantit\351 de cet article n'est pas une valeur valide permettant de le commander.");	
					document.getElementById("Bulle_Info_Txt").innerHTML = "Le tarif ou la quantit\351 de cet article n'est pas une valeur valide permettant de le commander.";
					} else {
							//alert("ajoute au panier...");
							// On ajoute cet article dans le panier
							//alert(article_qte);
							var xhr = Get_Xhr("js/panier.php","reference_produit="+reference_produit+"&tarif_produit="+article_tarif+"&id_produit="+id_produit+"&article_qte="+article_qte);
							xhr.onreadystatechange = function() 
								{ 
								if (xhr.readyState == 4)
									{
    			   					if (xhr.status == 200) 
										{
										// On affiche un message d'erreur si le produit existe déjà dans le panier sinon on récupère le nombre total de produit dans le panier
    									var chaine = xhr.responseText;
										chaine = chaine.split('|');
										// On test si ce produit est déjà présent dans le panier
										if(chaine[0] != "1")
											{
											//alert(chaine[0]);
											document.getElementById("Bulle_Info_Txt").innerHTML = chaine[0];
											}
										// On affiche le nombre de produit dans le panier
										var tot_produit = chaine[1];
										var text_panier = "Il y a " + tot_produit + " article(s) dans le panier.";
										//alert("fin");
    									panier_info(text_panier);
										//alert("fin 2");
										if(chaine[0] == "1")
											{
											document.getElementById("Bulle_Info_Txt").innerHTML = "L'article "+reference_produit+" a \351t\351 int\351gr\351 dans votre commande.<br>"+text_panier+"<br><br><br><p align='center'><a href='panier_affiche.php'><img src=\"../images/skin/panier/btn_cmd_fin.jpg\" border='0' /></a> <a href='#' onclick='Close_Window();return false;'><img src=\"../images/skin/cat/chapitre/tableau/retour_catalogue.jpg\" border='0' /></a></p>";
											}
										//alert("fin 3");
										//Close_Window();
    			        				} else {
    			            					alert('Erreur AJAX');
    			        						}
    			    				}
								}
							}
	
				}
	}
	
	
// Fonction permettant d'afficher le nombre d'article dans le panier
function panier_info(text)
	{
	//alert(document.getElementById('info').value);
	//document.getElementById('panier_txt').innerHTML = "Il y a 0 article(s) dans le panier.";
	
	//document.getElementById('panier_txt').innerHTML = text;
	}
	
// Fonction permettant de lister le contenu du panier
function Panier_liste()
	{
	var xhr = Get_Xhr("js/panier_contenu.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					alert("contenu panier : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}

function Session_liste()
        {
        alert("test");
	var xhr = Get_Xhr("js/session_contenu.php",null);
        xhr.onreadystatechange = function()
                        {
                        if (xhr.readyState == 4)
                                {
                        if (xhr.status == 200)
                                        {
                                        //document.getElementById('images').innerHTML = xhr.responseText;
                                        var chaine = xhr.responseText;
                                        alert("contenu panier : \n"+chaine);
                        		} else {
                                        	alert('Erreur AJAX');
                                        	}
                        	}
                        }
        }

	
// Fonction permettant de modifier le montant d'un article du panier après avoir modifié la quantité
//function Ajax_Modif_Montant(div_montant,tarif_produit,qte_produit)
	//{
	//alert(div_montant + " => " + tarif_produit + " => " + qte_produit);	
	//}
	
function Ajax_Modif_QTE(div_montant,tarif_produit,qte_produit,ref_produit)
	{
	/*	
	alert(div_montant + " => " + tarif_produit + " => " + qte_produit + " => " + ref_produit);
	
	var new_montant = (tarif_produit * qte_produit);
	alert("new_montant : " + new_montant);
	document.getElementById("montant_0").innerHTML = new_montant;
	*/
	
	/*
	// On modifi les valeurs du panier
	var xhr = Get_Xhr("js/panier_modif.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					//alert("contenu panier : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	*/
	}
	
// Fonction permettant de calculer tous le panier
function calc_panier()
	{
	//alert("debut");
	// on récupère les nouvelles quantités
	var tot_produit = document.getElementById('i_produit').value;
	
	
	if(tot_produit == "")
		{
		// Le panier ne contient rien car l'utilisateur n'est pas connecté
		} else
				{
				var TAB_QTE = new Array();
				for(i=0 ; i < tot_produit; i++)
					{
					var My_qte = document.getElementById('qte_'+i).value;
					//alert(My_qte);
					TAB_QTE.push(My_qte);
					}
				//alert(TAB_QTE);	
	
				var xhr = Get_Xhr("js/panier_calcul.php","TAB_QTE="+TAB_QTE);
				xhr.onreadystatechange = function() 
					{ 
					if (xhr.readyState == 4)
						{
       					if (xhr.status == 200) 
							{
							var chaine_panier = xhr.responseText;
							//alert("contenu panier : \n"+chaine);
            				//alert(chaine_panier);
							// On affiche le contenu de la session du tableau dans la page actuel du panier
					
							// On explode la chaine
							var TAB_article = chaine_panier.split("|");
							//alert(TAB_article);
							var Total = 0;
							for(i=0 ; i < TAB_article.length; i++)
								{
								//alert(TAB_article[i]);
								var TAB_article_info = 	TAB_article[i].split(":");
								//////for(j=0 ; j < TAB_article_info.length; j++)
								//////{
								var Article_Ref = TAB_article_info[0];
								var Article_Qte = TAB_article_info[1];
								var Article_Tarif = TAB_article_info[2];
								var Article_montant = TAB_article_info[3];
								//var Article_i_produit = TAB_article_info[4];
								//var Article_stock = TAB_article_info[5];
								document.getElementById('montant_'+i).innerHTML = Article_montant;
								
								// On affiche l'état du stock de ce produit
								//var stock_id = "stock_".$Article_i_produit;
								//var stock = Article_stock(Article_Ref);
								//Ajax_Affiche_Stock(Article_stock,Article_Qte,stock_id);
							
							
								Total = (parseFloat(Total) + parseFloat(Article_montant));
								//alert("Total : " + Total);
								//alert(Article_montant);
								//////}
								//alert(Article_Ref);
								}
								//alert("Total : " + Total);
							Total = Math.round(Total * 100) / 100;
							//alert("Total : " + Total);
							document.getElementById('div_total').innerHTML = ("<b>"+Total+"</b>");
							} else {
                					alert('Erreur AJAX');
            						}
        				}
					}
				// Fin de la condition IF
				}		
	//alert("fin");			
	}

// Fonction permettant de supprimer un produit du panier
function Panier_del_article(i_produit)
	{
	//alert(i_produit);
	
	
	var xhr = Get_Xhr("js/panier_article_del.php","i_produit="+i_produit);
	//var xhr = Get_Xhr("js/panier_article_del.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					//var chaine = xhr.responseText;
					//alert(chaine);
					//alert("Elément supprimé.");
					//alert("Supprime : " + xhr.responseText);
					window.location.href = "panier_affiche.php";
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
			
	
	// On réaffiche le panier
	//
	}
	



// ---------------------------------- Gestion du Panier    ----------------------------------------------- //

// Fonction permettant de mettre un fond à une rubrique
function Ajax_Branche_Over(tr)
	{
	tr.style.backgroundColor="#F0F0F0";
	}
function Ajax_Branche_Out(tr)
	{
	tr.style.backgroundColor="#FFFFFF";	
	}
	
	
// Fonction permettant de rechercher le prix d'un produit (ou à partir de...)
function Ajax_Tarif_Produit(id_produit,div_produit,id_client,client_type)
	{
	//alert("Ajax_Tarif_Produit");
	//alert("client_type : "+client_type);
	//alert("client_id : "+id_client);
	//alert(id_produit);
	//alert(div_produit);
	
	var js_TAB_id_produit= new Array();
	var js_TAB_div_produit= new Array();
	
	js_TAB_id_produit = id_produit.split('<id_produit>');
	js_TAB_div_produit = div_produit.split('<div_produit>');
	//$pieces = explode(" ", $pizza);
	//alert(js_TAB_id_produit.length);
	//alert(js_TAB_div_produit[0]);
	//alert(js_TAB_id_produit[0]);
	for(var i=0; i < js_TAB_id_produit.length; i++)
		{
		var nom_div = js_TAB_div_produit[i];
		var id_produit = js_TAB_id_produit[i];
		
		//alert(nom_div + ' | ' + id_produit);
		
		document.getElementById(nom_div).innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
		
		//alert(id_produit);
		var ActionTag = "4";
		var mAjax = new ajaxClass(ActionTag,"html/affiche_tarif_produit.php", nom_div,"id_produit="+id_produit+"&id_client="+id_client+"&client_type="+client_type);
		mAjax.execute();
		}
	}
	
// Fonction permettant de changer la valeur de la quantité dans la cellule
function Ajax_Change_Qte(myObj, sens)
	{
		
	//alert(myObj);
	valeur_origine = document.getElementById(myObj).value;
	//alert(valeur_origine);
	//alert(valeur_origine);
	//if(isFinite(valeur_origine) == false)
	//if(isFinite(valeur_origine) == false || !isNaN(valeur_origine) == false || valeur_origine<1 || parseFloat(valeur_origine) == false)
	
	var exp = new RegExp("^[0-9]+$","g");
	if(exp.test(valeur_origine) == false) 
		{
		// La valeur d'origine n'est pas un chiffre donc on remet sur 1
		document.getElementById(myObj).value = parseInt(1);
		} else {
				// On converti la chaine de caractère en entier
				//valeur_origine = parseFloat(valeur_origine);
				valeur_origine = parseInt(valeur_origine);
				// On peut modifier la valeur
				if((sens == "-") && (valeur_origine >= 2))
					{
					document.getElementById(myObj).value = valeur_origine - 1;
					//Ajax_Change_Qte_Panier(ref,document.getElementById(myObj).value);
					}
				if(sens == "+")
					{
					document.getElementById(myObj).value = valeur_origine + 1;
					//Ajax_Change_Qte_Panier(ref,document.getElementById(myObj).value);
					}
				}
	//alert("fin");
	
	}

/*
// Fonction permettant de changer la QTE de la session du panier
function Ajax_Change_Qte_Panier(ref,new_qte)
	{
	alert(ref + " => " + new_qte);
	// On change la QTE de la session du panier
	
	var xhr = Get_Xhr("js/panier_change_qte.php","ref="+ref+"&new_qte="+new_qte);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					alert("Vore panier a bien été mis à jour");	
					//document.getElementById("div_pa").innerHTML = (xhr.responseText);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	
	}
*/

function Ajax_Stock_Ref(js_TAB_stock,js_TAB_stock_div,js_TAB_stock_qte)
	{
	//alert("stock => " + js_TAB_stock.length);	
	for(var i=0; i < js_TAB_stock.length; i++)
		{
		var stock = js_TAB_stock[i];
		var stock_id = js_TAB_stock_div[i];
		var qte_id = js_TAB_stock_qte[i];
		//alert(stock + " => " + stock_id + " => " + qte_id);
		Ajax_Affiche_Stock(stock,qte_id,stock_id)
		}	
	}

// Fonction permettant d'afficher le bon stock
// 1 Qte < stock => pastille verte : "En stock"
// 2 Delai Mercure => pastille rouge : "Délais entre 5 et 10 jours ouvrables"
// 3 Qte >= stock => pastille rouge : "Délais entre 2 et 10 jours ouvrable, pour toute urgence nous consulter"
function Ajax_Affiche_Stock(stock,qte_id,stock_id)
	{
	
	qte = document.getElementById(qte_id).value;
	//alert(stock + " | " + qte);	
	//qte = parseFloat(qte);
	//stock = parseFloat(stock);
	
	//alert(stock + " ==== " + qte);
	
	message_stock = "";
	
	if(stock == "SC")
		{
		//message_stock = "Delai 5/10 jrs ("+stock+")";
		//message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_3.jpg\" border=\"0\"/> ("+stock+")";
		message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_3.png\" border=\"0\"/ alt=\"D\351lai 5/10 jours\">";
		} else if(stock == "NC")
			{
			message_stock = "NC";	
			} else if(parseFloat(qte) <= parseFloat(stock))
				{
				//message_stock = "En Stock ("+stock+")";	
				//message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_1.jpg\" border=\"0\"/> ("+stock+")";
				message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_1.png\" border=\"0\" alt=\"En stock\"/>";
				} else {
						//message_stock = "Delai entre 2 et 10 jrs ("+stock+")";
						//message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_2.jpg\" border=\"0\"/> ("+stock+")";
						message_stock = "<img src=\"./images/skin/cat/chapitre/tableau/stock_2.png\" border=\"0\" alt=\"D\351lai 2/10 jours\"/>";
						}
	
	
	document.getElementById(stock_id).innerHTML=message_stock;
	
	}

	
// Fonction permettant de mettre un div en opacity
//function set_opacity(id, opacity)
function set_opacity(id, action)	
	{
	//alert(id);	
		
    el = document.getElementById(id);
    //el.style["filter"] = "alpha(opacity="+opacity+")";
    //el.style["-moz-opacity"] = opacity/100;
    //el.style["-khtml-opacity"] = opacity/100;
    //el.style["opacity"] = opacity/100;
    //alert(el);
	if(action == "out")
		{
		el.className = "voile";
		} else {
				el.className = "voile_off";
				}
	
	return true;
	
	}
	
// Fonction permettant d'afficher les Produits Associées
function Ajax_affiche_PA(Id_produit)
	{
	//alert("go");	
	//document.getElementById('div_pa').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	document.getElementById('div_pa').innerHTML = "Chargement en cours...";
	var xhr = Get_Xhr("html/affiche_pro_assoc.php","Id_produit="+Id_produit+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					//alert(xhr.responseText);	
					document.getElementById("div_pa").innerHTML = (xhr.responseText);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
	
// Fonction permettant d'afficher les même produit de cette gamme
function Ajax_affiche_meme_gam(Id_produit,Id_gamme)
	{
	//alert("go");	
	//document.getElementById('div_pa').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	document.getElementById('div_pa').innerHTML = "Chargement en cours...";
	var xhr = Get_Xhr("html/affiche_meme_gam.php","Id_produit="+Id_produit+"&Id_gamme="+Id_gamme);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					//alert(xhr.responseText);	
					document.getElementById("div_pa").innerHTML = (xhr.responseText);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
	
// Fonction pemettant d'afficher la fiche technique de ce produit
function Ajax_affiche_FT(Id_produit)
	{
	//alert("go");	
	//document.getElementById('div_pa').innerHTML = "<img src='./images/chargement.gif' alt='' width='32' height='32' />";
	document.getElementById('div_pa').innerHTML = "Chargement en cours...";
	var xhr = Get_Xhr("html/affiche_ft.php","Id_produit="+Id_produit+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200)
					{
					//alert(xhr.responseText);	
					document.getElementById("div_pa").innerHTML = (xhr.responseText);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
	
////////////////// Comparateur ///////////////////////////	
// Fonction permettant de lister le contenu du panier
function Comparateur_liste()
	{
	var xhr = Get_Xhr("js/comparateur_contenu.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					alert("contenu comparateur : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}
	
// Fonction permettant d'ajouter une référence dans le comparateur
function Comparateur_add_article(ref,titre,id_produit)
	{
	//alert(ref + " => " + titre);
	document.getElementById('comp_info').innerHTML = "Ajout d'un nouveau produit en cours...";
	var xhr = Get_Xhr("js/comparateur_add.php","reference_produit="+ref+"&titre_produit="+titre+"&id_produit="+id_produit);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					if(chaine == 0)
						{
						info = "Le comparateur à été mis à jour";	
						//alert(info);
						// On affiche le nouveau contenu du comparateur
						Comparateur_affiche();
						} else {
								info = chaine;
								document.getElementById('comp_info').innerHTML = info;
								}
								
					//alert("contenu comparateur : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}
	
// Fonction pemettant de supprimer un produit du comparateur
function Comparateur_del_article(i_produit)
	{
	//alert(i_produit);
	document.getElementById('comp_info').innerHTML = "Suppression d'un nouveau produit en cours...";
	var xhr = Get_Xhr("js/comparateur_del.php","i_produit="+i_produit);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					if(chaine == 0)
						{
						info = "Le comparateur à été mis à jour";	
						//alert(info);
						// On affiche le nouveau contenu du comparateur
						Comparateur_affiche();
						} else {
								info = chaine;
								document.getElementById('comp_info').innerHTML = info;
								}
								
					//alert("contenu comparateur : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	}


function Comparateur_vide()
	{
	Create_Window(500,300,"Souhaitez-vous vider votre comparateur ?<br><br><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\"><a href='#' onclick='Comparateur_vide_valide();return false;'><img src=\"./images/skin/btn_oui.jpg\" width=\"72\" height=\"29\" border=\"0\" /></a></td><td align=\"center\"><a href='#' onclick='Close_Window();return false;'><img src=\"./images/skin/btn_non.jpg\" width=\"72\" height=\"29\" border=\"0\" /></a></td></tr></table>")	
	}

// Fonction permettant de vider entièrement le comparateur
function Comparateur_vide_valide()
	{
	//alert("vide comparateur");
	//if (confirm("Voulez-vous vider le comparateur en cours ?")) 
	//{
	document.getElementById('comp_info').innerHTML = "Suppression du comparateur en cours...";
	var xhr = Get_Xhr("js/comparateur_vide.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					if(chaine == 0)
						{
						info = "Le comparateur à été mis à jour";	
						//alert(info);
						// On affiche le nouveau contenu du comparateur
						Comparateur_affiche();
						} else {
								info = chaine;
								document.getElementById('comp_info').innerHTML = info;
								}
								
					//alert("contenu comparateur : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	//} else {
		
			//}
	Close_Window();		
	}
/*
function Comparateur_vide()
	{
	//alert("vide comparateur");
	if (confirm("Voulez-vous vider le comparateur en cours ?")) 
	{
	document.getElementById('comp_info').innerHTML = "Suppression du comparateur en cours...";
	var xhr = Get_Xhr("js/comparateur_vide.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					if(chaine == 0)
						{
						info = "Le comparateur à été mis à jour";	
						//alert(info);
						// On affiche le nouveau contenu du comparateur
						Comparateur_affiche();
						} else {
								info = chaine;
								document.getElementById('comp_info').innerHTML = info;
								}
								
					//alert("contenu comparateur : \n"+chaine);
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	} else {
		
			}
	}
*/

// Fonction permettant d'afficher le comparateur dans la page
function Comparateur_affiche()
	{
	//alert("affiche comparateur");	
	
	//        ./js/comparateur_affiche.php
	
	document.getElementById('comp_contenu').innerHTML = "Veuillez patienter...";
	var xhr = Get_Xhr("js/comparateur_affiche.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('images').innerHTML = xhr.responseText;
					var chaine = xhr.responseText;
					//alert("TEST : " + chaine);
					document.getElementById('comp_contenu').innerHTML = chaine;
					document.getElementById('comp_info').innerHTML = "";
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	
	}
	
// Fonction permettant de vider le panier
function Panier_vide()
	{

	//document.getElementById('comp_info').innerHTML = "Veuillez patienter...";
	var xhr = Get_Xhr("js/panier_vide.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					//document.getElementById('comp_info').innerHTML = "";
					//Comparateur_affiche();
					//alert("Fin");
					//alert("Votre panier est vide");
					window.location.reload();
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
	
	}
//////////////////////////////////////////////////////////


///////////////////////////////////////////////////////// TREEVIEW //////////////////////////////////////////////////////////
// Récupère les coordonnées Y d'un DIV
function OffsetY(Obj) 
	{
	if (Obj.offsetParent) 
		{
		return (Obj.offsetTop + OffsetY(Obj.offsetParent));
		} else {
				return (Obj.offsetTop);
				}
	}
	
// Récupère les coordonnées Right d'un DIV
function OffsetR(Obj) 
	{
	if (Obj.offsetParent) 
		{
		return (Obj.offsetLeft + OffsetR(Obj.offsetParent));
		} else {
				return (Obj.offsetLeft);
				}
	}	
//alert(OffsetL(document.getElementById('menu-principal')));

/// Affichage du treeview ///
function Ajax_cha_enter(div_name,Enfant,tot_fam,i_cour)
	{
	//alert(i_cour);	
	// On supprime toutes les familles ouvertes
	for (i=0; i<=tot_fam ; i++)
		{
		var tmp_div = "div_fam_"+i;
		//alert(i);
		if(document.getElementById(tmp_div) != null)
			{
			//alert("supprime : " + tmp_div);
			document.body.removeChild(document.getElementById(tmp_div));
			}
		}
		
		
	//alert(tot_fam);
	//var Obj = document.getElementById(div_name);

	var coordonneeY = OffsetY(document.getElementById(div_name));
	var coordonneeR = (OffsetR(document.getElementById(div_name)) + document.getElementById(div_name).offsetWidth);


	//alert(div_name + " => " + Enfant + " => " + coordonneeY + " => " + coordonneeR);
	
	// On crait le nouveau DIV
	var nouveauDiv = document.createElement('div');
	nouveauDiv.id = 'div_fam_'+i_cour;
	//nouveauDiv.offsetLeft = coordonneeR;
	//nouveauDiv.offsetTop = coordonneeY;
	//nouveauDiv.offsetWidth = 300;
	//nouveauDiv.offsetHeigth = 300;
	nouveauDiv.innerHTML = "<table width=\"300\" border=\"1\"><tr><td>Veuillez patienter...</td></tr></table>";
	nouveauDiv.style.position="absolute";
	nouveauDiv.style.zIndex = 10;

	nouveauDiv.style.left=coordonneeR - 20 +'px';
	nouveauDiv.style.top=coordonneeY+'px';
	//nouveauDiv.style.width='290';
	//nouveauDiv.style.height='75';
	//nouveauDiv.style.z-index = '1';
	
	//nouveauDiv.style.width = 300;
	//document.body.appendChild(nouveauDiv);
	document.body.appendChild(nouveauDiv);
	
	Ajax_Teeview_Fam(nouveauDiv,Enfant,i_cour);
	
	//var nouveautexteli = document.createTextNode("C'est l'élément de liste numéro ");
  	//document.body.appendChild(nouveautexteli);

	
	//document.getElementById(div_name).appendChild(nouveauDiv);
	}
	
// Fonction permettant de récupérer le contenu d'un chapitre
function Ajax_Teeview_Fam(nouveauDiv,Enfant,i_cour)
	{
	//alert(nouveauDiv.id);
	//alert(document.getElementById('div_fam_12').innerHTML);
	var div_name = nouveauDiv.id;
	//document.getElementById('comp_info').innerHTML = "Veuillez patienter...";
	var xhr = Get_Xhr("js/treeview_fam.php","id_fam="+Enfant+"&div_name="+div_name+"&i_cour="+i_cour+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					nouveauDiv.innerHTML = chaine;
					//alert("Fin");
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}
////////////////////////////////////////////////// FIN TREEVIEW ////////////////////////////////////////////////////////////

// Fonction permettant d'afficher un élément marketing dans la page en cours
function Ajax_Affiche_MKT(Id_Pro)
	{
	//alert("test : " + Id_Pro);
	
	// On affiche un fond blanc
	voile_affiche();
	
	// On crait un nouveau DIV
	var nouveauDiv = document.createElement('div');
	nouveauDiv.id = 'div_mkt';
	//nouveauDiv.innerHTML = "<table width=\"300\" border=\"1\"><tr><td>Veuillez patienter...</td></tr></table>";
	
	var table = "";
	table = table + "<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" heigth=\"100\">";
	table = table + "<tr>"
    //table = table + "<td height=\"21\" bgcolor=\"#999999\"><div align=\"right\"><a href='#' onclick='div_close(\"div_mkt\");div_close(\"div_voile\");'>X</a></div></td>";
	table = table + "<td bgcolor=\"#999999\"><div align=\"left\" id=\"div_mkt_titre\">...</div></td>";
    table = table + "<td align=\"right\" bgcolor=\"#999999\"><a href='#' onclick='div_close(\"div_mkt\");div_close(\"div_voile\");'>X</td>";
	table = table + "</tr>";
  	table = table + "<tr>";
    table = table + "<td colspan=\"2\" bordercolor=\"#FFFFFF\" bgcolor=\"#CCCCCC\"><div align=\"center\" id=\"div_mkt_contenu\">Veuillez patienter...</div></td>";
 	table = table + "</tr>";
	table = table + "</table>";
	
	nouveauDiv.innerHTML = table;
	
	nouveauDiv.style.position="absolute";
	//nouveauDiv.style.left='100px';
	//nouveauDiv.style.top='100px';
	
	
	
	document.body.appendChild(nouveauDiv);
	
	centre_div('div_mkt');
	
	var xhr = Get_Xhr("js/recherche_mkt.php","id_pro="+Id_Pro);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					//nouveauDiv.innerHTML = chaine;
					var TAB_chaine = chaine.split("<mercure>");
					var titre = TAB_chaine[0];
					var contenu = TAB_chaine[1];
					var html = TAB_chaine[2];
					//document.getElementById("contenu").innerHTML = chaine;
					//alert(titre);
					document.getElementById("div_mkt_titre").innerHTML = titre;
					if(html == "")
						{
						document.getElementById("div_mkt_contenu").innerHTML = contenu;
						} else {
								document.getElementById("div_mkt_contenu").innerHTML = html;
								}
					} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	
	}
	
// Fonction permettant de fermer un div
function div_close(div_id)
	{
	//alert("close");	
	if(document.getElementById(div_id) != null)
			{
			//alert("supprime : " + tmp_div);
			document.body.removeChild(document.getElementById(div_id));
			}
	}
	
// Fonction pemettant d'afficher un voile blanc en fond
function voile_affiche()
	{
	//alert("affiche voile");
	//alert(window.height);
	if (document.body) 
		{
		iHauteur = (document.body.clientHeight);
		iLargeur = (document.body.clientWidth);
		} else {
				iHauteur = (window.innerHeight);
				iLargeur = (window.innerWidth);
				}
	
	//alert(iHauteur);
	
	var nouveauDiv = document.createElement('div');
	nouveauDiv.id = 'div_voile';
	
	//nouveauDiv.innerHTML = "------------------------------------------------------------------";
	
	nouveauDiv.style.background="#000000";
	
	nouveauDiv.style.position="absolute";
	nouveauDiv.style.left='0px';
	nouveauDiv.style.top='0px';
	nouveauDiv.style.width = iLargeur+'px';
	nouveauDiv.style.height = iHauteur+'px';
	//nouveauDiv.style.width = '100%';
	//nouveauDiv.style.height = '100%';
	document.body.appendChild(nouveauDiv);
	//nouveauDiv.style.width = '100%';
	//nouveauDiv.style.height = '100%';
	
	set_opacity("div_voile", "out")
	
	}
/*
function getWindowHeight() 
	{
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number')
		{
        windowHeight=window.innerHeight;
    	} else {
				if (document.documentElement && document.documentElement.clientHeight) 
					{
        			windowHeight = document.documentElement.clientHeight;
					} else {
     						if (document.body && document.body.clientHeight) 
								{
         						windowHeight=document.body.clientHeight;
      							}
     						}	
				}
    return windowHeight;
}
function windowHeight() 
	{
   // Standard browsers (Mozilla, Safari, etc.)
   if (self.innerHeight)
      return self.innerHeight;
   // IE 6
   if (document.documentElement && document.documentElement.clientHeight)
      return document.documentElement.clientHeight;
   // IE 5
   if (document.body)
      return document.body.clientHeight;
   // Just in case.
   return 0;
	}

*/

// Fonction pemrettant de centrer un Div dans une page
function centre_div(element)
	{
	/*
	var My_Div_L = (document.getElementById(My_Div).style.width);
	var My_Div_H = (document.getElementById(My_Div).style.height);
	
	document.getElementById(My_Div).style.left = '0px';
	document.getElementById(My_Div).style.top = '0px';
	

	
	// Mozilla !
	if (navigator.appName == "Netscape")
		{
		iHauteur = 	window.innerHeight;
		iLargeur = 	window.innerWidth;
		} else {
				// IE
				//iHauteur = 	window.clientHeight;
				//iLargeur = 	window.clientWidth;
				if (document.body) 
					{
					iHauteur = (document.body.clientHeight);
					iLargeur = (document.body.clientWidth);
					} else {
							iHauteur = (window.innerHeight);
							iLargeur = (window.innerWidth);
							}
				}
	
	
	//alert(document.getElementById(My_Div).style.height);
	document.getElementById(My_Div).style.left = ((iLargeur / 2) - (document.getElementById(My_Div).offsetWidth) /2) + 'px';
	document.getElementById(My_Div).style.top = "75px";

	
	
	var element = My_Div;
	var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	myParent=document.getElementById(element).parentNode;
	var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	var sTop=myParent.scrollTop;//Hauteur de défilement de l'élément parent
	var sLeft=myParent.scrollLeft;//Longueur de défilement de l'élément parent
	var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	document.getElementById(element).style.top=posY+"px";
	document.getElementById(element).style.left=posX+"px";
	*/
	var sTop = document.documentElement.scrollTop;
	var sLeft = document.documentElement.scrollLeft;
	//myParent=document.getElementById(element).parentNode;
	//var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	var pWidth=document.body.offsetWidth;//Largeur de l'élément parent
	//var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	//var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posY=sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	document.getElementById(element).style.top=posY+"px";
	document.getElementById(element).style.left=posX+"px";
	}

function centre_div_v2(element)
	{
	//alert("test");
	//var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	//var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	//myParent=document.getElementById(element).parentNode;
	//var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	//var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	//var sTop=myParent.scrollTop;//Hauteur de défilement de l'élément parent
	//var sLeft=myParent.scrollLeft;//Longueur de défilement de l'élément parent
	//var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	//var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	//document.getElementById(element).style.top=posY+"px";
	//document.getElementById(element).style.left=posX+"px";
	
	//document.getElementById(element).style.top=sTop+"px";
	//alert("test fin =>"+sTop+" => "+pHeight+" => "+height+"");
	
	//var arrayPageSize = getPageSize();
	//var object2 = document.getElementById(myDiv);
	//var object2 = element; 
	//object2.style.top=((arrayPageSize[3]/2) - (object2.offsetWidth / 2))+'px';
	//object2.style.left=((arrayPageSize[2]/2) -(object2.offsetHeight / 2)) +'px';
	 //document.getElementById(element).style.top = ((arrayPageSize[3]/2) - (object2.offsetWidth / 2))+'px';
	 //document.getElementById(element).style.left = ((arrayPageSize[2]/2) -(object2.offsetHeight / 2)) +'px';
	//var val_top = ((arrayPageSize[3]/2) - (document.getElementById(element).offsetWidth / 2)- sTop)+'px';
	//var val_left = ((arrayPageSize[2]/2) -(document.getElementById(element).offsetHeight / 2)) +'px';
	//alert("test fin => "+val_top+" => "+val_left);
	//document.getElementById(element).style.top = val_top;
	//document.getElementById(element).style.left = val_left;
	
	var sTop = document.documentElement.scrollTop;
	var sLeft = document.documentElement.scrollLeft;
	//myParent=document.getElementById(element).parentNode;
	//var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	//var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	//var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posY=sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	document.getElementById(element).style.top=posY+"px";
	document.getElementById(element).style.left=posX+"px";
	//alert(document.documentElement.scrollTop);
	}

	     
	
function Ajax_Panier_PDF()
	{
	//document.getElementById('comp_info').innerHTML = "Veuillez patienter...";
	var xhr = Get_Xhr("modules/panier_pdf.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					nouveauDiv.innerHTML = chaine;
					//alert("Fin");
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}

function getTop(MyObject)
//Fonction permettant de connaître la position d'un objet
//par rapport au bord haut de la page.
//Cet objet peut être à l'intérieur d'un autre objet.
    {
    if (MyObject.offsetParent)
        return (MyObject.offsetTop + getTop(MyObject.offsetParent));
    else
        return (MyObject.offsetTop);
    }


function Ajax_CAT_Branche(nom_div,level,fichier,parent,i_tag,id_cha,sens)
	{
	//alert(i_tag + '=> ' + fichier);
	//alert("parent : " + parent);	
	//alert(sens +' => '+ i_tag);
	//alert(id_cha);
	//alert(fichier + " id_cha : " + id_cha);
	//var id_cha = parent;
	//alert(sens);
	//alert(i_tag);
	// On déplace la frame de droite si on est en bas de la frame de gauche
	//document.getElementById("decal_h").style.height = "500px";
	
	//alert(sens);
	// On déplace la frame de droite si on est en bas de la frame de gauche
	if(sens == "R")
	//if(sens == "R" && document.documentElement.scrollTop > 0)
		{
		//alert("deplace");
		var MyObject = document.getElementById("fleche_left_"+i_tag);
		//var tmp = getTop(MyObject);
		var tmp = MyObject.offsetParent.offsetParent.offsetTop;
		//alert(tmp);
		document.getElementById("decal_h").style.height = tmp+"px";
		}

	
	if(sens == "L")
		{
		// On change l'affichage du niveau
		//alert("niveau level : " + level + " > parent : " + parent);
		
		
		var mAjax = new ajaxClass("3","modules/niveau_change.php", "niveau","level="+level+"&parent="+parent);
		mAjax.execute();
		}
	
	//alert(nom_div);
	document.getElementById(nom_div).innerHTML = "Chargement en cours...";
	/*
		//var image_id = js_TAB_id[i];
		var ActionTag = "3";
		//ActionElement = "document.getElementById("+image_id+").src";
		//ActionElement = nom_div;
		var mAjax = new ajaxClass(ActionTag,"modules/"+fichier+".php", nom_div,"level="+level+"&parent="+parent);
		mAjax.execute();
		//alert(document.getElementById("div_right").value);
		//alert("fin");
	*/
	var xhr = Get_Xhr("modules/"+fichier+".php","level="+level+"&parent="+parent+"&id_cha="+id_cha+"&i_tag="+i_tag);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					//alert(sens + " => " + level);
					// On affiche le contenu de la frame (gauche ou droite)
					document.getElementById(nom_div).innerHTML = chaine;
					//alert(i_tag);
					//Ajax_Cat_Fleche_Initialise("All_Left_Fleche","All_Left_Fond",i_tag,id_cha,sens);
					// Seulement dans la frame de gauche
					if(sens == 'L')
						{
						// On enlève les sélections des branche (fleche et fond)
						//alert(i_tag);
						//////Ajax_Cat_Fleche_Initialise("All_Left_Fleche","All_Left_Fond",i_tag,id_cha,sens);
					
						
					
						// On met la flêche et le fond de la branche sélectionnée ouverte sur ON
						if(i_tag == null)
							{
							i_tag = 0;
							}	
							var td_fond = "fleche_fond_left_"+i_tag;
							var div_fleche = "fleche_left_"+i_tag;
							
							// On génère la fleche de fond
							//////Ajax_Fleche(sens,td_fond,div_fleche,id_cha);
							//alert(i_tag);
							// On tag cette branche pour la définir comme branche ouverte
							//document.getElementById("tag_left").value = i_tag;
							//////////////////////////////
							// On récupère la position di div left sur lequel on a cliqué
							//var tmp = document.body.scrollY;
							//alert(tmp);
							//alert(document.body.scrollLeft);
							//var div_fond_cour = $new_img = "img_left_"+i_tag;
							//var div_fond_cour = $new_img = "titre_left_"+i_tag;
							//var div_left_y = document.getElementById(div_fond_cour).style.offsetTop;
							//var div_left_y = window.document.getElementById(div_fond_cour).offsetTop;
							//var div_left_y = window.document.getElementById(div_fond_cour).style.offsetTop;
							//
							//alert(div_fond_cour + " => " + div_left_y);
							//document.getElementById("decal_h").style.top = div_left_y+"px";
							//alert("test");
						}
					// Seulement sur la frame de droite
					if(sens == 'R')
						{
						//alert("refresh");
						//alert("TAG "+ i_tag);
						// On tag cette branche pour la définir comme branche ouverte
							document.getElementById("tag_left").value = i_tag;
						Ajax_Cat_Fleche_Initialise("All_Left_Fleche","All_Left_Fond",i_tag,id_cha,sens);
						
						if (level == '4')
							{
							var id_client = document.getElementById('hiden_id_client').value;
							//alert(document.getElementById('hiden_client_type').value);
							var client_type = document.getElementById('hiden_client_type').value;

							
							if(id_client != "")
								{
								// Ajax_Tarif_Produit(id_produit,div_produit,id_client,client_type)
								Ajax_Tarif_Produit(document.getElementById('hiden_produit').value,document.getElementById('hiden_div_tarif').value,id_client,client_type);
								}
								
							}
						// On enlève les sélections des branche (fleche et fond)
						//Ajax_Cat_Fleche_Initialise("All_Right_Fleche","All_Right_Fond",i_tag,id_cha,sens);	
							
						// On sélectionne le premier produit
						//var td_fond = "fleche_fond_right_"+i_tag;
						//var div_fleche = "fleche_right_"+i_tag;
							
						// On génère la fleche de fond
						//Ajax_Fleche(sens,td_fond,div_fleche,id_cha);
						//alert("test");
						}
					
						
					// On affiche la frame de droite
					//alert(sens + " | " + nom_div);
					//if((level == "2" && nom_div == "cat_left") || (level == "3" && nom_div == "cat_left"))
					if(sens == "L" && nom_div == "cat_left")
						{
						var right_enfant = document.getElementById("div_right").value;
						var right_level = document.getElementById("level_right").value;
						//alert(right_enfant + "(droite) => itag : "+ i_tag);
						Ajax_CAT_Branche('cat_right',right_level,"cat_branche_right",right_enfant,i_tag,id_cha,'R')

						// On affiche le bon fond
						var stylefond = "Cat_R_Fond_"+id_cha;
						//alert(stylefond);
						document.getElementById("cat_right").className = stylefond;
						
						/*
						//var tmp = document.getElementById("cat_left").style.height;
						//var tmp = document.getElementById("cat_left").innerHTML;
						//alert(tmp);
						var height_left = document.getElementById("cat_left").offsetHeight;
						var height_right = document.getElementById("cat_right").offsetHeight;
						
						if(height_left > height_right)
							{
							alert(height_left + " > " + height_right);
							//document.getElementById("cat_right").style.height = height_left+"px";
							//alert(height_right);
							}
						*/
						//alert(document.body.scrollLeft);
						}
						
					} else {
                			alert('Erreur AJAX');
            				}
        		}
			}	
	}

function Ajax_CAT_Picto_OFF(new_div_img,picto_chemin_big,td_fond,div_fleche,tag_i,id_cha,nom_div,sens,div_titre)
	{
	//alert(sens);	
	//alert(tag_i);
	//alert(div_fleche);
	
	document.body.style.cursor = 'default';
	
	document.getElementById(new_div_img).src = picto_chemin_big;
	
	document.getElementById(div_titre).className = "branche_titre_off";
	
	
	
	//alert(new_tag_i);
	// On enlève les fond seulement si cette branche n'est pas en cours (tagé)
	//alert(new_tag_i + " => " + document.getElementById(tag_right).value);
	if(tag_i == null)
			{
			tag_i = 0;	
			}
			
	//alert(document.getElementById("tag_left").value);		
	//alert(tag_i);
	//alert(sens + " => " + document.getElementById("tag_left").value);
	if(sens == 'L')
		{
		if (tag_i != document.getElementById("tag_left").value)
			{
			// On change le fond de la flêche et la flêche
			//document.getElementById(td_fond).className = "fond_fleche_OFF_01";
			//document.getElementById(div_fleche).className = "cat_fleche_01_OFF";
			Ajax_Fleche_OFF(sens,td_fond,div_fleche,id_cha);
			}
		}
		
	if(sens == 'R')
		{
		Ajax_Fleche_OFF(sens,td_fond,div_fleche,id_cha);	
		}
		
	
	
	
	
	// On précharge l'image ON

      //preload_image = new Image(25,25); 
      //preload_image.src="http://mydomain.com/image.gif"; 

  
	}
	
function Ajax_CAT_Picto_ON(new_div_img,picto_chemin_small,td_fond,div_fleche,new_tag_i,id_cha,nom_div,sens,div_titre,i_tag)
	{
	
	document.body.style.cursor = 'pointer';
	//alert(new_div_img + " => " + picto_chemin_big);	
	document.getElementById(new_div_img).src = picto_chemin_small;
	
	//alert("test");
	document.getElementById(div_titre).className = "branche_titre_on";
	
	// On change le fond de la flêche
	///document.getElementById(td_fond).className = "fond_fleche_01";
	///document.getElementById(div_fleche).className = "cat_fleche_01_ON";
	//alert(i_tag +' => '+ new_tag_i);
	//alert(document.getElementById("tag_left").value);
	var i_tag_cour = document.getElementById("tag_left").value;
	//alert(i_tag);
	Ajax_Fleche(sens,td_fond,div_fleche,id_cha,i_tag_cour,i_tag)
	}	


// Fonction permettant d'initialiser toutes les flêches et les fond d'une branche
	function Ajax_Cat_Fleche_Initialise(Obj_Fleche,Obj_Fond,i_tag,id_cha,sens)
		{
		//alert(document.getElementById(Obj_Fleche).value);
		//alert(document.getElementById(Obj_Fond).value);
		//alert('initialise');
		if(i_tag == null)
			{
			i_tag = 0;	
			}
		//alert(i_tag);
		
		var js_TAB_fleche = document.getElementById(Obj_Fleche).value.split(';');
		var js_TAB_fond = document.getElementById(Obj_Fond).value.split(';');
		
		
		var i_tag_cour = document.getElementById("tag_left").value;
		for(var i=0; i < js_TAB_fond.length; i++)
			{
			
			if(i == i_tag)
				{
				// On tag cette branche
				//alert("tag : " + js_TAB_fond[i]);
				//document.getElementById(js_TAB_fond[i]).className = "fond_fleche_01";
				//document.getElementById(js_TAB_fleche[i]).className = "cat_fleche_01_ON";
				//alert("test : " + id_cha);
				
				var td_fond = "fleche_fond_left_"+i_tag;
				var div_fleche = "fleche_left_"+i_tag;
				//alert(td_fond);
				Ajax_Fleche('L',td_fond,div_fleche,id_cha,i_tag_cour,i_tag);
				
				//Ajax_Fleche(sens,js_TAB_fond[i],js_TAB_fleche[i],id_cha)

				} else {
						//document.getElementById(js_TAB_fond[i]).className = "";
						//document.getElementById(js_TAB_fleche[i]).className = "";
						// On enlève la flêche
						Ajax_Fleche_OFF('L',js_TAB_fond[i],js_TAB_fleche[i],id_cha);
						}
			}
		}
		
// Fonction pemettant d'afficher la bonne image de fond ou de fleche pour les branches du catalogue
// 
//function Ajax_CAT_Fleche_Style(cote,objet,i_cha)
//Ajax_CAT_Fleche_Style()
	//{
	// cat_ "côté" "objet" "i_catalogue"
	// ex => cat_left_fleche_01
	// ex => Cat_L_Fleche_1
	
	//alert("id_cha");
	
	//document.getElementById(td_fond).className = "fond_fleche_01";
					//document.getElementById(div_fleche).className = "cat_fleche_01_ON";
	
	//cote = "L";
	//objet = "Fleche";
	//i_cha = "1";
	
	//stylename = "Cat_"+cote+"_"+objet+"_"+i_cha;
	//return "";
	//return stylename;
	//}

/*
function Ajax_CAT_Left_Fleche_ON(i_chapitre)
	{
	var stylename = "";	
	switch (i_chapitre) 
		{
		case 0:
		stylename = "";
		break;
		
		case 1:
		alert("0");
		break;
	
	return stylename;
	}
	
	}
function Ajax_CAT_Left_Fond_ON()
	{
		
	}
*/

/*
function Ajax_CAT_Img(js_TAB_div,js_TAB_id)
	{
	for(var i=0; i < js_TAB_div.length; i++)
		{
		var nom_div = js_TAB_div[i];
		var image_id = js_TAB_id[i];
		var ActionTag = "1";
		//ActionElement = "document.getElementById("+image_id+").src";
		//ActionElement = nom_div;
		var mAjax = new ajaxClass(ActionTag,"html/affiche_img_fam.php", nom_div,"image_id="+image_id);
		mAjax.execute();
		
		}	
	}
*/	

function Ajax_Fleche(sens,td_fond,div_fleche,id_cha,i_tag_cour,i_tag)
	{
	//i_tag_left_cour = document.getElementById("tag_left").value);
//alert(i_tag_cour);
	//alert(sens);
	// On recherche la bonne feuille de style en fonction du chapitre
	// Cat_L_Fond_1
	// Cat_L_Fleche_1
	if(sens == 'L')
		{
		var fs_fond = "Cat_L_Fond_"+id_cha;
		var fs_fleche = "Cat_L_Fleche_"+id_cha;
		} 
	if(sens == 'R')	
		{
		//var fs_fond = "Cat_R_Fond_"+id_cha;
		var fs_fleche = "Cat_R_Fleche_"+id_cha;
		}

//alert(sens +' => '+ div_fleche)
	
	
	//alert(i_tag + ' => ' + i_tag_cour);
	// On met la flêche seulement si cette branche est en cours pour la partie de gauche
	if(i_tag == i_tag_cour && sens == 'L')
		{
		document.getElementById(div_fleche).className = fs_fleche;
		// On affiche le fond seulement si c'est une flêche
		document.getElementById(td_fond).className = fs_fond;
		
		}
		
	// On met toujours la flêche pour la partie de droite
	if (sens == 'R')
		{
		document.getElementById(div_fleche).className = fs_fleche;	
		}
	
		
	}
function Ajax_Fleche_OFF(sens,td_fond,div_fleche,id_cha)
	{
	//alert(sens);	
	//alert(id_cha);
	//document.getElementById(td_fond).className = "fond_fleche_01";
	//document.getElementById(div_fleche).className = "cat_fleche_01_ON";
	if(sens == 'L')
		{
		document.getElementById(td_fond).className = "";
		document.getElementById(div_fleche).className = "";
		}
	if(sens == 'R')
		{
		//var fs_fond = "Cat_R_Fond_"+id_cha;
		// Cat_R_Fleche_OFF_1172
		
		var fs_fleche = "Cat_R_Fleche_OFF_"+id_cha;
		document.getElementById(div_fleche).className = fs_fleche;

		}	
	
	}
	
function navig(level,Id_enfant,id_cha,Div_cour)
	{
	//document.getElementById("tag_left").value = "3";
		
	window.location.replace("catalogue.php?level="+level+"&Id_enfant="+Id_enfant+"&id_cha="+id_cha+"&Div_cour="+Div_cour+"");
	//alert(document.getElementById("tag_left").value);
	}
	
function Rollover_Onglet(indice)
	{
	//alert(this.innerHTML);	
	//alert(document.getElementById("td_fond_"+indice).style.background);
	// OFF
	for(i=1 ; i <= 3; i++)
		{
		document.getElementById("img_o_g_"+i).src="./images/skin/cat/info/cha01/onglet_off_g.jpg";
		document.getElementById("img_o_d_"+i).src="./images/skin/cat/info/cha01/onglet_off_d.jpg";
		document.getElementById("td_fond_"+i).className = "Cat_Onglet_Off";
		}
	
	// ON
	document.getElementById("img_o_g_"+indice).src="./images/skin/cat/info/cha01/onglet_on_g.jpg";
	document.getElementById("img_o_d_"+indice).src="./images/skin/cat/info/cha01/onglet_on_d.jpg";
	document.getElementById("td_fond_"+indice).className = "Cat_Onglet_On";
	}
	
// Fonction pemettant de changer le pointer de la sourie
function Change_pointeur(valeur)
	{
	if(valeur == "0")
		{
		document.body.style.cursor = 'default';
		}
	if(valeur == "1")
		{
		document.body.style.cursor = 'pointer';
		}	
	}

function Resize_element(MyElement,New_width,New_height)
	{
	document.getElementById(MyElement).style.width = New_width+"px";
	document.getElementById(MyElement).style.height = New_height+"px";	
	}

function reconstruction()
	{
	//alert("test");
	//document.getElementById('Div_Fond_Voile').style.width = document.body.clientWidth+"px";
	//document.getElementById('Div_Fond_Voile').style.height = clientHeight+"px";
	Resize_element('Div_Fond_Voile',document.body.clientWidth,document.body.clientHeight)
	centre_div("Div_Bulle_Info");
	}
	
// fonction permettant de créer	un fenetre en premier plan et de cacher le second plan
function Create_Window(new_width,new_height,contenu)
	{
	
	
	//Affiche_element("Div_Fond_Voile");
	//Resize_element("Div_Fond_Voile",document.body.clientWidth,document.body.clientHeight);	
	//alert(document.getElementById('Div_Fond_Voile').style.width);
	
	Resize_element("Div_Fond_Voile",document.body.clientWidth,document.body.clientHeight);
	document.getElementById('Div_Fond_Voile').className = "Div_Background_on";
	
	document.getElementById('Div_Bulle_Info').className = "Div_Bulle_on";
	document.getElementById('Bulle_Info_Txt').innerHTML=contenu;
	Resize_element("Div_Bulle_Info",new_width,new_height);
	centre_div("Div_Bulle_Info");
	
	// On remet le bon lien pour le btn de fermeture car il a pu être changé
	//document.getElementById('Btn_close').innerHTML = "<a href=\"#\" onclick=\"Close_Window();return false;\" class=\"txt_del_red\">[X] Fermer</a>";
		
	//centre_div_v2("Div_Bulle_Info");
	//document.getElementById('Div_Bulle_Info').className = "Div_Bulle_on";
	/*	
	alert("go");	
	//var coordonneeY = OffsetY(document.getElementById(div_name));
	//var coordonneeR = (OffsetR(document.getElementById(div_name)) + document.getElementById(div_name).offsetWidth);

	var coordonneeY = "100";
	var coordonneeR = "100";

	//alert(div_name + " => " + Enfant + " => " + coordonneeY + " => " + coordonneeR);
	
	// On crait le DIV de fond
	// On crait le nouveau DIV
	var nouveauDivFond = document.createElement('div');
	nouveauDivFond.id = 'info_background';
	nouveauDivFond.innerHTML = "TEST";
	//nouveauDivFond.style.position="absolute";
	
	nouveauDivFond.style.left='0';
	nouveauDivFond.style.top='0';
	var larg = (document.body.clientWidth);
	var haut = (document.body.clientHeight);
	//alert(larg + ' X ' + haut)
	nouveauDivFond.style.width=larg+'px';
	nouveauDivFond.style.height=haut+'px';

	document.body.appendChild(nouveauDivFond);
	
	document.getElementById('info_background').className = "Div_Background";
	*/
	
	/*
	// On crait le nouveau DIV
	var nouveauDiv = document.createElement('div');
	nouveauDiv.id = 'info_window';
	nouveauDiv.innerHTML = "<table width=\"500\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#205073\" bgcolor=\"#FFFFFF\"><tr><td><div id=\"info_div\">Veuillez patienter...</div></td></tr></table>";
	nouveauDiv.style.position="absolute";
	
	nouveauDiv.style.left=coordonneeR+'px';
	nouveauDiv.style.top=coordonneeY+'px';

	document.body.appendChild(nouveauDiv);
	*/
	}

function Close_Window()
	{
	//alert("close");	
	document.getElementById('Div_Bulle_Info').className = "Div_Bulle_off";
	document.getElementById('Bulle_Info_Txt').innerHTML="";
	document.getElementById('Div_Fond_Voile').className = "Div_Background_off";
	}
	
// Fonction pemettant d'ajouter un produit rapidement dans la panier
function Cmd_Speed(new_ref, new_qte)
	{
	//alert(isNaN(new_ref));
	//if(!isNaN(new_ref) && !isNaN(new_qte) && new_qte >= 1)
	var exp = new RegExp("^[0-9]+$","g");
	if(exp.test(new_qte) == true) 
		{
		Create_Window(400,200,"Recherche rapide du produit "+new_ref);
		
		var xhr = Get_Xhr("modules/cmd_speed.php","new_ref="+new_ref+"&new_qte="+new_qte);
		xhr.onreadystatechange = function() 
				{ 
				if (xhr.readyState == 4)
					{
					if (xhr.status == 200) 
						{
						var chaine = xhr.responseText;
						//alert(chaine);
						document.getElementById('Bulle_Info_Txt').innerHTML=chaine;
						
						// On recherche le tarif de ce produit
						//Ajax_Tarif_Ref(div_cr_tmp,new_ref,'<?=$client_user?>','<?=$client_type?>');
						
						//nouveauDiv.innerHTML = chaine;
						//alert("Fin");
						} else {
								alert('Erreur AJAX');
								}
					}
				}
		} else {
				alert("Vous devez entrer un code catalogue et une quantit\351 sous forme d'entier.");
				}
	
	// Panier_add_article('$reference','".$div_id."','$produit','$client_user')
	}
	
function ec_menu_style(action,defaut_style,Obj)
	{
	//alert("test");
	//alert(action);
	//alert(Obj.className);
	Obj.className = defaut_style;
	}


// Fonction permettant 	d'afficher une commande en cours
function Cmd_View(cmd_id,table)
	{
	//alert(cmd_table);
	
	Create_Window(800,200,"Affichage de la commande "+cmd_id+". Veuillez patienter...");
	centre_div('Div_Bulle_Info');
	var xhr = Get_Xhr("modules/cmd_view.php","cmd_id="+cmd_id+"&table="+table+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					document.getElementById('Bulle_Info_Txt').innerHTML=chaine;
					
					// On recherche le tarif de ce produit
					//Ajax_Tarif_Ref(div_cr_tmp,new_ref,'<?=$client_user?>','<?=$client_type?>');
					
					//nouveauDiv.innerHTML = chaine;
					//alert("Fin");
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
			
	}



// Fonction permettant d'afficher les conditions de vente avant ed valider définitivement la commande
function Affiche_Condition_Vente()
	{
	//alert(cmd_table);
	
	Create_Window(800,200,"Conditions Générales de Vente");
	centre_div('Div_Bulle_Info');
	var xhr = Get_Xhr("modules/cmd_cv.php",null);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					document.getElementById('Bulle_Info_Txt').innerHTML=chaine;
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
			
	}
	
// Fonction permettant de mettre à jour les informations personnelles du clients
function Ajax_update_info_perso(client_user)
	{
	document.getElementById('ip_info').innerHTML = "Enregistrement en cours...";
	
	//alert(document.getElementById('ip_nom').value);	
	var client_nom = document.getElementById('ip_nom').value;
	var client_prenom = document.getElementById('ip_prenom').value;
	var client_mail = document.getElementById('ip_mail').value;
	var client_passwd = document.getElementById('ip_passwd').value;
	//var newsletter = document.getElementById('if_newsletter').value;
	//alert(document.getElementById('if_newsletter').checked);
	var newsletter = "";
	if(document.getElementById('if_newsletter').checked == true)
		{
		newsletter = "1";	
		} else {
				newsletter = "0";
				}
	//alert(newsletter);			
	//alert(client_user +" | "+ client_nom +" | "+ client_prenom +" | "+ client_mail +" | "+ client_passwd + " => " + client_passwd.length);
	if(client_passwd.length <=4 || client_passwd.length >=11)
		{
		var myalert = "Votre mot de passe doit comporter entre 5 et 10 caractères";
		alert(myalert);
		document.getElementById('ip_info').innerHTML = myalert;
		} else {
				// On enregistre la fiche
				//alert(document.getElementById('ip_passwd').value.length);
				//alert("go ajax");
				//document.getElementById('form_ip').submit();
				//document.getElementById('div_pa').innerHTML = "Chargement en cours...";
				var xhr = Get_Xhr("html/update_info_perso.php","client_user="+client_user+"&client_nom="+client_nom+"&client_prenom="+client_prenom+"&client_mail="+client_mail+"&client_passwd="+client_passwd+"&newsletter="+newsletter);
				xhr.onreadystatechange = function() 
					{ 
					if (xhr.readyState == 4)
						{
       					if (xhr.status == 200)
							{
							//alert(xhr.responseText);	
							//document.getElementById("div_pa").innerHTML = (xhr.responseText);
							document.getElementById('ip_info').innerHTML = "Vos informations personnelles ont bien &eacute;t&eacute; enregistr&eacute;s";
            				} else {
                					alert('Erreur lors de l\'enregistrement de votre fiche');
									document.getElementById('ip_info').innerHTML = "Erreur lors de l\'enregistrement de votre fiche";
            						}
        				}
					}
			
			}
		
	}
	
// Fonction permettant de supprimer un panier enregistré
function Panier_Save_Delete(panier_id)
	{
	Create_Window(500,300,"Ce panier sera d\351finitivement supprim\351 de votre espace client.<br><br><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"center\"><a href='#' onclick=\"Panier_Save_Delete_Valide('"+panier_id+"');return false;\"><img src=\"./images/skin/btn_oui.jpg\" width=\"72\" height=\"29\" border=\"0\" /></a></td><td align=\"center\"><a href='#' onclick='Close_Window();return false;'><img src=\"./images/skin/btn_non.jpg\" width=\"72\" height=\"29\" border=\"0\" /></a></td></tr></table>")	
	}
	
function Panier_Save_Delete_Valide(panier_id)
	{
	//alert(panier_id);
	//var r=confirm("Ce panier sera d\351finitivement supprim\351 de votre espace client.");
	//if (r==true)
  		//{
  		//alert("You pressed OK!");
		var xhr = Get_Xhr("html/panier_delete.php","panier_id="+panier_id);
		xhr.onreadystatechange = function() 
					{ 
					if (xhr.readyState == 4)
						{
       					if (xhr.status == 200)
							{
							//alert(xhr.responseText);
							
							if(xhr.responseText != "0")
								{
								alert("Erreur lors de la suppression de votre panier.");
								}
								window.location = "liste_panier.php";		
							
            				} else {
                					alert('Erreur lors de la suppression de ce panier');
            						}
        				}
					}
		
  		//}
		//else {
  			//alert("You pressed Cancel!");
  			//}

	}

// Fonction permettant d'afficher le suivie de commande
function Affiche_Suivie_Cmd(var_order,var_sens)
	{
	//alert("go");
	if (var_order == "") {var_order = "colonne_date";}
	if (var_sens == "") {var_sens = "1";}
	//alert(var_order + " | " + var_sens);
	var xhr = Get_Xhr("modules/suivie_commande_new.php","order="+var_order+"&sens="+var_sens+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					//document.getElementById('Bulle_Info_Txt').innerHTML=chaine;
					document.getElementById('Div_suivie_cmd').innerHTML=chaine;
					// On recherche le tarif de ce produit
					//Ajax_Tarif_Ref(div_cr_tmp,new_ref,'<?=$client_user?>','<?=$client_type?>');
					
					//nouveauDiv.innerHTML = chaine;
					//alert("Fin");
            		} else {
                			alert('Erreur AJAX');
					document.getElementById('Div_suivie_cmd').innerHTML = "Une erreur s'est produite.";
            				}
        		}
			}
			
	}

// Fonction permettant d'afficher l'onglet telechargement ou PA d'une fichier produit
function Ajax_Affiche_Onglet_Produit(Id_produit,id_onglet)
	{
	//Ajax_affiche_PA(Id_produit);
	Rollover_Onglet(id_onglet);
	if(id_onglet == '3')
		{
		// On affiche les telechargement
		Ajax_affiche_FT(Id_produit);
		} else {
				// On affiche les suggestions
				Ajax_affiche_PA(Id_produit);
				}
	}
	
// Fonction permettant d'aller en haut de la page
function Retour_haut_page()
	{
	//window.scrollTo(0,0);
	}
	
// Fonction permettant d'extraire une chaien de caractère entre deux balises
function Extract_balise(chaine,chaine_debut,chaine_fin) {
	//alert("test");
	
  //var exp=new RegExp("[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+","g");
  //var exp = new RegExp("`<id>(.*)</id>`","g");
  //alert("chaine : " + chaine);
  //var exp = new RegExp("<id>(.*)</id>","g");
  var exp = new RegExp(chaine_debut + "(.*)" + chaine_fin,"g");
  var tabchaine = chaine.match(exp);
  
  if(tabchaine != null)
  	{
	result = tabchaine[0];
	result = result.replace(chaine_debut,'');
	result = result.replace(chaine_fin,'');
	} else {
			result = "";
			}
	//alert(result);
	//alert("test 2");		
	return result;
	
}	

// Fonction permettant de connaitre l'extention du prix (HT ou TTC)
function Extention_HT_TTC(variable)
	{
	Ext_HT_TTC = "";	
	var id_client_tmp = Extract_balise(variable,"client=","&");
		if(id_client_tmp != "-1")
			{
			// PRO	
			Ext_HT_TTC = "&euro; HT";
			} else {
					// PAS CONNECTE
					Ext_HT_TTC = "&euro; TTC";
					}
	return Ext_HT_TTC;				
	}	

// Fonction permettant d'enlever la fenetre du détail d'une commande, pour afficher la commande rapide, puis de réafficher la fenêtre de détail
function Cmdrapide_after_detail(new_ref,new_qte,detail_id)
	{
	
	//Close_Window();	
	//alert(isNaN(new_ref));
	//if(!isNaN(new_ref) && !isNaN(new_qte) && new_qte >= 1)
	var exp = new RegExp("^[0-9]+$","g");
	if(exp.test(new_qte) == true) 
		{
		elem = document.createElement("div");
		elem.id = "div_cr";
		target = document.getElementById('Div_Fond_Voile').parentNode;
		document.getElementById('Div_Fond_Voile').parentNode.insertBefore(elem,document.getElementById('Div_Bulle_Info'));
		document.getElementById('div_cr').className = "Div_info_on";
		//document.getElementById('div_cr').innerHTML="chaine";
		
		contenu = "";
		contenu =("<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"5\" bgcolor=\"#FFFFFF\">");
    	contenu+=("<tr>");
      	contenu+=("<td width=\"104\">&nbsp;</td>");
      	contenu+=("<td align=\"right\" valign=\"top\"><div align=\"right\" id=\"Btn_close\"><a href=\"#\" onclick=\"delElem('div_cr');return false;\" class=\"txt_del_red\">[X] Fermer</a></div></td>");
    	contenu+=("</tr>");
    	contenu+=("<tr>");
      	contenu+=("<td><img src=\"./images/skin/perso_gp.jpg\" width=\"104\" height=\"200\" /></td>");
      	contenu+=("<td width=\"100%\"><div class=\"bulle_texte\" id=\"Bulle_Info_Txt\">");
        contenu+=("<div id=\"div_cr_txt\" align=\"center\">-</div>");
      	contenu+=("</div></td>");
    	contenu+=("</tr>");
    	contenu+=("<tr>");
      	contenu+=("<td>&nbsp;</td>");
      	contenu+=("<td>&nbsp;</td>");
    	contenu+=("</tr>");
  		contenu+=("</table>");
		
		//document.getElementById('div_cr').innerHTML=document.getElementById('Div_Bulle_Info').innerHTML;
		document.getElementById('div_cr').innerHTML = contenu;
		centre_div("div_cr");
		
		//alert(document.getElementById('div_cr').innerHTML);
		//Create_Window(400,200,"Recherche rapide du produit "+new_ref);
		
		var xhr = Get_Xhr("modules/cmd_speed.php","new_ref="+new_ref+"&new_qte="+new_qte);
		//alert(detail_id);
		xhr.onreadystatechange = function() 
				{ 
				if (xhr.readyState == 4)
					{
					if (xhr.status == 200) 
						{
						var chaine = xhr.responseText;
						//alert(chaine);
						
						///////
						document.getElementById('div_cr_txt').innerHTML=chaine;
						Masque_element("Div_Bulle_Info");
						} else {
								alert('Erreur AJAX');
								}
					}
					
				}
				
		} else {
				alert("Vous devez entrer un code catalogue et une quantit\351 sous forme d'entier.");
				}
	}
	
////// creation / supression d'element ///////
function create(target_id, obj, new_id)
	{
		
	target = document.getElementById(target_id);
	elem = document.createElement(obj);
	txt = document.createTextNode('-');
	elem.appendChild(txt);
	elem.id = new_id;
	body.appendChild(elem);
	document.getElementById(new_id).className = "Div_info_on";
	/*
	elem = document.createElement("div");
		elem.id = "Div_detail";
		target = document.getElementById('Div_Fond_Voile').parentNode;
		document.getElementById('Div_Fond_Voile').parentNode.insertBefore(elem,document.getElementById('Div_Bulle_Info'));
		document.getElementById('div_cr').className = "Div_info_on";
	*/
	//Cmd_Speed('2007395','1');return false;
	// 
	//Panier_add_article('2007395','tarif_0','170647','4124880'); 
	//return false;
	}

//function delElem(parent, child)
function delElem(Elem)
	{
	/*	
	obj = document.getElementById(parent);
	old = document.getElementById(child);
	obj.removeChild(old);
	*/
	//document.getElementById(parent).removeNode(true);
	//var d = document.getElementById('myDiv');
	/*
	alert("delete : "+child);
 	 olddiv = document.getElementById(child);
	 alert(olddiv.innerHTML);
  olddiv.removeChild(olddiv);
*/
/*
var obj = document.getElementById(target);

        var old = document.getElementById(child);

        alert(old.innerHTML);

        obj.removeChild(old);
		*/
		mydiv = document.getElementById(Elem);
		mydivparent = document.getElementById(Elem).parentNode;
		//alert(mydiv);
		//alert(mydivparent);
		mydivparent.removeChild(mydiv);
		//Affiche_element("Div_Bulle_Info");
	}

/*
function test_cmd_detail()
	{
	// On ferme la fenêtre en cours
	//Close_Window();
	// On ouvre la fenêtre de commaned rapide
	Cmd_Speed('2007395','1');
	//document.getElementById('Btn_close').innerHTML = "<a href=\"#\" onclick=\"Close_Window();Cmd_View_new('872881','FGPBEVP1');return false;\" class=\"txt_del_red\">[X] Fermer</a>";
	}
*/	
function Cmd_View_new(cmd_id,table)
	{
		
	// Fond voile
	elem = document.createElement("div");
	elem.id = "Div_Detail_Fond";
	target = document.getElementById('Div_Fond_Voile').parentNode;
	document.getElementById('Div_Fond_Voile').parentNode.insertBefore(elem,document.getElementById('Div_Bulle_Info'));
	document.getElementById('Div_Detail_Fond').className = "Div_Detail_Fond_on";
	document.getElementById('Div_Detail_Fond').style.zIndex = 0;
	document.getElementById('Div_Detail_Fond').style.height=document.documentElement.scrollHeight+'px';
	document.getElementById('Div_Detail_Fond').style.width=document.body.clientWidth+'px';
	//document.getElementById('Div_Detail_Fond').innerHTML = "";
	//centre_div('Div_Detail');
	
	
	//alert(cmd_table);
	
	//Create_Window(800,200,"Affichage de la commande "+cmd_id+". Veuillez patienter...");
	// on crait la fenetre
	/*
	elem = document.createElement("div");
	txt = document.createTextNode('-');
	elem.appendChild(txt);
	elem.id = "Div_Detail";
	document.body.appendChild(elem);
	document.getElementById("Div_Detail").className = "Div_info_on";
	*/
	

	elem = document.createElement("div");
	elem.id = "Div_Detail";
	target = document.getElementById('Div_Fond_Voile').parentNode;
	document.getElementById('Div_Fond_Voile').parentNode.insertBefore(elem,document.getElementById('Div_Bulle_Info'));
	document.getElementById('Div_Detail').className = "Div_info_on";

	/*
	target = document.getElementById("Div_Fond_Voile").parentNode;
	elem = document.createElement("div");
	txt = document.createTextNode('-');
	elem.appendChild(txt);
	elem.id = "Div_Detail";
	target.appendChild(elem);
	document.getElementById("Div_Detail").className = "Div_info_on";
	//centre_div('Div_Detail');
	*/
	
	document.getElementById('Div_Detail').style.zIndex = 1;
	
	contenu = "<table width=\"400\" cellspacing=\"5\" cellpadding=\"5\" border=\"0\" bgcolor=\"#ffffff\">";
    //contenu += "<tbody>";
		contenu += "<tr>";
    		contenu += "<td width=\"104\">&nbsp;</td>";
    		contenu += "<td valign=\"top\" align=\"right\"><div align=\"right\" id=\"Btn_close\"><a class=\"txt_del_red\" onclick=\"Cmd_View_new_close();return false;\" href=\"#\">[X] Fermer</a></div></td>";
    contenu += "</tr>";
    contenu += "<tr>";
    		contenu += "<td><img height=\"200\" width=\"104\" src=\"./images/skin/perso_gp.jpg\"></td>";
    		contenu += "<td width=\"100%\"><div id=\"Bulle_detail_Txt\" class=\"bulle_texte\">Recherche en cours...</div></td>";
	contenu += "</tr>";
	//contenu += "</tbody>";
	contenu += "</table>";
	
	document.getElementById('Div_Detail').innerHTML=contenu;
	centre_div('Div_Detail');
	
// <div align="right" id="Btn_close"><a class="txt_del_red" onclick="Close_Window();Cmd_View_new('872881','FGPBEVP1');return false;" href="#">[X] Fermer</a></div>
	
	
	var xhr = Get_Xhr("modules/cmd_view_new.php","cmd_id="+cmd_id+"&table="+table+"");
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					var chaine = xhr.responseText;
					//alert(chaine);
					//document.getElementById('Div_Detail').innerHTML=chaine;
					document.getElementById('Bulle_detail_Txt').innerHTML=chaine;
					centre_div('Div_Detail');
					// On recherche le tarif de ce produit
					//Ajax_Tarif_Ref(div_cr_tmp,new_ref,'<?=$client_user?>','<?=$client_type?>');
					
					//nouveauDiv.innerHTML = chaine;
					//alert("Fin");
            		} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
			
	}
	
function Cmd_View_new_close()
	{
	mydiv = document.getElementById("Div_Detail");
	mydivparent = document.getElementById("Div_Detail").parentNode;
	mydivparent.removeChild(mydiv);	
	
	mydiv = document.getElementById("Div_Detail_Fond");
	mydivparent = document.getElementById("Div_Detail_Fond").parentNode;
	mydivparent.removeChild(mydiv);	
	}
    
function AjaxPhp(classname,functionname,classvariable)
    {
    classvariable = encodeURIComponent(classvariable); //decodeURIComponent(str)    
    //alert(classvariable);    
	variable = "classname="+classname+"&functionname="+functionname+"&classvariable="+classvariable;
	var xhr = Get_Xhr("/js/AjaxPhp.php",variable);
	xhr.onreadystatechange = function() 
			{ 
			if (xhr.readyState == 4)
				{
       			if (xhr.status == 200) 
					{
					alert(xhr.responseText);
                    //return xhr.responseText;
					} else {
                			alert('Erreur AJAX');
            				}
        		}
			}
    }
    
function searchOtherProduct(classname,functionname,classvariable)
    {
    if (document.getElementById("codesearch").value == "")
        {
        alert("Vous devez saisir un code ou une partie de code dans la zone de recherche.");
        } else {    
                //alert(classvariable);    
                document.getElementById("BTNrechercher").disabled = true;
                document.getElementById("DIVcoderesult").innerHTML = "Recherche en cours...";    
                //classvariable = document.getElementById("codesearch").value;    
                classvariable = classvariable + "&searchcode="+document.getElementById("codesearch").value; 
                //alert(classvariable);
                //var resultAjax = AjaxPhp(classname,functionname,classvariable);
                //alert("resultAjax : "+resultAjax);
                classvariable = encodeURIComponent(classvariable); //decodeURIComponent(str)    
                //alert(classvariable);    
            	variable = "classname="+classname+"&functionname="+functionname+"&classvariable="+classvariable; 
            	var xhr = Get_Xhr("/js/AjaxPhp.php",variable);
            	xhr.onreadystatechange = function() 
            			{ 
            			if (xhr.readyState == 4)
            				{
                   			if (xhr.status == 200) 
            					{
            					//alert("resultat ajax\n"+xhr.responseText);
                                document.getElementById("BTNrechercher").disabled = false;
                                document.getElementById("DIVcoderesult").innerHTML = xhr.responseText 
            					} else {
                            			alert('Erreur AJAX');
                        				}
                    		}
            			}
                }
    }
   
function test()
    {
    alert("test");
    }            
////////////////////////////////////////////////////	

