if(typeof(STOCK0)=="undefined")
{
	var STOCK0="Produit momentanément épuisé. Réassort en cours.";
	function useIt(chaine,stock)
	{
		if(typeof(stock)=="undefined")
			stock=1;
		if(stock!=0)
		{
			var temp = chaine.split("(");
			if(temp.length>1)
			{
				temp = temp[1].replace(");","");
				bw_addToCart(temp.split(',')[0]);
			}
			else
			{
					window.location.href=chaine;
			}
		}
		else
			alert(STOCK0);
	}

	function bw_addToCart(idf){
		var myAjax = new Ajax.Request('/_include/cart/cart.asp?action=add&idf='+idf+'&qt=1&action_form=ajax',
		{
			method:'post',
			parameters : {},
			onSuccess: function (xhr)
			{
				var retour = xhr.responseText;
				if(retour.indexOf('result="ko"')!=-1)
				{
					alert(STOCK0);
				}
				else
				{
					alert('Votre produit a bien été ajouté au panier');
					window.location.reload();
				}
			}
		});
	}

	function bw_submitCart(stock){

		if(stock!=0)
		{
			var bad=0;
			
			if (SelectCharacteristic1){
				if (SelectCharacteristic1.value==''&&SelectCharacteristic1.options.length>1){bad=1;}
			}
			if (SelectCharacteristic2){
				if (SelectCharacteristic2.value==''&&SelectCharacteristic2.options.length>1){bad=1;}
			}
			if (SelectCharacteristic3){
				if (SelectCharacteristic3.value==''&&SelectCharacteristic3.options.length>1){bad=1;}
			}
			if (bad==0){
				var formProduit = $('detailProduct');
				var myAjax = new Ajax.Request(formProduit.action+"&action_form=ajax",
				{
					method:'post',
					parameters : formProduit.serialize(true),
					onSuccess: function (xhr)
					{
						var retour = xhr.responseText;
						if(retour.indexOf('result="ko"')!=-1)
						{
							alert(STOCK0);
						}
						else
						{
							alert('Votre produit a bien été ajouté au panier');
							window.location.reload();
						}
					}
				});
			}else{
				alert("Vous devez sélectionner les options avant d'ajouter au panier.")
			}
		}
		else	
			alert(STOCK0);
	}
}
