function no_cache()
{
	date_object = new Date();
	var param = date_object.getTime();

	return param;
}

function AjaxObject()
{
	if(window.XMLHttpRequest)
	{
		xhr_object = new XMLHttpRequest();
		return xhr_object;
	}
	else if(window.ActiveXObject)
	{
		xhr_object = new ActiveXObject('Microsoft.XMLHTTP');
		return xhr_object;
	}
	else
	{ 
		alert('Votre navigateur ne supporte pas les objets XMLHTTPRequest...');
		return;
	}
}

function testEquinorm(adr1,adr2,cp,ville,pays,form)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById(adr1).value;
	var add2 = document.getElementById(adr2).value;
	var contenu_cp = document.getElementById(cp).value;
	var contenu_ville = document.getElementById(ville).value;
	var contenu_pays = document.getElementById(pays).value;
	
	ie = 'non';
	if(navigator.appName=='Microsoft Internet Explorer'){
		ie = 'oui';
	}
	
	test = true;
	if(form=='form_mod_fact' || form=='form_add_fact' || form=='form_mod_liv' || form=='form_add_liv'){
		test = checkModifAddFac();
	}

	if(contenu_pays == 1 && test)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				
				var result = reponse.split('::');
				document.getElementById(adr1).value = result[0];
				document.getElementById(adr2).value = result[1];
				document.getElementById(cp).value = result[2];
				document.getElementById(ville).value = result[3];
				
				document.forms[form].submit();
			}
		}
		xhr_object.open('GET','/ajax/testEquinorm/' + add1 + '/' + add2 + '/' + contenu_cp + '/' + contenu_ville + '/' + contenu_pays + '/' + ie ,true);
		xhr_object.send(null);
	}else if(!test){
		return false;
	}else{
		document.forms[form].submit();
	}	
}

/* Fonction AJAX de correction des adresses */
function checkEquinorm(pays)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById('adresse1').value;
	var add2 = document.getElementById('adresse2').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	
	if(pays == 1)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				document.getElementById('equinorm').innerHTML = reponse;
			}
		}
		xhr_object.open('GET','/ajax/equinorm/' + add1 + '/' + add2 + '/' + cp + '/' + ville ,true);
		xhr_object.send(null);
	}	
}

/* Fonction AJAX d'ajout de points de fid */
function ajouterPts(total,tranche,prix_pts,pts_min_to_use,total_com)
{

	xhr_object = AjaxObject();
	var param = no_cache();
	
	var encours = document.getElementById('pts_used').value;
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			reductionFid(reponse,prix_pts,total_com);
			document.getElementById('pts_used').value = reponse;
		}
	}
	xhr_object.open('GET','/ajax/ajouter_pts_fid/' + encours + '/' + tranche + '/' + total + '/' + pts_min_to_use+'/' ,true);
	xhr_object.send(null);		
}

/* Fonction AJAX d'enlevement de points de fid */
function enleverPts(total,tranche,prix_pts,pts_min_to_use,total_com)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var encours = document.getElementById('pts_used').value;
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			reductionFid(reponse,prix_pts,total_com);
			document.getElementById('pts_used').value = reponse;
		}
	}
	xhr_object.open('GET','/ajax/enlever_pts_fid/' + encours + '/' + tranche + '/' + total + '/' + pts_min_to_use+'/' ,true);
	xhr_object.send(null);
}

