function lighten(SelectedItem) // OK
{
  document.getElementById(SelectedItem).style.color = '#0063D8';
};


function darken(SelectedItem) // OK
{
  document.getElementById(SelectedItem).style.color = '#000022';
};


function ShowPDF(s) // NOT TESTED
{
  var menu = document.getElementById(s);
  var pdf  = './' + menu.options[menu.selectedIndex].value;
  var DrawingWindow;
  DrawingWindow = window.open('', 'DrawingPreview', 'toolbar=0,scrollbars=0,resizable=0,menubar=0,width=1,height=1');
  DrawingWindow.close();
  DrawingWindow = window.open('', 'DrawingPreview', 'toolbar=0,scrollbars,resizable,menubar=0,width=800,height=600');
  DrawingWindow.document.write('<html><body bgcolor="#FFFFFF"><br><br><br><br><center> Loading drawing...</center></body></html>');
  DrawingWindow.document.URL = pdf;
  DrawingWindow.focus();
};


function CalcVolume() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var vesdiameter;
    var veslength;
    var volume;

    var diamunits;
    var lenunits;
    var volunits;

    if(navigator.appName == 'Netscape')
    {
      vesdiameter  = document.forms['Volume'].elements['VesDiameter'].value;
      veslength    = document.forms['Volume'].elements['VesLength'].value;

      diamunits    = document.forms['Volume'].elements['DiamUnits'].value;
      lenunits     = document.forms['Volume'].elements['LenUnits'].value;
      volunits     = document.forms['Volume'].elements['VolUnits'].value;

      volume       = eval((veslength * lenunits) * (Math.PI * Math.pow(eval((vesdiameter * diamunits) / 2) ,2)));

      document.forms['Volume'].elements['VesVolume'].value = Math.round(Math.abs(volume * volunits)*10) / 10;
    }
    else
    {
      vesdiameter  = eval(document.all.Volume.VesDiameter.value);
      veslength    = eval(document.all.Volume.VesLength.value);

      diamunits    = eval(document.all.Volume.DiamUnits.value);
      lenunits     = eval(document.all.Volume.LenUnits.value);
      volunits     = eval(document.all.Volume.VolUnits.value);

      volume       = eval((veslength * lenunits) * (Math.PI * Math.pow(eval((vesdiameter * diamunits) / 2), 2)));

      document.all.Volume.VesVolume.value = Math.round(Math.abs(volume * volunits) * 10) / 10;
    }
  }
};


function CalcPressureA() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var A;
    var Aunits;
    var Bunits;

    if(navigator.appName == 'Netscape')
    {
      A       = document.forms['Pressure'].elements['PressureA'].value * 1;
      Aunits  = document.forms['Pressure'].elements['AUnits'].value * 1;
      Bunits  = document.forms['Pressure'].elements['BUnits'].value * 1;

      document.forms['Pressure'].elements['PressureB'].value = Math.round(Math.abs((A / Aunits) * Bunits) * 10) / 10;
    }
    else
    {
      A       = document.all.Pressure.PressureA.value * 1;
      Aunits  = document.all.Pressure.AUnits.value * 1;
      Bunits  = document.all.Pressure.BUnits.value * 1;

      document.all.Pressure.PressureB.value = Math.round(Math.abs((A / Aunits) * Bunits) * 10) / 10;
    }
  }
};


function CalcPressureB() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var B;
    var Aunits;
    var Bunits;

    if(navigator.appName == 'Netscape')
    {
      B       = document.forms['Pressure'].elements['PressureB'].value * 1;
      Aunits  = document.forms['Pressure'].elements['AUnits'].value * 1;
      Bunits  = document.forms['Pressure'].elements['BUnits'].value * 1;

      document.forms['Pressure'].elements['PressureA'].value = Math.round(Math.abs((B / Bunits) * Aunits) * 10) / 10;
    }
    else
    {
      B       = document.all.Pressure.PressureB.value * 1;
      Aunits  = document.all.Pressure.AUnits.value * 1;
      Bunits  = document.all.Pressure.BUnits.value * 1;

      document.all.Pressure.PressureA.value = Math.round(Math.abs((B / Bunits) * Aunits) * 10) / 10;
    }
  }
};


