
<!--
function RetardationFactor(data,CurrentDate)
{
//***********************************************************************
//*
//* Function RetardationFactor (Calculator)
//*
//* Language:  JavaScript1.1
//*
//* Inputs:
//*     data           noexample -- process  input data and perform calculation
//*                    example   -- load example data and perform calculation
//*                    clear     -- clear all data fields and exit
//*                    save      -- save data in cookie
//*                    restore   -- restore data from cookie
//*     CurrentDate    if true   -- use current date on calculation
//*
//* Returns:
//*
//* Limitations:
//*
//* Author:
//*  Dr. Jim Weaver
//*  Hydrologist
//*  Regulatory Support Branch
//*  Ecosystems Research Division
//*  National Exposure Research Laboratory
//*  United States Environmental Protection Agency
//*  960 College Station Road
//*  Athens, Georgia 30605
//*  weaver.jim@epa.gov
//* 
//*
//* Reference:
//*  Flanagan, D., 1997, JavaScript: The Definitive Guide, 2ed, O'Reilly and Associates
//*
//* Created:
//*   Revised to include data sets from various regulatory programs, 9-15-2002, jww
//*   Revised to demonstrate cookie application for saving regulatory program identifier, 10-16-2002, jww
//*
//* Required objects: GetKocProgram 
//*
//* Required functions: Input, Num2String, CheckSelection, ShortDate, SelectIndex, clearAll, back
//*
//* Required scripts: input.js, digits.js, sdate.js, back.js, getkocprogram.js, index.js, cselect.js, clear.js
//*
//***********************************************************************



  
  var f = document.retardation;
  var rd = 1;
  var kd = 0;
  var koc = 0;
  var koc2 = 0;
  var dens = 2.65;
  var por = 0;
  var foc = 0;
  var SiteDate = "";
  var SiteName = "";
  var chemical = "";
  var dataset = "";
  f.rd.value = "*";
  var date = new Date();
  var ent = new Array();

  if (data=="noexample" || data=="save")
    {
      por = Input(f.porosity.value);
      foc = Input(f.foc.value);
      
      f.chemical.selectedIndex = CheckSelection (f.chemical); 
      chemical = f.chemical.options[f.chemical.selectedIndex].value;

      f.datasource.selectedIndex = CheckSelection(f.datasource);
      datasource = f.datasource.options[f.datasource.selectedIndex].value;

      SiteName = f.site.value;
      if (CurrentDate) {SiteDate = ShortDate(date); f.date.value=SiteDate;} 
      else {SiteDate = f.date.value;}

      if (chemical=="other")
       {
        //let the user enter a koc instead of using the internal data
        koc = Input(f.kocinput.value);
       }
      else
       {
        //get the value from the selected chemical
         //koc = getKOCFromDataSet(chemical,datasource);
        }
      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 rd cookie
        ent[0] = foc;
        ent[1] = koc;
        //create the rd cookie
        save ("rd",ent);    

        //create the porosity virtual cookie
        ent[0] = por;
        save ("po",ent);    

        //create the chemical name virtual cookie
        ent[0] = f.chemical.selectedIndex;
        save ('ch',ent);
        */

        }
     }
  if (data=="example")
     {
       SiteName = "Example";
       SiteDate = ShortDate(date);
       dens = 2.65;
       por = 0.25;
       foc = 0.0001; 
       f.chemical.selectedIndex = SelectIndex (f.chemical,'toluene');
       chemical = f.chemical.options[f.chemical.selectedIndex].value;
       f.datasource.selectedIndex = SelectIndex (f.datasource,'onsite');
       datasource = f.datasource.options[f.datasource.selectedIndex].value;
 
     }
  if (data=="restore")
     {

      //display the cookie message
      window.open('../../home/storage.html','storage','width=620,height=400,resizable,scrollbars');
      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);
      
      //recover from the rd cookie
      foc = restore("rd","foc");
      koc = restore("rd","koc");
      por = restore("po","porosity");
      */
     }

  if (data=="restore" || data=="example")
     {
      f.date.value = SiteDate; 
      f.site.value = SiteName; 
      f.solid.value = dens;
      f.porosity.value = por;
      f.foc.value = foc;  
      f.kocinput.value = koc;
     }


  if (data=="clear") {clearAll(f);return;}
 
  //create the prototype
  new GetKocProgram("","");

  //create a new GetKocProgram object
  Kp = new GetKocProgram(chemical,datasource);


  //use the GetKocProgram object to estimate the Koc
  var note = Kp.note();
  koc = Kp.koc();
  var datadate = Kp.date();
  
  f.note.value = note;
  f.datadate.value = datadate;

  var bd = dens*(1.-por);
  f.bulk.value = Num2String(bd,3,-7,7,-5,5);
  f.solid.value = dens;

  kd = foc*koc
  var t1 = bd*kd;
  if (por > 0 && koc > 0) 
    {
     f.kocinput.value = koc;
     rd=1+t1/por; 
     f.rd.value = Num2String(rd,2,-10,10,-6,6); 
     f.kd.value = Num2String(kd,4,-10,10,-6,6);
    }
   else
    {
      f.kocinput.value = "";
      f.rd.value = "";
      f.kd.value = "";
    }
}
//  -->
<!-- end retard_1.js -->