function changePointsUse()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			calculTotalCommande();
			document.getElementById('pts_used').value = reponse;
		}
	}
	xhr_object.open('GET','/ajax/change_points_used/' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul de la reduction fid */
function reductionFid(nb_pts_used,prix_pts,total_com)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			changePointsUse();						
			document.getElementById('reduction_fid').innerHTML = reponse;			
		}
	}
	xhr_object.open('GET','/ajax/calcul_reduction_fid/' + nb_pts_used + '/' + prix_pts + '/' + total_com ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul du total de la commande */
function calculTotalCommande()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			recalculNbProduitsPanier();
			document.getElementById('total_cmd').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/calcul_total_cmd' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul des frais de port */
function fdpGratos(id_pays,poids)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			calculTotalCommande();
			if(document.getElementById('fdp_gratos'))
				document.getElementById('fdp_gratos').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/fdp_gratos/' + id_pays + '/' + poids ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul des frais de port */
function fdpGratos2(poids)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			calculTotalCommande();
			document.getElementById('fdp_gratos').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/fdp_gratos2/' + poids ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul des frais de port */
function recupFdp(id_pays,poids)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	// xhr_object.open('GET','/ajax/recup_fdp/' + id_pays + '/' + poids ,true);
	// xhr_object.send(null);
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			fdpGratos(id_pays,poids);
			document.getElementById('recup_fdp').innerHTML = reponse;
			
			//alert("pays : "+id_pays+" poids : "+poids+" reponse : "+reponse);
		}
	}
	xhr_object.open('GET','/ajax/recup_fdp/' + id_pays + '/' + poids ,true);
	xhr_object.send(null);
	
	
}

/* Fonction AJAX du calcul du total produit apres changement quantite */
function recalculPrixProduit(id_produit,quantite)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			recalculNbProduitsPanier();
			document.getElementById('table_panier').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/recalcul_prix/' + id_produit + '/' + quantite ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul du nb total de produit dans le panier */
function recalculNbProduitsPanier()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;			
			document.getElementById('nb_produits_panier').innerHTML = reponse;
		
			if(document.getElementById('nb_produit'))
			{	
				if(document.getElementById('nb_produit').value == 0)
				{
					document.getElementById('mask_quand_vide').style.display = 'none';
				}
			}
		}
	}
	xhr_object.open('GET','/ajax/recalcul_nb' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX de la suppression d'un produit du panier */
function suppProduitPanier(id_produit)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			recalculNbProduitsPanier();
			document.getElementById('table_panier').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/supp_produit/' + id_produit ,true);
	xhr_object.send(null);
}

/* Fonction JS Ouvrir Div et Fermer un autre */
function openClose(ouvrir,fermer)
{
	document.getElementById(ouvrir).style.display = 'block';
	document.getElementById(fermer).style.display = 'none';
}

/* Fonction AJAX d'ajout d'un produit au panier */
function addProduitPanier(id_produit,quantite,hidden)
{
	//decaleProd('#img_'+id_produit);
	
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('nb_produits_panier').innerHTML = reponse;			
		}
	}
	
	if(hidden)
	{
		//alert("with hidden '"+hidden+"'");
		xhr_object.open('GET','/ajax/ajout_panier/' + id_produit + '/' + quantite + '/' + hidden ,true);
	}
else
	{
		//alert("no hidden");
		xhr_object.open('GET','/ajax/ajout_panier/' + id_produit + '/' + quantite ,true);
	}
	xhr_object.send(null);
	
	
}

/* Fonction AJAX d'ajout d'une alerte produit */
function addProduitAlerte(id_produit,email)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			if(reponse == 'false'){
				alert("il faut saisir une adresse email");
			}
		}
	}
	xhr_object.open('GET','/ajax/alerte_stock/' + id_produit + '/' + email ,true);
	xhr_object.send(null);
}

function verifProduitAlerte(id_produit,email)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('email_alerte_control').value = reponse;	
		}
	}
	xhr_object.open('GET','/ajax/alerte_stock/' + id_produit + '/' + email + '/test' ,true);
	xhr_object.send(null);
}


/* Fonction AJAX modification adresse de facturation */
function modifAddFact()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('adresse_facturation').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/mod_add_fact' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX de correction des adresses dans le panier (Modif Fact) */
function checkEquinormTab(pays)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById('adresse1').value;
	var add2 = document.getElementById('adresse2').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	
	var selObj = document.getElementById('civilite'+rot2);
	var selIndex = selObj.selectedIndex;
	
	var civilite = selObj.options[selIndex].value;
	var prenom = document.getElementById('prenom').value;
	var nom = document.getElementById('nom').value;
	
	if(pays == 1)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				document.getElementById('equinormTab').innerHTML = reponse;
			}
		}
		xhr_object.open('GET','/ajax/equinorm_tab/' + add1 + '/' + add2 + '/' + cp + '/' + ville + '/' + pays + '/' + civilite + '/' + nom+ '/' + prenom ,true);
		xhr_object.send(null);
	}	
}

