function addToCart (id_product, token, quantity, cat_id) {

	if (cat_id == undefined) cat_id = 0;
	
	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=add&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity,

		success: function(success)	{

			if (success == 'TRUE') {

				refreshCart(cat_id);

			}

		}

	});
	
	return false;

}
function addToCart_petit_panier(id_product,token, quantity, cat_id){
if (cat_id == undefined) cat_id = 0;
	if($('#plat_p option:selected').val() != 0 && $('#chips_p option:selected').val() != 0)
	{	
	var remarque = $('#plat_p option:selected').val()+'<br/>'+$('#chips_p option:selected').val();
		$.ajax({
			type: 'POST',
			url: baseDir + 'ajax.php',
			async: true,
			cache: false,
			data: 'action=add&demande=panier_repas&remarque=' + remarque + '&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity,
			
			success: function(success)	{
				if (success == 'TRUE') {
					refreshPanierCart (0);
				}
			}
		});
	}
}
function addToCart_complet_panier(id_product,token, quantity, cat_id){
if (cat_id == undefined) cat_id = 0;
	if($('#plat_c option:selected').val() != 0 && $('#chips_c option:selected').val() !=0 && $('#boisson_c option:selected').val() != 0)
	{
	var remarque = $('#plat_c option:selected').val()+'<br/>'+$('#chips_c option:selected').val()+'<br/>'+$('#boisson_c option:selected').val();
		$.ajax({
				type: 'POST',
				url: baseDir + 'ajax.php',
				async: true,
				cache: false,
				data: 'action=add&demande=panier_repas&remarque=' + remarque + '&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity,
				success: function(success)	{
					if (success == 'TRUE') {
						refreshPanierCart (0);
					}
				}
			});
	}
}
function addToCart_gourmand_panier(id_product,token, quantity, cat_id){
	if (cat_id == undefined) cat_id = 0;
	if($('#plat_g option:selected').val() != 0 && $('#chips_g option:selected').val() !=0 && $('#boisson_g option:selected').val() != 0 && $('#dessert_g option:selected').val() != 0)
	{
	var remarque = $('#plat_g option:selected').val()+'<br/>'+$('#chips_g option:selected').val()+'<br/>'+$('#boisson_g option:selected').val()+'<br/>'+$('#dessert_g option:selected').val();
		$.ajax({
				type: 'POST',
				url: baseDir + 'ajax.php',
				async: true,
				cache: false,
				data: 'action=add&demande=panier_repas&remarque=' + remarque + '&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity,
				success: function(success)	{
					if (success == 'TRUE') {
						refreshPanierCart (0);
					}
				}
			});
	}
}

function addNewSaladToCart (id_product, saladtype, token, quantity, id_salad) {

	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=add_new_salad&submitCustomizedDatas=1&token=' + token + '&id_product=' + id_product + saladtype + '&add=1&qty=' + quantity + '&id_salad=' + id_salad,

		success: function(success)	{

			if (success == 'TRUE') {

				refreshCart(0);

			}

		}

	});

}

function refreshPanierCart (id_category) {
	$.ajax({
		type: 'POST',
		url: baseDir + 'ajax.php',
		async: true,
		cache: false,
		data: 'action=refresh_cart&id_category=' + id_category,
		success: function(content)	{
			if (content) { $('#replace_cart').html('<div id="product_listing_sidebar" style="margin-left:50px; float:left">'+content+'</div>');}
		}
	});
}

function updateCart (id_product, token, quantity) {

	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=update&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity,

		success: function(success)	{

			if (success == 'TRUE') {

				refreshCart(0);

			}

		}

	});

}



function refreshCart (id_category) {
	
	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=refresh_cart&id_category=' + id_category,

		success: function(content)	{

			if (content) {
			//alert(content);
				
				$('#product_listing_sidebar').html(content);

			}

			else {

				// $('#product_listing_sidebar').html('');

			}

		}

	});

}



function favoris() {



if ( navigator.appName != 'Microsoft Internet Explorer' )

	{ window.sidebar.addPanel("EatnDrink","http://www.eatndrink.fr",""); }

else { window.external.AddFavorite("http://www.eatndrink.fr","EatnDrink"); } 

}



function addToCartAndSalade (id_product, token, quantity, id_category, salad_id) {
	$.ajax({
		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=addsalade&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity + '&salad_id=' + salad_id,

		success: function(success)	{

			if (success != '') {

				
				refreshCart(id_category);

				

				$('#product_salade_list').html(success);

			}

		}

	});

}



function updateCartAndSalade (id_product, token, quantity, id_category, salad_id) {

	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=updatesalade&token=' + token + '&id_product=' + id_product + '&add=1&qty=' + quantity + '&salad_id=' + salad_id,

		success: function(success)	{

			if (success != '') {

				refreshCart(id_category);

				

				$('#product_salade_list').html(success);

			}

		}

	});

}



function getProdSaladePage (page_number, salad_id) {

	$.ajax({

		type: 'POST',

		url: baseDir + 'ajax.php',

		async: true,

		cache: false,

		data: 'action=getprodsaladepage&page_number=' + page_number + '&salad_id=' + salad_id,

		success: function(success)	{

			if (success != '') {				

				$('#product_salade_list').html(success);

			}

		}

	});

}
