www/js/rec_edit.js

changeset 220
14e349ff2a10
parent 175
da16371538c3
child 221
a8aabb63fbcc
--- a/www/js/rec_edit.js	Sun Jan 27 23:35:19 2019 +0100
+++ b/www/js/rec_edit.js	Tue Jan 29 21:52:08 2019 +0100
@@ -74,6 +74,15 @@
 	var     MMNaCl = 58.443;
 	var     MMCaOH2 = 74.06268;
 
+	var	fermentableRow = 0;
+	var	fermentableData = {};
+	var	hopRow = 0;
+	var	hopData = {};
+	var	miscRow = 0;
+	var	miscData = {};
+	var	yeastRow = 0;
+	var	yeastData = {};
+
 	console.log("record:" + my_record + "  return:" + my_return + "  theme:" + theme);
 	$("#jqxLoader").jqxLoader({
 		width: 250,
@@ -85,17 +94,18 @@
 
 	function setReadonly(ro) {
 		var rw = ! ro;
-		var w100 = 100;
+		var w100 = 110;
 		var w80 = 80;
 		if (ro) { // jqxNumberInput width -20 for no spinbuttons
-			w100 = 80;
+			w100 = 90;
 			w80 = 60;
 		}
 		$("#batch_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 });
 		$("#boil_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 });
 		$("#boil_time").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 });
 		$("#efficiency").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 });
-		$("#est_og").jqxNumberInput({ spinButtons: rw, readOnly: ro });
+		$("#est_og").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 });
+		// id="st_fg_min" margin-left 15/35 maken
 		$("#type").jqxDropDownList({ disabled: ro });
 		$("#styleSelect").jqxDropDownList({ disabled: ro });
 		$("#color_method").jqxDropDownList({ disabled: ro });
@@ -157,12 +167,12 @@
 			var row = rows[i];
 			if (row.f_adjust_to_total_100)
 				my_100 = true;
-			if (row.f_type == "Sugar")
+			if (row.f_type == 1)		// Sugar
 				psugar += row.f_percentage;
-			if (row.f_graintype == "Crystal")
+			if (row.f_graintype == 2)	// Crystal
 				pcara += row.f_percentage;
 			var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
-			if (row.f_added == "Mash") {
+			if (row.f_added == 0) {		// Mash
 				d = parseFloat(dataRecord.efficiency) / 100 * d;
 				sugarsm += d;
 				mashkg += row.f_amount;
@@ -171,6 +181,11 @@
 			colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436;
 		}
 		to_100 = my_100;
+		if (to_100) {
+			$("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false  });
+		} else {
+			$("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true });
+		}
 		var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size));
 		$('#est_og').val(est_og);
 		$('#est_og2').val(est_og);
@@ -191,7 +206,7 @@
 	function hopFlavourContribution(bt, vol, use, amount) {
 		var result;
 
-		if ((use == "First Wort") || (use == "First wort")) {
+		if (use == 1) {	// First wort
 			result = 0.15;		// assume 15% flavourcontribution for fwh
 		} else if (bt > 50) {
 			result = 0.10;		// assume 10% flavourcontribution as a minimum
@@ -212,13 +227,13 @@
 			result = 0;
 		} else if (bt > 7.5) {
 			result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2));
-		} else if (use == "Boil") {
+		} else if (use == 2) {	// Boil
 			result = 1;
-		} else if (use == "Aroma") {
+		} else if (use == 3) {	// Aroma / vlamuit
 			result = 1.2;
-		} else if (use == "Whirlpool") {
+		} else if (use == 4) { // Whirlpool
 			result = 1.2;
-		} else if ((use == "Dry Hop") || (use == "Dry hop")) {
+		} else if (use == 5) {	// Dry hop
 			result = 1.33;
 		}
 		result = (result * amount * 1000) / vol;
@@ -252,7 +267,7 @@
 		var rows = $('#yeastGrid').jqxGrid('getrows');
 		for (var i = 0; i < rows.length; i++) {
 			var row = rows[i];
-			if (row.y_use == "Primary")
+			if (row.y_use == 0)	// Primary
 				svg = parseFloat(row.y_attenuation);
 		}
 	}
