﻿/*--------------------------------------------------------------------------------
methode voor de berekening van een volledige order
--------------------------------------------------------------------------------*/
function calculateOrder() {

	calculate('SH11', getPrice('SH11','SH11'), getWeight('SH11'));
	calculate('SH12', getPrice('SH11','SH12'), getWeight('SH11'));
	calculate('TD01', getPrice('TD01','TD01'), getWeight('TD01'));
	
	calculate('DC07', getPrice('DC07','DC07'), getWeight('DC07'));
	calculate('DC08', getPrice('DC08','DC08'), getWeight('DC08'));
	
	calculate('DD02', getPrice('DD02','DD02'), getWeight('DD02'));
	calculate('RG09', getPrice('RG09','RG09'), getWeight('RG09'));
	calculate('RG10', getPrice('RG09','RG10'), getWeight('RG09'));
	calculate('VN03', getPrice('VN03','VN03'), getWeight('VN03'));
	calculate('VN04', getPrice('VN03','VN04'), getWeight('VN03'));
	calculate('HL06', getPrice('HL06','HL06'), getWeight('HL06'));
	
	calculate('HB13', getPrice('HB13','HB13'), getWeight('HB13'));
	calculate('HB14', getPrice('HB13','HB14'), getWeight('HB13'));

	calculate('KW15', getPrice('KW15','KW15'), getWeight('KW15'));
	calculate('KW16', getPrice('KW16','KW16'), getWeight('KW15'));
}


/*--------------------------------------------------------------------------------
methode om de regio in te stellen aan de hand van het geselecteerde land
--------------------------------------------------------------------------------*/
function setRegion(type) {
	
	//basis variabel voor object definitie
	var subt_obj = 'document.dutchshop';
	
	//aflever- of factuuradres
	switch (type) {
		case 'origin':
		//land voor levering ophalen
		var country = eval(subt_obj + '.Country.options[' + subt_obj + '.Country.selectedIndex]').value;
		break
		
		case 'delivery':
		//land voor levering ophalen
		var country = eval(subt_obj + '.DelCountry.options[' + subt_obj + '.DelCountry.selectedIndex]').value;
		break
	}
	
	
	/*--------------------------------------------------------------------------------
	regio samenstellen volgens TNT (Buitenland Pakket)
	--------------------------------------------------------------------------------*/
	// Internationaal (Europese Unie 1)
	var EUR1 = new Array();
	EUR1[1]  = 'Belgium';
	EUR1[2]  = 'Luxembourg';
	EUR1[3]  = 'Denmark';
	EUR1[4]  = 'Germany';	
	EUR1[5]  = 'France';
	EUR1[5]  = 'Monaco';
	EUR1[6]  = 'Italy';
	EUR1[7]  = 'Austria';
	EUR1[8]  = 'Spain';
	EUR1[9]  = 'United Kingdom';
	EUR1[10] = 'Sweden';
	
	// Internationaal (Europese Unie 2)
	var EUR2 = new Array();
	EUR2[1]  = 'Bulgaria';
	EUR2[2]  = 'Estonia';
	EUR2[3]  = 'Finland';
	EUR2[4]  = 'Hungary';
	EUR2[5]  = 'Ireland';
	EUR2[6]  = 'Latvia';
	EUR2[7]  = 'Lithuania';
	EUR2[8]  = 'Poland';
	EUR2[9]  = 'Portugal';
	EUR2[10] = 'Romania';
	EUR2[11] = 'Slovenia';
	EUR2[12] = 'Slovakia (Slovak Republic)';
	EUR2[13] = 'Czech Republic';
	
	// Internationaal (buiten de Europese Unie 1)
	var ROW1 = new Array();
	ROW1[1] = 'Albania';
	ROW1[2] = 'Andorra';
	ROW1[3] = 'Bosnia and Herzegowina';
	ROW1[4] = 'Canary Islands';
	ROW1[5] = 'Cyprus';
	ROW1[6] = 'Faeroe Islands';
	ROW1[7] = 'Gibraltar';
	ROW1[8] = 'Greece';
	ROW1[9] = 'Greenland';
	ROW1[10] = 'Iceland';
	ROW1[11] = 'Channel Islands';
	ROW1[12] = 'Croatia (Local Name: Hrvatska)';
	ROW1[13] = 'Liechtenstein';
	ROW1[14] = 'Macedonia, Former Yugoslav Rep. of';
	ROW1[15] = 'Malta';
	ROW1[16] = 'Moldova, Republic of';
	ROW1[17] = 'Montenegro';
	ROW1[18] = 'Norway';
	ROW1[19] = 'Ukraine';
	ROW1[20] = 'San Marino';
	ROW1[21] = 'Serbia, Republic of';
	ROW1[22] = 'Turkey';
	ROW1[23] = 'Vatican City State (Holy See)';
	ROW1[24] = 'White Russia';
	ROW1[25] = 'Switzerland';
	
	// Internationaal (buiten de Europese Unie 2)
	// alle overigen ...
	
	/*--------------------------------------------------------------------------------
	regio defineren
	--------------------------------------------------------------------------------*/
	// Nederland
	if (country == 'Netherlands' ) var region = 'NL';
	// Internationaal (Europese Unie 1)
	for (key in EUR1) {
		if (EUR1[key] == country) var region = 'EUR1'; }
	// Internationaal (Europese Unie 2)
	for (key in EUR2) {
		if (EUR2[key] == country) var region = 'EUR2'; }
	// Internationaal (buiten de Europese Unie 1)
	for (key in ROW1) {
		if (ROW1[key] == country) var region = 'ROW1'; }
	// Internationaal (buiten de Europese Unie 2)
	if (region == undefined) var region = 'ROW2';
	
	
	//aflever- of factuuradres
	switch (type) {
		case 'origin':
		//regio instellen
		eval(subt_obj).region.value = region;
		break
		
		case 'delivery':
		//regio instellen
		eval(subt_obj).region2.value = region;
		break
	}
	
	
	/*--------------------------------------------------------------------------------
	btw berekenen
	--------------------------------------------------------------------------------*/
	var subtotals_C_VAT = getVAT();
	
	//totaal berekenen
	var subtotals_C     = round_decimals(parseFloat(eval(subt_obj + '.subtotals_C').value), 2);
	var subtotals_C_INC = round_decimals(parseFloat(subtotals_C) + parseFloat(subtotals_C_VAT), 2);
	
	//subtotaal cards & books en BTW weergeven in HTML
	eval(subt_obj + '.subtotals_C').value     = subtotals_C;
	eval(subt_obj + '.subtotals_C_VAT').value = subtotals_C_VAT;
	eval(subt_obj + '.subtotals_C_INC').value = subtotals_C_INC;
	
	
	/*--------------------------------------------------------------------------------
	shipmentcosts op aanvraag of totaal berekenen
	--------------------------------------------------------------------------------*/
	//shipmentcosts bepalen
	var shipmentcosts = getShipmentcosts();
	
	//shipmentcosts op aanvraag
	if (shipmentcosts != 'onrequest') {
		
		//totaal inclusief en shipmentcosts weergeven in HTML
		eval(subt_obj + '.shipmentcosts').value = shipmentcosts;
		//eval(subt_obj + '.subtotals_C_INC').value = round_decimals(parseFloat(subtotals_C_INC) + parseFloat(shipmentcosts), 2);
		
		//shipmentcosts berekenen
		subtotals_C_INC = round_decimals(parseFloat(subtotals_C_INC) + parseFloat(shipmentcosts), 2);
		
		//shipmentcosts samenstellen
		eval(subt_obj + '.subtotals_C_INC').value = subtotals_C_INC;
	}
}