function CalcCapacity() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var RUnits;
    var LUnits;
    var HUnits;

    var radius;
    var length;
    var height;
    var volunits;
    var capacity;

    if(navigator.appName == 'Netscape')
    {
      RUnits    = Math.abs(document.forms['Capacity'].elements['RUnits'].value);
      LUnits    = Math.abs(document.forms['Capacity'].elements['LUnits'].value);
      HUnits    = Math.abs(document.forms['Capacity'].elements['HUnits'].value);

      radius    = Math.abs(document.forms['Capacity'].elements['VesRadius'].value * RUnits);
      length    = Math.abs(document.forms['Capacity'].elements['VesLength'].value * LUnits);
      height    = Math.abs(document.forms['Capacity'].elements['LiqHeight'].value * HUnits);
      volunits  = Math.abs(document.forms['Capacity'].elements['VUnits'].value);
    }
    else
    {
      RUnits    = Math.abs(document.all.Capacity.RUnits.value);
      LUnits    = Math.abs(document.all.Capacity.LUnits.value);
      HUnits    = Math.abs(document.all.Capacity.HUnits.value);

      radius    = Math.abs(document.all.Capacity.VesRadius.value * RUnits);
      length    = Math.abs(document.all.Capacity.VesLength.value * LUnits);
      height    = Math.abs(document.all.Capacity.LiqHeight.value * HUnits);
      volunits  = Math.abs(document.all.Capacity.VUnits.value);
    }

    if(height > (radius * 2))
    {
      if(navigator.appName == 'Netscape')
      {
        height    = 2 * (document.forms['Capacity'].elements['VesRadius'].value / HUnits * RUnits);
        document.forms['Capacity'].elements['LiqHeight'].value = Math.round(height * 10) / 10;
        height    = height * HUnits;
        capacity  = length * (Math.pow(radius, 2) * Math.PI);
      }
      else
      {
        height    = 2 * (document.all.Capacity.VesRadius.value / HUnits * RUnits);
        document.all.Capacity.LiqHeight.value = Math.round(height * 10) / 10;
        height    = height * HUnits;
        capacity  = length * (Math.pow(radius, 2) * Math.PI);
      }
    }
    else if(height == (2 * radius))
    {
      capacity = length * (Math.pow(radius, 2) * Math.PI);
    }
    else if(height > radius)
    {
      capacity = length * (Math.pow(radius, 2) * Math.PI) - (length * Math.pow(radius, 2) / 2 * (2 * Math.acos((radius - ((2 * radius) - height)) / radius) - Math.sin(2 * Math.acos((radius - ((2 * radius) - height)) / radius))));
    }
    else if(height == radius)
    {
      capacity = length * (Math.pow(radius, 2) * Math.PI) / 2;
    }
    else if(height < radius)
    {
      capacity = length * Math.pow(radius, 2) / 2 * (2 * Math.acos((radius - height) / radius) - Math.sin(2 * Math.acos((radius - height) / radius)));
    }

    if(navigator.appName == 'Netscape')
    {
      document.forms['Capacity'].elements['VesVolume'].value = Math.round(capacity * volunits * 10) / 10;
    }
    else
    {
      document.all.Capacity.VesVolume.value = Math.round(capacity * volunits * 10) / 10;
    }
  }
};


