function roundNumber(number, length){
	var newnumber = Math.round(number*Math.pow(10,length))/Math.pow(10,length);
	var string = '' + newnumber;
	if((string.indexOf('.') > 0) && ((string.length-string.indexOf('.')) == 2)){
    	string = string + '0';
	}
	return string;
}

function popup(url, breedte, hoogte){
   	var LeftPosition=(screen.width)?(screen.width-breedte)/2:100;
   	var TopPosition=(screen.height)?(screen.height-hoogte)/2:100;

	settings = 'toolbar=0, location=0, directories=0, statusbar=0, menubar=0, scrollbars=1, resizable=1, width=' + breedte + ', height=' + hoogte + ', top=' + TopPosition + ',left=' + LeftPosition;

	venster = window.open(url, 'product_info', settings);
}

function productTotaal(aantal, verpakt_per, prijs_per_stuk, product_id){
	if((!isNaN(aantal)) && (aantal > 0)){
		document.getElementById('product_' + product_id + '_totaal').innerHTML = roundNumber(Math.round(aantal) * verpakt_per * prijs_per_stuk, 2);
	}else if(aantal == ''){
		document.getElementById('product_' + product_id + '_totaal').innerHTML = '-';
	}
}

function regioTotaal(producten, aantal){
	var totaal = 0;
	for(i = 0; i < aantal; i++){
		if(document.getElementById('product_' + producten[i] + '_totaal').innerHTML != '-'){
			totaal = totaal + parseFloat(document.getElementById('product_' + producten[i] + '_totaal').innerHTML);
		}
	}
	if(totaal != 0){
		document.getElementById('regio_totaal').innerHTML = roundNumber(totaal, 2);
	}else{
		document.getElementById('regio_totaal').innerHTML = '-';
	}
}