/*--------------------------------------------------------------------------------
methode om de regio te defineren
--------------------------------------------------------------------------------*/
function getRegion(type) {
	
	//aflever- of factuuradres
	switch (type) {
		case 'origin':
		//regio ophalen
		var region = document.dutchshop.region.value;
		
		if (region == '') {
			var region = 'NL';
			document.dutchshop.Country.selectedIndex = 152;
		}
		break
		
		case 'delivery':
		//regio ophalen
		var region = document.dutchshop.region2.value;
		
		if (region == '') {
			var region = 'NL';
			document.dutchshop.DelCountry.selectedIndex = 152;
		}
		break
	}
	
	
	//waarde teruggeven
	return region;
}


/*--------------------------------------------------------------------------------
methode om het totaalgewicht te defineren per product
--------------------------------------------------------------------------------*/
function getWeight(id) {

	//gewicht opzoeken
	switch(id) {
		
		/*--------------------------------------------------------------------------------
		gewicht The Dutch, I Presume?
		--------------------------------------------------------------------------------*/
		case 'TD01':
		w = 450;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Dutch Delight
		--------------------------------------------------------------------------------*/
		case 'DD02':
		w = 400;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Visions of the Netherlands
		--------------------------------------------------------------------------------*/
		case 'VN03':
		w = 1033;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht From Holland with love
		--------------------------------------------------------------------------------*/
		case 'HL06':
		w = 1300;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Dutch Details Cardset A
		--------------------------------------------------------------------------------*/
		case 'DC07':
		w = 150;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Dutch Details Cardset B
		--------------------------------------------------------------------------------*/
		case 'DC08':
		w = 150;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht The Rembrandt Guide (& De Rembrandt Gids)
		--------------------------------------------------------------------------------*/
		case 'RG09':
		w = 410;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht How to survive Holland (& Het hoofd boven water)
		--------------------------------------------------------------------------------*/
		case 'SH11':
		w = 240;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Hans Brinker (nl & en)
		--------------------------------------------------------------------------------*/
		case 'HB13':
		w = 270;
		break
		
		
		/*--------------------------------------------------------------------------------
		gewicht Kwartet (nl & en)
		--------------------------------------------------------------------------------*/
		case 'KW15':
		w = 110;
		break
	}
	
	//waarde teruggeven
	return w;
}


