
//define globals
window.prices = new Array();
var selWidth = 0;
var selHeight = 0;
var group = '';
var extra = 0.00;
window.price = 0.00;
var total = 0.00;

//define data columns (numbers are mesurements in CM, corresponding to the prices array.)
var dimensions = new Array(
'PG1|180|60',
'PG2|180|60',
'PG3|180|60',
'PG4|180|60',
'PG1|240|60',
'PG2|240|60',
'PG3|240|60',
'PG4|240|60',
'PG1|300|60',
'PG2|300|60',
'PG3|300|60',
'PG4|300|60',
'PG1|180|70',
'PG2|180|70',
'PG3|180|70',
'PG4|180|70',
'PG1|240|70',
'PG2|240|70',
'PG3|240|70',
'PG4|240|70',
'PG1|300|70',
'PG2|300|70',
'PG3|300|70',
'PG4|300|70',
'PG1|180|80',
'PG2|180|80',
'PG3|180|80',
'PG4|180|80',
'PG1|240|80',
'PG2|240|80',
'PG3|240|80',
'PG4|240|80',
'PG1|300|80',
'PG2|300|80',
'PG3|300|80',
'PG4|300|80',
'PG1|180|90',
'PG2|180|90',
'PG3|180|90',
'PG4|180|90',
'PG1|240|90',
'PG2|240|90',
'PG3|240|90',
'PG4|240|90',
'PG1|300|90',
'PG2|300|90',
'PG3|300|90',
'PG4|300|90',
'PG1|180|100',
'PG2|180|100',
'PG3|180|100',
'PG4|180|100',
'PG1|240|100',
'PG2|240|100',
'PG3|240|100',
'PG4|240|100',
'PG1|300|100',
'PG2|300|100',
'PG3|300|100',
'PG4|300|100',
'PG1|180|110',
'PG2|180|110',
'PG3|180|110',
'PG4|180|110',
'PG1|240|110',
'PG2|240|110',
'PG3|240|110',
'PG4|240|110',
'PG1|300|110',
'PG2|300|110',
'PG3|300|110',
'PG4|300|110',
'PG1|180|120',
'PG2|180|120',
'PG3|180|120',
'PG4|180|120',
'PG1|240|120',
'PG2|240|120',
'PG3|240|120',
'PG4|240|120',
'PG1|300|120',
'PG2|300|120',
'PG3|300|120',
'PG4|300|120',
'PG1|180|130',
'PG2|180|130',
'PG3|180|130',
'PG4|180|130',
'PG1|240|130',
'PG2|240|130',
'PG3|240|130',
'PG4|240|130',
'PG1|300|130',
'PG2|300|130',
'PG3|300|130',
'PG4|300|130',
'PG1|180|140',
'PG2|180|140',
'PG3|180|140',
'PG4|180|140',
'PG1|240|140',
'PG2|240|140',
'PG3|240|140',
'PG4|240|140',
'PG1|300|140',
'PG2|300|140',
'PG3|300|140',
'PG4|300|140',
'PG1|180|150',
'PG2|180|150',
'PG3|180|150',
'PG4|180|150',
'PG1|240|150',
'PG2|240|150',
'PG3|240|150',
'PG4|240|150',
'PG1|300|150',
'PG2|300|150',
'PG3|300|150',
'PG4|300|150',
'PG1|180|160',
'PG2|180|160',
'PG3|180|160',
'PG4|180|160',
'PG1|240|160',
'PG2|240|160',
'PG3|240|160',
'PG4|240|160',
'PG1|300|160',
'PG2|300|160',
'PG3|300|160',
'PG4|300|160',
'PG1|180|170',
'PG2|180|170',
'PG3|180|170',
'PG4|180|170',
'PG1|240|170',
'PG2|240|170',
'PG3|240|170',
'PG4|240|170',
'PG1|300|170',
'PG2|300|170',
'PG3|300|170',
'PG4|300|170',
'PG1|180|180',
'PG2|180|180',
'PG3|180|180',
'PG4|180|180',
'PG1|240|180',
'PG2|240|180',
'PG3|240|180',
'PG4|240|180',
'PG1|300|180',
'PG2|300|180',
'PG3|300|180',
'PG4|300|180',
'PG1|180|190',
'PG2|180|190',
'PG3|180|190',
'PG4|180|190',
'PG1|240|190',
'PG2|240|190',
'PG3|240|190',
'PG4|240|190',
'PG1|300|190',
'PG2|300|190',
'PG3|300|190',
'PG4|300|190',
'PG1|180|200',
'PG2|180|200',
'PG3|180|200',
'PG4|180|200',
'PG1|240|200',
'PG2|240|200',
'PG3|240|200',
'PG4|240|200',
'PG1|300|200',
'PG2|300|200',
'PG3|300|200',
'PG4|300|200',
'PG1|180|210',
'PG2|180|210',
'PG3|180|210',
'PG4|180|210',
'PG1|240|210',
'PG2|240|210',
'PG3|240|210',
'PG4|240|210',
'PG1|300|210',
'PG2|300|210',
'PG3|300|210',
'PG4|300|210',
'PG1|180|220',
'PG2|180|220',
'PG3|180|220',
'PG4|180|220',
'PG1|240|220',
'PG2|240|220',
'PG3|240|220',
'PG4|240|220',
'PG1|300|220',
'PG2|300|220',
'PG3|300|220',
'PG4|300|220',
'PG1|180|230',
'PG2|180|230',
'PG3|180|230',
'PG4|180|230',
'PG1|240|230',
'PG2|240|230',
'PG3|240|230',
'PG4|240|230',
'PG1|300|230',
'PG2|300|230',
'PG3|300|230',
'PG4|300|230',
'PG1|180|240',
'PG2|180|240',
'PG3|180|240',
'PG4|180|240',
'PG1|240|240',
'PG2|240|240',
'PG3|240|240',
'PG4|240|240',
'PG1|300|240',
'PG2|300|240',
'PG3|300|240',
'PG4|300|240',
'PG1|180|250',
'PG2|180|250',
'PG3|180|250',
'PG4|180|250',
'PG1|240|250',
'PG2|240|250',
'PG3|240|250',
'PG4|240|250',
'PG1|300|250',
'PG2|300|250',
'PG3|300|250',
'PG4|300|250',
'PG1|180|260',
'PG2|180|260',
'PG3|180|260',
'PG4|180|260',
'PG1|240|260',
'PG2|240|260',
'PG3|240|260',
'PG4|240|260',
'PG1|180|270',
'PG2|180|270',
'PG3|180|270',
'PG4|180|270',
'PG1|240|270',
'PG2|240|270',
'PG3|240|270',
'PG4|240|270',
'PG1|180|280',
'PG2|180|280',
'PG3|180|280',
'PG4|180|280',
'PG1|240|280',
'PG2|240|280',
'PG3|240|280',
'PG4|240|280',
'PG1|180|300',
'PG2|180|300',
'PG3|180|300',
'PG4|180|300',
'PG1|240|300',
'PG2|240|300',
'PG3|240|300',
'PG4|240|300',
'PG1|180|320',
'PG2|180|320',
'PG3|180|320',
'PG4|180|320',
'PG1|240|320',
'PG2|240|320',
'PG3|240|320',
'PG4|240|320',
'PG1|180|330',
'PG2|180|330',
'PG3|180|330',
'PG4|180|330',
'PG1|240|330',
'PG2|240|330',
'PG3|240|330',
'PG4|240|330'
);
prices[0] = 54.054;
prices[1] = 67.500;
prices[2] = 74.700;
prices[3] = 85.500;
prices[4] = 70.200;
prices[5] = 88.200;
prices[6] = 96.300;
prices[7] = 110.700;
prices[8] = 90.000;
prices[9] = 108.900;
prices[10] = 118.800;
prices[11] = 134.100;
prices[12] = 61.261;
prices[13] = 72.000;
prices[14] = 79.200;
prices[15] = 90.900;
prices[16] = 79.200;
prices[17] = 93.600;
prices[18] = 102.600;
prices[19] = 118.800;
prices[20] = 99.900;
prices[21] = 115.200;
prices[22] = 125.100;
prices[23] = 142.200;
prices[24] = 66.667;
prices[25] = 76.500;
prices[26] = 84.600;
prices[27] = 97.200;
prices[28] = 86.400;
prices[29] = 99.900;
prices[30] = 109.800;
prices[31] = 126.000;
prices[32] = 108.000;
prices[33] = 121.500;
prices[34] = 132.300;
prices[35] = 150.300;
prices[36] = 68.468;
prices[37] = 80.100;
prices[38] = 88.200;
prices[39] = 101.700;
prices[40] = 88.200;
prices[41] = 104.400;
prices[42] = 114.300;
prices[43] = 131.400;
prices[44] = 109.800;
prices[45] = 126.900;
prices[46] = 137.700;
prices[47] = 156.600;
prices[48] = 70.200;
prices[49] = 85.500;
prices[50] = 94.500;
prices[51] = 108.000;
prices[52] = 90.900;
prices[53] = 111.600;
prices[54] = 122.400;
prices[55] = 140.400;
prices[56] = 112.500;
prices[57] = 134.100;
prices[58] = 145.800;
prices[59] = 165.600;
prices[60] = 72.000;
prices[61] = 90.000;
prices[62] = 99.000;
prices[63] = 114.300;
prices[64] = 93.600;
prices[65] = 117.000;
prices[66] = 128.700;
prices[67] = 147.600;
prices[68] = 115.200;
prices[69] = 140.400;
prices[70] = 153.000;
prices[71] = 173.700;
prices[72] = 73.800;
prices[73] = 92.700;
prices[74] = 101.700;
prices[75] = 117.000;
prices[76] = 95.400;
prices[77] = 120.600;
prices[78] = 132.300;
prices[79] = 152.100;
prices[80] = 117.900;
prices[81] = 144.000;
prices[82] = 157.500;
prices[83] = 178.200;
prices[84] = 74.775;
prices[85] = 95.400;
prices[86] = 105.300;
prices[87] = 120.600;
prices[88] = 97.200;
prices[89] = 124.200;
prices[90] = 136.800;
prices[91] = 156.600;
prices[92] = 118.800;
prices[93] = 147.600;
prices[94] = 161.100;
prices[95] = 183.600;
prices[96] = 76.577;
prices[97] = 98.100;
prices[98] = 108.000;
prices[99] = 124.200;
prices[100] = 99.900;
prices[101] = 127.800;
prices[102] = 140.400;
prices[103] = 161.100;
prices[104] = 121.500;
prices[105] = 152.100;
prices[106] = 165.600;
prices[107] = 188.100;
prices[108] = 78.378;
prices[109] = 102.600;
prices[110] = 112.500;
prices[111] = 129.600;
prices[112] = 101.700;
prices[113] = 133.200;
prices[114] = 146.700;
prices[115] = 168.300;
prices[116] = 124.200;
prices[117] = 158.400;
prices[118] = 172.800;
prices[119] = 196.200;
prices[120] = 80.180;
prices[121] = 107.100;
prices[122] = 117.900;
prices[123] = 135.900;
prices[124] = 104.400;
prices[125] = 139.500;
prices[126] = 153.000;
prices[127] = 176.400;
prices[128] = 126.900;
prices[129] = 164.700;
prices[130] = 179.100;
prices[131] = 204.300;
prices[132] = 81.982;
prices[133] = 109.800;
prices[134] = 120.600;
prices[135] = 138.600;
prices[136] = 106.200;
prices[137] = 143.100;
prices[138] = 156.600;
prices[139] = 180.900;
prices[140] = 129.600;
prices[141] = 168.300;
prices[142] = 183.600;
prices[143] = 208.800;
prices[144] = 83.784;
prices[145] = 115.200;
prices[146] = 126.900;
prices[147] = 145.800;
prices[148] = 108.900;
prices[149] = 149.400;
prices[150] = 164.700;
prices[151] = 189.000;
prices[152] = 131.400;
prices[153] = 175.500;
prices[154] = 191.700;
prices[155] = 218.700;
prices[156] = 85.586;
prices[157] = 119.700;
prices[158] = 131.400;
prices[159] = 151.200;
prices[160] = 111.600;
prices[161] = 155.700;
prices[162] = 171.000;
prices[163] = 197.100;
prices[164] = 134.100;
prices[165] = 181.800;
prices[166] = 198.900;
prices[167] = 226.800;
prices[168] = 87.387;
prices[169] = 123.300;
prices[170] = 135.900;
prices[171] = 155.700;
prices[172] = 113.400;
prices[173] = 160.200;
prices[174] = 176.400;
prices[175] = 202.500;
prices[176] = 136.800;
prices[177] = 187.200;
prices[178] = 204.300;
prices[179] = 233.100;
prices[180] = 89.189;
prices[181] = 125.100;
prices[182] = 137.700;
prices[183] = 158.400;
prices[184] = 116.100;
prices[185] = 162.900;
prices[186] = 179.100;
prices[187] = 206.100;
prices[188] = 139.500;
prices[189] = 189.900;
prices[190] = 207.000;
prices[191] = 235.800;
prices[192] = 121.622;
prices[193] = 148.500;
prices[194] = 163.800;
prices[195] = 188.100;
prices[196] = 158.400;
prices[197] = 193.500;
prices[198] = 212.400;
prices[199] = 243.900;
prices[200] = 184.500;
prices[201] = 222.300;
prices[202] = 243.000;
prices[203] = 277.200;
prices[204] = 138.739;
prices[205] = 155.700;
prices[206] = 171.000;
prices[207] = 197.100;
prices[208] = 180.000;
prices[209] = 202.500;
prices[210] = 222.300;
prices[211] = 255.600;
prices[212] = 208.800;
prices[213] = 232.200;
prices[214] = 253.800;
prices[215] = 289.800;
prices[216] = 146.847;
prices[217] = 159.300;
prices[218] = 175.500;
prices[219] = 201.600;
prices[220] = 190.800;
prices[221] = 207.000;
prices[222] = 227.700;
prices[223] = 261.900;
prices[224] = 219.600;
prices[225] = 237.600;
prices[226] = 260.100;
prices[227] = 296.100;
prices[228] = 154.955;
prices[229] = 168.300;
prices[230] = 185.400;
prices[231] = 213.300;
prices[232] = 201.600;
prices[233] = 218.700;
prices[234] = 240.300;
prices[235] = 277.200;
prices[236] = 231.300;
prices[237] = 250.200;
prices[238] = 273.600;
prices[239] = 312.300;
prices[240] = 163.063;
prices[241] = 179.100;
prices[242] = 197.100;
prices[243] = 226.800;
prices[244] = 212.400;
prices[245] = 233.100;
prices[246] = 256.500;
prices[247] = 294.300;
prices[248] = 176.576;
prices[249] = 189.000;
prices[250] = 207.900;
prices[251] = 239.400;
prices[252] = 229.500;
prices[253] = 245.700;
prices[254] = 270.000;
prices[255] = 310.500;
prices[256] = 183.784;
prices[257] = 196.200;
prices[258] = 266.400;
prices[259] = 248.400;
prices[260] = 238.500;
prices[261] = 254.700;
prices[262] = 280.800;
prices[263] = 323.100;
prices[264] = 198.198;
prices[265] = 215.100;
prices[266] = 236.700;
prices[267] = 271.800;
prices[268] = 257.400;
prices[269] = 279.900;
prices[270] = 307.800;
prices[271] = 353.700;
prices[272] = 202.703;
prices[273] = 234.000;
prices[274] = 257.400;
prices[275] = 296.100;
prices[276] = 263.700;
prices[277] = 304.200;
prices[278] = 334.800;
prices[279] = 385.200;
prices[280] = 211.500;
prices[281] = 252.000;
prices[282] = 277.200;
prices[283] = 318.600;
prices[284] = 275.400;
prices[285] = 327.600;
prices[286] = 360.000;
prices[287] = 414.000;
;
var widths = new Array(
60,
70,
80,
90,
100,
110,
120,
130,
140,
150,
160,
170,
180,
190,
200,
210,
220,
230,
240,
250,
260,
270,
280,
300,
320,
330
);
var heights = new Array(
180,
240,
300
);

