// Global variables

glVmole=22.414; // l/mole
glR=8314.5; // J/kmole.K

// #1: analyze - Check input number validity
// This function calls "calculate()" and "resRes()" - reset result fields

function analyze(inp, low, high, lowInc, highInc) { // low, high range; Inc=1 for inclusive
  var ok=true;
  var y=parseFloat(inp.value);
  if (isNaN(y)) ok=false;
  else if (y<low || lowInc!=1 && y==low) ok=false;
       else if (y>high || highInc!=1 && y==high) ok=false;
if (ok) calculate(); else {inp.value='*'; resRes();}
} 


// #2: format x before it's displayed

function format(x, n) {
if (x==0) return 0;
if (x>1e99 || x<-1e99) return "Infinity";
var nn = new (Number);
if (nn.toPrecision) {return x.toPrecision(n)}
else {return x}
}


// #3: air density=f(t), kg/m3; deg.C

function airDens(t) {
	var tc = t + 273.15
	var ro = 101325*28.966/glR/tc;
	return ro;
}

// eof