function addToCart(klant,product){
	if(klant!=''&&product!='')
	{
		new Ajax.Request("ajax/addToCart.php",
		{
			method: 'post',
			postBody: 'klant='+klant+'&prod='+product,
			onComplete: function(t){
				reloadTopCart(klant);
			}
		});
	}
	
}
function checkGebruiker(el){
	new Ajax.Request("ajax/checkGebruiker.php",
		{
			method: 'post',
			postBody: 'gebruikersnaam='+el.value,
			onComplete: function(t){
				if(t.responseText=='bestaat'){
					$('gebrmelding').update('Deze gebruikersnaam is al in gebruik.');
					$('accountButton').hide();
				}
				else{
					$('gebrmelding').update('');
					$('accountButton').show();
				}
			}
		});			
}
function reloadTopCart(klant){
	if(klant!='')
	{
		new Ajax.Request("ajax/getTopCart.php",
		{
			method: 'post',
			postBody: 'klant='+klant,
			onComplete: function(t){
				arr = t.responseText.split('|');
				total = number_format(arr[0],2,',','.');
				aantal = arr[1];
				total = total.sub(',00',',-');
				$('sc_art').update(aantal);
				$('sc_tot').update(total);
			}
		});
	}
}
function removeFromCart(klantid,prodid){
	new Ajax.Request("ajax/removeFromCart.php",
			{
				method: 'post',
				postBody: 'klant='+klantid+'&prod='+prodid,
				onComplete: function(t){
					document.location.reload(true);
				}
			});

}
function checkBezorg(){
	if($('bezorgcheck').checked)
	{
		$('bezorgadres').show();
	}
	else
	{
		$('bezorgadres').hide();
	}
}
function number_format( number, decimals, dec_point, thousands_sep ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)    
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
 
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "," : dec_point;
    var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
 
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}