function showhideSubmit() {
	var breed = document.getElementById('breed');
	var hoog = document.getElementById('hoog');
	
	//var bedien = document.bestelform.bediening.value;
	//var lamel = document.bestelform.breedte.value;
	var bedien = '';
	var lamel = '';
	
	for (var i = 0;i < document.forms[0].bediening.length; i++) {
		if (document.forms[0].bediening[i].checked) {
			bedien = document.forms[0].bediening[i].value;
		}
	}
	
	var klr = document.bestelform.kleur.value;
	
	if ( (breed.value > 0) && (hoog.value > 0) && (bedien != '') && (klr != '')) {
		var subber = document.getElementById('winkelknop');
		subber.innerHTML = '<input value=" Plaats in winkelmandje " type="submit">';
	} else {
		var subber = document.getElementById('winkelknop');
		var fields = 'Nog in te vullen velden:<br />';
		
		if (breed.value <= 0) {
			fields += '- breedte<br />';
		}
		
		if (hoog.value <= 0) {
			fields += '- hoogte<br />';
		}
		
		if (bedien == '') {
			fields += '- bediening<br />';
		}
		
		if (klr == '') {
			fields += '- kleur<br />';
		}
		
		subber.innerHTML = fields;
			
	}
	
	
}

//show/hide colors
/*
function showhideColors(sp) {
	var radio1 = document.getElementById('16mm');
	var radio2 = document.getElementById('25mm');
	var radio3 = document.getElementById('50mm');
	
	if(sp == 'mm16') {
		
		var sp1 = document.getElementById('mm25');
		var sp2 = document.getElementById('mm1625');
		var sp3 = document.getElementById('mmall');
		var sp4 = document.getElementById('trladderband');
		
		sp1.style.display = 'none';
		sp2.style.display = 'inline';
		sp3.style.display = 'inline';
		sp4.style.display = 'none';
		
	}
	
	if(sp == 'mm25') {
		
		var sp1 = document.getElementById('mm25');
		var sp2 = document.getElementById('mm1625');
		var sp3 = document.getElementById('mmall');
		var sp4 = document.getElementById('trladderband');
		
		sp1.style.display = 'inline';
		sp2.style.display = 'inline';
		sp3.style.display = 'inline';
		sp4.style.display = 'none';
		
	}
	
	if(sp == 'mm50') {
		
		var sp1 = document.getElementById('mm25');
		var sp2 = document.getElementById('mm1625');
		var sp3 = document.getElementById('mmall');
		var sp4 = document.getElementById('trladderband');
		
		sp1.style.display = 'none';
		sp2.style.display = 'none';
		sp3.style.display = 'inline';
		sp4.style.display = 'inline';
	}
}
*/