/*--------------------------------------------------------------------------------
shipmentcosts berekenen
--------------------------------------------------------------------------------*/
function getShipmentcosts() {
	
	//basis variabel voor object definitie
	var subt_obj = 'document.dutchshop';
	
	//totaalgewicht berekenen boeken
	var subgew_A1  = parseFloat(eval(subt_obj + '.TD01_gewicht').value);
	var subgew_A2  = parseFloat(eval(subt_obj + '.DD02_gewicht').value);
	var subgew_A3  = parseFloat(eval(subt_obj + '.VN03_gewicht').value);
	var subgew_A4  = parseFloat(eval(subt_obj + '.VN04_gewicht').value);
	var subgew_A6  = parseFloat(eval(subt_obj + '.HL06_gewicht').value);
	var subgew_A7  = parseFloat(eval(subt_obj + '.RG09_gewicht').value);
	var subgew_A8  = parseFloat(eval(subt_obj + '.RG10_gewicht').value);
	var subgew_A11 = parseFloat(eval(subt_obj + '.SH11_gewicht').value);
	var subgew_A12 = parseFloat(eval(subt_obj + '.SH12_gewicht').value);
	var subgew_A13 = parseFloat(eval(subt_obj + '.HB13_gewicht').value);
	var subgew_A14 = parseFloat(eval(subt_obj + '.HB14_gewicht').value);
	
	var subgew_A = subgew_A1 + subgew_A2 + subgew_A3 + subgew_A4 + subgew_A6 + subgew_A7 + subgew_A8 + subgew_A11 + subgew_A12 + subgew_A13 + subgew_A14;
	
	//totaalgewicht berekenen cards
	var subgew_B1  = parseFloat(eval(subt_obj + '.DC07_gewicht').value);
	var subgew_B2  = parseFloat(eval(subt_obj + '.DC08_gewicht').value);
	var subgew_B15 = parseFloat(eval(subt_obj + '.KW15_gewicht').value);
	var subgew_B16 = parseFloat(eval(subt_obj + '.KW16_gewicht').value);
	
	var subgew_B = subgew_B1 + subgew_B2 + subgew_B15 + subgew_B16;
	
	//totaalgewicht boeken en cards
	var subgew_C = subgew_A + subgew_B;
	
	//prijs regio defineren
	var region = getRegion('delivery');
	
	//uitroepteken ivm shipments of max 5 kg verbergen
	//var exclmark3 = document.getElementById('exclmark3');
	//exclmark3.src = '../image/spacer.gif';
	
	if (subgew_C > 0) {
		
		//gewicht verpakkingsmateriaal toevoegen
		var verpakgew = 200;
		var subgew_C  = subgew_C + verpakgew;
		
		//shipmentcosts op aanvraag ongedaan maken
		var onrequest = false;
		
		//prijs bepalen aan de hand van gewicht en regio
		switch(region) {
			
			/*--------------------------------------------------------------------------------
			// Nederland
			--------------------------------------------------------------------------------*/
			case 'NL':
			//aantallen tellen om te zien of geen shipmentcosts berekend hoeven te worden (bij 100 of meer)
			var aantallen = new Array;
			aantallen['subaant_A1']  = parseFloat(eval(subt_obj + '.TD01_aantal').value);
			aantallen['subaant_A2']  = parseFloat(eval(subt_obj + '.DD02_aantal').value);
			aantallen['subaant_A3']  = parseFloat(eval(subt_obj + '.VN03_aantal').value);
			aantallen['subaant_A4']  = parseFloat(eval(subt_obj + '.VN04_aantal').value);
			aantallen['subaant_A6']  = parseFloat(eval(subt_obj + '.HL06_aantal').value);
			aantallen['subaant_A7']  = parseFloat(eval(subt_obj + '.RG09_aantal').value);
			aantallen['subaant_A8']  = parseFloat(eval(subt_obj + '.RG10_aantal').value);
			aantallen['subaant_A11'] = parseFloat(eval(subt_obj + '.SH11_aantal').value);
			aantallen['subaant_A12'] = parseFloat(eval(subt_obj + '.SH12_aantal').value);
			aantallen['subaant_A13'] = parseFloat(eval(subt_obj + '.HB13_aantal').value);
			aantallen['subaant_A14'] = parseFloat(eval(subt_obj + '.HB14_aantal').value);
			
			//gewicht op nul zetten wanneer er 100 of meer boeken worden besteld
			for (key in aantallen) {
				if (aantallen[key] >= 100) {
					var subgew_C = 0;
					
					//shipmentcosts op aanvraag
					var onrequest = false;
				}
			}
			
			//kwartet aantallen tellen om te zien of geen shipmentcosts berekend hoeven te worden (bij 250 of meer)
			var aantallen = new Array;
			aantallen['subaant_B15']  = parseFloat(eval(subt_obj + '.KW15_aantal').value);
			aantallen['subaant_B16']  = parseFloat(eval(subt_obj + '.KW16_aantal').value);
			
			//gewicht op nul zetten wanneer er 250 of meer decks worden besteld
			for (key in aantallen) {
				if (aantallen[key] >= 250) {
					var subgew_C = 0;
					
					//shipmentcosts op aanvraag
					var onrequest = false;
				}
			}
			
			//regio Nederland
			if (subgew_C == 0) {
				wPrice = 0.00;
			} else if (subgew_C <= 700) {
				wPrice = 2.64;
			} else if (subgew_C <= 10000) {
				wPrice = 6.75;
			} else if (subgew_C <= 14500) {
				wPrice = 13.20; // inclusief btw
			} else if (subgew_C > 14500) {
				
				//basis instellen per doos
				wPrice = 13.20; // inclusief btw
				
				//hoeveel keer het gewicht/prijs
				divided_w = Math.ceil(subgew_C / 14500);
				wPrice = divided_w * wPrice;
			}
			break
			
			
			/*--------------------------------------------------------------------------------
			// Internationaal (Europese Unie 1)
			--------------------------------------------------------------------------------*/
			case 'EUR1':
			// in het geval van één kopie (Brievenbuspost) (incl. 200 gr verpakkingsmateriaal)
			if (subgew_C == 600) {
				wPrice = 9.24;
			} else if (subgew_C == 610) {
				wPrice = 9.24;
			} else if (subgew_C == 650) {
				wPrice = 9.24;
			} else if (subgew_C == 1233) {
				wPrice = 9.24;
			
			// <= 500 gr
			} else if (subgew_C <= 500) {
				wPrice = 6.16;
				
			// 500 gr - 2 kg
			} else if (subgew_C <= 2000) {
				wPrice = 13.10;
				
			// 2 - 5 kg
			} else if (subgew_C <= 5000) {
				wPrice = 19.50;
				
			// > 5kg
			} else if (subgew_C > 5000) {
				//kosten op aanvraag
				var onrequest = true;
				wPrice = 0;
			}
			break
			
				
			/*--------------------------------------------------------------------------------
			// Internationaal (Europese Unie 2)
			--------------------------------------------------------------------------------*/
			case 'EUR2':
			// in het geval van één kopie (Brievenbuspost) (incl. 200 gr verpakkingsmateriaal)
			if (subgew_C == 600) {
				wPrice = 9.24;
			} else if (subgew_C == 610) {
				wPrice = 9.24;
			} else if (subgew_C == 650) {
				wPrice = 9.24;
			} else if (subgew_C == 1233) {
				wPrice = 9.24;
			
			// <= 500 gr
			} else if (subgew_C <= 500) {
				wPrice = 6.16;
				
			// 500 gr - 2 kg
			} else if (subgew_C <= 2000) {
				wPrice = 18.80;
				
			// 2 - 5 kg
			} else if (subgew_C <= 5000) {
				wPrice = 24.50;
				
			// > 5kg
			} else if (subgew_C > 5000) {
				//kosten op aanvraag
				var onrequest = true;
				wPrice = 0;
			}
			break
			
			
			/*--------------------------------------------------------------------------------
			// Internationaal (buiten de Europese Unie 1)
			--------------------------------------------------------------------------------*/
			case 'ROW1':
			// <= 500 gr
			if (subgew_C <= 500) {
				wPrice = 10.45;
				
			// 500 gr - 2 kg
			} else if (subgew_C <= 2000) {
				wPrice = 18.80;
				
			// 2 - 5 kg
			} else if (subgew_C <= 5000) {
				wPrice = 25;
				
			// > 5kg
			} else if (subgew_C > 5000) {
				//kosten op aanvraag
				var onrequest = true;
				wPrice = 0;
			}
			break
			
			
			/*--------------------------------------------------------------------------------
			// Internationaal (buiten de Europese Unie 2)
			--------------------------------------------------------------------------------*/
			case 'ROW2':
			// in het geval van één kopie (Brievenbuspost) (incl. 200 gr verpakkingsmateriaal)
			if (subgew_C == 600) {
				wPrice = 19.95;
			} else if (subgew_C == 610) {
				wPrice = 19.95;
			} else if (subgew_C == 650) {
				wPrice = 19.95;
			} else if (subgew_C == 1233) {
				wPrice = 19.95;
			
			// <= 500 gr
			} else if (subgew_C <= 500) {
				wPrice = 10.45;
				
			// 500 gr - 2 kg
			} else if (subgew_C <= 2000) {
				wPrice = 24.10;
				
			// 2 - 5 kg
			} else if (subgew_C <= 5000) {
				wPrice = 34.20;
				
			// > 5kg
			} else if (subgew_C > 5000) {
				//kosten op aanvraag
				var onrequest = true;
				wPrice = 0;
			}
			break
		}
		
		//transactie- en administratiekosten instellen
		var transaction = 3.50;
		
		//transactie- en administratiekosten toevoegen
		wPrice = parseFloat(wPrice) + parseFloat(transaction);
		
	} else {
		wPrice = 0;
	}
	
	
	/*--------------------------------------------------------------------------------
	shipmentcosts op aanvraag of totaal berekenen
	--------------------------------------------------------------------------------*/
	//shipmentcosts op aanvraag
	if (onrequest == true) {
		
		//vervolg actie wijzigen
		eval(subt_obj).onrequest.value = 'true';
		
		//uitroeptekens tonen ivm shipmentcosts
		var exclmark1 = document.getElementById('exclmark1');
		var exclmark2 = document.getElementById('exclmark2');
		
		exclmark1.src = '../image/uitroepteken.gif';
		exclmark2.src = '../image/uitroepteken.gif';
		
		//subbedragen incl en excl VAT resetten
		eval(subt_obj).shipmentcosts.value   = '?';
		eval(subt_obj).subtotals_C_INC.value = '?';
		
		//waarde teruggeven
		return 'onrequest';
		
	//totaal berekenen
	} else {
		
		//vervolg terugzetten
		eval(subt_obj).onrequest.value = 'false';
		
		//uitroeptekens ivm shipmentcosts verbergen
		var exclmark1 = document.getElementById('exclmark1');
		var exclmark2 = document.getElementById('exclmark2');
		
		exclmark1.src = '../image/spacer.gif';
		exclmark2.src = '../image/spacer.gif';
		
		//shipmentcosts volgens standaard
		var shipmentcosts = round_decimals(wPrice, 2);
		
		//waarde teruggeven
		return shipmentcosts;
	}
}