function CalcTempA() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var A;
    var B;
    var AU;
    var BU;

    if(navigator.appName == 'Netscape')
    {

      A   = document.forms['Temperature'].elements['TempA'].value;
      B   = document.forms['Temperature'].elements['TempB'].value;
      AU  = document.forms['Temperature'].elements['AUnits'].value;
      BU  = document.forms['Temperature'].elements['BUnits'].value;

      if(AU == 'F' && BU == 'F')
      {
        document.forms['Temperature'].elements['TempB'].value = A;
      }
      if(AU == 'F' && BU == 'C')
      {
        document.forms['Temperature'].elements['TempB'].value = Math.round((eval(A - 32)  * .555555) * 100) / 100;
      }
      if(AU == 'F' && BU == 'K')
      {
        document.forms['Temperature'].elements['TempB'].value = Math.round((eval(A - 32)  * .555555 + 273.15) * 100) / 100;
      }
      if(AU == 'C' && BU == 'F')
      {
        F = (A * 1.8) + 32;
        document.forms['Temperature'].elements['TempB'].value = Math.round(F * 100) / 100;
      }
      if(AU == 'C' && BU == 'C')
      {
        document.forms['Temperature'].elements['TempB'].value = A;
      }
      if(AU == 'C' && BU == 'K')
      {
        document.forms['Temperature'].elements['TempB'].value = Math.round((A * 1 + 273.15) * 100) / 100;
      }
      if(AU == 'K' && BU == 'F')
      {
        C = A * 1 + 273.15;
        F = (C * 9 / 5) + 32;
        document.forms['Temperature'].elements['TempB'].value = Math.round(F * 100) / 100;
      }
      if(AU == 'K' && BU == 'C')
      {
        C = A * 1 + 273.15;
        document.forms['Temperature'].elements['TempB'].value = Math.round(C * 100) / 100;
      }
      if(AU == 'K' && BU == 'K')
      {
        document.forms['Temperature'].elements['TempB'].value = A;
      }
    }
    else
    {
      A   = document.all.Temperature.TempA.value;
      B   = document.all.Temperature.TempB.value;
      BU  = document.all.Temperature.BUnits.value;
      AU  = document.all.Temperature.AUnits.value;

      if(AU == 'F' && BU == 'F')
      {
        document.all.Temperature.TempB.value = A;
      }
      if(AU == 'F' && BU == 'C')
      {
        document.all.Temperature.TempB.value = Math.round((eval(A - 32)  * .555555) * 100) / 100;
      }
      if(AU == 'F' && BU == 'K')
      {
        document.all.Temperature.TempB.value = Math.round((eval(A - 32)  * .555555 + 273.15) * 100) / 100;
      }
      if(AU == 'C' && BU == 'F')
      {
        F = (A * 1.8) + 32;
        document.all.Temperature.TempB.value = Math.round(F * 100) / 100;
      }
      if(AU == 'C' && BU == 'C')
      {
        document.all.Temperature.TempB.value = A;
      }
      if(AU == 'C' && BU == 'K')
      {
        document.all.Temperature.TempB.value = Math.round((A * 1 + 273.15) * 100) / 100;
      }
      if(AU == 'K' && BU == 'F')
      {
        C = A * 1 + 273.15;
        F = (C * 9 / 5) + 32;
        document.all.Temperature.TempB.value = Math.round(F * 100) / 100;
      }
      if(AU == 'K' && BU == 'C')
      {
        C = A * 1 + 273.15;
        document.all.Temperature.TempB.value = Math.round(C * 100) / 100;
      }
      if(AU == 'K' && BU == 'K')
      {
        document.all.Temperature.TempB.value = A;
      }
    }
  }
};


