<!--
function consum(dist,consumption,rbmile,rbgallon)
{
/*
  consum.js
  Copyright 2001 by Roger Luff (DG2HL).
  Web:   http://www.talknet.de/~alke.spreckelsen/roger/roger.html
  Email: rluff@gmx.de
  Last updated April 2001

  CONSUM Calculates the consumption of a car in units of
  gallons / (100 Miles) and liter / (100 Km)
*/

  dist = dist*1.0;
  consumption = consumption*1.0;
  /*the constants: */
  var mile = 1.609344;
  var gallon = 3.78543;

  /*use SI units for calculation: */
  if (rbmile)
  { 
    dist = dist * mile;
  }
  if (rbgallon)
  { 
    consumption = consumption * gallon;
  }
  /*the main calculation, first l/100km and from the secondly the g/100mile value and
    finally the most commen value miles per gallon...: */
  var lp100km = consumption * 100.0 / dist;
  var gp100M  = lp100km / gallon * mile;
  var mpg     = 100.0 / gp100M;

/* Check if formfield is present on called html page an print result */
  if (document.RLForm.lkmresult)
    document.RLForm.lkmresult.value = Math.round(lp100km*1000)/1000;
  if (document.RLForm.gmresult)
    document.RLForm.gmresult.value = Math.round(gp100M*1000)/1000;
  if (document.RLForm.mpgresult)
    document.RLForm.mpgresult.value = Math.round(mpg*1000)/1000;

}
  //-->
