	function ajoutcadeau(id) {
		i = 0;
		test = false;
		while(($("#cadeau" + i).length > 0) && (!test)) {
			if($("#cadeau" + i).is(":checked")) test = true;
			i++;
		}
		
		if(!test) {
			alert("Veuillez choisir une taille de paquet de couches");
			return;
		}
		else i--;

		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/ajoutKdo.php",
			data: "internaute=" + id + "&codekdo=" + $("#cadeau"+i).val(),
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function supprimerAvoir(id) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/valideAvoir.php",
			data: "internaute=" + id + "&code=",
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function valideAvoir(id) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/valideAvoir.php",
			data: "internaute=" + id + "&code=" + $("#codeavoir").val(),
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function viderPanier(id) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/viderEtape1.php",
			data: "internaute=" + id,
			success: function(retour) {
				eval(retour);
			}
		});
	}
	
	function sup(ref, id, idOffre, ou, idligne) {
		if($("#" + idligne).length > 0) $("#qte_" + ref + idOffre).val("-" + $("#" + idligne).html());
		else $("#qte_header_" + ref + idOffre).val("-" + $("#qte_header_" + ref + idOffre).val());
		MAJPanier(ref, id, idOffre, ou);
	}

	function moins(ref, id, idOffre, ou) {
		$("#qte_" + ref + idOffre).val("-1");
		MAJPanier(ref, id, idOffre, ou);
	}

	function plus(ref, id, idOffre, ou) {
		$("#qte_" + ref + idOffre).val("1");
		MAJPanier(ref, id, idOffre, ou);
	}

	function MAJPanier(ref, id, idOffre, ou) {
		//gestion si un article en taille n'a pas été choisi
		if(ref == "" && $("#choix_taille").val() == "") {
			$("#verrou").css("width",$(document).width() + "px");
			$("#verrou").css("height",$(document).height() + "px");
			windowCenter("InfoTaille");
			$(document).scrollTop(0);
			$(document).scrollLeft(0);
			$("#verrou").show("Fast");
			$("#InfoTaille").show("Fast");
			return;
		}
		
		//récupération de la référence dite initiale (toujours pour la gestion des articles en taille)
		if(ref == "") {
			ref = $("#choix_taille").val();
			s = ref.split("_");
			refInfoArticle = s[0];
		}
		else refInfoArticle = ref;
		
		var datas = "";
		if(ou != "panier_header") datas = "quantite=" + $("#qte_" + refInfoArticle + idOffre).val() + "&reference=" + ref + "&internaute=" + id + "&ou=" + ou + "&idoffre=" + idOffre;
		else datas = "quantite=" + $("#qte_header_" + refInfoArticle + idOffre).val() + "&reference=" + ref + "&internaute=" + id + "&ou=" + ou + "&idoffre=" + idOffre;
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/MAJPanier.php",
			beforeSend: function() {
				if(ou == "fiche") {
					$("#verrou").css("width",$(document).width() + "px");
					$("#verrou").css("height",$(document).height() + "px");
					$("#verrou").show("fast");
				}
				$("#img_loading").show("fast");
			},
			data: datas,
			success: function(retour){
				if(ou == "fiche" || ou == "grande_fiche") {
					if($("#qte_"+refInfoArticle).val() > 1) $("#fap_quantiteAjoutee").html($("#qte_"+refInfoArticle).val() + " exemplaires");
					else $("#fap_quantiteAjoutee").html("1 exemplaire");
					$("#img_loading").hide("fast");
					openCalc("FAP");
				}
				//alert(retour);
				eval(retour);
			}
		});
	}

	function ajoutOffre(id, id_offre, ref) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/ajoutOffre.php",
			data: "reference=" + ref + "&internaute=" + id + "&id_offre=" + id_offre,
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function valideRemise(id) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/ajoutRemise.php",
			data: "code=" + $('#codeOffre').val() + "&internaute=" + id,
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function suppRemise(id, code) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/suppRemise.php",
			data: "code=" + code + "&internaute=" + id,
			success: function(retour) {
				eval(retour);
			}
		});
	}

	function changeAdresse(id_addresse, id_client) {
		$.ajax({
			type: "POST",
			url: "./util/php/Ajax/panier/MAJAdressePanier.php",
			data: "adresse=" + id_addresse + "&internaute=" + id_client,
			success: function(retour) {
				eval(retour);
			}
		});
	}

	/*function rechercheRelaisTNT(cp, ville){
		var xhr_object = null;

		if(window.XMLHttpRequest) // Firefox
			xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else { // XMLHttpRequest non supporté par le navigateur
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
			return;
		}
		xhr_object.open("POST", "./util/php/Ajax/rechercherelaistnt.php", true);

		xhr_object.onreadystatechange = function() {
				if(xhr_object.readyState == 4){
					$("#img_loading").hide("fast");
					//alert(xhr_object.responseText);
					eval(xhr_object.responseText);
					openCalc("resultTNT");
				}
				else {
					$("#verrou").css("width",$(document).width() + "px");
					$("#verrou").css("height",$(document).height() + "px");
					$("#verrou").show("fast");
					$("#img_loading").show("fast");
				}
		}

		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		if(ville == "") var data = "cp="+ window.document.getElementById("inputcpTNT").value; else var data = "cp="+cp+"&ville="+ville;
		xhr_object.send(data);
	}*/