function CalcTempB() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var A;
    var B;
    var AU;
    var BU; 

    if(navigator.appName == 'Netscape')
    {
      A   = document.forms['Temperature'].elements['TempA'].value;
      B   = document.forms['Temperature'].elements['TempB'].value;
      AU  = document.forms['Temperature'].elements['AUnits'].value;
      BU  = document.forms['Temperature'].elements['BUnits'].value;

      if(BU == 'F' && AU == 'F')
      {
        document.forms['Temperature'].elements['TempA'].value = B;
      }
      if(BU == 'F' && AU == 'C')
      {
        var f = (B - 32) * 5 / 9;
        document.forms['Temperature'].elements['TempA'].value = Math.round(f * 100) / 100;
      }
      if(BU == 'F' && AU == 'K')
      {
        document.forms['Temperature'].elements['TempA'].value = Math.round(eval((B * 1 - 32)  * .555555 + 273.15) * 100) / 100;
      }
      if(BU == 'C' && AU == 'F')
      {
        document.forms['Temperature'].elements['TempA'].value = Math.round(eval((B * 1.8 + 32) * 100)) / 100;
      }
      if(BU == 'C' && AU == 'C')
      {
        document.forms['Temperature'].elements['TempA'].value = B;
      }
      if(BU == 'C' && AU == 'K')
      {
        document.forms['Temperature'].elements['TempA'].value = Math.round(eval(B * 1 + 273.15) * 100) / 100;
      }
      if(BU == 'K' && AU == 'F')
      {
        var c = (B * 1 - 273.15);
        var f = (c * 1.8) + 32;
        document.forms['Temperature'].elements['TempA'].value = Math.round(f * 100) / 100;
      }
      if(BU == 'K' && AU == 'C')
      {
        document.forms['Temperature'].elements['TempA'].value = Math.round(eval(B * 1 - 273.15) * 100) / 100;
      }
      if(BU == 'K' && AU == 'K')
      {
        document.forms['Temperature'].elements['TempA'].value = B;
      }
    }
    else
    {
      A   = document.all.Temperature.TempA.value;
      B   = document.all.Temperature.TempB.value;
      AU  = document.all.Temperature.AUnits.value;
      BU  = document.all.Temperature.BUnits.value;

      if(BU == 'F' && AU == 'F')
      {
        document.all.Temperature.TempA.value = B;
      }
      if(BU == 'F' && AU == 'C')
      {
        var f = (B - 32) * 5 / 9;
        document.all.Temperature.TempA.value = Math.round(f * 100) / 100;
      }
      if(BU == 'F' && AU == 'K')
      {
        document.all.Temperature.TempA.value = Math.round(eval((B * 1 - 32)  * .555555 + 273.15) * 100) / 100;
      }
      if(BU == 'C' && AU == 'F')
      {
        document.all.Temperature.TempA.value = Math.round(eval((B * 1.8 + 32) * 100)) / 100;
      }
      if(BU == 'C' && AU == 'C')
      {
        document.all.Temperature.TempA.value = B;
      }
      if(BU == 'C' && AU == 'K')
      {
        document.all.Temperature.TempA.value = Math.round(eval(B * 1 + 273.15) * 100) / 100;
      }
      if(BU == 'K' && AU == 'F')
      {
        var c = (B * 1 - 273.15);
        var f = (c * 1.8) + 32;
        document.all.Temperature.TempA.value = Math.round(f * 100) / 100;
      }
      if(BU == 'K' && AU == 'C')
      {
        document.all.Temperature.TempA.value = Math.round(eval(B * 1 - 273.15) * 100) / 100;
      }
      if(BU == 'K' && AU == 'K')
      {
        document.all.Temperature.TempA.value = B;
      }
    }
  }
};


function CalcFlowA() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var A;
    var AU;
    var BU;

    if(navigator.appName == 'Netscape')
    {
      A   = document.forms['Flow'].elements['FlowA'].value;
      AU  = document.forms['Flow'].elements['AUnits'].value;
      BU  = document.forms['Flow'].elements['BUnits'].value;

      document.forms['Flow'].elements['FlowB'].value = Math.round((A/AU) * BU * 100) / 100;
    }
    else
    {
      A   = document.all.Flow.FlowA.value;
      AU  = document.all.Flow.AUnits.value;
      BU  = document.all.Flow.BUnits.value;

      document.all.Flow.FlowB.value = Math.round((A/AU) * BU * 100) / 100;
    }
  }
};


function CalcFlowB() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    var B;
    var AU;
    var BU;

    if(navigator.appName == 'Netscape')
    {
      B   = document.forms['Flow'].elements['FlowB'].value;
      AU  = document.forms['Flow'].elements['AUnits'].value;
      BU  = document.forms['Flow'].elements['BUnits'].value;

      document.forms['Flow'].elements['FlowA'].value = Math.round((B / BU) * AU * 100) / 100;
    }
    else
    {
      B   = document.all.Flow.FlowB.value;
      AU  = document.all.Flow.AUnits.value;
      BU  = document.all.Flow.BUnits.value;

      document.all.Flow.FlowA.value = Math.round((B / BU) * AU * 100) / 100;
    }
  }
};


