function Fmt(x) { 
var v
if(x>=0) { v=''+(x+0.0005) } else { v=''+(x-0.0005) }
return v.substring(0,v.indexOf('.')+3) 
}

  function compute(form) {

if((form.fio2.value==null)||(form.fio2.value=="")||(isNaN(form.fio2.value))){
alert('Please enter the inspired oxygen concentration (fio2)value.');
return false;
}

if((form.patm.value==null)||(form.patm.value=="")||(isNaN(form.patm.value))){
alert('Please enter the atomspheric pressure value.');
return false;
}


if((form.ph2o.value==null)||(form.ph2o.value=="")||(isNaN(form.ph2o.value))){
alert('Please enter the water vapor pressure(pH2O)value.');
return false;
}

if((form.rq.value==null)||(form.rq.value=="")||(isNaN(form.rq.value))){
alert('Please enter the respiratory quotient RQ.');
return false;
}


if((form.paco2.value==null)||(form.paco2.value=="")||(isNaN(form.paco2.value))){
alert('Please enter the partial pressure of arterial CO2.');
return false;
}

if((form.pao2.value==null)||(form.pao2.value=="")||(isNaN(form.pao2.value))){
alert('Please enter the partial pressure of arterial O2.');
return false;
}

form.gradient.value =Fmt((1*form.patm.value-1*form.ph2o.value)*(1*form.fio2.value/100)-form.pao2.value-(1*form.paco2.value/form.rq.value));;



form.estgradient.value =((1*form.age.value/4) + 4)






}