function showSchulp() {
	
	var sch = document.getElementById("schulpdiv");

	if (document.getElementById("radioschulpranden").checked) {
		sch.style.display = 'block';
	} else {
		sch.style.display = 'none';
		$("#schulpdiv input[type='radio']").attr('checked',false);
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_OR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_DR").hide();
	}
	
	Extra();
}

function Calculate(){
	if (group == '') {
		group = 'PG1';
	}
	
	price = 0;
	showhideSubmit();
	if(selWidth > 0 && selHeight > 0){
		//get width key
		w = 0;
		for(i in widths){
			if(widths[i] >= selWidth){
				w = widths[i];
				break;
			}
		}

		//get height key
		h = 0;
		for(i in heights){
			if(heights[i] >= selHeight){
				h = heights[i];
	    		break;
	    	}
		}

		//do checks
		var checker = group + "|" + h + "|" + w;
		var arlength = dimensions.length;
		//var price = 0;
		
		for(q = 0; q < arlength; q++) {
			if (dimensions[q] == checker) {
				price = prices[q];
			}
		}
		
		if(price == 0){
	    	alert("Sorry, de door u opgegeven maat is in prijsgroep '" + group + "' niet leverbaar.");
	    	document.getElementById('breed').value = '';
	  		document.getElementById('hoog').value = '';
	  		document.getElementById('breed').focus();
	  		document.getElementById('price').innerHTML = '';
	  		document.getElementById('piece_price').innerHTML = '';
	  		selHeight = 0;
	  		selWidth = 0;
	    	//alert("DEBUG: No price found?! prices["+h+"]["+w+"]");
	   } else {
			//Do some extra price calculations, depanding on the selected width
			if(selWidth < 30) {
							}
			
			if((selWidth >= 30 && selWidth < 40) || (selHeight >= 30 && selHeight < 40)) {
							}

			//parse to screen
			document.getElementById('price').innerHTML = "Basis: <span class=\"price\">&euro; " + roundTotal(price) + "</span>";
			document.getElementById('basisprice').innerHTML = "Basis: <span class=\"price\">&euro; " + roundTotal(price) + "</span>";
			
			//change total gui
			Total();

			//parse to screen
			document.getElementById('piece_price').innerHTML = "Basis + kleur: <span class=\"price\">&euro; " + roundTotal(price) + "</span>";
		}
	}
}

