//
// Ostoskori
//
function addToCart() {
	var options = { 
		dataType:  'json',
		success:    function (data) {
			switch (data.type) {
				case 'error' :
					alert(data.message);
				break;
				case 'allok' :
					$("#cart_items").html(data.updateData);
				break;
			}
		},
		error: 		function () {
			alert('Virhe lisäyksessä!');
		}
	}; 
	// pass options to ajaxForm 
	$('#form_tuote').ajaxForm(options);
	$('#form_tuote').submit();
}

function moreToCart(id) {
	$.ajax({
		type:      "POST",
		url:       domain+"/docs/ajax/ajax.addToCart2.php",   
        dataType:  "json",
		data: 	   "tuote="+ id,
		success:    function (data) {
			switch (data.type) {
				case 'error' :
					alert(data.message);
				break;
				case 'allok' :
					$("#cart_items").html(data.updateData);
				break;
			}
		},
		error: 	   function ( _response )
		{
			alert('Virhe lisäyksessä!');
		}
	});
}

function removeFromCart(id) {
	$.ajax({
		type:      "POST",
		url:       domain+"/docs/ajax/ajax.removeFromCart.php",   
        dataType:  "json",
		data: 	   "tuote="+ id,
		success:    function (data) {
			switch (data.type) {
				case 'error' :
					alert(data.message);
				break;
				case 'allok' :
					$("#cart_items").html(data.updateData);
				break;
			}
		},
		error: 	   function ( _response )
		{
			alert('Virhe lisäyksessä!');
		}
	});
}