function SubmitQuote() // NOT TESTED
{
  if(navigator.appName == 'Netscape')
  {
    var QuoteForm = document.forms['Quote'];
  }
  else
  {
    var QuoteForm  = document.all.Quote;
    var sName      = QuoteForm.RequestedBy.value;
    var sCompany   = QuoteForm.Company.value;
    var sAddress   = QuoteForm.Address.value;
    var sCity      = QuoteForm.City.value;
    var sZip       = QuoteForm.Zip.value;
    var sPhone     = QuoteForm.Phone.value;
    var sDim       = QuoteForm.Dimensions.value;
    var sMatl      = QuoteForm.Material.value;

  }

  var missingdata = false;
  var errortext   = 'The following fields require data: \r\r';

  if(!sName)
  {
    missingdata = true;
    errortext  += 'Name \r';
  }
  if(!sCompany)
  {
    missingdata = true;
    errortext  += 'Company \r';
  }
  if(!sAddress)
  {
    missingdata = true;
    errortext  += 'Address \r';
  }
  if(!sCity)
  {
    missingdata = true;
    errortext  += 'City \r';
  }
  if(!sZip)
  {
    missingdata = true;
    errortext  += 'Zip \r';
  }
  if(!sPhone)
  {
    missingdata = true;
    errortext  += 'Phone \r';
  }
  if(!sDim)
  {
    missingdata = true;
    errortext  += 'Dimensions \r';
  }
  if(!sMatl)
  {
    missingdata = true;
    errortext  += 'Matl of Construction \r';
  }
  if(missingdata)
  {
    alert(errortext);
    return false;
  }
  else
  {
    var listvalue = QuoteForm.Industry.options[QuoteForm.Industry.selectedIndex].value;

    switch(listvalue)
    {
      case 'Industrial':
        QuoteForm.action = 'mailto:industrial@bendelcorp.com?Request for Quotation';
        break;
      case 'Petroleum':
        QuoteForm.action = 'mailto:petroleum@bendelcorp.com?Request for Quotation';
        break;
    }
    QuoteForm.submit();
    alert('Your request has been sent to' + QuoteForm.action);
  }
};


function SubmitInfoRequest() // NOT TESTED
{
};


function MakeTen(s) // NOT TESTED
{
  var n     = '';
  var strng = stripCharsInBag(s, '()[]/\.-extEXT ');

  if(strng.length < 10 && !strng == '')
  {
    alert('Phone number must have 10 digits. Please include your area code.');
  }
  else
  {
    for (i = 0; i < 10; i++)
    {
      n += strng.charAt(i);
    }
    return n;
  }
};


function stripCharsInBag(s, bag) // NOT TESTED
{
  var i;
  var returnString = '';

  for (i = 0; i < s.length; i++)
  {
    var c = s.charAt(i);
    if(bag.indexOf(c) == -1) returnString += c;
  }
  return returnString;
};


function FormatPhone(s) // NOT TESTED
{
  var p = '';
  var a = '(';
  var e = ')';
  var n = '-';

  if(s.length == 10)
  {
    for (i = 0; i < 10; i++)
    {
    if(i < 3)          {a += s.charAt(i);}
    if(i > 2 && i <6)  {e += s.charAt(i);}
    if(i > 5)          {n += s.charAt(i);}
  }

  p = a + e + n;
  return p;
  }
  else
  {
    return '';
  }
};


