// JavaScript Document
function choiceA(form) {
  form.first_value.value  = form.one.options[form.one.selectedIndex].value;
}
 
function choiceB(form) {
  form.second_value.value  = form.two.options[form.two.selectedIndex].value;
}
 
function getExplanation(msg) {
  document.forms[0].first_value.value = msg;
  document.forms[0].first_value.focus();
  document.forms[0].first_value.select();
}
 
 
function FP_setStatusBarText(txt) {//v1.0
  window.status=txt;
}

function tonum(obj) {
  return parseFloat(obj);
}

function inputtest(form, button){
 cal_humid(form);
 return;
}

function cal_humid(form) {
  var a=tonum(form.inputbox1.value);
  var b=tonum(form.inputbox2.value);
  var c=6.11*Math.pow(10,((7.5*a/(237.7+a))));
  var d=6.11*Math.pow(10,((7.5*b/(237.7+b))));
  var e=(d/c)*100;
  {
  form.outputbox1.value=(Math.round(e*100))/100;
  }
}

function inputtest1(form, button){
 cal_humid1(form);
 return;
}

function cal_humid1(form){
  var m=tonum(form.inputbox3.value);
  var n=tonum(form.inputbox4.value);
  var k=tonum(form.inputbox5.value);

  var p=21.40-(5351/(m+273.15));
  var q=21.40-(5351/(n+273.15));

  var z=Math.exp(p);
  var y=Math.exp(q);

  var l=Math.log(s);
  var u=(5351/(21.40-l))-273.15; 
  var r=100*s/w;
  {
  form.outputbox2.value=(Math.round(r*100))/100;
  form.outputbox3.value=(Math.round(u*100))/100;
  }
}


function calculate() {
var water = (document.aciddp.water.value) / 100;
var so2 = (document.aciddp.so2.value) / 100;
var pressure = (document.aciddp.pressure.value / 14.7)+ 1;
//now compute the log of the partial presure of water
var lnph2o = Math.log(water * pressure * 760);
//Calculate the log of the partial pressure of so3
var lnso3 = Math.log(12.16 * so2 * pressure);
var dewpointK = Math.round(1000 /(2.276 - (0.0294 * lnph2o)- (0.0858 * lnso3) + (0.0062 * lnph2o * lnso3)));
//Dewpoint in Kelvin - convert to C
var dewpoint = dewpointK - 273;

//Check that the result is a finite number and display the results.
if (!isNaN(dewpoint) &&
	(dewpoint != Number.	POSITIVE_INFINITY) &&
	(dewpoint != Number.NEGATIVE_INFINITY)) {
	
	document.aciddp.dewpoint.value= dewpoint;
	}
//OTHERWISE, THE USER'S IMPUT WAS PROBABLY INVALID, SO DON'T DISPLAY ANYTHING.
else {
	document.aciddp.water.value = "";
	document.aciddp.so2.value = "";
	document.aciddp.pressure = "";
	}
}