@@ -412,7 +427,7 @@
 		var rows = $('#fermentableGrid').jqxGrid('getrows');
 		for (var i = 0; i < rows.length; i++) {
 			var row = rows[i];
-			if (row.f_added == 'Mash' && row.f_graintype != 'No malt') {
+			if (row.f_added == 0 && row.f_graintype != 6) {	// Added == Mash && graintype != No Malt
 				// Check if acid is required
 				var C1 = 0;
 				if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) {
@@ -421,16 +436,16 @@
 					// If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid.
 					var ebc = row.f_color;
 					switch (row.f_graintype) {
-						case 'Base':
-						case 'Special':
-						case 'Kilned':	C1 = 0.014 * ebc - 34.192;
-								break;
-						case 'Crystal':	C1 = -0.0597 * ebc - 32.457;
-								break;
-						case 'Roast':	C1 = 0.0107 * ebc - 54.768;
-								break;
-						case 'Sour':	C1 = -149;
-								break;
+						case 0:					// Base, Special, Kilned
+						case 3:
+						case 5:	C1 = 0.014 * ebc - 34.192;
+							break;
+						case 2:	C1 = -0.0597 * ebc - 32.457;	// Crystal
+							break;
+						case 1:	C1 = 0.0107 * ebc - 54.768;	// Roast
+							break;
+						case 4:	C1 = -149;			// Sour malt
+							break;
 					}
 				}
 				x = C1 * (pHZ - row.f_di_ph);	// AcidRequired(ZpH)
@@ -462,39 +477,40 @@
 
 	function GetAcidSpecs(AT) {
 		switch(AT) {
-			case 'Melkzuur':	return {
-							pK1: 3.08,
-							pK2: 20,
-							pK3: 20,
-							MolWt: 90.08,
-							AcidSG: 1214,
-							AcidPrc: 0.88
-						};
-			case 'Zoutzuur':	return {
-							pK1: -10,
-							pK2: 20,
-							pK3: 20,
-							MolWt: 36.46,
-							AcidSG: 1142,
-							AcidPrc: 0.28
-						};
-			case 'Fosforzuur':	return {
-							pK1: 2.12,
-							pK2: 7.20,
-							pK3: 12.44,
-							MolWt: 98.00,
-							AcidSG: 1170,
-							AcidPrc: 0.25
-						};
-			case 'Zwavelzuur':	return {
-							pK1: -10,
-							pK2: 1.92,
-							pK3: 20,
-							MolWt: 98.07,
-							AcidSG: 1700,
-							AcidPrc: 0.93
-						};
+			case 0:	return {	// Melkzuur
+					pK1: 3.08,
+					pK2: 20,
+					pK3: 20,
+					MolWt: 90.08,
+					AcidSG: 1214,
+					AcidPrc: 0.88
+				};
+			case 1:	return {	// Zoutzuur
+					pK1: -10,
+					pK2: 20,
+					pK3: 20,
+					MolWt: 36.46,
+					AcidSG: 1142,
+					AcidPrc: 0.28
+				};
+			case 2:	return {	// Fosforzuur
+					pK1: 2.12,
+					pK2: 7.20,
+					pK3: 12.44,
+					MolWt: 98.00,
+					AcidSG: 1170,
+					AcidPrc: 0.25
+				};
+			case 3:	return {	// Zwavelzuur
+					pK1: -10,
+					pK2: 1.92,
+					pK3: 20,
+					MolWt: 98.07,
+					AcidSG: 1700,
+					AcidPrc: 0.93
+				};
 		}
+		console.log("Bummer, AT is " + AT);
 	}
 
 	// Procedure TFrmWaterAdjustment.CalcWater2;
@@ -595,8 +611,8 @@
 			last_base = 'NaHCO3';
 		}
 
-		var AT = $("#wa_acid_name").val();
-		var BT = $("#wa_base_name").val();
+		var AT = dataRecord.wa_acid_name; // parseFloat($("#wa_acid_name").jqxNumberInput('decimal'));
+		var BT = parseFloat($("#wa_base_name").jqxNumberInput('decimal'));
 
 		var result = GetAcidSpecs(AT);
 		var pK1 = result.pK1;
@@ -637,79 +653,79 @@
 				var f2d = f1d * r1d;
 				var f3d = f2d * r2d;
 				switch (BT) {
-					case 'NaHCO3':	RA = -protonDeficit / (f1d - f3d); //mmol totaal
-							RA = RA * MMNaHCO3/1000; //gram
-							$("#wa_base").val(Math.round(RA * 100) / 100);
-							setWaterAgent(BT, Math.round(RA * 100) / 100);
-							if (liters > 0) {
-								// Na
-								RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
-								RA = 1000 * RA / liters;
-								sodium = wg_sodium + RA;
-								// HCO3
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-							}
-							break;
-					case 'Na2CO3':	RA = -protonDeficit / (2 * f1d + f2d); //mmol totaal
-							RA = RA * MMNa2CO3/1000; //gram
-							$("#wa_base").val(Math.round(RA * 100) / 100);
-							setWaterAgent(BT, Math.round(RA * 100) / 100);
-							if (liters > 0) {
-								RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
-								RA = 1000 * RA / liters;
-								sodium = wg_sodium + RA;
-								// HCO3
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-							}
-							break;
-					case 'CaCO3':	RA = -protonDeficit * (f1d - f3d); //mmol totaal
-							RA = RA * MMCaCO3/1000; //gram
-							//but only 1/3 is effective, so add 3 times as much
-							RA = 3 * RA;
-							$("#wa_base").val(Math.round(RA * 100) / 100);
-							setWaterAgent(BT, Math.round(RA * 100) / 100);
-							if (liters > 0) {
-								//Bicarbonate
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								//Ca precipitates out as Ca10(PO4)6(OH)2
-								RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
-								     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
-								RA = 1000 * RA / liters;
-								calcium = wg_calcium + RA;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-							}
-							break;
-					case 'Ca(OH)2':	RA = -protonDeficit / 19.3; // g
-							$("#wa_base").val(Math.round(RA * 100) / 100);
-							setWaterAgent(BT, Math.round(RA * 100) / 100);
-							if (liters > 0) {
-								// Bicarbonate
-								RA = -protonDeficit / liters;
-								total_alkalinity = wg_total_alkalinity + RA;
-								bicarbonate = total_alkalinity * 61 / 50;
-								// Calcium
-								RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
-								     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2;
-								RA = 1000 * RA / liters;
-								calcium = wg_calcium + RA;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-							}
-							break;
+					case 0:	RA = -protonDeficit / (f1d - f3d); //Sodiumbicarbonate, mmol totaal
+						RA = RA * MMNaHCO3/1000; //gram
+						$("#wa_base").val(Math.round(RA * 100) / 100);
+						setWaterAgent(BT, Math.round(RA * 100) / 100);
+						if (liters > 0) {
+							// Na
+							RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
+							RA = 1000 * RA / liters;
+							sodium = wg_sodium + RA;
+							// HCO3
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+						}
+						break;
+					case 1:	RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal
+						RA = RA * MMNa2CO3/1000; //gram
+						$("#wa_base").val(Math.round(RA * 100) / 100);
+						setWaterAgent(BT, Math.round(RA * 100) / 100);
+						if (liters > 0) {
+							RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
+							RA = 1000 * RA / liters;
+							sodium = wg_sodium + RA;
+							// HCO3
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+						}
+						break;
+					case 2:	RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal
+						RA = RA * MMCaCO3/1000; //gram
+						//but only 1/3 is effective, so add 3 times as much
+						RA = 3 * RA;
+						$("#wa_base").val(Math.round(RA * 100) / 100);
+						setWaterAgent(BT, Math.round(RA * 100) / 100);
+						if (liters > 0) {
+							//Bicarbonate
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							//Ca precipitates out as Ca10(PO4)6(OH)2
+							RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
+							     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
+							RA = 1000 * RA / liters;
+							calcium = wg_calcium + RA;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+						}
+						break;
+					case 3:	RA = -protonDeficit / 19.3; // Calciumhydroxide
+						$("#wa_base").val(Math.round(RA * 100) / 100);
+						setWaterAgent(BT, Math.round(RA * 100) / 100);
+						if (liters > 0) {
+							// Bicarbonate
+							RA = -protonDeficit / liters;
+							total_alkalinity = wg_total_alkalinity + RA;
+							bicarbonate = total_alkalinity * 61 / 50;
+							// Calcium
+							RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
+							     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2;
+							RA = 1000 * RA / liters;
+							calcium = wg_calcium + RA;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+						}
+						break;
 				}
 			}
 			ph = TpH;
