function formatNumber(fltNumber)
{

   strNumber = (parseInt(fltNumber)).toString();
   if (strNumber.length > 3)
   {
      switch(strNumber.length)
      {
         case 4:
            strNumber = strNumber.charAt(0) + "," + strNumber.substr(1)
            break;
         case 5:
            strNumber = strNumber.substr(0,2) + "," + strNumber.substr(2)
            break;
         case 6:
            strNumber = strNumber.substr(0,3) + "," + strNumber.substr(3)
            break;
      }
   }
   return strNumber;
}


function checkValue(docEnergy, energyName, sysType, lowCheck, highCheck)
{
   if ((docEnergy.value < lowCheck) || (docEnergy.value > highCheck)) 
   {
      alert("The " + energyName + " value for " + sysType + " systems must be between " + lowCheck + " and " + highCheck + " inclusive. Please reenter the " + energyName + " value.");
      docEnergy.focus();
      docEnergy.select();
      return true;
   }
   
}

function newWindow(Source, Name)
{
   newwin = window.open(Source, Name, 'width=375,height=400,toolbar=no,location=no,resizable=no,scrollbars=no');
   newwin.creator = top;
}

function formatCurrency(num) {
   num = num.toString().replace(/\$|\,/g,'');
   if(isNaN(num))
   num = "0";
   sign = (num == (num = Math.abs(num)));
   num = Math.floor(num*100+0.50000000001);
   cents = num%100;
   num = Math.floor(num/100).toString();
   if(cents<10)
   cents = "0" + cents;
   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
   num = num.substring(0,num.length-(4*i+3))+','+
   num.substring(num.length-(4*i+3));
   return (((sign)?'':'-') + '$' + num + '.' + cents);
}

var HSPF = new Array(4)
{
   HSPF[0] = 4.6;
   HSPF[1] = 5.4;
   HSPF[2] = 6.0;
   HSPF[3] = 6.6;
}

var newHSPF = new Array(2)
{
   newHSPF[0] = 6.8;
   newHSPF[1] = 8.0;
}

var SEER = new Array(4)
{
   SEER[0] = 6;
   SEER[1] = 7;
   SEER[2] = 8;
   SEER[3] = 9;
}

var newSEER = new Array(2)
{
   newSEER[0] = 10;
   newSEER[1] = 13;
}


var newAFUE = new Array(4)
{
   newAFUE[0] = 80;
   newAFUE[1] = 90;
}

var oldAFUE = new Array(4)
{
   oldAFUE[0] = 65;
   oldAFUE[1] = 70;
   oldAFUE[2] = 76;
   oldAFUE[3] = 78;
}


//water heating variables

var StandByLoss = new Array(4)
{
   StandByLoss[0] = new Array(3)
   {
      StandByLoss[0][0] = 575;
      StandByLoss[0][1] = 720;
      StandByLoss[0][2] = 912;
   }
   StandByLoss[1] = new Array(3)
   {
      StandByLoss[1][0] = 847;
      StandByLoss[1][1] = 1059;
      StandByLoss[1][2] = 1341;
   }
   StandByLoss[2] = new Array(3)
   {
      StandByLoss[2][0] = 1088
      StandByLoss[2][1] = 1360
      StandByLoss[2][2] = 1723
   }
   StandByLoss[3] = new Array(3)
   {
      StandByLoss[3][0] = 1398
      StandByLoss[3][1] = 1748
      StandByLoss[3][2] = 2208
   }
}

var TemperatureValue = new Array(3)
{
   TemperatureValue[0] = 115
   TemperatureValue[1] = 125
   TemperatureValue[2] = 140
}

var StandBy = new Array(4)
{
   StandBy[0] = new Array(3)
   {
      StandBy[0][0] = 17;
      StandBy[0][1] = 21;
      StandBy[0][2] = 27;
   }
   StandBy[1] = new Array(3)
   {
      StandBy[1][0] = 27;
      StandBy[1][1] = 39;
      StandBy[1][2] = 42;
   }
   StandBy[2] = new Array(3)
   {
      StandBy[2][0] = 35
      StandBy[2][1] = 43
      StandBy[2][2] = 55
   }
   StandBy[3] = new Array(3)
   {
      StandBy[3][0] = 45
      StandBy[3][1] = 56
      StandBy[3][2] = 72
   }
}