/* Fonction JS Check Form Mod Fact */
function checkModifAddFac()
{
	if(document.getElementById('civilite').value == '')
	{
		alert('Vous devez indiquer votre civilite !');
		return false;
	}
	
	if(document.getElementById('prenom').value == '')
	{
		alert('Vous devez indiquer votre prenom !');
		return false;
	}
	
	if(document.getElementById('nom').value == '')
	{
		alert('Vous devez indiquer votre nom !');
		return false;
	}
	
	if(document.getElementById('adresse1').value == '')
	{
		alert('Vous devez indiquer votre adresse1 !');
		return false;
	}
	
	if(document.getElementById('cp').value == '')
	{
		alert('Vous devez indiquer votre cp !');
		return false;
	}
	
	if(document.getElementById('ville').value == '')
	{
		alert('Vous devez indiquer votre ville !');
		return false;
	}
	
	if(document.getElementById('id_pays').value == '')
	{
		alert('Vous devez indiquer votre pays !');
		return false;
	}
	
	if(document.getElementById('checkHere').value == 1)
	{
		if(document.getElementById('new_addresse').checked == false)
		{			
			alert('Vous devez indiquer si votre adresse est exacte !');
			return false;
		}
	}
	
	return true;
}

/* Fonction AJAX ajout adresse de facturation */
function AjoutAddFact()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('adresse_facturation').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/ajout_add_fact' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX de correction des adresses dans le panier (Ajout Fact) */
function checkEquinormTabA(pays)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById('adresse1').value;
	var add2 = document.getElementById('adresse2').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	var civ = document.getElementById('civilite').value;
	var prenom = document.getElementById('prenom').value;
	var nom = document.getElementById('nom').value;
	
	if(pays == 1)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				document.getElementById('equinormTabA').innerHTML = reponse;
			}
		}
		xhr_object.open('GET','/ajax/equinorm_taba/' + add1 + '/' + add2 + '/' + cp + '/' + ville + '/' + civ + '/' + prenom + '/' + nom ,true);
		xhr_object.send(null);
	}	
}

/* Fonction AJAX change selection add facturation */
function selAddFact(id_add)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('adresse_facturation').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/sel_add_fact/' + id_add ,true);
	xhr_object.send(null);
}

/* Fonction AJAX modification adresse de livraison */
function modifAddLiv()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('adresse_livraison').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/mod_add_liv' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX de correction des adresses dans le panier (Modif liv) */
function checkEquinormTab2(pays)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById('adresse1').value;
	var add2 = document.getElementById('adresse2').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	
	var selObj = document.getElementById('civilite'+rot2);
	var selIndex = selObj.selectedIndex;
	
	var civilite = selObj.options[selIndex].value;
	var prenom = document.getElementById('prenom').value;
	var nom = document.getElementById('nom').value;
	
	if(pays == 1)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				document.getElementById('equinormTab2').innerHTML = reponse;
			}
		}
		xhr_object.open('GET','/ajax/equinorm_tab2/' + add1 + '/' + add2 + '/' + cp + '/' + ville + '/' + pays + '/' + civilite + '/' + nom+ '/' + prenom ,true);
		xhr_object.send(null);
	}	
}

/* Fonction AJAX ajout adresse de livraison */
function AjoutAddLiv()
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('adresse_livraison').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/ajout_add_liv' ,true);
	xhr_object.send(null);
}

/* Fonction AJAX de correction des adresses dans le panier (Ajout liv) */
function checkEquinormTabA2(pays)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	var add1 = document.getElementById('adresse1').value;
	var add2 = document.getElementById('adresse2').value;
	var cp = document.getElementById('cp').value;
	var ville = document.getElementById('ville').value;
	var civ = document.getElementById('civilite').value;
	var prenom = document.getElementById('prenom').value;
	var nom = document.getElementById('nom').value;
	
	if(pays == 1)
	{
		xhr_object.onreadystatechange = function()
		{
			if (xhr_object.readyState != 4) 
			{
				
			}
			if(xhr_object.readyState == 4 && xhr_object.status == 200)
			{
				var reponse = xhr_object.responseText;
				document.getElementById('equinormTabA2').innerHTML = reponse;
			}
		}
		xhr_object.open('GET','/ajax/equinorm_taba2/' + add1 + '/' + add2 + '/' + cp + '/' + ville + '/' + civ + '/' + prenom + '/' + nom ,true);
		xhr_object.send(null);
	}	
}

