/*
 * Horizon calculations.
 * By Dave Pearson <davep@davep.org>
 */
   
function doHorizon()
{
   var result    = document.getElementById( "horizonResult" );
   var eyeHeight = document.getElementById( "eyeHeight" ).value;
   var diameter  = document.getElementById( "horDiameter" ).options[ document.getElementById( "horDiameter" ).selectedIndex ].value;
   var distance  = Math.sqrt( ( eyeHeight / 1000 ) * diameter );

   if ( isNaN( distance ) )
   {
      result.innerHTML = "Input error";
   }
   else
   {
      result.innerHTML = "Approximate distance to the horizon would be " +
         StringifyFloat( distance, 2 ) + " km";
   }
}