function Height(obj){
	h = parseFloat(obj.value.replace(',','.'));
	selHeight = Math.ceil(h);
	if(selHeight < 28) {
		alert("Sorry, onder de 28 cm is er niets leverbaar.");
		document.getElementById('breed').value = '';
	  document.getElementById('hoog').value = '';
	} else {
		document.getElementById('hoog').value = h;
		Calculate();
	}
	
	if(selHeight > 130) {
		$("#zijgelijdingcontainer, #zijgelijdingbedrag").hide();
		$("#zijgelijding").attr("checked",false);
		Extra();
		Calculate();
	} else {
		$("#zijgelijdingcontainer, #zijgelijdingbedrag").show();
		Extra();
		Calculate();
	}
}

function Width(obj){
	b = parseFloat(obj.value.replace(',','.'));
	selWidth = Math.ceil(b);
	if(selWidth < 28) {
		alert("Sorry, onder de 28 cm is er niets leverbaar.");
		document.getElementById('breed').value = '';
	  document.getElementById('hoog').value = '';
	} else {
		document.getElementById('breed').value = b;
		Extra();
		Calculate();
	}
	
	var buis = document.getElementById('buis38mm');
	var buisbed = document.getElementById('buisbedrag');
	if (selWidth < 220) {
		buis.style.display = 'inline';
		buisbed.style.display = 'inline';
	} else {
		buis.style.display = 'none';
		buisbed.style.display = 'none';
		buis.checked = false;
	}
	
	if(selWidth > 130) {
		$("#zijgelijdingcontainer, #zijgelijdingbedrag").hide();
		$("#zijgelijding").attr("checked",false);
		Extra();
		Calculate();
	} else {
		$("#zijgelijdingcontainer, #zijgelijdingbedrag").show();
		Extra();
		Calculate();
	}
}