/*--------------------------------------------------------------------------------
methode om de prijs/staffelprijs te defineren
--------------------------------------------------------------------------------*/
function getPrice(id, idqnt) {
	
	//aantal ophalen voor eventuele staffelprijs (en afronden)
	var aantal = Math.round(eval('document.dutchshop.' + idqnt + '_aantal').value);
	
	//en afgeronde waarde weer terugzetten
	eval('document.dutchshop.' + idqnt + '_aantal').value = aantal;
	
	
	//prijs/staffelprijs opzoeken
	switch(id) {
		
		/*--------------------------------------------------------------------------------
		staffel The Dutch, I Presume?
		--------------------------------------------------------------------------------*/
		case 'TD01':
		if (aantal <= 1) {
			price = 14.10;
		} else if (aantal > 1 && aantal < 10) {
			price = 13.55;
		} else if (aantal > 9 && aantal < 30) {
			price = 12.95;
		} else if (aantal > 29 && aantal < 100) {
			price = 12.30;
		} else if (aantal > 99 && aantal < 250) {
			price = 11.65;
		} else if (aantal > 249 && aantal < 500) {
			price = 10.85;
		} else if (aantal > 499 && aantal < 1000) {
			price = 10.00;
		} else if (aantal >= 1000) {
			price = 9.10;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Dutch Delight
		--------------------------------------------------------------------------------*/
		case 'DD02':
		if (aantal <= 1) {
			price = 14.10;
		} else if (aantal > 1 && aantal < 10) {
			price = 13.55;
		} else if (aantal > 9 && aantal < 30) {
			price = 12.95;
		} else if (aantal > 29 && aantal < 100) {
			price = 12.30;
		} else if (aantal > 99 && aantal < 250) {
			price = 11.65;
		} else if (aantal > 249 && aantal < 500) {
			price = 10.85;
		} else if (aantal > 499 && aantal < 1000) {
			price = 10.00;
		} else if (aantal >= 1000) {
			price = 9.10;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Visions of the Netherlands
		--------------------------------------------------------------------------------*/
		case 'VN03':
		if (aantal <= 1) {
			price = 20.33;
		} else if (aantal > 1 && aantal < 10) {
			price = 19.50;
		} else if (aantal > 9 && aantal < 30) {
			price = 18.60;
		} else if (aantal > 29 && aantal < 100) {
			price = 17.70;
		} else if (aantal > 99 && aantal < 250) {
			price = 16.80;
		} else if (aantal > 249 && aantal < 500) {
			price = 15.65;
		} else if (aantal > 499 && aantal < 1000) {
			price = 14.50;
		} else if (aantal >= 1000) {
			price = 13.40;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel From Holland with love
		--------------------------------------------------------------------------------*/
		case 'HL06':
		if (aantal <= 1) {
			price = 22.59;
		} else if (aantal > 1 && aantal < 10) {
			price = 21.70;
		} else if (aantal > 9 && aantal < 30) {
			price = 20.85;
		} else if (aantal > 29 && aantal < 100) {
			price = 20.00;
		} else if (aantal > 99 && aantal < 250) {
			price = 19.15;
		} else if (aantal > 249 && aantal < 500) {
			price = 18.20;
		} else if (aantal > 499 && aantal < 1000) {
			price = 17.25;
		} else if (aantal >= 1000) {
			price = 16.30;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Dutch Details Cardset A
		--------------------------------------------------------------------------------*/
		case 'DC07':
		price = 7.98;
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Dutch Details Cardset B
		--------------------------------------------------------------------------------*/
		case 'DC08':
		price = 10.50;
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel The Rembrandt Guide (& De Rembrandt Gids)
		--------------------------------------------------------------------------------*/
		case 'RG09':
		if (aantal <= 1) {
			price = 9.39;
		} else if (aantal > 1 && aantal < 10) {
			price = 9.39;
		} else if (aantal > 9 && aantal < 30) {
			price = 8.93;
		} else if (aantal > 29 && aantal < 100) {
			price = 8.46;
		} else if (aantal > 99 && aantal < 250) {
			price = 7.50;
		} else if (aantal > 249 && aantal < 500) {
			price = 7.00;
		} else if (aantal > 499 && aantal < 1000) {
			price = 6.50;
		} else if (aantal >= 1000) {
			price = 6.00;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel How to survive Holland (& Het hoofd boven water)
		--------------------------------------------------------------------------------*/
		case 'SH11':
		if (aantal <= 1) {
			price = 12.22;
		} else if (aantal > 1 && aantal < 10) {
			price = 12.22;
		} else if (aantal > 9 && aantal < 30) {
			price = 11.61;
		} else if (aantal > 29 && aantal < 100) {
			price = 11.00;
		} else if (aantal > 99 && aantal < 250) {
			price = 9.90;
		} else if (aantal > 249 && aantal < 500) {
			price = 9.40;
		} else if (aantal > 499 && aantal < 1000) {
			price = 8.95;
		} else if (aantal >= 1000) {
			price = 8.50;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Hans Brinker (nl & en)
		--------------------------------------------------------------------------------*/
		case 'HB13':
		if (aantal <= 1) {
			price = 9.39;
		} else if (aantal > 1 && aantal < 10) {
			price = 9.39;
		} else if (aantal > 9 && aantal < 30) {
			price = 8.93;
		} else if (aantal > 29 && aantal < 100) {
			price = 8.46;
		} else if (aantal > 99 && aantal < 250) {
			price = 7.50;
		} else if (aantal > 249 && aantal < 500) {
			price = 7.00;
		} else if (aantal > 499 && aantal < 1000) {
			price = 6.50;
		} else if (aantal >= 1000) {
			price = 6.00;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Kwartet (en)
		--------------------------------------------------------------------------------*/
		case 'KW15':
		if (aantal < 10) {
			price = 7.52;
		} else if (aantal > 9 && aantal < 30) {
			price = 7.15;
		} else if (aantal > 29 && aantal < 100) {
			price = 6.80;
		} else if (aantal > 99 && aantal < 250) {
			price = 6.45;
		} else if (aantal > 249 && aantal < 500) {
			price = 6.15;
		} else if (aantal > 499 && aantal < 1000) {
			price = 5.85;
		} else if (aantal >= 1000) {
			price = 5.60;
		}
		break
		
		
		/*--------------------------------------------------------------------------------
		staffel Kwartet (nl)
		--------------------------------------------------------------------------------*/
		case 'KW16':
		price = 7.50;
		break
	}
	
	//waarde teruggeven
	return price;
}


/*--------------------------------------------------------------------------------
methode om te controleren of het om een bedrijf buiten de regio 'EUR' gaat
--------------------------------------------------------------------------------*/
function setVATnumber() {
	//basis variabel voor object definitie
	var subt_obj = 'document.dutchshop';
	
	//btw van subbedragen optellen
	var subtotals_C_VAT = getVAT();
	
	//shipmentcosts ophalen
	var shipmentcosts = eval(subt_obj + '.shipmentcosts').value;
	
	//totaal berekenen
	var subtotals_C     = round_decimals(parseFloat(eval(subt_obj + '.subtotals_C').value), 2);
	var subtotals_C_INC = round_decimals(parseFloat(subtotals_C) + parseFloat(subtotals_C_VAT) + parseFloat(shipmentcosts), 2);
	
	//subtotaal cards & books en BTW weergeven in HTML
	eval(subt_obj + '.subtotals_C').value     = subtotals_C;
	eval(subt_obj + '.subtotals_C_VAT').value = subtotals_C_VAT;
	eval(subt_obj + '.subtotals_C_INC').value = subtotals_C_INC;
}


/*--------------------------------------------------------------------------------
methode om te kijken of er VAT betaald moet worden
--------------------------------------------------------------------------------*/
function getVAT() {
	
	//basis variabel voor object definitie
	var subt_obj = 'document.dutchshop';
	
	//btw van subbedragen optellen
	var subtotals_C_VAT = round_decimals(parseFloat(eval(subt_obj + '.subtotals_A_VAT').value) + parseFloat(eval(subt_obj + '.subtotals_B_VAT').value), 2);
	
	//btw uitzonderingen
	var region = getRegion('origin');
	
	//binnen de regio 'EUR'
	if (region == 'EUR') {
		//met of zonder BTW nummer (bedrijf of niet)
		var VAT_number = eval(subt_obj + '.VATnumber').value;
		
		//gaat het om een bedrijf
		if (VAT_number != '' && VAT_number != '-') {
			var subtotals_C_VAT = 0.00;
		}
	} else if (region == 'OTH') {
		var subtotals_C_VAT = 0.00;
	}
	
	//waarde teruggeven
	return subtotals_C_VAT;
}



/*--------------------------------------------------------------------------------
methode om de prijs opnieuw te berekenen
--------------------------------------------------------------------------------*/
function calculate(id, prijs, gewicht) {
	
	//objecten defineren
	var obj_prijs   = 'document.dutchshop.' + id + '_prijs';
	var obj_gewicht = 'document.dutchshop.' + id + '_gewicht';
	var aantal      = eval('document.dutchshop.' + id + '_aantal').value;
	var obj_subt    = 'document.dutchshop.' + id + '_subt';
	
	
	//minimale afname's?
	if (id == "KW16") {
		var min_aantal = 500;
	}
	
	//resetten naar minimale afname?
	if (aantal != 0 && aantal < min_aantal) {
		eval('document.dutchshop.' + id + '_aantal').value = min_aantal;
		aantal = min_aantal;
	}
	
	
	//aantal wijzigen in shoppingcart indien nodig
	if(aantal != '') { chQTT(id,aantal); }
	
	//gewicht berekening
	eval(obj_gewicht).value = gewicht * aantal;
	
	
	//prijs berekening
	eval(obj_prijs).value = round_decimals(prijs, 2);
	eval(obj_subt).value = round_decimals(prijs * aantal, 2);
	
	
	//basis variabel voor object definitie
	var subt_obj = 'document.dutchshop';
	
	
	/*--------------------------------------------------------------------------------
	boeken
	--------------------------------------------------------------------------------*/
	//subtotalen optellen boeken (6% btw)
	var subtotals_A1  = parseFloat(eval(subt_obj + '.TD01_subt').value);
	var subtotals_A2  = parseFloat(eval(subt_obj + '.DD02_subt').value);
	var subtotals_A3  = parseFloat(eval(subt_obj + '.VN03_subt').value);
	var subtotals_A4  = parseFloat(eval(subt_obj + '.VN04_subt').value);
	var subtotals_A6  = parseFloat(eval(subt_obj + '.HL06_subt').value);
	var subtotals_A7  = parseFloat(eval(subt_obj + '.RG09_subt').value);
	var subtotals_A8  = parseFloat(eval(subt_obj + '.RG10_subt').value);
	var subtotals_A11 = parseFloat(eval(subt_obj + '.SH11_subt').value);
	var subtotals_A12 = parseFloat(eval(subt_obj + '.SH12_subt').value);
	var subtotals_A13 = parseFloat(eval(subt_obj + '.HB13_subt').value);
	var subtotals_A14 = parseFloat(eval(subt_obj + '.HB14_subt').value);
	
	//subtotaal berekenen
	var subtotals_A  = round_decimals(subtotals_A1 + subtotals_A2 + subtotals_A3 + subtotals_A4 + subtotals_A6 + subtotals_A7 + subtotals_A8 + subtotals_A11 + subtotals_A12 + subtotals_A13 + subtotals_A14, 2);
	
	//VAT + subtotaal incl VAT berekenen
	var subtotals_A_VAT = round_decimals((subtotals_A / 100) * 6, 2);
	var subtotals_A_INC = round_decimals(parseFloat(subtotals_A) + parseFloat(subtotals_A_VAT), 2);
	
	//subtotalen boeken weergeven in HTML
	eval(subt_obj + '.subtotals_A').value = subtotals_A;
	eval(subt_obj + '.subtotals_A_VAT').value = subtotals_A_VAT;
	eval(subt_obj + '.subtotals_A_INC').value = subtotals_A_INC;
	
	
	/*--------------------------------------------------------------------------------
	kaarten + kwartet
	--------------------------------------------------------------------------------*/
	//subtotalen optellen cards (19% btw)
	var subtotals_B1  = parseFloat(eval(subt_obj + '.DC07_subt').value);
	var subtotals_B2  = parseFloat(eval(subt_obj + '.DC08_subt').value);
	var subtotals_B15 = parseFloat(eval(subt_obj + '.KW15_subt').value);
	var subtotals_B16 = parseFloat(eval(subt_obj + '.KW16_subt').value);
	
	//subtotaal berekenen
	var subtotals_B  = round_decimals(subtotals_B1 + subtotals_B2 + subtotals_B15 + subtotals_B16, 2);
	
	//VAT + subtotaal incl VAT berekenen
	var subtotals_B_VAT = round_decimals((subtotals_B / 100) * 19, 2);
	var subtotals_B_INC = round_decimals(parseFloat(subtotals_B) + parseFloat(subtotals_B_VAT), 2);
	
	//subtotalen cards weergeven in HTML
	eval(subt_obj + '.subtotals_B').value = subtotals_B;
	eval(subt_obj + '.subtotals_B_VAT').value = subtotals_B_VAT;
	eval(subt_obj + '.subtotals_B_INC').value = subtotals_B_INC;
	
	//subtotaal C + VAT + INC berekenen
	var subtotals_C = round_decimals(parseFloat(subtotals_A) + parseFloat(subtotals_B), 2);
	
	
	/*--------------------------------------------------------------------------------
	btw berekenen
	--------------------------------------------------------------------------------*/
	var subtotals_C_VAT = getVAT();
	
	//totaal berekenen
	var subtotals_C_INC = round_decimals(parseFloat(subtotals_C) + parseFloat(subtotals_C_VAT), 2);
	
	//subtotaal cards & books en BTW weergeven in HTML
	eval(subt_obj + '.subtotals_C').value     = subtotals_C;
	eval(subt_obj + '.subtotals_C_VAT').value = subtotals_C_VAT;
	eval(subt_obj + '.subtotals_C_INC').value = subtotals_C_INC;
	
	
	/*--------------------------------------------------------------------------------
	shipmentcosts op aanvraag of totaal berekenen
	--------------------------------------------------------------------------------*/
	//shipmentcosts bepalen
	var shipmentcosts = getShipmentcosts();
	
	
	//shipmentcosts op aanvraag
	if (shipmentcosts != 'onrequest') {
		
		//totaal inclusief en shipmentcosts weergeven in HTML
		eval(subt_obj + '.shipmentcosts').value = shipmentcosts;
		
		//shipmentcosts berekenen
		subtotals_C_INC = round_decimals(parseFloat(subtotals_C_INC) + parseFloat(shipmentcosts), 2);
		
		//shipmentcosts samenstellen
		eval(subt_obj + '.subtotals_C_INC').value = subtotals_C_INC;
	}
}



/*--------------------------------------------------------------------------------
This script is Copyright (c) Paul McFedries and 
Logophilia Limited (http://www.mcfedries.com/).
Permission is granted to use this script as long as 
this Copyright notice remains in place.
--------------------------------------------------------------------------------*/

function round_decimals(original_number, decimals) {
		var result1 = original_number * Math.pow(10, decimals)
		var result2 = Math.round(result1)
		var result3 = result2 / Math.pow(10, decimals)
		return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

		// Convert the number to a string
		var value_string = rounded_value.toString()
		
		// Locate the decimal point
		var decimal_location = value_string.indexOf(".")

		// Is there a decimal point?
		if (decimal_location == -1) {
				
				// If no, then all decimal places will be padded with 0s
				decimal_part_length = 0
				
				// If decimal_places is greater than zero, tack on a decimal point
				value_string += decimal_places > 0 ? "." : ""
		}
		else {

				// If yes, then only the extra decimal places will be padded with 0s
				decimal_part_length = value_string.length - decimal_location - 1
		}
		
		// Calculate the number of decimal places that need to be padded with 0s
		var pad_total = decimal_places - decimal_part_length
		
		if (pad_total > 0) {
				
				// Pad the string with 0s
				for (var counter = 1; counter <= pad_total; counter++) 
						value_string += "0"
				}
		return value_string
}