@@ -720,42 +736,43 @@
 			if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) {
 				if (liters > 0) {
 					switch (BT) {
-						case 'NaHCO3':	// Na
-								RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
-								RA = 1000 * RA / liters;
-								sodium = wg_sodium + RA;
-								// HCO3
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-								break;
-						case 'Na2CO3':	RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
-								RA = 1000 * RA / liters;
-								sodium = wg_sodium + RA;
-								// HCO3
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-								break;
-						case 'CaCO3':	// Bicarbonate
-								RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
-								RA = 1000 * RA / liters;
-								bicarbonate = wg_bicarbonate + RA;
-								total_alkalinity = bicarbonate * 50 / 61;
-								RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
-								// Ca
-								RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
-								     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
-								     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
-								RA = 1000 * RA / liters;
-								calcium = wg_calcium + RA;
-								break;
+						case 0:	// Sodiumbicarbonate, Na
+							RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3;
+							RA = 1000 * RA / liters;
+							sodium = wg_sodium + RA;
+							// HCO3
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+							break;
+						case 1:	// Sodiumcarbonate
+							RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3;
+							RA = 1000 * RA / liters;
+							sodium = wg_sodium + RA;
+							// HCO3
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+							break;
+						case 2:	// Calciumcarbonate: Bicarbonate
+							RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3;
+							RA = 1000 * RA / liters;
+							bicarbonate = wg_bicarbonate + RA;
+							total_alkalinity = bicarbonate * 50 / 61;
+							RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium);
+							// Ca
+							RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 +
+							     parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 +
+							     parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3;
+							RA = 1000 * RA / liters;
+							calcium = wg_calcium + RA;
+							break;
 					}
 				}
 			}
@@ -802,13 +819,13 @@
 			}
 		}
 
-		if ((AT == 'Zwavelzuur') && (liters > 0)) {
+		if ((AT == 3) && (liters > 0)) {	// Sulfuctic / Zwavelzuur
 			RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 +
 			     parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 +
 			     Acidmg / 1000 * MMSO4 / (MMSO4 + 2);
 			RA = 1000 * RA / liters;
 			sulfate = wg_sulfate + RA;	// Not add to sulfate??
-		} else if ((AT == 'Zoutzuur') && (liters > 0)) {
+		} else if ((AT == 1) && (liters > 0)) {	// Hydrochloric, Zoutzuur
 			RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 +
 			     parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl +
 			     Acidmg / 1000 * MMCl / (MMCL + 1);
@@ -932,9 +949,9 @@
 		//Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L)
 		var Acid = alkalinity * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH);  //mEq/l
 
-		if ($("#sparge_acid_type").val() == "") {
-			$("#sparge_acid_type").val('Melkzuur');
-			dataRecord.sparge_acid_type = 'Melkzuur';
+		if ($("#sparge_acid_type").val() == NaN) {
+			$("#sparge_acid_type").val(0);
+			dataRecord.sparge_acid_type = 0;
 		}
 		var AT = dataRecord.sparge_acid_type;
 		var result = GetAcidSpecs(AT);
@@ -974,7 +991,7 @@
 		for (var i = 0; i < rows.length; i++) {
 			var row = rows[i];
 			var d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100);
-			if (row.f_added == "Mash")
+			if (row.f_added == 0)	// Mash
 				d = efficiency / 100 * d;
 			tot += d;
 		}
@@ -1069,8 +1086,12 @@
 		});
 		$('#wa_acid_perc').on('change', function (event) { calcWater(); });
 
-		$('#color_method').on('change', function (event) { calcFermentables(); });
+		$('#color_method').on('change', function (event) {
+			dataRecord.color_method = event.args.index;
+			calcFermentables();
+		});
 		$('#ibu_method').on('change', function (event) {
+			dataRecord.ibu_method = event.args.index;
 			calcFermentables();
 			calcIBUs(); 
 		});
@@ -1157,8 +1178,8 @@
 		theme: theme,
 		source: styleslist,
 		displayMember: "name",
-		width: 150,
-		height: 27,
+		width: 180,
+		height: 23,
 		dropDownVerticalAlignment: 'top',
 		dropDownWidth: 500,
 		dropDownHeight: 380,
@@ -1176,7 +1197,7 @@
 			$("#st_category_number").val(datarecord.category_number);
 			$("#st_letter").val(datarecord.style_letter);
 			$("#st_guide").val(datarecord.style_guide);
-			$("#st_type").val(datarecord.type);
+			$("#st_type").val(StyleTypeData[datarecord.type].nl);
 			$("#st_og_min").val(datarecord.og_min);
 			$("#st_og_max").val(datarecord.og_max);
 			$("#st_fg_min").val(datarecord.fg_min);
@@ -1194,54 +1215,6 @@
 
 	var dataRecord = {};
 	var url = "includes/db_recipes.php";