function Extra(){
	
	extra = 0;
		
	if($("#groep_schulp_ABCFHKMN input[type='radio']:checked").length > 0) {

		extra+= 25.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'25,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;
				
					extra += mr * 25.00;				}
						
	} else if($("#groep_schulp_R input[type='radio']:checked").length > 0) {

		extra+= 14.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'14,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 14.00;				}
							
	} else if($("#groep_schulp_Z input[type='radio']:checked").length > 0) {

		extra+= 14.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'14,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 14.00;				}
						
	} else if($("#groep_schulp_DJPO input[type='radio']:checked").length > 0) {

			} else if($("#groep_schulp_DR input[type='radio']:checked").length > 0) {

		extra+= 25.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'25,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 25.00;				}
				
	} else if($("#groep_schulp_JR input[type='radio']:checked").length > 0) {

		extra+= 25.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'25,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 25.00;				}
					} else if($("#groep_schulp_PR input[type='radio']:checked").length > 0) {

		extra+= 25.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'25,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 25.00;				}
						
	} else if($("#groep_schulp_OR input[type='radio']:checked").length > 0) {

		extra+= 25.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'25,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 25.00;				}
				
	} else if($("#groep_schulp_onderlat input[type='radio']:checked").length > 0) {

		extra+= 15.00;
				$("#schulpbreedtemeterprijs").html('&euro; '+'15,00');
				var meter = document.getElementById("breed");
				if (meter.value > 100) {
					var mr = (meter.value - 100) / 100;

					extra += mr * 15.00;				}
				
	} else {
		$("#schulpbreedtemeterprijs").html('&euro; '+'0,00');	
	}
	
	if(document.getElementById('buis38mmchk').checked) {
		extra+= 22.00;
	}
	
	if(document.getElementById('deurclips').checked) {
		extra+= 3.50;
	}
	
	if(document.getElementById('zijgelijding').checked) {
		extra+= 15.00;
	}
	
	
	//change total gui
	Total();
}