/* Fonction AJAX change selection add livraison */
function selAddLiv(id_add,poids)
{
	xhr_object = AjaxObject();
	var param = no_cache();	
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			recupFdpAddSel(poids);
			document.getElementById('adresse_livraison').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/sel_add_liv/' + id_add ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du calcul des frais de port pour une adresse du carnet du client */
function recupFdpAddSel(poids)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			fdpGratos2(poids);
			document.getElementById('recup_fdp_sel').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/recup_fdp_sel/' + poids ,true);
	xhr_object.send(null);
}

/* Fonction AJAX du vote */
function voteToProduit(note)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('note').value = reponse;
		}
	}
	xhr_object.open('GET','/ajax/vote_produit/' + note ,true);
	xhr_object.send(null);
}

/* Fonction AJAX d'affichage du btn de paiement et application du type a la transaction */
function btnPaiement(type,transaction)
{
	if(type == "CB")
	{
		document.getElementById('btn_valider_cmd').style.display = 'none';
		document.getElementById('logo_cb_banque').style.display = 'block';
	}
	else
	{
		document.getElementById('btn_valider_cmd').style.display = 'block';
		document.getElementById('logo_cb_banque').style.display = 'none';
	}
	
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
		}
	}
	xhr_object.open('GET','/ajax/type_paiement/' + transaction + '/' + type ,true);
	xhr_object.send(null);
}

/**/
function choixSousCategorie(id_cat)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('cat_produit').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/id_sous_categorie/' + id_cat ,true);
	xhr_object.send(null);
}

/* */
function suppImageProduit(id_img)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.location.href = '/admin/produits/edit/'+reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/liste_image/' + id_img ,true);
	xhr_object.send(null);
}

function activeImgPrincipal(id_img)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			
		}
	}
	xhr_object.open('GET','/admin/ajax/active_first/' + id_img ,true);
	xhr_object.send(null);
}

function choixSousCategorie2(id_cat)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('cat_produit2').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/id_sous_categorie2/' + id_cat ,true);
	xhr_object.send(null);
}

function choixSousCategorieProduit(id_cat)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('cat_produit3').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/id_sous_categorie_prod/' + id_cat ,true);
	xhr_object.send(null);
}

function choixSousCategorie3(id_cat)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('cat_produit3').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/id_sous_categorie3/' + id_cat ,true);
	xhr_object.send(null);
}

function choixSousCatSerena(id_cat,ordre)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('cat_produit_serena'+ordre).innerHTML = reponse;			
		}
	}
	xhr_object.open('GET','/admin/ajax/choix_sous_cat_serena/' + id_cat + '/' + ordre ,true);
	xhr_object.send(null);
}

function choixProduitSerena(id_cat,ordre)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('produit_serena'+ordre).innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/choix_produit_serena/' + id_cat + '/' + ordre ,true);
	xhr_object.send(null);
}

function delStock(div)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	var encours = document.getElementById(div).value;
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById(div).value = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/gestion_stock/del/' + encours ,true);
	xhr_object.send(null);
}

function addStock(div)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	var encours = document.getElementById(div).value;
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById(div).value = reponse;
		}
	}
	xhr_object.open('GET','/admin/ajax/gestion_stock/add/' + encours ,true);
	xhr_object.send(null);
}

function suppImageCadeau(id_kdo,num_img)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.location.href = '/admin/marketing/cadeaux/'+id_kdo;
		}
	}
	xhr_object.open('GET','/admin/ajax/supp_img_kdo/' + id_kdo + '/' + num_img ,true);
	xhr_object.send(null);
}

function newTypePart(id,div)
{
	if(id == -1)
	{
		document.getElementById(div).style.display = 'block';	
	}
	else
	{
		document.getElementById(div).style.display = 'none';
	}
}

function favoris(nom,url)
{
	if( navigator.appName != 'Microsoft Internet Explorer' )
	{
		window.sidebar.addPanel(nom,url,"");
	}
	else
	{
		window.external.AddFavorite(url,nom);
	}
}

