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;
	}
}

/* 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();
			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.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;
		}
	}
	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').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)
{
	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;			
		}
	}
	xhr_object.open('GET','/ajax/ajout_panier/' + id_produit + '/' + quantite ,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;
	
	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 ,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;
	
	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 ,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";
	}
}