
<!--
function Seepage(data,UnitChange,ChangeHeadUnit,TimeUnitChange,RechargeUnitChange,ConductivityUnitChange,CurrentDate)
{
//***********************************************************************
//*
//* Function  Seepage calculates the seepage velocity and travel time for a set of chemicals, 
//*           hydraulic variables and distance
//*
//* Language:  JavaScript1.1
//*
//* Inputs:
//*
//* Returns:  nothing
//*
//* 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:  
//*         11-15-99  Use of JavaScript cookies
//*         01-17-01  display of koc in textinput box when chemical selected from list box
//*         02-13-01  removal of travel time calculation
//*
//* Required functions: ShortDate, save, restore, Gradient, Num2String, UnitFlux, unitdistance,
//*                     getKOC, clearAll
//*
//* Required scripts: sdate.js, cookie.js, Input.js, digits.js, unitks.js, chemical.js, clear.js
//*
//***********************************************************************
   var f=document.Seepage0;
   var SiteName = "";
   var SiteDate = "";
   var rd = 1;
   var bd = 0;
   var qs = 0;
   var time0 = 0;
   var dens = 2.65;

   var unitout = "";
   var unitKsIn = "";
   var unitKs = "";
   var unitdist = "";
   var unittime = "";
   var unithead = "";
   var unitrech = "";

   f.rd.value = "*";
   f.output.value = "*";
  
   var ucf = 1;
   var ucf1 = 1;
   var ucf2 = 1;
   var ucf3 = 1; 
   var ucfh = 1;
   var ucfa = 1;
   var ucfKs = 1;  
 

   var ks = 0;
   var ksIn = 0;
   var grad = 0;

  
   var kd = 0;
   
   var foc = 0;
   var koc = 0;
   var por = 0;
   
   var distance = 0;
   var chemical = "";

   var x1 = 0;
   var y1 = 0;
   var x2 = 0;
   var y2 = 0;
   var h1 = 0;
   var h2 = 0;

   var date = new Date();
   var Ent = new Array();
    
//results
if (data=="noexample" || data=="save")
   {

      //set the site date and name
      SiteName = f.site.value;
      if (CurrentDate==true) {SiteDate=ShortDate(date); f.date.value=SiteDate;}
      else {SiteDate = f.date.value;}
     
      //get the chemical name
      f.chemical.selectedIndex = CheckSelection (f.chemical); 
      chemical = f.chemical.options[f.chemical.selectedIndex].value;
 
      //get the koc    
      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 = getKOC(chemical);
      }
      //1-17-2001
      f.kocinput.value = koc;

      //get the fraction organic carbon
      foc = Input(f.foc.value);
     
      //get the porosity
      por = Input(f.poro.value);


      //Input hydraulic conductivity
      ksIn = Input(f.ksIn.value);

      //hydraulic conductivity
      ks = Input(f.ks.value);
 
  
      //distances and heads
      x1 = Input(f.x1.value);
      y1 = Input(f.y1.value);
      x2 = Input(f.x2.value);
      y2 = Input(f.y2.value);
      h1 = Input(f.h1.value);
      h2 = Input(f.h2.value);
     
  
     //distance to receptor   

     
     unitout = f.SeepUnit.options[f.SeepUnit.selectedIndex].value
     unitKsIn = f.unit1In.options[f.unit1In.selectedIndex].value
     unitKs = f.unit1.options[f.unit1.selectedIndex].value
     unitdist = f.DistUnit.options[f.DistUnit.selectedIndex].value
     unittime = f.TimeUnit.options[f.TimeUnit.selectedIndex].value
     unithead = f.HeadUnit.options[f.HeadUnit.selectedIndex].value


     if (data=="save")
     { 
       //display the cookie message
       window.open('../../home/storage.html','storage','width=620,height=400,resizable');
       return;

       /*
       //set and save the cookie values
       Ent[0] = SiteDate;
       Ent[1] = SiteName;
       Ent[2] = chemical;
       //save the id virtual cookie
       save("id",Ent);

       //retardation virtual cookie
       Ent[0] = foc;
       Ent[1] = koc;
       save("rd",Ent);


       //gradient virtual cookie
       Ent[0] = 1;
       Ent[1] = 0;
       Ent[2] = x1;
       Ent[3] = y1;
       Ent[4] = x2;
       Ent[5] = y2;
       Ent[6] = 1;
       Ent[7] = f.DistUnit.selectedIndex;
       Ent[8] = f.HeadUnit.selectedIndex;
       Ent[9] = h1;
       Ent[10] = h2;
       save("ng",Ent);

       //Darcy virtual cookie
       Ent[0] = ksIn;
       Ent[1] = f.unit1In.selectedIndex;
       Ent[2] = f.DistUnit.selectedIndex;
       Ent[3] = f.TimeUnit.selectedIndex;
       save('dc',Ent);

       //Porosity virtual cookie
       Ent[0] = por;
       save('po',Ent);

       //Travel Time virtual cookie
       //Ent[0] = distance;
       //Ent[1] = f.SeepUnit.selectedIndex;
       //save('tt',Ent);
       */
     }
    
   }
