function CalculateVolume(frm)
{
   var vol;
   var area;
   var chosen;
   var shallowend;
   var deepend;
   var depth;
   var A;
   var B;
   var C;
   var R;
   
   for (var i = 0; i < frm.poolshape.length; i++)
   {
      if (frm.poolshape[i].checked)
      {
         chosen = frm.poolshape[i].value;
         break;
      }
   }
   
   shallowend = parseFloat(frm.shallow.value);
   deepend = parseFloat(frm.deep.value);
   depth = (shallowend + deepend) / 2;
   
   if (isNaN(depth))
   {
      alert("You must fill in the deep end and shallow end depths.")
      return;
   }
   
   switch(chosen)
   {
      case "rectangle":
         A = parseFloat(frm.RA.value);
         B = parseFloat(frm.RB.value);
         area = A * B;
         break;
      case "oblong":
         A = parseFloat(frm.OA.value);
         B = parseFloat(frm.OB.value);
         C = parseFloat(frm.OC.value);
         area = (A + B) * C * .45;
         break;
      case "circle":
         R = parseFloat(frm.CR.value);
         area = R * R * Math.PI;
         break;
      case "triangle":
         A = parseFloat(frm.TA.value);
         B = parseFloat(frm.TB.value);
         area = A * B / 2;
   }
   vol = area * depth * 1000;
   
   if (isNaN(vol))
   {
      alert("You must fill in all the fields for the chosen pool shape.")
   }
   else
   {
      frm.volume.value = Math.round(vol * 100) / 100;
   }
   return;
}

function setRadioFocus(typ, frm)
{
   for (var i = 0; i < frm.poolshape.length; i++)
   {
      if (frm.poolshape[i].value == typ)
      {
         frm.poolshape[i].checked = true;
         break;
      }
   }
   return;
}