var newElectricEFF = new Array(2)
{
   newElectricEFF[0] = new Array(4)
   {
      newElectricEFF[0][0] = .93;
      newElectricEFF[0][1] = .92;
      newElectricEFF[0][2] = .88;
      newElectricEFF[0][3] = .86;
   }
   newElectricEFF[1] = new Array(4)
   {
      newElectricEFF[1][0] = .95;
      newElectricEFF[1][1] = .94;
      newElectricEFF[1][2] = .90;
      newElectricEFF[1][3] = .88;
   }
}
var newGasEFF = new Array(2)
{
   newGasEFF[0] = new Array(4)
   {
      newGasEFF[0][0] = .61;
      newGasEFF[0][1] = .59;
      newGasEFF[0][2] = .58;
      newGasEFF[0][3] = .53;
   }
   newGasEFF[1] = new Array(4)
   {
      newGasEFF[1][0] = .63;
      newGasEFF[1][1] = .61;
      newGasEFF[1][2] = .60;
      newGasEFF[1][3] = .55;
   }
   
}

var existElectricEFF = new Array(4)
{
   existElectricEFF[0] = new Array(4)
   {
      existElectricEFF[0][0] = .91;
      existElectricEFF[0][1] = .89;
      existElectricEFF[0][2] = .87;
      existElectricEFF[0][3] = .85;
   }
   existElectricEFF[1] = new Array(4)
   {
      existElectricEFF[1][0] = .90;
      existElectricEFF[1][1] = .88;
      existElectricEFF[1][2] = .86;
      existElectricEFF[1][3] = .84;
   }
   existElectricEFF[2] = new Array(4)
   {
      existElectricEFF[2][0] = .86;
      existElectricEFF[2][1] = .84;
      existElectricEFF[2][2] = .82;
      existElectricEFF[2][3] = .80;
   }
   existElectricEFF[3] = new Array(4)
   {
      existElectricEFF[3][0] = .84;
      existElectricEFF[3][1] = .82;
      existElectricEFF[3][2] = .80;
      existElectricEFF[3][3] = .78;
   }
   
}

var existGasEFF = new Array(4)
{
   existGasEFF[0] = new Array(4)
   {
      existGasEFF[0][0] = .59;
      existGasEFF[0][1] = .57;
      existGasEFF[0][2] = .55;
      existGasEFF[0][3] = .53;
   }
   existGasEFF[1] = new Array(4)
   {
      existGasEFF[1][0] = .57;
      existGasEFF[1][1] = .55;
      existGasEFF[1][2] = .53;
      existGasEFF[1][3] = .51;
   }
   existGasEFF[2] = new Array(4)
   {
      existGasEFF[2][0] = .56;
      existGasEFF[2][1] = .54;
      existGasEFF[2][2] = .52;
      existGasEFF[2][3] = .50;
   }
   existGasEFF[3] = new Array(4)
   {
      existGasEFF[3][0] = .51;
      existGasEFF[3][1] = .49;
      existGasEFF[3][2] = .47;
      existGasEFF[3][3] = .45;
   }
   
}


elecStandard = "<br />Standard electric<br />water heater<img src=\"../images/adds/electric_water_heater.jpg\" border=\"0\" />";
elecHighEff = "<br />High efficiency electric<br />water heater<br /><img src=\"../images/adds/electric_water_heater.jpg\" border=\"0\" />";
gasStandard = "<br />Standard gas<br />water heater<img src=\"../images/adds/gas_water_heater.jpg\" border=\"0\" />";
gasHighEff = "<br />High efficiency gas<br />water heater<img src=\"../images/adds/gas_water_heater.jpg\" border=\"0\" />";
vsText = "<br /><font size=\"4\">VS.</font><br />";

var imageSet = new Array(4)
{
   imageSet[0] = new Array(4)
   {
      imageSet[0][0] = elecStandard + vsText + elecStandard;
      imageSet[0][1] = elecHighEff + vsText + elecStandard;
      imageSet[0][2] = gasStandard + vsText + elecStandard;
      imageSet[0][3] = gasHighEff + vsText + elecStandard;
   }
   imageSet[1] = new Array(4)
   {
      imageSet[1][0] = elecStandard + vsText + elecHighEff;
      imageSet[1][1] = elecHighEff + vsText + elecHighEff;
      imageSet[1][2] = gasStandard + vsText + elecHighEff;
      imageSet[1][3] = gasHighEff + vsText + elecHighEff;
   }
   imageSet[2] = new Array(4)
   {
      imageSet[2][0] = elecStandard + vsText + gasStandard;
      imageSet[2][1] = elecHighEff + vsText + gasStandard;
      imageSet[2][2] = gasStandard + vsText + gasStandard;
      imageSet[2][3] = gasHighEff + vsText + gasStandard;
   }
   imageSet[3] = new Array(4)
   {
      imageSet[3][0] = elecStandard + vsText + gasHighEff;
      imageSet[3][1] = elecHighEff + vsText + gasHighEff;
      imageSet[3][2] = gasStandard + vsText + gasHighEff;
      imageSet[3][3] = gasHighEff + vsText + gasHighEff;
   }
}