function ongletProduit(id_prod,onglet)
{
	xhr_object = AjaxObject();
	var param = no_cache();
	
	xhr_object.onreadystatechange = function()
	{
		if (xhr_object.readyState != 4) 
		{
			
		}
		if(xhr_object.readyState == 4 && xhr_object.status == 200)
		{
			var reponse = xhr_object.responseText;
			document.getElementById('ajax_onglet').innerHTML = reponse;
		}
	}
	xhr_object.open('GET','/ajax/ajax_onglet/' + id_prod + '/' + onglet ,true);
	xhr_object.send(null);
}

function checkFormProduit()
{
	if(document.getElementById('poids').value == '')
	{
		alert('Vous devez entrer un poids pour ce produit !');
		return false;
	}
	
	return true;
}

function checkCGV(url)
{
	if(document.getElementById('cgv').checked == true)
	{
		document.location.href = url;
	}
	else
	{
		alert('Vous devez accepter les Conditions Générales de Vente pour valider la commande !');
	}
}

function affEtoiles(num,chemin)
{
	for(var i=1;i<=num;i++)
	{
		var n = 'vote'+i;
		document.getElementById(n).src= chemin +"/images/vote/on.jpg";
	}
	
	for(var j=i;j<=5;j++)
	{
		var n = 'vote'+j;
		document.getElementById(n).src= chemin +"/images/vote/off.jpg";
	}
}


function activemenu(cat,img,affiche)
{
	if(document.getElementById("menucatimg_"+cat)) document.getElementById("menucatimg_"+cat).src= "/images/img_categories/"+img;
	
	var d = document.getElementById("submenu_"+cat);
	//si on quitte un élément du menu
	if (d && !affiche) 
	{
		d.style.display='none'; //on l'efface
		d.style.visibility='hidden'; //on l'efface
	}
	//sinon si on se mets sur un élément du menu
	else if (d && affiche)
	{ 
		d.style.display='block'; //on l'affiche
		d.style.visibility='visible'; //on l'affiche
	}
}

function decaleProd(id)
{
	drag1 = $(id).before($(id).clone());//.prependTo("body");//(false).append('#prod_cont');//
	
	//drag1.attr("id","panier_jetter");

	drag1.css({ position: "absolute", display:"block" , zIndex: 10000, opacity: 0.7 ,borderWidth: "10px",width:"110px",height:"68px",marginLeft: 0, marginTop: 0});
	
	drag1.animate({   left:"980px" , top:"6px"  },  5000 );
	sleep(1000);
	drag1.remove();
	
	//window.setTimeout("efface()",15000);
	
	//drag1.animate({   top:"6px"  },  2500 );
	//drag1.animate({   left:"850px"  },  2500 );
	//while(drag1.css("left")<"850px")
	//{
	//	drag1.animate({   left:"+=1px"  },  10 );
	//}
	
	//while(drag1.css("top")>"6px")
	//{
	//	drag1.animate({   top:"-=1px"  },  10 );
	//}
	
	//while(drag1.css("top")<"6px")
	//{
	//	drag1.animate({   top:"+=1px"  },  10 );
	//}
	
	//drag1.remove();
	
	//try
	//{
		//
	//	sleep(1000);
	//	drag1.remove();
	//}
	//catch(e)
	//{
	//	sleep(1000);
	//	drag1.remove();
	//}
	//finally { sleep(1000);drag1.remove(); }
	
	//if(sleep(1000)){return;}
	
	//drag1.remove();
}

function efface()
{
	drag1.remove();
}

function sleep1(time){
   
	var date = new Date();
   var start = date.getTime();
    
   while(start+time < date.getTime()) {
	   ;
   }
   return true ;
}

function sleep2( intTime )
{
	if( !is_numeric( intTime ) )
	{
		return; // Arret de l'éxecution
	}

	intTime = ( intTime / 1000 );
	var Exp = DateInt() + intTime; // TimeOut

	while( Exp > DateInt() )
	{
		;
	}
 }

var drag1 = '' ;

//au chargement de la page, on appelle la fonction activemenu()
window.onload=activemenu;

