// FONCTION du MENU
	function navMenu(c1,c2,c3,n1,n2,n3,prod,chem) {
		var cible = "";
		if (n1!=0) {cible+=n1;}
		if (n2!=0) {cible+="/"+n2;}
		if (n3!=0) {cible+="/"+n3;}
		if (prod!=0) {cible+="-"+prod;}
		document.forms['enregNav'].c1.value=c1;
		document.forms['enregNav'].c2.value=c2;
		document.forms['enregNav'].c3.value=c3;
		document.forms['enregNav'].action=chem+cible;
		document.forms['enregNav'].method="post";
		document.forms['enregNav'].submit();
	}

// FONCTION de l'ADMINISTRATION

// GESTION des CATEGORIES
	function adminCat(c1,c2,c3,a,nom) {
    var xhr; 
    if (window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
  		xhr=new XMLHttpRequest();
  	} else {
			// code for IE6, IE5
	  	xhr=new ActiveXObject("Microsoft.XMLHTTP");
  	}
		if (nom!=0) {
			var nom = document.getElementById(nom).value;
			nom = nom.replace('&','%26');
			nom = nom.replace('+','%2b');	
		} else {
			var nom="...";
		}
 		if (a==2) {
			var cible = "i";
			if (c1!=0) {cible+="l"+c1;}
			if (c2!=0) {cible+="l"+c2;}
			if (c3!=0) {cible+="l"+c3;}
			document.getElementById(cible).innerHTML="<img src='../images/loading.gif' style='margin-left:12px;' />";
		} else {
			cible='contentDyna';
		}		
		 xhr.onreadystatechange = function() { 
         if(xhr.readyState == 4) {
              if(xhr.status == 200) { 
                 document.getElementById(cible).innerHTML=xhr.responseText; 
							} else { 
                 document.getElementById(cible).innerHTML="Problème...";
							}
         }
    }; 
		xhr.open( "POST", "code_categories.php",  true);
		xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1");
		xhr.send("c1="+c1+"&c2="+c2+"&c3="+c3+"&a="+a+"&nom="+nom);		
	}

// GESTION des PRODUITS
	function adminProd(c1,c2,c3,c4) {
		document.forms['navigProd'].c1.value=c1;
		document.forms['navigProd'].c2.value=c2;
		document.forms['navigProd'].c3.value=c3;
		document.forms['navigProd'].c4.value=c4;
		document.forms['navigProd'].action="admin_fiches.php";
		document.forms['navigProd'].method="post";
		document.forms['navigProd'].submit();
	}
	function naviProd(c1,c2,c3,id,ou) {
		document.forms['navigProd'].c1.value=c1;
		document.forms['navigProd'].c2.value=c2;
		document.forms['navigProd'].c3.value=c3;
		document.forms['navigProd'].id.value=id;
		switch (ou) {
			case 1:
			document.forms['navigProd'].action="admin_page.php";
			break;
			case 2:
			document.forms['navigProd'].action="admin_page_dep.php";
			break;
			case 3:
			document.forms['navigProd'].action="admin_produit.php";
			break;
			case 4:
			document.forms['navigProd'].action="admin_produits_dep.php";
			break;
		}
		document.forms['navigProd'].method="post";
		document.forms['navigProd'].submit();
	}



	function adminFiche(c1,c2,c3,c4,a,id) {
		document.forms['enregFiche'].c1.value=c1;
		document.forms['enregFiche'].c2.value=c2;
		document.forms['enregFiche'].c3.value=c3;
		document.forms['enregFiche'].c4.value=c4;
		document.forms['enregFiche'].id.value=id;
		switch  (a) {
			case 1:
			document.forms['enregFiche'].action="admin_crea_pro.php";
			break;
			case 2:
			document.forms['enregFiche'].action="admin_edit_pro.php";
			break;
		}
		document.forms['enregFiche'].method="post";
		document.forms['enregFiche'].submit();
	}
// GESTION de la VISIONNEUSE
	function majVisio(type) {
		c0 = document.forms['formAdmin'].listec0.value;
		c1 = document.forms['formAdmin'].listec1.value;
		c2 = document.forms['formAdmin'].listec2.value;
		var xhr; 
    if (window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
  		xhr=new XMLHttpRequest();
  	} else {
			// code for IE6, IE5
	  	xhr=new ActiveXObject("Microsoft.XMLHTTP");
  	}
 
    xhr.onreadystatechange = function() { 
         if(xhr.readyState == 4) {
              if(xhr.status == 200) { 
                 document.getElementById('contentDyna').innerHTML=xhr.responseText; 
							} else { 
                 document.getElementById('contentDyna').innerHTML="Problème...";
							}
         }
    };
	 xhr.open( "POST", "ajax_pub.php",  true);
	 xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1"); 
   xhr.send("c0="+c0+"&c1="+c1+"&c2="+c2+"&t="+type);		
	}
// GESTION des STOCKS
	function majStock(id) {
		cible = 'q'+id;
		num = document.getElementById('i'+id).value;
		var xhr; 
    if (window.XMLHttpRequest) {
			// code for IE7+, Firefox, Chrome, Opera, Safari
  		xhr=new XMLHttpRequest();
  	} else {
			// code for IE6, IE5
	  	xhr=new ActiveXObject("Microsoft.XMLHTTP");
  	}
 		document.getElementById(cible).innerHTML="<img src='../images/loading.gif' style='margin-right:12px;' />";
    xhr.onreadystatechange = function() { 
         if(xhr.readyState == 4) {
              if(xhr.status == 200) { 
                 document.getElementById(cible).innerHTML=xhr.responseText; 
							} else { 
                 document.getElementById(cible).innerHTML="Problème...";
							}
         }
    }; 
   xhr.open( "POST", "ajax_stocks.php",  true);
	 xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=ISO-8859-1"); 
   xhr.send("id="+id+"&num="+num);		
	}