if (data=="example" )
   {

     //example data set
     SiteName = "Travel Time Example"
     SiteDate = ShortDate(date);

     ks = 10;
     ksIn = ks;
     grad = .002;
     

     x1 = 100;
     y1 = 0;
     x2 = 2100;
     y2 = 0;
     h1 = 20;
     h2 = 19;

     unitKs = "ft/day";
     unitout = "ft/day";
     unitdist = "ft";
     unittime = "days";

     f.unit1In.selectedIndex = 0;
     f.unit1.selectedIndex = 0;
     f.SeepUnit.selectedIndex = 0;
     f.DistUnit.selectedIndex = 0;
     f.TimeUnit.selectedIndex = 0;
    
    
     f.chemical.selectedIndex = 1;
     chemical = f.chemical.options[f.chemical.selectedIndex].value;
     koc = getKOC(chemical);
     foc = 0.0001;
     por = 0.25
     bd = 2.65;
    }

   
   if (data=="restore")
    {
      //display the cookie message
      window.open('../../home/storage.html','storage','width=620,height=400,resizable');
      return;

      /*
      SiteName = restore("id",'site');
      SiteDate = restore("id",'date');
      chemical = restore('id','chemical');
      f.chemical.selectedIndex = SelectIndex(f.chemical,chemical);
      x1 = restore("ng",'x1');
      y1 = restore("ng",'y1');
      x2 = restore("ng",'x2');
      y2 = restore("ng",'y2');
      //f.DistUnit.selectedIndex = restore("ng",'UnitOut');
      f.HeadUnit.selectedIndex = restore("ng",'UnitHead');
      h1 = restore("ng",'h1');
      h2 = restore("ng",'h2'); 
      foc = restore("rd",'foc');
      koc = restore("rd",'koc');
      ksIn = restore('dc','conductivity');
      f.unit1In.selectedIndex = restore('dc','UnitKc');
      f.DistUnit.selectedIndex = restore('dc','UnitDistance');
      f.TimeUnit.selectedIndex = restore('dc','UnitTime');
      por = restore('po','porosity');
      f.SeepUnit.selectedIndex = restore('tt','UnitSeep');
      */
    }

   if (data=="example" || data=="restore")
    {
      f.site.value = SiteName;
      f.date.value = SiteDate;
      f.ksIn.value = ksIn;
      f.grad.value = grad;
      f.x1.value = x1;
      f.y1.value = y1;
      f.x2.value = x2;
      f.y2.value = y2;
      f.h1.value = h1;
      f.h2.value = h2;
      f.foc.value = foc;
      f.kocinput.value = koc;
      f.poro.value = por;
   
    }


   if (data=="clear") {clearAll(f); return;}

    

  //length unit conversions;
  ucf1 = 1;
  if (UnitChange=="true")
    {
     if (f.DistUnit.options[f.DistUnit.selectedIndex].value=="ft") {ucf1=1/0.3048; unitdist="ft";}
     if (f.DistUnit.options[f.DistUnit.selectedIndex].value=="m") {ucf1=0.3048; unitdist="m";}
    }
 
 
  
  x1 = x1*ucf1;
  y1 = y1*ucf1;
  x2 = x2*ucf1;
  y2 = y2*ucf1;
  h1 = h1*ucf1;
  h2 = h2*ucf1;     
  f.x1.value = x1;
  f.y1.value = y1;
  f.x2.value = x2;
  f.y2.value = y2;
  f.h1.value = h1;
  f.h2.value = h2;


    
  //time unit changes
  ucf2 = 1;
  if (TimeUnitChange=="true")
    {
      if (f.TimeUnit.options[f.TimeUnit.selectedIndex].value=="days"){ucf2=365.25; unittime="days";}
      if (f.TimeUnit.options[f.TimeUnit.selectedIndex].value=="years"){ucf2=1/365.25; unittime="years";}
     }

  //Head Unit Conversions
  if (ChangeHeadUnit==true)
    {
     if (f.HeadUnit.options[f.HeadUnit.selectedIndex].value=="ft"){ucfh = 1/0.3048; unithead="ft"}
     if (f.HeadUnit.options[f.HeadUnit.selectedIndex].value=="m"){ucfh = 0.3048; unithead="m"}
    }

  h1 = h1*ucfh;
  h2 = h2*ucfh;
  f.h1.value = Num2String(h1,4,-10,10,-6,6);
  f.h2.value = Num2String(h2,4,-10,10,-6,6);


  //additional unit conversion factor if the two distance units are not equal
  if (unithead=="ft" && unitdist=="m" ) {ucfa = 0.3048;}
  if (unithead=="m" && unitdist=="ft") {ucfa = 1/0.3048;}

  //calculate the gradient
  grad = Gradient (x1,y1,x2,y2,h1,h2); 
  grad = grad*ucfa;     
  f.grad.value = Num2String(grad,2,-10,10,-6,6); 




  //convert values
  

  //first convert the input hydraulic conductivity to the value wanted by the user
  ucfKs = UnitKs(unitKsIn,unitKs)
  ks = ksIn*ucfKs;
  f.ks.value = Num2String(ks,4,-15,10,-6,6);
  
  //convert the hydraulic conductivity to the units used in the calculation
  




  //the next set of unit conversion factors forces the units to match 
  //the desired output units (unitout)
  ucf = UnitFlux (unitout,unitdist,unittime);
  ucf3 = UnitFlux (unitrech,unitdist,unittime);
  ucfKs = UnitFlux (unitKs,unitdist,unittime);
 

  //bulk density
  var bd = dens*(1.-por);
  f.BulkDensity.value = Num2String(bd,3,-10,10,-6,6);


  //the soil/water distribution coefficient
  kd = foc*koc;

  
if (por!=0)
  {
     //retardation coefficient
     rd = 1 + bd*foc*koc/por;
     f.rd.value = Num2String(rd,3,-10,10,-6,6);
     f.kd.value = Num2String(kd,3,-10,10,-6,6);

     //seepage velocity
     qs = -ks*grad*ucfKs/ucf/por;
     f.output.value=Num2String(qs,4,-15,15,-6,6) + ' ' + unitout;
     f.output2.value=Num2String(qs/rd,4,-15,15,-6,6) + ' ' +  unitout;
     
  
  }



}



  

function unitdistance (unitout,unitdist)
{
//distance unit
var ucf1 = 1
if (unitout=="ft/day") {if (unitdist=="m") {ucf1 = 0.3048}}
if (unitout=="ft/yr") {if (unitdist=="m") {ucf1 = 0.3048}}
if (unitout=="m/yr") {if (unitdist=="ft") {ucf1 = 1/.3048}}
if (unitout=="m/day") {if (unitdist=="ft"){ucf1 = 1/.3048}}
return ucf1;
}
// -->
<!-- end seepage_1.js -->