-	// tooltips
-	$("#name").jqxTooltip({ content: 'De naam voor dit recept.' });
-	$("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' });
-	$("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
-	$("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' });
-	$("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' });
-	$("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' });
-	$("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' });
-	$("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
-	$("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
-	$("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
-	$("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
-	$("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
-	$("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
-	$("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
-	$("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
-	$("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
-
-	$("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
-	$("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
-	$("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
-	$("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
-	$("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
-	$("#st_type").jqxTooltip({ content: 'Het bierstijl type.'});
-	$("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
-	$("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
-	$("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
-	$("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
-	$("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
-	$("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
-	$("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
-	$("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
-	$("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
-	$("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
-	$("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
-	$("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
-	$("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'});
-	$("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'});
-	$("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'});
-	$("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'});
-	$("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'});
-	$("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'});
-
-	$("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'});
-	$("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'});
-	$("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'});
-	$("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'});
-	$("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'});
 
 	// prepare the data
 	var source = {
@@ -1254,7 +1227,7 @@
 			{ name: 'st_name', type: 'string' },
 			{ name: 'st_letter', type: 'string' },
 			{ name: 'st_guide', type: 'string' },
-			{ name: 'st_type', type: 'string' },
+			{ name: 'st_type', type: 'int' },
 			{ name: 'st_category', type: 'string' },
 			{ name: 'st_category_number', type: 'float' },
 			{ name: 'st_og_min', type: 'float' },
@@ -1271,7 +1244,7 @@
 			{ name: 'st_abv_max', type: 'float' },
 			{ name: 'name', type: 'string' },
 			{ name: 'notes', type: 'string' },
-			{ name: 'type', type: 'string' },
+			{ name: 'type', type: 'int' },
 			{ name: 'batch_size', type: 'float' },
 			{ name: 'boil_size', type: 'float' },
 			{ name: 'boil_time', type: 'float' },
@@ -1280,15 +1253,15 @@
 			{ name: 'est_fg', type: 'float' },
 			{ name: 'est_abv', type: 'float' },
 			{ name: 'est_color', type: 'float' },
-			{ name: 'color_method', type: 'string' },
+			{ name: 'color_method', type: 'int' },
 			{ name: 'est_ibu', type: 'float' },
-			{ name: 'ibu_method', type: 'string' },
+			{ name: 'ibu_method', type: 'int' },
 			{ name: 'est_carb', type: 'float' },
 			{ name: 'sparge_temp', type: 'float' },
 			{ name: 'sparge_ph', type: 'float' },
 			{ name: 'sparge_volume', type: 'float' },
 			{ name: 'sparge_source', type: 'string' },
-			{ name: 'sparge_acid_type', type: 'string' },
+			{ name: 'sparge_acid_type', type: 'int' },
 			{ name: 'sparge_acid_perc', type: 'float' },
 			{ name: 'sparge_acid_amount', type: 'float' },
 			{ name: 'mash_ph', type: 'float' },
@@ -1314,11 +1287,14 @@
 			{ name: 'w2_total_alkalinity', type: 'float' },
 			{ name: 'w2_ph', type: 'float' },
 			{ name: 'w2_cost', type: 'float' },
+			{ name: 'wa_acid_name', type: 'int' },
+			{ name: 'wa_acid_perc', type: 'int' },
+			{ name: 'wa_base_name', type: 'int' },
 			{ name: 'fermentables', type: 'array' },
-			{ name: 'hops', type: 'string' },
-			{ name: 'miscs', type: 'string' },
-			{ name: 'yeasts', type: 'string' },
-			{ name: 'mashs', type: 'string' }
+			{ name: 'hops', type: 'array' },
+			{ name: 'miscs', type: 'array' },
+			{ name: 'yeasts', type: 'array' },
+			{ name: 'mashs', type: 'array' }
 		],
 		id: 'record',
 		url: url + '?record=' + my_record
@@ -1337,7 +1313,7 @@
 			$("#st_guide").val(dataRecord.st_guide);
 			$("#st_category").val(dataRecord.st_category);
 			$("#st_category_number").val(dataRecord.st_category_number);
-			$("#st_type").val(dataRecord.st_type);
+			$("#st_type").val(StyleTypeData[dataRecord.st_type].nl);
 			$("#type").val(dataRecord.type);
 			$("#batch_size").val(dataRecord.batch_size);
 			$("#boil_size").val(dataRecord.boil_size);
@@ -1396,6 +1372,9 @@
 			$("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity);
 			$("#w2_ph").val(dataRecord.w2_ph);
 			$("#w2_cost").val(dataRecord.w2_cost);
+			$("#wa_acid_name").val(dataRecord.wa_acid_name);
+			$("#wa_acid_perc").val(dataRecord.wa_acid_perc);
+			$("#wa_base_name").val(dataRecord.wa_base_name);
 			editFermentable(dataRecord);
 			editHop(dataRecord);
 			editMisc(dataRecord);
@@ -1424,7 +1403,7 @@
 				{ name: 'f_supplier', type: 'string' },
 				{ name: 'f_amount', type: 'float' },
 				{ name: 'f_cost', type: 'float' },
-				{ name: 'f_type', type: 'string' },
+				{ name: 'f_type', type: 'int' },
 				{ name: 'f_yield', type: 'float' },
 				{ name: 'f_color', type: 'float' },
 				{ name: 'f_coarse_fine_diff', type: 'float' },
@@ -1432,15 +1411,16 @@
 				{ name: 'f_diastatic_power', type: 'float' },
 				{ name: 'f_protein', type: 'float' },
 				{ name: 'f_max_in_batch', type: 'float' },
-				{ name: 'f_graintype', type: 'string' },
-				{ name: 'f_added', type: 'string' },
+				{ name: 'f_graintype', type: 'int' },
+				{ name: 'f_added', type: 'int' },
 				{ name: 'f_dissolved_protein', type: 'float' },
-				{ name: 'f_recommend_mash', type: 'bool' },
-				{ name: 'f_add_after_boil', type: 'bool' },
-				{ name: 'f_adjust_to_total_100', type: 'bool' },
+				{ name: 'f_recommend_mash', type: 'int' },
+				{ name: 'f_add_after_boil', type: 'int' },
+				{ name: 'f_adjust_to_total_100', type: 'int' },
 				{ name: 'f_percentage', type: 'float' },
 				{ name: 'f_di_ph', type: 'float' },
-				{ name: 'f_acid_to_ph_57', type: 'float' }
+				{ name: 'f_acid_to_ph_57', type: 'float' },
+				{ name: 'f_stock', type: 'float' },
 			],
 			addrow: function (rowid, rowdata, position, commit) {
 				commit(true);
@@ -1451,13 +1431,11 @@
 		};
 		var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource);
 		$("#fermentableGrid").jqxGrid({
-			width: 1150,
+			width: 1240,
 			height: 400,
 			source: fermentableAdapter,
 			theme: theme,
 			selectionmode: 'singlerow',
-			editmode: 'selectedcell',
-			editable: true,
 			localization: getLocalization(),
 			showtoolbar: true,
 			rendertoolbar: function (toolbar) {
@@ -1504,13 +1482,13 @@
 						row["f_max_in_batch"] = datarecord.max_in_batch;
 						row["f_graintype"] = datarecord.graintype;
 						if (datarecord.add_after_boil) {
-							row["f_added"] = "Primary";
-						} else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) {
-							row["f_added"] = "Boil";
+							row["f_added"] = 2;	// Fermentation
+						} else if ((datarecord.type == 1) || (datarecord.type == 4)) {	// Sugar or Adjunct
+							row["f_added"] = 1;	// Boil
 						} else {
-							row["f_added"] = "Mash";
+							row["f_added"] = 0;	// Mash
 						}
-						row["f_dissolved_protein"] = 0;
+						row["f_dissolved_protein"] = datarecord.dissolved_protein;
 						row["f_recommend_mash"] = datarecord.recommend_mash;
 						row["f_add_after_boil"] = datarecord.add_after_boil;
 						if (rowscount == 0) {
@@ -1580,137 +1558,44 @@
 				$('#jqxTabs').jqxTabs('next');
 			},
 			columns: [
-				{ text: 'Vergistbaar ingredi&euml;nt', editable: false, datafield: 'f_name',
+				{ text: 'Vergistbaar ingredi&euml;nt', datafield: 'f_name',
 				  cellsrenderer:  function (row, columnfield, value, defaulthtml, columnproperties) {
 					var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row);
 					return "<span style='margin: 3px; margin-top: 6px; float: "+
 						columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>";
 				  }
 			       	},
-				{ text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' },
-				{ text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist',
-				  createeditor: function (row, column, editor) {
-					var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ];
-					editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded });
+				{ text: 'Type', width: 100, datafield: 'f_type',
+				  cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+					return "<div style='margin: 4px;'>" + FermentableTypeData[value].nl + "</div>";
+				  }
+				},
+				{ text: 'Moment', width: 110, datafield: 'f_added',
+				  cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
+					return "<div style='margin: 4px;'>" + AddedData[value].nl + "</div>";
 				  }
 				},
 				{ text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
-				{ text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3',
-				  columntype: 'numberinput',
-				  validation: function (cell, value) {
-					// Maximum weight is the batch_size, just a simple check.
-					var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal'));
-				  	if (value < 0 || value > maxmout) {
-						return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" };
-				  	}
-				  	return true;
-				  },
-				  initeditor: function (row, cellvalue, editor) {
-					editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false });
-				  },
-				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
-					if (to_100) {
-						return oldvalue;	// When using percentages, don't allow edited results.
-					}
-				  }
-				},
-				{ text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1',
-				  columntype: 'numberinput',
-				  validation: function (cell, value) {
-					if (value < 0 || value > 100) {
-						return { result: false, message: "Percentage moet 0-100 zijn" };
+				{ text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
+				{ text: 'Voorr. Kg', datafield: 'f_stock', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
+				{ text: 'Percent', datafield: 'f_percentage', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' },
+				{ text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 },
+				{ text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
+					return "Wijzig";
+				        }, buttonclick: function (row) {
+						fermentableRow = row;
+						fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
+						$("#wf_name").val(fermentableData.f_name);
+						$("#wf_amount").val(fermentableData.f_amount);
+						$("#wf_percentage").val(fermentableData.f_percentage);
+						$("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100);
+						$("#wf_added").val(fermentableData.f_added);
+						// show the popup window.
+						$("#popupFermentable").jqxWindow('open');
 					}
-					return true;
-				  },
-				  initeditor: function (row, cellvalue, editor) {
-					editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false });
-				  },
-				  cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
-					oldvalue = Math.round(oldvalue * 10) / 10.0;
-					var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
-					if ((oldvalue != newvalue) && (rowscount > 1)) {
-						var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
-						if (rowdata.f_adjust_to_total_100) {
-							return oldvalue;
-						}
-						var diff = newvalue - oldvalue;
-						var tw = 0;	// total weight
-						for (i = 0; i < rowscount; i++) {
-							var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-							tw += rowdata.f_amount;
-						}
-						if (to_100) {
-							// Adjust this row and the 100% row.
-							var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row);
-							rowdata.f_amount += tw * diff / 100;
-							for (i = 0; i < rowscount; i++) {
-								var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-								if (rowdata.f_adjust_to_total_100) {
-									rowdata.f_percentage -= diff;
-									rowdata.f_amount -= tw * diff / 100;
-								}
-							}
-						} else {
-							// Adjust all the rows.
-							var nw = tw * diff / 100;
-							for (i = 0; i < rowscount; i++) {
-								var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-								if (i == row) {
-									rowdata.f_amount += nw;
-								} else {
-									rowdata.f_amount -= nw / (rowscount - 1);
-									rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0;
-								}
-							}
-						}
-					}
-				  }
-				},
-				{ text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80,
-			          cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) {
-					if (to_100) {
-						var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
-						for (i = 0; i < rowscount; i++) {
-							if (i != row) {
-								var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-								rowdata.f_adjust_to_total_100 = false;
-							}
-						}
-					}
-				  }
-			  	}
+				}
 			]
 		});
-		$("#fermentableGrid").on('cellendedit', function (event) {
-			var args = event.args;
-			console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value);
-			// Make sure the grid itself is updated.
-			$("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value);
-			if ((args.datafield == 'f_amount') && (! to_100)) {
-				// If one of the amounts is changed, recalculate the percentages.
-				console.log("adjust percentages");
-				var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
-	                        if (rowscount > 1) {
-					var tw = 0;
-					for (i = 0; i < rowscount; i++) {
-						var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-						tw += rowdata.f_amount;
-					};
-					for (i = 0; i < rowscount; i++) {
-						var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
-						var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
-						$("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
-					};
-				} else {
-					$("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
-				}
-			};
-			$('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc');	// TODO: not reliable
-			calcFermentables();
-			calcSVG();
-			calcABV();
-			calcIBUs();	// Depends on gravity, so recalculate.
-		});
 	};
 
 	// Inline hops editor
@@ -1725,9 +1610,9 @@
                                 { name: 'h_origin', type: 'string' },
                                 { name: 'h_amount', type: 'float' },
                                 { name: 'h_cost', type: 'float' },
-				{ name: 'h_type', type: 'string' },
-				{ name: 'h_form', type: 'string' },
-				{ name: 'h_useat', type: 'string' },
+				{ name: 'h_type', type: 'int' },
+				{ name: 'h_form', type: 'int' },
+				{ name: 'h_useat', type: 'int' },
                                 { name: 'h_time', type: 'float' },
 				{ name: 'h_alpha', type: 'float' },
 				{ name: 'h_beta', type: 'float' },
@@ -1945,10 +1830,10 @@
                                 { name: 'm_name', type: 'string' },
                                 { name: 'm_amount', type: 'float' },
                                 { name: 'm_cost', type: 'float' },
-                                { name: 'm_type', type: 'string' },
-                                { name: 'm_use_use', type: 'string' },
+                                { name: 'm_type', type: 'int' },
+                                { name: 'm_use_use', type: 'int' },
                                 { name: 'm_time', type: 'float' },
-                                { name: 'm_amount_is_weight', type: 'bool' },
+                                { name: 'm_amount_is_weight', type: 'int' },
 				{ name: 'm_weight', type: 'float' }
                         ],
                         addrow: function (rowid, rowdata, position, commit) {
@@ -1975,41 +1860,41 @@
 									break;
 						case 'NaCl':		$("#wa_nacl").val(row.m_weight);
 									break;
-						case 'Melkzuur':	$("#wa_acid_name").val('Melkzuur');
+						case 'Melkzuur':	$("#wa_acid_name").val(0);
 									$("#wa_acid").val(row.m_weight);
 									$("#wa_acid_perc").val(80);
-									last_acid = 'Melkzuur';
+									last_acid = 0;
 									break;
-						case 'Zoutzuur':	$("#wa_acid_name").val('Zoutzuur');
+						case 'Zoutzuur':	$("#wa_acid_name").val(1);
 									$("#wa_acid").val(row.m_weight);
 									$("#wa_acid_perc").val(80);
-									last_acid = 'Zoutzuur';
+									last_acid = 1;
 									break;
-						case 'Fosforzuur':	$("#wa_acid_name").val('Fosforzuur');
+						case 'Fosforzuur':	$("#wa_acid_name").val(2);
 									$("#wa_acid").val(row.m_weight);
 									$("#wa_acid_perc").val(80);
-									last_acid = 'Fosforzuur';
+									last_acid = 2;
 									break;
-						case 'Zwavelzuur':	$("#wa_acid_name").val('Zwavelzuur');
+						case 'Zwavelzuur':	$("#wa_acid_name").val(3);
 									$("#wa_acid").val(row.m_weight);
 									$("#wa_acid_perc").val(80);
-									last_acid = 'Zwavelzuur';
+									last_acid = 3;
 									break;
-						case 'NaHCO3':		$("#wa_base_name").val('NaHCO3');
+						case 'NaHCO3':		$("#wa_base_name").val(0);
 									$("#wa_base").val(row.m_weight);
-									last_base = 'NaHCO3';
+									last_base = 0;
 									break;
-						case 'Na2CO3':		$("#wa_base_name").val('Na2CO3');
+						case 'Na2CO3':		$("#wa_base_name").val(1);
 									$("#wa_base").val(row.m_weight);
-									last_base = 'Na2CO3';
+									last_base = 1;
 									break;
-						case 'CaCO3':		$("#wa_base_name").val('CaCO3');
+						case 'CaCO3':		$("#wa_base_name").val(2);
 									$("#wa_base").val(row.m_weight);
-									last_base = 'CaCO3';
+									last_base = 2;
 									break;
-						case 'Ca(OH)2':		$("#wa_base_name").val('Ca(OH)2');
+						case 'Ca(OH)2':		$("#wa_base_name").val(3);
 									$("#wa_base").val(row.m_weight);
-									last_base = 'Ca(OH)2';
+									last_base = 3;
 									break;
 					}
 				}
@@ -2178,14 +2063,14 @@
 				{ name: 'y_product_id', type: 'string' },
                                 { name: 'y_amount', type: 'float' },
                                 { name: 'y_cost', type: 'float' },
-                                { name: 'y_type', type: 'string' },
-                                { name: 'y_form', type: 'string' },
+                                { name: 'y_type', type: 'int' },
+                                { name: 'y_form', type: 'int' },
                                 { name: 'y_time', type: 'float' },
 				{ name: 'y_min_temperature', type: 'float' },
 				{ name: 'y_max_temperature', type: 'float' },
 				{ name: 'y_attenuation', type: 'float' },
-                                { name: 'y_amount_is_weight', type: 'bool' },
-				{ name: 'y_use', type: 'string' },
+                                { name: 'y_amount_is_weight', type: 'int' },
+				{ name: 'y_use', type: 'int' },
 				{ name: 'y_weight', type: 'float' }
                         ],
                         addrow: function (rowid, rowdata, position, commit) {
@@ -2257,9 +2142,9 @@
 						row["y_form"] = datarecord.form;
                                                 row["y_amount"] = 0;
                                                 row["y_cost"] = datarecord.cost;
-                                                row["y_use"] = "Primary";
+                                                row["y_use"] = 0;
                                                 row["y_time"] = 0;
-						if (datarecord.form == "Dry") {
+						if (datarecord.form == 1) {
 							row["y_amount_is_weight"] = 1;
 						} else {
 							row["y_amount_is_weight"] = 0;
@@ -2353,7 +2238,7 @@
 		var generaterow = function () {
 			var row = {};
 			row["step_name"] = "Stap 1";
-			row["step_type"] = "Infusion";
+			row["step_type"] = 0;
 			row["step_infuse_amount"] = 15;
 			row["step_temp"] = 62.0;
 			row['step_time'] = 20.0;
@@ -2368,7 +2253,7 @@
 			async: false,
                         datafields: [
                                 { name: 'step_name', type: 'string' },
-                                { name: 'step_type', type: 'string' },
+                                { name: 'step_type', type: 'int' },
 				{ name: 'step_infuse_amount', type: 'float' },
 				{ name: 'step_temp', type: 'float' },
 				{ name: 'step_time', type: 'float' },
@@ -2388,7 +2273,7 @@
 				var data = new Array();
 				for (var i = 0; i < records.length; i++) {
 					var row = records[i];
-					if (row.step_type == 'Infusion')
+					if (row.step_type == 0)	// Infusion
 						mash_infuse += parseFloat(row.step_infuse_amount);
 				}
 			},	
@@ -2490,66 +2375,280 @@
         };
 
 	// initialize the input fields.
-	var srcType = [ "All Grain", "Partial Mash", "Extract" ];
-	var srcColor = [ "Morey", "Mosher", "Daniels" ];
-	//var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
-	var srcIBU = [ "Tinseth", "Rager", "Daniels" ];	// Only these are supported at this time.
 	var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ];
 	var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ];
 	var srcSource = [ "Bron 1", "Bron 2", "Gemengd" ];
+
+	// Tab 1, Algemeen
+	$("#name").jqxTooltip({ content: 'De naam voor dit recept.' });
 	$("#name").jqxInput({ theme: theme, width: 640, height: 23 });
 	$("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23 });
+	$("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' });
 	$("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
+	$("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
+	$("#type").jqxDropDownList({
+		theme: theme,
+		source: RecipeTypeAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true
+	});
+	$("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' });
+	$("#efficiency").jqxNumberInput( Perc1dec5 );
+	$("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' });
+	$("#batch_size").jqxNumberInput( Spin1dec5 );
+	$("#batch_size").jqxNumberInput({ min: 4 });
+	$("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' });
+	$("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true });
+	$("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' });
+	$("#boil_time").jqxNumberInput( PosInt );
+	$("#boil_time").jqxNumberInput({ min: 4, max: 360 });
+
+	$("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
 	$("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
+	$("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'});
 	$("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
+	$("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'});
 	$("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
+	$("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'});
 	$("#st_category").jqxInput({ theme: theme, width: 250, height: 23 });
+	$("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'});
 	$("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
-	$("#st_type").jqxInput({ theme: theme, width: 90, height: 23 });
-	$("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 });
-	$("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' });
-	$("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' });
-	$("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true });
-	$("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right'  });
-	$("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
-	$("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
+	$("#st_type").jqxTooltip({ content: 'Het bierstijl type.'});
+	$("#st_type").jqxInput({ theme: theme, width: 180, height: 23 });
+
+	$("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
+	$("#est_og").jqxNumberInput( SGopts );
+	$("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'});
 	$("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
+	$("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'});
 	$("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
 
-	$("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
+	$("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' });
+	$("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true });
+	$("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'});
 	$("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
+	$("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'});
 	$("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
 
+	$("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' });
 	$("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'});
 	$("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'});
 	$("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
 
-	$("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
-	$("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
+	$("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
+	$("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'});
 	$("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'});
 	$("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
-	$("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
+	$("#color_method").jqxDropDownList({
+		theme: theme,
+		source: ColorMethodAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true
+	});
 
-	$("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
-	$("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
+	$("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'});
 	$("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'});
 	$("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
-	$("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' });
+	$("#ibu_method").jqxDropDownList({
+		theme: theme,
+		source: IBUmethodAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true,
+		dropDownVerticalAlignment: 'top'
+	});
 
+	$("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' });
 	$("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'});
 	$("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
+	$("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'});
 	$("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
 
-	$("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
-	$("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
-	// Several gauges
-	$("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
-	$("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
+	// Tab 2, Vergistbaar
+	$("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' });
+	$("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true });
+	$("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' });
+	$("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true });
 	$("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
 	$("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
 	$("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
+	$("#popupFermentable").jqxWindow({
+		width: 800,
+		height: 300,
+		position: { x: 230, y: 100 },
+		resizable: false,
+		theme: theme,
+		isModal: true,
+		autoOpen: false,
+		cancelButton: $("#FermentableReady"),
+		modalOpacity: 0.40
+	});
+	$("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme });
+	$("#FermentableReady").click(function () {
+		$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_name', $("#wf_name").val());
 
-	// Water treatment
+	//	$("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc');
+		// Recalc percentages
+	//	calcFermentables();
+	//	calcSVG();
+	//	calcABV();
+	//	calcIBUs();
+		// Waters: yes there is impact.
+	});
+	$("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 });
+	$("#wf_amount").jqxNumberInput( Spin3dec5 );
+	$('#wf_amount').on('change', function (event) {
+		console.log("amount changed: "+event.args.value);
+		$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value);
+		if (! to_100) {
+			// Recalculate percentages
+			console.log("adjust percentages");
+			var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
+			if (rowscount > 1) {
+				var tw = 0;
+				for (i = 0; i < rowscount; i++) {
+					var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
+					tw += rowdata.f_amount;
+				};
+				for (i = 0; i < rowscount; i++) {
+					var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
+					var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0;
+					$("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage);
+		//			if (i == fermentableRow) // Will crash the script.
+		//				$("#wf_percentage").val(percentage);
+				};
+			} else {
+				$("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100);
+			}
+			calcFermentables();
+		};
+	});
+	$("#wf_percentage").jqxNumberInput( Perc1dec1 );
+	$("#wf_percentage").on('change', function (event) {
+		var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0;
+		var newvalue = event.args.value;
+		console.log("percentage changed: "+newvalue+" old: "+oldvalue);
+		var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
+		if ((oldvalue != newvalue) && (rowscount > 1)) {
+			var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
+			if (rowdata.f_adjust_to_total_100) {
+				$("#wf_percentage").val(oldvalue);
+			} else {
+				var diff = newvalue - oldvalue;
+				var tw = 0;     // total weight
+				for (i = 0; i < rowscount; i++) {
+					var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
+					tw += rowdata.f_amount;
+				}
+				if (to_100) {
+					// Adjust this row and the 100% row.
+					var damount = tw * diff / 100;
+					var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
+					var namount = rowdata.f_amount + damount;
+					$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount);
+					$("#wf_amount").val(namount);
+					$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff);
+					for (i = 0; i < rowscount; i++) {
+						var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
+						if (rowdata.f_adjust_to_total_100) {
+							namount = rowdata.f_amount - damount;
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff);
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
+						}
+					}
+					calcFermentables();
+				} else {
+					// Adjust all the rows.
+					var nw = tw * diff / 100;
+					for (i = 0; i < rowscount; i++) {
+						var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i);
+						if (i == fermentableRow) {
+							var namount = rowdata.f_amount + nw;
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
+		//					$("#wf_amount").val(namount); // Will crash the script.
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newvalue);
+						} else {
+							var namount = rowdata.f_amount - (nw / (rowscount - 1));
+							var newperc = Math.round((namount / tw) * 1000) / 10.0;
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount);
+							$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newperc);
+						}
+					}
+					calcFermentables();
+				}
+			}
+		}
+
+	});
+	$("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 });
+	$("#wf_adjust_to_total_100").on('checked', function (event) {
+		if (fermentableData.f_adjust_to_total_100 == 0) {
+	//		console.log("wf_adjust_to_total_100: checked  row: "+fermentableRow+"  old: "+fermentableData.f_adjust_to_total_100);
+			if (to_100) {
+				// Reset other flag first.
+				var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
+				for (var i = 0; i < rowscount; i++) {
+					if (i != fermentableRow) {
+						$("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0);
+					}
+				}
+			}
+			$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1);
+			calcFermentables();
+		}
+	});
+	$("#wf_adjust_to_total_100").on('unchecked', function (event) {
+		if (fermentableData.f_adjust_to_total_100 != 0) {
+	//		console.log("wf_adjust_to_total_100: unchecked  row: "+fermentableRow+"  old: "+fermentableData.f_adjust_to_total_100);
+			$("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0);
+			calcFermentables();
+		}
+	});
+	$("#wf_added").jqxDropDownList({
+		theme: theme,
+		source: AddedAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true,
+		dropDownVerticalAlignment: 'top'
+	});
+
+	// Tab 3, Hoppen
+	$("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
+	$("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
+	$("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
+	$("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true });
+
+	// Tab 4, Diversen
+
+	// Tab 5, Gist
+
+	// Tab 6, Maischen
+	$("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
+
+	// Tab 7, Water
+	$("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true });
+	$("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
+
+	// Water source 1
 	$("#w1_name").jqxDropDownList({
 		placeHolder: "Kies hoofd water:",
 		theme: theme,
@@ -2592,7 +2691,7 @@
 	$("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-
+	// Water source 2
 	$("#w2_name").jqxDropDownList({
 		placeHolder: "Kies meng water:",
 		theme: theme,
@@ -2628,6 +2727,7 @@
 			calcWater();
 		}
 	});
+	$("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'});
 	$("#w2_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5, readOnly: true });
 	$("#w2_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#w2_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
@@ -2636,7 +2736,7 @@
 	$("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-
+	// Water mixed
 	$("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
@@ -2645,15 +2745,20 @@
 	$("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-
+	// Water treated
+	$("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'});
 	$("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
+	$("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'});
 	$("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
+	$("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'});
 	$("#wb_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
+	$("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'});
+	$("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
+	$("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'});
+	$("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-	$("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-	$("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-
+	// Water target profile
 	$("#pr_name").jqxDropDownList({
 		placeHolder: "Kies doel profiel:",
 		theme: theme,
@@ -2683,21 +2788,40 @@
 	$("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 	$("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
 
-	$("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true });
-	$("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true });
-
+	// Water agents
+	$("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'});
 	$("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
+	$("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'});
 	$("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
+	$("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'});
 	$("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
+	$("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'});
 	$("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' });
-
+	$("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'});
+	$("#mash_ph").jqxNumberInput( SpinpH );
 	$("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 });
-	$("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 100, height: 23, dropDownHeight: 128 });
+	$("#wa_base_name").jqxDropDownList({
+		theme: theme,
+		source: BaseTypeAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true
+	});
 	$("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' });
-	$("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 });
+	$("#wa_acid_name").jqxDropDownList({
+		theme: theme,
+		source: AcidTypeAdapter,
+		valueMember: 'id',
+		displayMember: 'nl',
+		width: 180,
+		height: 23,
+		autoDropDownHeight: true
+	});
 	$("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' });
 	$("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
-
+	// Sparge water
 	$("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
 	$("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
 	$("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4.5, max: 6.5, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
@@ -2772,7 +2896,7 @@
 			st_name: $('#st_name').val(),
 			st_letter: $('#st_letter').val(),
 			st_guide: $('#st_guide').val(),
-			st_type: $('#st_type').val(),
+			st_type: dataRecord.st_type,
 			st_category: $('#st_category').val(),
 			st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
 			st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
@@ -2830,6 +2954,9 @@
 			w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
 			w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
 			w2_cost: dataRecord.w2_cost,
+			wa_acid_name: $("#wa_acid_name").val(),
+			wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
+			wa_base_name: $("#wa_base_name").val(),
 			fermentables: fermentablerow,
 			hops: hoprow,
 			miscs: miscrow,

mercurial