
	function deleteSp(val){
		var submit = 0;
		$.ajax({
			url: "admin/gestion_sp.php?a=delete&ref="+ref_sp+"&var="+val,
			dataType: "html",
			success: function(html){
				switch (html){
				case "case0":
					if(confirm('Etes-vous s\373r de vouloir supprimer cet article optimis\351 ?')){ submit = 1; }
					break;
				case "case1":
					alert("Impossible de supprimer l'article. Veuillez d'abord choisir un autre article comme optimis\351 au contenu dupliqu\351.");
					break;
				case "case2":
					if(confirm("Cet article est un canonical d'un autre article. Etes-vous s\373r de vouloir le supprimer ?")){ submit = 1; }
					break;
				case "case3":
					if(confirm('Etes-vous s\373r de vouloir supprimer cet article ?')){ submit = 1; }
					break;
				}
				if(submit==1){ document.forms["form4"].submit(); }
			}
		});
	}

	function redAlertTitle(){
		var val = document.getElementById("titre").value;
		$.ajax({
			url: "admin/gestion_sp.php?a=title&ref="+ref_sp+"&var="+val,
			dataType: "html",
			success: function(html){
				$("#alertTitle").html(html);
			}
		});
	}

	function urlProdSp(){
		var url   = document.getElementById("prod_url_sp").value;
		var title = document.getElementById("prod_title_sp").value;
		var desc  = document.getElementById("prod_desc_sp").value;
		var txt   = FCKeditorAPI.GetInstance("txtopt").GetHTML();
		
		$("#infoAjax").html("<div style='font-weight:bold;color:red;margin:10px;'>Loading ...</div>");
		$.ajax({
			type: "POST",
			url: "admin/gestion_sp.php?a=url&ref="+ref_sp+"&var="+url,
			data: "url="+url+"&txt="+txt+"&title="+title+"&desc="+desc,
			dataType: "html",
			success: function(html){
				if(html=="new"){
					$.ajax({
						url: "admin/gestion_sp.php?a=add&ref="+ref_sp+"&var="+ref_sp,
						dataType: "html",
						success: function(html){
							$("#tabJointure").html(html);
						}
					});
				}
				$("#infoAjax").html("<div style='font-weight:bold;color:red;margin:10px;'>URL enregistr\351</div>");
			}
		});
	}
	
	function addProdSp(){
		var val = document.getElementById("prod_ref_sp").value;
		$.ajax({
			url: "admin/gestion_sp.php?a=add&ref="+ref_sp+"&var="+val,
			dataType: "html",
			success: function(html){
				test = html.substring(0,6);
				if(test=='Erreur'){
					alert(html);
				}else{
					$("#tabJointure").html(html);
					document.getElementById("prod_ref_sp").value = "";
				}
			}
		});
	}
	
	function modProdSp(val){
		if (confirm('Etes-vous sur de vouloir d\351finir ce produit comme le produit SP ?')){
			$.ajax({
				url: "admin/gestion_sp.php?a=mod&ref="+ref_sp+"&var="+val,
				dataType: "html",
				success: function(html){
					$("#tabJointure").html(html);
					ref_sp = val;
				}
			});
		}
	}
	
	function supProdSp(val){
		if (confirm('Etes-vous s\373r de vouloir supprimer la jointure SP avec ce produit ?')){
			$.ajax({
				url: "admin/gestion_sp.php?a=sup&ref="+ref_sp+"&var="+val,
				dataType: "html",
				success: function(html){
					$("#tabJointure").html(html);
				}
			});
		}
	}
