function tdsUiWaterHeating()
{
  var me = this;

  // Form Objects
  frm  = new tdsUiForm('frm', 0, 0, 415);
  frmT = new tdsUiFormTitle(frm, 'frmT', 'Energy Consumption & Cost - Water Heating', '', '', true);
  frmB = new tdsUiFormBody (frm, 'frmB',  430);

  t = new tdsUiTable(frmB, 't', 5, 35);
  t.addRow(0);
  t.addRow(1);
  t.addRow(2);
  t.addRow(3);
  t.row[0].addCell(0, 0, false, 'center', 'Type',        '', 1, 2);
  t.row[0].addCell(1, 0, false, 'center', 'Consumption', '', 2, 1);
  t.row[0].addCell(2, 0, false, 'center', 'Cost');
  t.row[1].addCell(0, 0, false, 'center', 'KWH');
  t.row[1].addCell(1, 0, false, 'center', 'Decatherm');
  t.row[1].addCell(2, 0, false, 'center', '$');
  t.row[2].addCell(0, 1, false,   'left', 'Electric',  80);
  t.row[2].addCell(1, 1,  true,  'right', '-',        110, '', '', '', 'ttConE');
  t.row[2].addCell(2, 1,  true,  'right', '-',        110);
  t.row[2].addCell(3, 1,  true,  'right', '-',         85, '', '', '', 'ttCostE');
  t.row[3].addCell(0, 1, false,   'left', 'Gas');
  t.row[3].addCell(1, 1,  true,  'right', '-');
  t.row[3].addCell(2, 1,  true,  'right', '-', '', '', '', '', 'ttConG');
  t.row[3].addCell(3, 1,  true,  'right', '-', '', '', '', '', 'ttCostG');

  btnC = new tdsUiButton(frmB, 'btnC', 'Calculate',             40, 125, 160, 30, 'Ui.calculate();',  '', 'ttC');
  btnD = new tdsUiButton(frmB, 'btnD', 'Reset Default Values', 215, 125, 160, 30, 'Ui.setDefault();', '', 'ttD');

  fldR = new tdsUiFieldset(frmB, 'fldR', 'Rates',             5, 170, 405,  60, '', 'ttRate',   true);
  fldD = new tdsUiFieldset(frmB, 'fldD', 'Details',           5, 245, 405, 110, '', 'ttDetail', true);
  fldE = new tdsUiFieldset(frmB, 'fldE', 'Electric Specific', 5, 370, 405,  35, '', 'ttElec',   true);
  fldG = new tdsUiFieldset(frmB, 'fldG', 'Gas Specific',      5, 420, 405,  35, '', 'ttGas',    true);

  lblRateE        = new tdsUiLabel(fldR, 'lblRateE',        'txtRateE',       'Electric',             0, 10, 145, 'right', '', 'ttRateE', true);
  lblRateG        = new tdsUiLabel(fldR, 'lblRateG',        'txtRateG',       'Gas',                  0, 35, 145, 'right', '', 'ttRateG', true);
  lblURateE       = new tdsUiLabel(fldR, 'lblURateE',       'txtRateE',       '$/KWH',              300, 10, 100,  'left', '', 'ttRateE', true);
  lblURateG       = new tdsUiLabel(fldR, 'lblURateG',       'txtRateG',       '$/Decatherm',        300, 35, 100,  'left', '', 'ttRateG', true);
  lblDuration     = new tdsUiLabel(fldD, 'lblDuration',     'txtDuration',    'Duration',             0, 10, 145, 'right', '', 'ttDuration', true);
  lblUseRate      = new tdsUiLabel(fldD, 'lblUseRate',      'txtUseRate',     'Usage Rate',           0, 35, 145, 'right', '', 'ttUseRate', true);
  lblTempFSource  = new tdsUiLabel(fldD, 'lblTempFSource',  'txtTempFSource', 'Source Temperature',   0, 60, 145, 'right', '', 'ttTempFSource', true);
  lblTempFOutlet  = new tdsUiLabel(fldD, 'lblTempFOutlet',  'txtTempFOutlet', 'Outlet Temperature',   0, 85, 145, 'right', '', 'ttTempFOutlet', true);
  lblUDuration    = new tdsUiLabel(fldD, 'lblUDuration',    'txtDuration',    'Day',                300, 10,  40,  'left', '', 'ttDuration', true);
  lblUUseRate     = new tdsUiLabel(fldD, 'lblUUseRate',     'txtUseRate',     'Gallon/Day',         300, 35,  40,  'left', '', 'ttUseRate', true);
  lblUTempFSource = new tdsUiLabel(fldD, 'lblUTempFSource', 'txtTempFSource', 'Fahrenheit',         300, 60,  40,  'left', '', 'ttTempFSource', true);
  lblUTempFOutlet = new tdsUiLabel(fldD, 'lblUTempFOutlet', 'txtTempFOutlet', 'Fahrenheit',         300, 85,  40,  'left', '', 'ttTempFOutlet', true);
  lblEFactorE     = new tdsUiLabel(fldE, 'lblEFactorE',     'txtEFactorE',    'Energy Factor',        0, 10, 145, 'right', '', 'ttEFactorE', true);
  lblEFactorG     = new tdsUiLabel(fldG, 'lblEFactorG',     'txtEFactorG',    'Energy Factor',        0, 10, 145, 'right', '', 'ttEFactorG', true);

  txtRateE       = new tdsUiText(fldR, 'txtRateE',       '', 150,  5, 145, 'right', '', 'ttRateE');
  txtRateG       = new tdsUiText(fldR, 'txtRateG',       '', 150, 30, 145, 'right', '', 'ttRateG');
  txtDuration    = new tdsUiText(fldD, 'txtDuration',    '', 150,  5, 145, 'right', '', 'ttDuration');
  txtUseRate     = new tdsUiText(fldD, 'txtUseRate',     '', 150, 30, 145, 'right', '', 'ttUseRate');
  txtTempFSource = new tdsUiText(fldD, 'txtTempFSource', '', 150, 55, 145, 'right', '', 'ttTempFSource');
  txtTempFOutlet = new tdsUiText(fldD, 'txtTempFOutlet', '', 150, 80, 145, 'right', '', 'ttTempFOutlet');
  txtEFactorE    = new tdsUiText(fldE, 'txtEFactorE',    '', 150,  5, 145, 'right', '', 'ttEFactorE');
  txtEFactorG    = new tdsUiText(fldG, 'txtEFactorG',    '', 150,  5, 145, 'right', '', 'ttEFactorG');

  frm.write();

  // Tool Tips
  sdw = new tdsUiShadow('sdw');

  ttConE  = new tdsUiToolTip('ttConE',  sdw, 340, 120, 25000, 'Electric Consumption', 'This is the electric consumption of an electric water heater based on the input below.<br><br>The unit of measurement of the electric consumption is (KWH) kilowatt hour.<br><br>Click the &quot;Reset Default Values&quot; button and values for a typical household for 1 year will be used.');
  ttConG  = new tdsUiToolTip('ttConG',  sdw, 340, 120, 25000, 'Gas Consumption',      'This is the gas consumption of a natural gas water heater based on the input below.<br><br>The unit of measurement of the natural gas consumption is decatherm.<br><br>Click the &quot;Reset Default Values&quot; button and values for a typical household for 1 year will be used.');
  ttCostE = new tdsUiToolTip('ttCostE', sdw, 340,  80, 20000, 'Electric Cost',        'This is the cost associated with operating an electric water heater based on the input below.<br><br>Since the default electric rate is 0 this value will be 0 until the actual electric rate is entered and the &quot;Calculate&quot; button is pressed.');
  ttCostG = new tdsUiToolTip('ttCostG', sdw, 340,  80, 20000, 'Gas Cost',             'This is the cost associated with operating a natural gas water heater based on the input below.<br><br>Click the &quot;Reset Default Values&quot; button and values for a typical household for 1 year will be used.');
  
  ttC = new tdsUiToolTip('ttC', sdw, 300, 65, 10000, 'Calculate',            'Pressing this button will calculate energy consumption and cost based on input values below.  Default values are provided.  However, these may be changed based on your own experience.');
  ttD = new tdsUiToolTip('ttD', sdw, 300, 35,  6000, 'Reset Default Values', 'Pressing this button will reset all input values to generic default values.');

  ttRate   = new tdsUiToolTip('ttRate',   sdw, 200,  20,  5000, 'Rates',             'Energy rate for electric and gas');
  ttDetail = new tdsUiToolTip('ttDetail', sdw, 340, 200, 50000, 'Details',           'Generic details associated with water heating, regardless of the type of energy used.<br><br>Click the &quot;Reset Default Values&quot; button and values for a typical household for 1 year will be used.<br><br>However, if you would like to compare the cost of a 10-min. shower vs a 30-min. shower, enter the time of the shower in the duration input box in minutes.  Then enter the flow rate of your shower head in the usage rate input box in gallons per minute.  Then click calculate.<br><br>You could also compare a warm shower vs a very hot shower by adjusting the outlet temperature. This calculator could be used for laundry, dishwashing, or any other usage of hot water.');
  ttElec   = new tdsUiToolTip('ttElec',   sdw, 200,  20,  4000, 'Electric Specific', 'Detail specific to the use of electricity.');
  ttGas    = new tdsUiToolTip('ttGas',    sdw, 200,  20,  4000, 'Gas Specific',      'Detail specific to the use of natural gas.');

  ttRateE       = new tdsUiToolTip('ttRateE',       sdw, 340, 150, 25000, 'Electric Rate',          'Enter your electric rate here.<br><br>This rate is the <b>energy</b> charge for electric usage.  It does <b>not</b> include the monthly service charge.<br><br>This rate must be entered in dollars per kilowatt hour.  On your bill, the electric rate may be expressed in cents per kilowatt hour.  If so, divide this number by 100.<br><br>Click the &quot;Reset Default Values&quot; button and 0 will be used.');
  ttRateG       = new tdsUiToolTip('ttRateG',       sdw, 340, 130, 20000, 'Gas Rate',               'Enter your gas rate here.<br><br>This rate is the <b>energy</b> charge for natural gas usage.  It does <b>not</b> include the monthly basic service fee.<br><br>This rate must be entered in dollars per decatherm.<br><br>Click the &quot;Reset Default Values&quot; button and the yearly average Questar Gas Utah residential rate as of 10/01/2011 will be used.');
  ttDuration    = new tdsUiToolTip('ttDuration',    sdw, 340, 130, 20000, 'Duration',               'Enter the duration of your hot water usage here.<br><br>The duration is the time or period in which the hot water is being used.  The default units for the duration are days.  However, for some examples of units other than days, move your mouse over the word &quot;Details.&quot;<br><br>Click the &quot;Reset Default Values&quot; button and 365 days (1 year) will be used.');
  ttUseRate     = new tdsUiToolTip('ttUseRate',     sdw, 340, 130, 25000, 'Usage Rate',             'Enter the usage rate of your hot water here.<br><br>The usage rate is the number of gallons used over the specified time.  The default units for the usage rate are gallons per day.  However, these units can be gallons per whatever units of time is used.<br><br>Click the &quot;Reset Default Values&quot; button and 64.7 gallons per day, a typical daily household usage rate, will be used.');
  ttTempFSource = new tdsUiToolTip('ttTempFSource', sdw, 340, 120, 20000, 'Source Temperature',     'Enter the source temperature of your water here.<br><br>The source temperature is the temperature of the water entering the water heater.  The units of the source temperature are degrees Fahrenheit.<br><br>Click the &quot;Reset Default Values&quot; button and 50º F, a typical average source inlet water temperature, will be used.');
  ttTempFOutlet = new tdsUiToolTip('ttTempFOutlet', sdw, 340, 120, 20000, 'Outlet Temperature',     'Enter the outlet temperature of your hot water here.<br><br>The outlet temperature is the temperature of the water leaving the water heater.  The units of the outlet temperature are degrees Fahrenheit.<br><br>Click the &quot;Reset Default Values&quot; button and 140º F, a typical outlet temperature, will be used.');
  ttEFactorE    = new tdsUiToolTip('ttEFactorE',    sdw, 340, 200, 40000, 'Electric Energy Factor', 'Enter the energy factor of your electric    water heater here.<br><br>The energy factor is an <b>efficiency ratio</b> of the energy supplied in the heated water divided by the energy input to the water heater.<br><br>The minimum energy factor is a calculation based on water heater capacity.  The minimum energy factors for electric    tank type water heaters are as follows:<br>40 Gallon: 0.92<br>50 Gallon: 0.90<br><br>Contact your manufacturer for your water heater&#145;s energy factor.<br><br>Click the &quot;Reset Default Values&quot; button and 0.92 will be used.');
  ttEFactorG    = new tdsUiToolTip('ttEFactorG',    sdw, 340, 200, 40000, 'Gas Energy Factor',      'Enter the energy factor of your natural gas water heater here.<br><br>The energy factor is an <b>efficiency ratio</b> of the energy supplied in the heated water divided by the energy input to the water heater.<br><br>The minimum energy factor is a calculation based on water heater capacity.  The minimum energy factors for natural gas tank type water heaters are as follows:<br>40 Gallon: 0.59<br>50 Gallon: 0.58<br><br>Contact your manufacturer for your water heater&#145;s energy factor.<br><br>Click the &quot;Reset Default Values&quot; button and 0.59 will be used.');

  // Objects
  w = new tdsWaterHeating();
  w.setPropertiesDefault();
  loadForm();

  // Methods Private
  function loadObject()
  {
    w.rateE = 1 * txtRateE.getValue();
    w.rateG = 1 * txtRateG.getValue();

    w.duration    = 1 * txtDuration.getValue();
    w.useRate     = 1 * txtUseRate.getValue();
    w.tempFSource = 1 * txtTempFSource.getValue();
    w.tempFOutlet = 1 * txtTempFOutlet.getValue();

    w.factorE = 1 * txtEFactorE.getValue();
    w.factorG = 1 * txtEFactorG.getValue();
  }
  
  function loadForm()
  {
    t.row[2].cell[1].setValue(round(w.conEE, 1000000));
    t.row[2].cell[2].setValue(round(w.conEG, 1000000));
    t.row[2].cell[3].setValue(round(w.costE, 100));

    t.row[3].cell[1].setValue(round(w.conGE, 1000000));
    t.row[3].cell[2].setValue(round(w.conGG, 1000000));
    t.row[3].cell[3].setValue(round(w.costG, 100));

    txtRateE.setValue(round(w.rateE, 100000000));
    txtRateG.setValue(round(w.rateG, 100000000));
   
    txtDuration.setValue   (round(w.duration, 100000000));
    txtUseRate.setValue    (round(w.useRate, 100000000));
    txtTempFSource.setValue(round(w.tempFSource, 100000000));
    txtTempFOutlet.setValue(round(w.tempFOutlet, 100000000));

    txtEFactorE.setValue(round(w.factorE, 100000000));
    txtEFactorG.setValue(round(w.factorG, 100000000));
  }

  // Methods Privileged
  me.calculate = function()
  {
    loadObject();
    w.setProperties();
    loadForm();
  }

  me.setDefault = function()
  {
    w.setPropertiesDefault();
    loadForm();
  }
}