function Total(){
	
    if(price > 0){
		total = price + extra;
		document.getElementById('total').innerHTML = "Totaal (incl. 19% BTW): <span class=\"price\">&euro; " + roundTotal(total) + "</span><input type=hidden name=TOTAAL value=\"&euro; " + roundTotal(total,true) + "\">";
//		document.getElementById('total').innerHTML = "Totaal (incl. 19% BTW): <span class=\"price\">&euro; " + roundTotal(total) + "</span>";
		adviesverkoopprijs(total);
	} else {
		document.getElementById('total').innerHTML = price
	}
}

function roundTotal(c,nohtml){
	if(c==0)
		return '0,00';
	var pennies = c * 100;
	pennies = Math.round(pennies);
	var strPennies = pennies.toString();
	var len = strPennies.length;
	e = strPennies.substring(0, len - 2);
	c = strPennies.substring(len - 2, len);
	if(!e)
		e = 0;
	if(!nohtml)
		return (e + ',<span class="cents">' + c + '</span>');
	else
		return (e + ',' + c);
}

function calcTax(price){
	return (price  / 119) * 19;
}

function SetColor(g){
	group = g;
	Calculate();
	Total();
}

function SetKleur(testkleur){
	document.getElementById('testkleur').innerHTML = "Kleur: " + testkleur;
	document.getElementById('kleur').value = testkleur; //insert into form
}

