// JavaScript Document
function goToCart(){
	// window.location.reload();
	window.location.href="/my-cart.html";
}

function addToCart(idPrice, type){
	var quantity = document.getElementById('qtyItem'+idPrice).value;
	
	switch(type){
		case 1: /* Cas ajout d'un cigar price dans le panier */
							//alert('Ajouter le cigar price: '+idPrice+' > qte : '+quantity);							
							$.ajax(
											{
												type: "POST",
												url: "/ajax/addCigarToMyCart",
												data: "idCigarPrice="+idPrice+"&qty="+quantity,
												success: function(data){goToCart();}
											}
										);														
							break;
		case 2: /* Cas ajout d'un accessoire dans le panier */
							//alert('Ajouter le cigar price: '+idPrice+' > qte : '+quantity);							
							$.ajax(
											{
												type: "POST",
												url: "/ajax/addAccessoryToMyCart",
												data: "id_accessory="+idPrice+"&qty="+quantity,
												success: function(data){goToCart();}
											}
										);														
							break;
		default:window.location.reload();break;
	}
}

function removeToCart(idPrice, type){
	
	switch(type){
		case 1: /* Cas suppression d'un cigar price dans le panier */
							//alert('Ajouter le cigar price: '+idPrice+' > qte : '+quantity);							
							$.ajax(
											{
												type: "POST",
												url: "/ajax/removeCigarToMyCart",
												data: "idCigarPrice="+idPrice,
												success: function(data){goToCart();}
											}
										);														
							break;
		case 2: /* Cas suppression d'un cigar price dans le panier */
							//alert('Ajouter le cigar price: '+idPrice+' > qte : '+quantity);							
							$.ajax(
											{
												type: "POST",
												url: "/ajax/removeAccessoryToMyCart",
												data: "id_accessory="+idPrice,
												success: function(data){goToCart();}
											}
										);														
							break;
		default:window.location.reload();break;
	}
}
