function addLoadEvent(func) {
//  alert("hello");
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
var calculator = {
	config : {
		formID : "flow"
	}, 
	init : function() {
		var theForm = document.getElementById(calculator.config.formID);
		theForm.onsubmit = function() {
 			// alert("hello, world");
			var psi = document.getElementById("psi");
			psi = psi.value;
			var insideDia = document.getElementById("insideDia");
			insideDia = insideDia.value;
			var feet = document.getElementById("feet");
			feet = feet.value;
			var cvFactor = (42.3*((insideDia*insideDia)*0.7854))*(Math.sqrt(insideDia/(0.02*(feet*12))));
			var cfm = cvFactor * (Math.sqrt((psi-15)*(15.7)))/1.024;
			var result = document.getElementById("cfm");
			cfm = Math.round(cfm * 100) / 100;
			result.value = cfm;
			return false;
		}
	}
}
addLoadEvent(calculator.init);