// JavaScript Document
function calculate(){
	$.post(PAGE_SELF, { func: "calculatePHP", B9:$("#B9").val(), B10:$("#B10").val(), B11:$("#B11").val(), B12:$("#B12").val(), B13:$("#B13").val(), B14:$("#B14").val(), B15:$("#B15").val(), B16:$("#B16").val(), B17:$("#B17").val(), B18:$("#B18").val(), B19:$("#B19").val(), B20:$("#B20").val()
		   }, 
		function(data){
			rawDataArr = data.split(delObj);
			data=new Object();
			for (i=0;i<rawDataArr.length;i++){
				rawLocalDataArr = rawDataArr[i].split(delFld); 	
				eval("data."+rawLocalDataArr[0]+" = '" + rawLocalDataArr[1] + "';");
			}
			$("#B24").val(formatFixed(data.Q3,2)); 
			$("#B25").val(formatFixed(data.Q4,2)); 
			valB28 = '';
			if(data.M4=="Yes"){
				valB28 = "Yes, O.K.";	
			}else{
				valB28 = "No, Violation!";	
			}
			$("#B28").val(valB28);
			
			valG28 = '';
			if(data.M5=="Yes"){
				valG28 = "Yes, O.K.";	
			}else{
				valG28 = "No, Violation!";	
			}
			$("#G28").val(valG28);
			$("#B33").val(formatFixed(data.M36,2)); 
			$("#B34").val(formatFixed(data.M37,2)); 
			$("#B38").val(formatFixed(data.M40,2)); 
			$("#B39").val(formatFixed(data.M41,2)); 
			$("#B40").val(formatFixed(data.M42,2)); 
			$("#B41").val(formatFixed(data.M43,2)); 
			$("#B44").val(formatFixed(data.M44,2)); 
			$("#B49").val(formatFixed(data.N32,2)); 
			$("#B50").val(formatFixed(data.N33,2)); 
			
			$("#B56").html(formatFixed(data.M9,2)); 
			$("#B57").html(formatFixed(data.M10,2)); 
			$("#B58").html(formatFixed(data.M11,2)); 
			$("#B59").html(formatFixed(data.M12,2)); 
			$("#B60").html(formatFixed(data.M13,2)); 
			$("#B61").html(formatFixed(data.M14,2)); 
			$("#B62").html(formatFixed(data.M15,2)); 
			$("#B63").html(formatFixed(data.M16,2)); 
			$("#B64").html(formatFixed(data.M17,2)); 
			$("#B65").html(formatFixed(data.M18,2)); 

			$("#F56").html(formatFixed(data.P9,2)); 
			$("#F57").html(formatFixed(data.P10,2)); 
			$("#F58").html(formatFixed(data.P11,2)); 
			$("#F59").html(formatFixed(data.P12,2)); 
			$("#F60").html(formatFixed(data.P13,2)); 
			$("#F61").html(formatFixed(data.P14,2)); 
			$("#F62").html(formatFixed(data.P15,2)); 
			$("#F63").html(formatFixed(data.P16,2)); 
			$("#F64").html(formatFixed(data.P17,2)); 
			$("#F65").html(formatFixed(data.P18,2)); 
			
			for(i=1;i<=10;i++){
				eval("var LocalB = data.M"+(8+parseInt(i))+";");
				eval("var LocalF = data.P"+(8+parseInt(i))+";");
				var LocalC = parseFloat(parseFloat(data.M44)*(parseFloat(LocalB)-parseFloat(data.M36))).toFixed(2);
				var LocalD = parseFloat(parseFloat(data.M44)*(parseFloat(LocalB)-parseFloat(data.M37))).toFixed(2);
				$("#C"+(55+i)).html(formatFixed(LocalC,2)); 
				$("#D"+(55+i)).html(formatFixed(LocalD,2)); 
				var LocalG = parseFloat(parseFloat(data.M44)*(parseFloat(LocalF)-parseFloat(data.M36))).toFixed(2);
				var LocalH = parseFloat(parseFloat(data.M44)*(parseFloat(LocalF)-parseFloat(data.M37))).toFixed(2);
				$("#G"+(55+i)).html(formatFixed(LocalG,2)); 
				$("#H"+(55+i)).html(formatFixed(LocalH,2)); 
				if(i<=4){
					$("#C"+(74+i)).html(formatFixed((parseFloat(LocalC)*0.25).toFixed(2),2));
					$("#D"+(74+i)).html(formatFixed((parseFloat(LocalD)*0.25).toFixed(2),2));
					$("#G"+(74+i)).html(formatFixed((parseFloat(LocalG)*0.25).toFixed(2),2));
					$("#H"+(74+i)).html(formatFixed((parseFloat(LocalH)*0.25).toFixed(2),2));
				}
			}
			$("#B69").val(formatFixed(data.M24,2)); 
			$("#G69").val(formatFixed(data.P24,2));
		}
	, "text");
}
