	function renewButtons()
	{
		$('button.cart').button(
		{
			icons: {
				primary: "ui-icon-cart"
			}
		});
		
		//knop om af te rekenen
		$('#afrekenen').click(function()
		{
			window.location = '/winkelwagen';
		});
		
		//winkelmandje verwijderen
		$('#legen').button(
		{
			icons: {
				primary: "ui-icon-trash"
			}
		}).click(function()
		{
			var answer = confirm('Weet je zeker dat het winkelmandje wilt leeggooien?')
			if (answer)
			{
				$.ajax("/winkelwagen/ajax.php?action=empty");
			}
		});	

	}

$(document).ready(function()
{
	$("#winkelwagen").load("/winkelwagen/ajax.php?action=mandje");
	renewButtons();
	$('.fancybox').fancybox();
	$(".lazyloader").lazyKarl();
	
	//it's the final countdown! tadadada! tadadada!
	var newYear = new Date(); 
	newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1); 
	$('#countdown').countdown({until: newYear}); 
});

function winkelmandje(action, art, winkel)
{
	if (winkel == 0)
	{
		jPrompt('<p><strong>Afhaalpunt selecteren</strong></p>Om te kunnen bestellen moet u eerst een afhaalpunt selecteren. Vul hier de cijfers van uw postcode in om een te zoeken:', '1234', 'Prompt Dialog', function(r)
		{
			if( r )
			{
				var location=("/winkeliers/?postcode=" + r);
				this.location.href = location;
			}
		});
	}
	else
	{
		if (action == 'add')
		{
			jPrompt('<p><strong>Aantal</strong></p>Hoeveel wilt u bestellen?', '1', 'Hoeveel?', function(r)
			{
				if( r )
				{
					$("#winkelmandje").html("<p>Bezig met laden van het winkelmandje...</p>").load("/winkelwagen/ajax.php?action=add&aantal=" + r + "&art=" + art, function () {renewButtons()});

				}
			});
		}
	}
}
