
<!--
function compute(data,CurrentDate)
{
  var f=document.effectivesolubility;

    
  var esoutput = 0;
  var mf = 0;
  var mwoil = 0;
  var mw = 0;
  var sol = 0;
  var sum = 0;
  var summf = 0;
  var note = "";
  mchemical = new Array(4);
  var SiteName = "";
  var SiteDate = "";
  var date = new Date();
  var Ent = new Array();
  var temperature = 15;

  var fuel = "0";
  var chemical = "0";

  if (data=="noexample" || data=="save")
    { 

     SiteName = f.site.value;
     if (CurrentDate) {SiteDate = ShortDate(date); f.date.value=SiteDate;} 
     else {SiteDate = f.date.value;}

     temperature = Input(f.temp.value);
     if (temperature==0) {temperature = 15;}
     chemical = f.chemical.options[f.chemical.selectedIndex].value
     if (chemical=='other') 
     {
       //user must enter the values......
       sol = Input(f.outsol.value);
       mw = Input(f.mw.value);
       mf = Input(f.massfraction.value)/100.;
       f.fuel.selectedIndex = SelectIndex(f.fuel,'other');
     }

     if (data=="save")
     {
      //display the cookie message
      window.open('../../home/storage.html','storage','width=620,height=400,resizable');
      return;

  
     }
   }

  if (data=="example")
   {
    SiteDate = ShortDate(date);
    SiteName = "Example Effective Solubility";

    f.fuel.selectedIndex = 0;
    f.chemical.selectedIndex = 0;
    temperature = 15;
   }

   if (data=="restore")
     {
      //display the cookie message
      window.open('../../home/storage.html','storage','width=620,height=400,resizable');
      return;
     }


  if (data=="example" || data=="restore")
    {
      f.date.value = SiteDate;
      f.site.value = SiteName;
      f.temp.value = temperature;
    }


  f.fuel.selectedIndex = CheckSelection (f.fuel); 
  fuel = f.fuel.options[f.fuel.selectedIndex].value;
  chemical = f.chemical.options[f.chemical.selectedIndex].value;

  if (data=="clear") {clearAll(f); return;}
   
  //create the prototype chemical object in preparation for later calls to estimate solubilities
  new getChemical("","");

 
         if (fuel=="other")
           {
             //let the user enter a mass fraction instead of using the internal data
             mf = Input(f.massfraction.value);
             mf = mf/100
             note = "User specified mass fraction"
             //let the user enter the average molecular weight
             mwoil = parseFloat(f.AvgMw.value)
             if (isNaN(mwoil)) {mwoil=105; f.AvgMw.value="105";}
           }
         else
           {  
             //get the value from the selected fuel
             if (chemical!='other')
             {
               mf = composition(fuel,chemical);
             }
             mwoil = fuelmw(fuel);
           }

         


        if (chemical=='other') 
        {
          //parameters obtained above
        }
        else
        {
    
         //create a new GetKh object
         gc = new getChemical(chemical,temperature);
 
         //use the GetKh object to estimate the Kh
         sol = gc.solubility();

         //get the molecular weight for the selected chemical
         mw = mole(chemical);
         
        }

        f.mw.value = Num2String(mw,4,-15,15,-6,6);
        //note on the fuel type
        note = fuelnote(fuel);

        //adjust average molecular weight to prevent effective solubilities from being greater than
        //the pure compound solubility
        mwoil = mf*mw + (1-mf)*mwoil;

        esoutput = mf*(mwoil/mw)*sol; 

        
         //set the output text boxes
         if (sol<0) {f.outsol.value = "temperature out of range";}
         else {f.outsol.value= Num2String(sol,3,-15,15,-6,6);}

         f.AvgMw.value = Num2String(mwoil,3,-15,15,-6,6);
         f.note.value = note

         if (mf>=0) {f.massfraction.value = Num2String(mf*100,3,-15,15,-6,6);}
         else {f.massfraction.value = "";}

         if (mf<0) {f.esoutput.value = "data not available";}
         else 
         {
           if (sol<0) {f.esoutput.value = "temperature out of range";}
           else {f.esoutput.value = Num2String(esoutput,3,-10,10,-5,5);}
         }

         //save the revised solubility and mass fraction data
         if (data=='save')
           {
             Ent[0] = mf;
             Ent[1] = rsol;
             Ent[2] = mwoil;
             save('es',Ent);
           }
         
     
}
//-->
<!-- end es-temperature_1.js -->