function Showlocator(loc) // NOT TESTED
{
  var locator;
  loc = eval(loc);

  if(loc > 7 && loc <13)
  {
    locator = document.all.locator2;
  }
  else
  {
    locator = document.all.locator1;
  }

  var map;
  map = document.all.map1;

  if(loc == 1)
  {
    locator.style.left = 178;
    locator.style.top  = 100;
  }
  if(loc == 2)
  {
    locator.style.left = 170;
    locator.style.top  = 128;
  }
  if(loc == 3)
  {
    locator.style.left = 148;
    locator.style.top  = 168;
  }
  if(loc == 4)
  {
    locator.style.left = 171;
    locator.style.top  = 119;
  }
  if(loc == 5)
  {
    locator.style.left = 178;
    locator.style.top  = 92;
  }
  if(loc == 6)
  {
    locator.style.left = 175;
    locator.style.top  = 99;
  }
  if(loc == 7)
  {
    locator.style.left = 175;
    locator.style.top  = 107;
  }
  if(loc == 8)
  {
    locator.style.left = 15;
    locator.style.top  = 120;
  }
  if(loc == 9)
  {
    locator.style.left = 34;
    locator.style.top  = 126;
  }
  if(loc == 10)
  {
    locator.style.left = 78;
    locator.style.top  = 198;
  }
  if(loc == 11)
  {
    locator.style.left = 30;
    locator.style.top  = 190;
  }
  if(loc == 12)
  {
    locator.style.left = 9;
    locator.style.top  = 119;
  }
  if(loc == 13)
  {
    locator.style.left = 52;
    locator.style.top  = 18;
  }
  if(loc == 14)
  {
    locator.style.left = 52;
    locator.style.top  = 13;
  }

   locator.style.visibility = 'visible';
   return true;
};


function Hidelocator() // NOT TESTED
{
  document.all.locator1.style.visibility = 'hidden';
  document.all.locator2.style.visibility = 'hidden';
};


