// JavaScript Documentfunction roundup(numb,decpl) {// raise incoming value by power of 10 times the number of decimal places; round to an integer; convert to stringvar str = "" + Math.round (eval(numb) * Math.pow(10, decpl))// pad small value strings with zeros to the left of rounded numberwhile (str.length <= decpl) {	str = "0" + str}// establish location of decimal pointvar decpoint = str.length - decpl// assemble final result from: (a) the string up to the position of the decimal point; (b) the decimal point; and (c) the balance of the string. Return finished product.return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);}function convert(units) {	var amnt = document.formC.amount.value;	if (amnt==0) return false;	var dec1=3;	var dec2=3;	// Convert units to Barrels per Day	if (units=="bpd") {amnt=amnt; dec2=2};	if (units=="lpd") {amnt=amnt/158.98729; dec1=4; dec2=2};	if (units=="ukpd") {amnt=amnt/34.9723; dec2=2};	if (units=="uspd") {amnt=amnt/42; dec2=2};	if (units=="tpd") {amnt=amnt/0.13643; dec1=2; dec2=1};		if (units=="bpy") {amnt=amnt/365; dec1=4; dec2=2};	if (units=="lpy") {amnt=amnt/158.98729/365; dec1=6; dec2=4};	if (units=="ukpy") {amnt=amnt/34.9723/365; dec1=5; dec2=3};	if (units=="uspy") {amnt=amnt/42/365; dec1=5; dec2=3};	if (units=="tpy") {amnt=amnt/0.13643/365; dec1=3; dec2=2};			// Print Results	document.formC.bpd.value=roundup(amnt,dec1);	document.formC.lpd.value=roundup(amnt*158.98729,dec1);	document.formC.ukpd.value=roundup(amnt*34.9723,dec1);	document.formC.uspd.value=roundup(amnt*42,dec1);	document.formC.tpd.value=roundup(amnt*0.13643,dec1);	document.formC.bpy.value=roundup(document.formC.bpd.value*365,dec2);	document.formC.lpy.value=roundup(document.formC.lpd.value*365,dec2);	document.formC.ukpy.value=roundup(document.formC.ukpd.value*365,dec2);	document.formC.uspy.value=roundup(document.formC.uspd.value*365,dec2);	document.formC.tpy.value=roundup(document.formC.tpd.value*365,dec2);	}
