<!--
//(temperatura)

function pula(){document.ConvertForm.ValueFrom.focus();}

function ToSI(temperature, temperatureUnit)
{
  if      (temperatureUnit == "Celsius")     return temperature + 273.15;
  else if (temperatureUnit == "Fahrenheit")  return 5/9 * (temperature + 459.67);
  else if (temperatureUnit == "Kelvin")      return temperature;
  else if (temperatureUnit == "Rankine")     return 5/9 * temperature;
  else if (temperatureUnit == "Réaumure")    return 4/5 * temperature + 273.15;
  else {
    window.alert('Error: Unknown temperature unit: ' + temperatureUnit);
    return 0;
  }
}

function Converttemperature()
{
  with (document.ConvertForm) {
    // Initialization
    TempIn       = parseFloat(ValueFrom.value);
    UnitFromName = UnitFrom.options[UnitFrom.selectedIndex].value;
    UnitToName   = UnitTo.options[UnitTo.selectedIndex].value;

    // Conversion
    TempSI        = ToSI(TempIn, UnitFromName);
    ValueTo.value = parent.formatFloat(FromSI(TempSI, UnitToName), parent.numDigs);
  }
}

function FromSI(temperature, temperatureUnit)
{
  if      (temperatureUnit == "Celsius")    return temperature - 273.15;
  else if (temperatureUnit == "Fahrenheit") return 9/5 * temperature - 459.67;
  else if (temperatureUnit == "Kelvin")     return temperature;
  else if (temperatureUnit == "Rankine")    return 9/5 * temperature;
  else if (temperatureUnit == "Réaumure")   return 5/4 * (temperature - 273.15);
  else {
    window.alert('Error: Unknown temperature unit: ' + temperatureUnit);
    return 0;
  }
}

function ConverttemperatureBack()
{
  with (document.ConvertForm) {
    // Initialization
    TempIn       = parseFloat(ValueTo.value);
    UnitFromName = UnitFrom.options[UnitFrom.selectedIndex].value;
    UnitToName   = UnitTo.options[UnitTo.selectedIndex].value;

    // Conversion
    TempSI          = ToSI(TempIn, UnitToName);
    ValueFrom.value = parent.formatFloat(FromSI(TempSI, UnitFromName), parent.numDigs);
  }
}

function initialize(){
  parent.initialize('temperature');
  Converttemperature();
}
// -->