function CapacityChart() // OK
{
  if(parseInt(navigator.appVersion) >= 4)
  {
    if(navigator.appName == 'Netscape')
    {
      var htmlcode = '';
      var RUnits  = Math.abs(document.forms['Capacity'].elements['RUnits'].value);
      var LUnits  = Math.abs(document.forms['Capacity'].elements['LUnits'].value);
      var HUnits  = Math.abs(document.forms['Capacity'].elements['HUnits'].value);
      var radius  = Math.abs(document.forms['Capacity'].elements['VesRadius'].value);
      var height  = Math.abs(document.forms['Capacity'].elements['LiqHeight'].value);
      var length  = Math.abs(document.forms['Capacity'].elements['VesLength'].value);
      var units   = eval(document.Capacity.RUnits.value);
      var VUnits  = Math.abs(document.forms['Capacity'].elements['VUnits'].value);
      var Oradius = radius;
      var Oheight = height;
      var Olength = length;
      var RLabel  = document.forms['Capacity'].elements['RUnits'].options[document.forms['Capacity'].elements['RUnits'].selectedIndex].text;
      var LLabel  = document.forms['Capacity'].elements['LUnits'].options[document.forms['Capacity'].elements['LUnits'].selectedIndex].text;
      var VLabel  = document.forms['Capacity'].elements['VUnits'].options[document.forms['Capacity'].elements['VUnits'].selectedIndex].text;
      var VIndex  = document.forms['Capacity'].elements['VUnits'].selectedIndex;
      var capacity;
      var unitlabel;
      var divisor = 1;
      var i;

      //...Convert Height unit to inches
      switch(document.forms['Capacity'].elements['HUnits'].selectedIndex)
      {
        case 0:
          height = eval(height * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
         break;
      }

      //...Convert RUnits to inches
      switch(document.forms['Capacity'].elements['RUnits'].selectedIndex)
      {
        case 0:
          radius = eval(radius * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
          break;
      }

      //...Convert LUnits to inches
      switch(document.forms['Capacity'].elements['LUnits'].selectedIndex)
      {
        case 0:
          length = eval(length * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
          break;
      }

      if(length > 0 && radius > 0)
      {
        GenerateChart(unitlabel, radius, length, false, Oradius, Oheight, Olength, RLabel, LLabel, VLabel, VIndex);
      }
      else
      {
        alert('Length and radius of vessel must be greater than 0.');
      }
    }
    else
    {
      var htmlcode = '';
      var RUnits = Math.abs(document.all.Capacity.RUnits.value);
      var LUnits = Math.abs(document.all.Capacity.LUnits.value);
      var HUnits = Math.abs(document.all.Capacity.HUnits.value);
      var radius = Math.abs(document.all.Capacity.VesRadius.value);
      var height = Math.abs(document.all.Capacity.LiqHeight.value);
      var length = Math.abs(document.all.Capacity.VesLength.value);
      var units  = eval(document.Capacity.RUnits.value);
      var VUnits = Math.abs(document.all.Capacity.VUnits.value);

      var VUnits  = Math.abs(document.all.Capacity.VUnits.value);
      var Oradius = radius;
      var Oheight = height;
      var Olength = length;

      var RLabel  = document.all.RUnits.options[document.all.RUnits.selectedIndex].text;
      var LLabel  = document.all.LUnits.options[document.all.LUnits.selectedIndex].text;
      var VLabel  = document.all.VUnits.options[document.all.VUnits.selectedIndex].text;
      var VIndex  = document.all.VUnits.selectedIndex;

      var capacity;
      var unitlabel;
      var divisor = 1;
      var i;

      //...Convert Height unit to inches
      switch(document.all.Capacity.HUnits.selectedIndex)
      {
        case 0:
          height = eval(height * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
         break;
      }

      //...Convert RUnits to inches
      switch(document.all.Capacity.RUnits.selectedIndex)
      {
        case 0:
          radius = eval(radius * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
          break;
      }

      //...Convert LUnits to inches
      switch(document.all.Capacity.LUnits.selectedIndex)
      {
        case 0:
          length = eval(length * 12);
          unitlabel = 'Inches';
          break;
        case 1:
          unitlabel = 'Inches';
          break;
      }
      if(length > 0 && radius > 0)
      {
        GenerateChart(unitlabel, radius, length, false, Oradius, Oheight, Olength, RLabel, LLabel, VLabel, VIndex);
      }
      else
      {
       alert('Length and radius of vessel must be greater than 0.');
      }
    }
  }
  else
  {
    alert('This capability is only available with internet browsers that support Javascript.');
  }
};


function GenerateChart(unitlabel, radius, length, height, Oradius, Oheight, Olength, RLabel, LLabel, VLabel, VIndex)
{
//alert('unitlabel: ' +unitlabel + '\nradius: ' + radius + '\nlength: ' + length + '\nheight: ' + height + '\nOradius: ' + Oradius + '\nOheight: ' + Oheight + '\nOlength: ' + Olength + '\nRLabel: ' + RLabel + '\nLLabel: ' + LLabel + '\nVLabel: ' + VLabel + '\nVIndex: ' + VIndex);

  //...change these to add more rows and/or columns
  //...rows must be evenly divisible by columns
  //...also increase the two table widths to accommodate the extra column(s)
  var rows = 40; // 60 90 100 100 120
  var cols = 2;  //  3  3   4   5   4

  if(parseInt(navigator.appVersion) >= 4)
  {
    var capacity;

    s  = '<html><head><link href="styles.css" rel="stylesheet" media="screen" type="text/css" /><script src="js/bendelcorp-pagination.js"></script></head>';
    s += '<body background="images/bendel_watermark.jpg">';
    s += '<span class="heading1">Capacity Chart</span><br><hr>';
    s += '<table align="center" width="80%">';
    s += '<tr><td align="left" valign="top" colspan="2">Inside dimensions</td></tr>';
    s += '<tr><td align="right" valign="top" rowspan="5"><img src="images/tools_capacity.jpg" alt="" width="172" height="139"></td><td>Length: ' + Olength + '&nbsp;' + LLabel + '</td></tr>';
    s += '<tr><td>Radius: ' + Oradius + '&nbsp;' + RLabel + '</td></tr>';
    s += '<tr><td>Height: (See Below)</td></tr>';
    s += '<tr><td>&nbsp;</td></tr>';
    s += '<tr><td>Volume: (See Below)</td></tr>';
    s += '</table>';
    s += '<br clear="all"><hr>';
    s += '<table width="550" border="0" cellpadding="2" cellspacing="0" align="center"><tr>';

    if(height)
    {
      if((height - rows) > 0) // previous page available
      {
        s += '<td align="left"><button onclick="GenerateChart(\'' + unitlabel + '\', ' + radius + ', ' + length + ', ' + (height - rows) + ', ' + Oradius + ', ' + Oheight + ', ' + Olength + ', \'' + RLabel + '\', \'' + LLabel + '\', \'' + VLabel + '\', ' + VIndex + ');">PREVIOUS Page</button></td>';
      }

      if((radius * 2) > (height + rows)) // next page available
      {
        s += '<td align="right"><button onclick="GenerateChart(\'' + unitlabel + '\', ' + radius + ', ' + length + ', ' + (height + rows) + ', ' + Oradius + ', ' + Oheight + ', ' + Olength + ', \'' + RLabel + '\', \'' + LLabel + '\', \'' + VLabel + '\', ' + VIndex + ');">NEXT Page</button></td>';
      }
    }
    else // first pass only
    {
      height = 1;

      if(radius > (rows / 2))
      {
        s += '<td align="right"><button onclick="GenerateChart(\'' + unitlabel + '\', ' + radius + ', ' + length + ', ' + (rows + 1) + ', ' + Oradius + ', ' + Oheight + ', ' + Olength + ', \'' + RLabel + '\', \'' + LLabel + '\', \'' + VLabel + '\', ' + VIndex + ');">NEXT Page</button></td>';
      }
    }

    s += '</tr></table>';
    s += '<table width="550" border="0" cellpadding="0" cellspacing="0" align="center"><tr>';

    var increment = height;
    for(i = increment; (i <= (2 * radius)) && (i < (increment + rows)); i++)
    {
      height = i;

      //...new column
    //if((i - 1) % (rows / 2) == 0)
      if((i - 1) % (rows / cols) == 0)
      {
        s += '<td valign="top"><table width="275" border="1" cellpadding="2" cellspacing="0" align="center"><tr><td align="middle">Height (' + unitlabel + ')</td><td align="middle">Volume (' + VLabel + ')</td></tr>';
      }

      if(height > (radius * 2))
      {
        height   = 2 * (radius);
        height   = Math.round(height * 10) / 10;
        capacity = length * (Math.pow(radius, 2) * Math.PI);
      }
      if(height == (2 * radius))
      {
        capacity = length * (Math.pow(radius, 2) * Math.PI);
      }
      if(height > radius)
      {
        capacity = length * (Math.pow(radius, 2) * Math.PI) - (length * Math.pow(radius, 2) / 2 * (2 * Math.acos((radius - ((2 * radius) - height))/radius) - Math.sin(2 * Math.acos((radius - ((2 * radius) - height))/radius))));
      }
      if(height == radius)
      {
        capacity = length * (Math.pow(radius, 2) * Math.PI) / 2;
      }
      if(height < radius)
      {
        capacity = length * Math.pow(radius, 2) / 2 * (2 * Math.acos((radius - height)/radius) - Math.sin(2 * Math.acos((radius - height)/radius)));
      }

      //...Convert capacity into selected units
      switch(VIndex)
      {
        case 0:
          capacity = eval(capacity / 1728 );
          break;
        case 1:
          break;
        case 2:
          capacity = eval(capacity * 0.0000163871527);
          break;
        case 3:
          capacity = eval(capacity * 16.387064);
          break;
        case 4:
          capacity = eval(capacity * 0.016387064);
          break;
        case 5:
          capacity = eval(capacity * 0.0043290040509);
          break;
        case 6:
          capacity = eval(capacity * 0.000137428819);
          break;
        case 7:
          capacity = eval(capacity * 0.000103071759);
          break;
      }

    //s += '<tr><td align="middle">' + height + '</td><td align="middle">' + Math.round(capacity * 10) / 10 + '</td></tr>';
      s += '<tr><td align="middle">' + height + '</td><td align="middle">' + Math.round(capacity) + '</td></tr>';

      //...end column
    //if((i % (rows / 2) == 0) || (i == (2 * radius)))
      if((i % (rows / cols) == 0) || (i == (2 * radius)))
      {
        s += '</table></td>';
      }
    }

    s += '</tr></table><br clear="all"><hr>';
    s += '</body></html>';

    CapacityWindow = window.open(document.location, 'CapacityWindow', 'toolbar,scrollbars,menubar,width=565,height=650');
    CapacityWindow.document.write(s);
    CapacityWindow.document.close();
  }
};

