<!-- esthenry_1.js exported by wcms -->
<!--
function EstHenry(data,CurrentDate)
{
//***********************************************************************
//*
//* Function   EstHenry   Estimation of Henry's Law Constants at different temperatures
//*
//* Language:  JavaScript
//*
//*
//* Limitations:
//*
//* Author:
//*  Jim Weaver and John Washington
//*  Regulatory Support Branch
//*  Ecosystems Research Division
//*  National Exposure Research Laboratory
//*  United States Environmental Protection Agency
//*  960 College Station Road
//*  Athens, Georgia 30605
//* 
//*
//* Reference:
//*  Flanagan, D., 1997, JavaScript: The Definitive Guide, 2ed, O'Reilly and Associates
//*  Washington, J., 1996, Gas partitioning of dissolved volatile organic compounds in the
//*     vadose zone:  Principles, temperature effects and literature review, 
//*     Ground Water, 34(4), 709-718.
//*
//* Created:  3-13-2000
//* Revised:  12-5-2003; MTBE data added
//* Revised:  3-9-2004; OSWER method added
//*
//* Required functions:  Input, Num2String, ShortDate, save, restore, back, HenryUnit, clearAll, CheckSelection
//* Required objects:  GetKh, GetKhVI, VIData (used within GetHkVI)
//*                      
//*
//* Required scripts:  input.js, digits.js, sdate.js, cookie.js, back.js, henryunit.js, clear.js
//*                    cselect.js, getKhtemp-revised.js, getKhVItemp.js, vidata.js
//*
//***********************************************************************
  var f = document.EstimateHenryConstant;
  var SiteDate = "";
  var SiteName = "";
  var chemical = "";
  var date = new Date();
  var ent = new Array();
  var temp = 0;
  var temp2 = "";
  var kh = "";
  var khIn = "";
  var unitout = "";
  var unitoutName = "";
  f.kh.value = "";
  var ucf = 1;
  var ii = 0;
  var method = "";
  var tempTest = false;
  var boolContinue = false;

 
  if (data=="noexample" || data=="save")
    {
      //check the chemical index to see if a separator was chosen
      //CheckSelection invalidates this choice and returns the first item in the list
      f.chemical.selectedIndex = CheckSelection (f.chemical); 
      chemical = f.chemical.options[f.chemical.selectedIndex].value;

      SiteName = f.site.value;
      if (CurrentDate) {SiteDate = ShortDate(date); f.date.value=SiteDate;} 
      else {SiteDate = f.date.value;}

      //temperature in C
      temp = Input(f.temp.value);

      unitout = f.unit2.options[f.unit2.selectedIndex].value


      if (data=="save")
       {
        //display the cookie message
        window.open('../../home/storage.html','storage','width=620,height=400,resizable');
        return;

        /*
        //save data for future use

        //store the data in an array for saving to cookie
        ent[0] = SiteDate;
        ent[1] = SiteName;
        ent[2] = chemical;

        //create the id cookie
        save("id",ent);


        //create the chemical name virtual cookie
        ent[0] = f.chemical.selectedIndex;
        save ('ch',ent);

        //create the temperature cookie
        ent[0] = temp;
        save ('te',ent);

        //create the henry's law unit cookie
        ent[0] = f.unit2.selectedIndex;
        save ('hu',ent);
        */
        }
     }

  if (data=="example")
     {
       SiteName = "Example Henry's Law Estimate";
       SiteDate = ShortDate(date);
       f.chemical.selectedIndex = 1;
       temp = 15;
       f.unit2.selectedIndex = 0;
     }
  if (data=="restore")
     {
      //display the cookie message
      window.open('../../home/storage.html','storage','width=620,height=400,resizable');
      return;

      /*
      //recover each value from the cookie
      SiteDate = restore("id","date");
      SiteName = restore("id","site");
      chemical = restore('id','chemical');
      f.chemical.selectedIndex = SelectIndex(f.chemical,chemical);
      temp = restore('te','Temperature');
      f.unit2.selectedIndex = restore('hu','HenryUnit');
      */
     }

  if (data=="restore" || data=="example")
     {
      f.date.value = SiteDate; 
      f.site.value = SiteName; 
      f.temp.value = temp;
   
     }

  

  chemical = f.chemical.options[f.chemical.selectedIndex].value;
  unitout = f.unit2.options[f.unit2.selectedIndex].value;

  if (unitout=='hcc') {unitoutName = 'dimensionless';}
  if (unitout=='hyx') {unitoutName = 'dimensionless (mole fraction basis) or atm';}
  if (unitout=='hpc') {unitoutName = 'atm-m3/mol';}

  if (data=="clear") {clearAll(f); return;}

  //first perform all calculations for the Washington Method:

  //create the prototype
  new GetKh("","");

  //create a new GetKh object
  Kho = new GetKh(chemical,temp);

  //determine if the chemical is in the Washington data set
  boolContinue = Kho.cPresent();
  var note = "";
  temp2 = temp;

  if (boolContinue==true)
  {

  //use the GetKh object to estimate the Kh
  var type = Kho.type();
  note = Kho.note();


  //check the three cases: no data, constant value at a given temperature,  or 
  //temperature-variable estimate with thermodynamic data
  if (type=='nodata') 
   {
    method = 'No data available';
   }
  else
   {
    if (type=='constant')
    {
     temp2 = Kho.temperature();
     khIn = Kho.constant();
     method = 'Literature constant (only for certain temperature)';
    }
    else
    {
     if (type=='thermo')
     {
      tempTest = Kho.checkTemp();
      if (tempTest==true)
      {
        khIn = Kho.thermo();
        temp2 = temp;
        method = 'Thermodynamic calculation (variable temperature)';
      }
      else
      {
        method = '';
        note = 'Requested temperature is out of the acceptable range of 0 to ' + Kho.maxTemp() + ' C';
        khIn = 0;
      }
     }
    }
   }

 
  }

  f.note.value = note;
  f.temp2.value = Num2String(temp2,4,-10,10,-6,6) + " C"; 

  //check to see if a non-zero khIn has been found
  if (khIn>0)
  {   
    ucf1 = HenryUnit ('hpc',unitout,temp2);
    kh = khIn*ucf1;
    f.kh.value = Num2String(kh,3,-10,10,-6,6) + " " + unitoutName;
    //f.method.value = method;
 
  }
  else
  {
    f.kh.value = "";
    //f.method.value = "";
  }


 

  //separate approach for the EPA VI dataset:
  //create prototype:
  new GetKhVI("","");

  KhoVI = new GetKhVI(chemical,temp);

  KhoVI.addChemicals();

  boolContinue = KhoVI.cPresent();
  if (boolContinue==true)
  {
    //dimensional (atm-m3/mol) henry's law coefficient
    var khEst = KhoVI.estimateHenryConstant()

    //convert to required output unit
    ucf1 = HenryUnit ('hpc',unitout,temp2);
    khEst = khEst*ucf1;

    f.VIfskh.value = Num2String(khEst,3,-10,10,-7,7) + " " + unitoutName;
  }
  else 
  {
    f.VIfskh.value = "";
  }

}
//  -->
<!-- end esthenry_1.js -->