function addToBasket(productId)
{
	suspend();
	$.post("/ajax/?do=basket", { 'action':'add', 'productId': productId },
			  function(data){
			    updateBasket(data['contents']);
			    message(data['message']);
			  }, "json");
}

function updateQuantities(form)
{
	form = suspend(form);
	$.post("/ajax/?do=basket", { 'action':'edit', 'form': form},
			  function(data){
			    updateBasket(data['contents']);
			    message(data['message']);
			  }, "json");
}

function updateBasket(contents)
{
	document.getElementById('basket').innerHTML=contents;
}

function suspend(form)
{
	f = $('#' + form).serialize();
	$('#basket-small').html('<div class="basket-loading"></div>');
	
	return f;
}

function message(m)
{
	if(m)
	{
		var myClose=function(hash) { hash.w.fadeOut('2000',function(){ hash.o.remove(); }); };
		$('#dialog').jqm({onHide:myClose}); 
		$('#dialog').html(m);
		$('#dialog').jqmShow();
		setTimeout(function() {$("#dialog").jqmHide()}, 4000); 
	}
}