function berekenvoordeel(formname){
  var aantal = $('aantal_leden').value;
  var contr_pl = $('contr_pl').value;
  if(aantal != '' && (!isNaN(aantal)) && contr_pl != '' && (!isNaN(contr_pl))){
    var tot_contr = aantal*contr_pl
    $('tot_contr').value = CommaFormatted(tot_contr.toFixed(2).toString());
    $('ontvang').innerHTML = "&euro; "+CommaFormatted((tot_contr*0.50).toFixed(2).toString())+""; //(tot_contr*0.50).toFixed(2);
    $('bereken_results').style.display = '';
  }else{
    alert('De door u ingevoerd gegegevens zijn incompleet of ongeldig');
    $('bereken_results').style.display = 'none';
  }
}
function CommaFormatted(amount)
{
	var delimiter = "."; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + ',' + d; }
	amount = minus + amount;
	return amount;
}


