	/**
	 *
	 */
	function number_format(number, decimals, dec_point, thousands_sep)
	{
		var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;
        };
		// Fix for IE parseFloat(0.55).toFixed(0) = 0;
		s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
		if (s[0].length > 3) {
			s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
		}
		if ((s[1] || '').length < prec) {
			s[1] = s[1] || '';
			s[1] += new Array(prec - s[1].length + 1).join('0');
		}
		return s.join(dec);
	};
	
	
	var aantal_boetes = 15;
	
	/**
	 *
	 */
	function berekenRatio()
	{
		var ratio = 0;
		
		for(var r = 1; r <= 3; r++)
		{
			var checkbox = $('#ratio_'+r);
			
			if(checkbox.attr('checked') == true)
				ratio = checkbox.val();
		};
		
		return ratio;
	}
	
	/**
	 *
	 */
	function berekenTotaleBoete()
	{
		var totale_boete = 0;
		
		for(var b = 1; b <= aantal_boetes; b++)
		{
			if($('#boete_'+b).val() > 0)
				totale_boete += parseInt($('#boete_'+b).val());
		};
		
		$('#boete_totaal_2').html("&euro; "+number_format(totale_boete, null, null, ".")+",-");
		
		$('#boete_popup').animate({marginTop: "-=10px", opacity: "toggle"}, 400);
	}
	
	/**
	 *
	 */
	function resetBoetes()
	{
		
		for(var b = 1; b <= aantal_boetes; b++)
		{
			$('#boete_'+b).val("0");
		};
		
		$('#boete_totaal_2').html("&euro; 0,-");
	}
	
	/**
	 *
	 */
	function zetBoete(nr, bedrag)
	{
		var ratio = berekenRatio();
		
		$('#boete_'+nr).val(Math.round(bedrag * ratio, 0));
	}
