<search function="temp">
  <name>Temperature Converter</name>
  <description>
    Convert temperatures from any of Celsius, Fahrenheit, Kelvin, and Rankine to the other three. A switch is required to indicate the units the given value is in.<br/>
    <div class="helpboxDescLabels">Switches:</div>
    <table class="helpboxDescTable">
      <tr><td>/celsius, /centigrade</td><td> - </td><td>Convert the given Celsius value to Fahrenheit, Kelvin, and Rankine.</td></tr>
      <tr><td>/fahrenheit</td><td> - </td><td>Convert the given Fahrenheit value to Celsius, Kelvin, and Rankine.</td></tr>
      <tr><td>/kelvin</td><td> - </td><td>Convert the given Kelvin value to Celsius, Farenheit, and Rankine.</td></tr>
      <tr><td>/rankine</td><td> - </td><td>Convert the given Rankine value to Celsius, Farenheit, and Kelvin.</td></tr>
    </table>
    <div class="helpboxDescLabels">Examples:</div>
    <table class="helpboxDescTable">
      <tr><td>temp 22 /c</td></tr>
    </table>
  </description>
  <category>Functions</category>
  <contributor>Ryan Edwards, Volker Wick, Steven Ehrbar</contributor>
  
  <script><![CDATA[
    function temp(q) 
    {
      var args = parseArgs(q, "celsius, centigrade, fahrenheit, kelvin, rankine");
      
      if( nullArgs("temp",q) )
        return false;
      else if( args.switches.length == 1 )
      {
        switch( args.switches[0].name )
        {
          case "celsius": // convert a Celsius value.
          case "centigrade":
            setSearchWindowText(args.q + "\u00b0C = " + parseInt(eval(1.8 * args.q + 32 + 0.5),10) + "\u00b0F " + parseInt(eval(1 * args.q + 273.15 + 0.5),10) + "\u00b0K " + parseInt(eval((1.8 * args.q) + 32 + 459.67 + 0.5),10) + "\u00b0R", true);
            break;
            
          case "fahrenheit": // convert a Fahrenheit value
            setSearchWindowText(args.q + "\u00b0F = " + parseInt(eval((args.q - 32) / 1.8 + 0.5),10) + "\u00b0C " + parseInt(eval((args.q - 32) / 1.8 + 273.15 + 0.5),10) + "\u00b0K " + parseInt(eval(1 * args.q + 459.67 + 0.5),10) + "\u00b0R", true);
            break;
            
          case "kelvin": // convert a Kelvin value
            setSearchWindowText(args.q + "\u00b0K = " + parseInt(eval(1 * args.q - 273.15 + 0.5),10) + "\u00b0C " + parseInt(eval((1.8 * args.q) - 459.67 + 0.5),10) + "\u00b0F " + parseInt(eval(1.8 * args.q + 0.5),10) + "\u00b0R", true);
            break;
            
          case "rankine": // convert a Rankine value
            setSearchWindowText(args.q + "\u00b0R = " + parseInt(eval((args.q) / 1.8 - 273.15 + 0.5),10) + "\u00b0C " + parseInt(eval((args.q) * 1 - 459.67 + 0.5),10) + "\u00b0F " + parseInt(eval((args.q) / 1.8 + 0.5),10) + "\u00b0K", true);
            break;
        }
      }
      else
        nullArgs("temp","?");
    }
  ]]></script>

  <copyright>
	Copyright (c) 2002 David Bau
	Distributed under the terms of the
	GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
  </copyright>
</search>