function roll_over(img_name, img_src){
	document[img_name].src = img_src;
}

$(document).ready(function(){

	$("#schulpdiv input[type='radio']").click(function(){
		
		if($("#radioschulpranden:checked").length > 0) {
			Extra();
		}
		
	});
	
	$("#groep_schulp_ABCFHKMN input[type=radio], #groep_schulp_standaard input[type=radio]").click(function(){		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();	
		$("#groep_schulp_alle input[type=radio]").show();	
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_voorkeuze_D input[type=radio]").click(function(){
		alert("Kies de gewenste soort roede");		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").show();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();
		$("#groep_schulp_alle input[type=radio]").show();	
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_voorkeuze_J input[type=radio]").click(function(){
		alert("Kies de gewenste soort roede");		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").show();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();
		$("#groep_schulp_alle input[type=radio]").show();	
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_voorkeuze_P input[type=radio]").click(function(){
		alert("Kies de gewenste soort roede");		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").show();
		$("#groep_schulp_OR").hide();
		$("#groep_schulp_alle input[type=radio]").show();
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_schulp_R input[type=radio]").click(function(){
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();	
		$("#groep_schulp_alle input[type=radio]").show();
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_voorkeuze_O input[type=radio]").click(function(){
		alert("Kies de gewenste soort roede");		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").show();	
		$("#groep_schulp_alle input[type=radio]").show();
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	$("#voorkeuze_kleur_schulpranden_Z").click(function(){
		alert("Kies de gewenste soort ringen");			
		$("#groep_schulp_Z").show();
		$("#groep_schulp_onderlat").hide();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();
		$("#groep_schulp_alle input[type=radio]").show();
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	$("#groep_voorkeuze_onderlat input[type=radio]").click(function(){
		alert("Kies de gewenste soort onderlat");		
		$("#groep_schulp_Z").hide();
		$("#groep_schulp_onderlat").show();
		$("#groep_schulp_DR").hide();
		$("#groep_schulp_JR").hide();
		$("#groep_schulp_PR").hide();
		$("#groep_schulp_OR").hide();	
		$("#groep_schulp_alle input[type=radio]").show();
		$("#groep_schulp_alle div").removeClass("schulpranden_rand");
		$(this).hide().parents("div:first").addClass("schulpranden_rand");
	});
	
});



function roundAdviesTotal(c){
	var a = Math.round(c/10);
	var b = a * 10;
	var c = b - 1;
	return c;
}
function adviesverkoopprijs(pr) {
	
	 var advprice = pr + (pr * (20/100));
	
	$('#adviesprijs').html("Adviesprijs: <span class='price'>&euro; " + roundTotal(roundAdviesTotal(advprice)) + "</span>");
		
}

