var ACCalculator = {

  ACCapacity: function(inGeoLoc,inWalls,inCeil,inFloor,inDoor,inWindows,inPeople,inKitchen,inAddedHeat,inNightUseOnly) {
    
    // Step (2) Walls
    var theWallsShadedInterior = inWalls.shaded + inWalls.interior;
    //  document.write(theWallsShadedInterior+"<br>");
    var theNorthWall=0;
    var theOtherWall=0;
    if (inWalls.frame == "unins") {
      theNorthWall = theWallsShadedInterior * 30;
      if(inNightUseOnly == "no")
	theOtherWall = inWalls.other * 60;
      else
	theOtherWall = inWalls.other * 30;
    }
    if (inWalls.frame == "ins") {
      theNorthWall = theWallsShadedInterior * 20;
      if(inNightUseOnly == "no")
        theOtherWall = inWalls.other * 30;
      else
        theOtherWall = inWalls.other * 20;
    }
    
    var theCeilFactor = 1;
    if(inCeil.height > 0)
      theCeilFactor = inCeil.height/8;
    theNorthWall *= theCeilFactor;
    theOtherWall *= theCeilFactor;
    
    //Step 3 Ceilings
    var theCeilHeat=0;
    if(inNightUseOnly=="no") {
      if (inCeil.type == "unins")
	theCeilHeat=inCeil.area * 19;
      if (inCeil.type == "unat")
	theCeilHeat=inCeil.area * 12;
      if (inCeil.type == "inso")
	theCeilHeat=inCeil.area * 8;
      if (inCeil.type == "insat")
	theCeilHeat=inCeil.area * 5;
      if (inCeil.type == "occ")
	theCeilHeat=inCeil.area * 3;
    }
    if(inNightUseOnly=="yes") {
      if (inCeil.type == "unins")
        theCeilHeat=inCeil.area * 5;
      if (inCeil.type == "unat")
        theCeilHeat=inCeil.area * 7;
      if (inCeil.type == "inso")
        theCeilHeat=inCeil.area * 3;
      if (inCeil.type == "insat")
        theCeilHeat=inCeil.area * 4;
      if (inCeil.type == "occ")
        theCeilHeat=inCeil.area * 3;
    }
    
    //Step (4) DOORS/ARCHES
    var theDoorWidth=0;
   if(inDoor > 0) {
     if(inNightUseOnly=="no")
       theDoorWidth=inDoor * 300;
     if(inNightUseOnly=="yes")
       theDoorWidth=inDoor * 200;
   }
    
    //Step (5) FLOOR
    var theFloorArea=0;
    if(inFloor > 0)
      theFloorArea=inFloor * 3;
    
    // Step (6a) Windows Heat
    var theSingleWinArea = 0;
    var theDoubleWinArea = 0;
    for (var theWin in inWindows) {
      if (inWindows[theWin].glass == "single") 
	theSingleWinArea += inWindows[theWin].area;
      if (inWindows[theWin].glass == "double" || inWindows[theWin].glass == "block")
	theDoubleWinArea += inWindows[theWin].area;
    }
    var theSingleWinHeat = theSingleWinArea * 14;
    var theDoubleWinHeat = theDoubleWinArea * 7;
    
    // Step (6b) SUN THROUGH WINDOW
    //todo: these would be better implemented using a hash table of multiplicative factors
    var theWindows= new Object;
    theWindows.NE={area:0};
    theWindows.E= {area:0};
    theWindows.SE= {area:0};
    theWindows.S= {area:0};
    theWindows.SW= {area:0};
    theWindows.W= {area:0};
    theWindows.NW= {area:0};
    
    if(inWindows.NE) {
      if(inWindows.NE.shades == "nosh")
	theWindows.NE.area=inWindows.NE.area * 60;
      if(inWindows.NE.shades == "insh")
	theWindows.NE.area=inWindows.NE.area * 25;
      if(inWindows.NE.shades == "awn")
	theWindows.NE.area=inWindows.NE.area * 20;
      
      if(inWindows.NE.glass == "block")
	theWindows.NE.area=theWindows.NE.area * .5;
      if(inWindows.NE.glass == "double")
	theWindows.NE.area=theWindows.NE.area * .8;
      if(inWindows.NE.glass == "single")
	theWindows.NE.area=theWindows.NE.area * 1;
    }
    
    if(inWindows.E) {
      if(inWindows.E.shades == "nosh")
        theWindows.E.area=inWindows.E.area * 80;
      if(inWindows.E.shades == "insh")
        theWindows.E.area=inWindows.E.area * 40;
      if(inWindows.E.shades == "awn")
        theWindows.E.area=inWindows.E.area * 25;
      
      if(inWindows.E.glass == "block")
        theWindows.E.area=theWindows.E.area * .5;
      if(inWindows.E.glass == "double")
        theWindows.E.area=theWindows.E.area * .8;
      if(inWindows.E.glass == "single")
        theWindows.E.area=theWindows.E.area * 1;
    }
    
    if(inWindows.SE) {
      if(inWindows.SE.shades == "nosh")
        theWindows.SE.area=inWindows.SE.area * 75;
      if(inWindows.SE.shades == "insh")
        theWindows.SE.area=inWindows.SE.area * 30;
      if(inWindows.SE.shades == "awn")
        theWindows.SE.area=inWindows.SE.area * 20;

      if(inWindows.SE.glass == "block")
        theWindows.SE.area=theWindows.SE.area * .5;
      if(inWindows.SE.glass == "double")
        theWindows.SE.area=theWindows.SE.area * .8;
      if(inWindows.SE.glass == "single")
        theWindows.SE.area=theWindows.SE.area * 1;
    }
    
    if(inWindows.S) {
      if(inWindows.S.shades == "nosh")
      theWindows.S.area=inWindows.S.area * 75;
      if(inWindows.S.shades == "insh")
      theWindows.S.area=inWindows.S.area * 35;
      if(inWindows.S.shades == "awn")
      theWindows.S.area=inWindows.S.area * 20;
      
      if(inWindows.S.glass == "block")
     theWindows.S.area=theWindows.S.area * .5;
      if(inWindows.S.glass == "double")
     theWindows.S.area=theWindows.S.area * .8;
      if(inWindows.S.glass == "single")
      theWindows.S.area=theWindows.S.area * 1;
    }
    
    if(inWindows.SW) {
      if(inWindows.SW.shades == "nosh")
      theWindows.SW.area=inWindows.SW.area * 110;
      if(inWindows.SW.shades == "insh")
      theWindows.SW.area=inWindows.SW.area * 45;
      if(inWindows.SW.shades == "awn")
      theWindows.SW.area=inWindows.SW.area * 30;

      if(inWindows.SW.glass == "block")
      theWindows.SW.area=theWindows.SW.area * .5;
      if(inWindows.SW.glass == "double")
      theWindows.SW.area=theWindows.SW.area * .8;
      if(inWindows.SW.glass == "single")
      theWindows.SW.area=theWindows.SW.area * 1;
    }
    
    if(inWindows.W) {
      if(inWindows.W.shades == "nosh")
        theWindows.W.area=inWindows.W.area * 150;
      if(inWindows.W.shades == "insh")
        theWindows.W.area=inWindows.W.area * 65;
      if(inWindows.W.shades == "awn")
        theWindows.W.area=inWindows.W.area * 45;
      
      if(inWindows.W.glass == "block")
        theWindows.W.area=theWindows.W.area * .5;
      if(inWindows.W.glass == "double")
        theWindows.W.area=theWindows.W.area * .8;
      if(inWindows.W.glass == "single")
        theWindows.W.area=theWindows.W.area * 1;
    }
    
    if(inWindows.NW) {
      if(inWindows.NW.shades == "nosh")
        theWindows.NW.area=inWindows.NW.area * 120;
      if(inWindows.NW.shades == "insh")
        theWindows.NW.area=inWindows.NW.area * 50;
      if(inWindows.NW.shades == "awn")
        theWindows.NW.area=inWindows.NW.area * 35;
      
      if(inWindows.NW.glass == "block")
        theWindows.NW.area=theWindows.NW.area * .5;
      if(inWindows.NW.glass == "double")
        theWindows.NW.area=theWindows.NW.area * .8;
      if(inWindows.NW.glass == "single")
        theWindows.NW.area=theWindows.NW.area * 1;
    }
    
    
    var theSunHeat=0;
    for (theWin in theWindows) {
      if (theWindows[theWin].area > theSunHeat)
	theSunHeat=theWindows[theWin].area;
    }
    if(inNightUseOnly=="yes")
      theSunHeat=0;


   //Subtotals
   var theSubTotal = theNorthWall+theOtherWall+theCeilHeat+theDoorWidth+theFloorArea+theSingleWinHeat+theDoubleWinHeat+theSunHeat;
  // document.write(theNorthWall+":"+theOtherWall+":"+theCeilHeat+":"+theDoorWidth+": "+theFloorArea+": "+theSingleWinHeat+" double "+theDoubleWinHeat+" "+theSunHeat);
    
    //Step (1) Geographical Location Climate Correction
    var theCorrectionFactor = 1.00;
    var theAnnualHours = 1000;

    if (inGeoLoc == 'albirm') { theCorrectionFactor = 1.03; theAnnualHours = 997; }
    else if (inGeoLoc == 'alente') { theCorrectionFactor = 0.97; theAnnualHours = 1092; }
    else if (inGeoLoc == 'alhunt') { theCorrectionFactor = 1.00; theAnnualHours = 957; }
    else if (inGeoLoc == 'almont') { theCorrectionFactor = 1.03; theAnnualHours = 1162; }
    else if (inGeoLoc == 'azflag') { theCorrectionFactor = 0.66; theAnnualHours = 151; }
    else if (inGeoLoc == 'azhuac') { theCorrectionFactor = 1.00; theAnnualHours = 816; }
    else if (inGeoLoc == 'azphoe') { theCorrectionFactor = 1.59; theAnnualHours = 1648; }
    else if (inGeoLoc == 'aztucs') { theCorrectionFactor = 1.31; theAnnualHours = 1447; }
    else if (inGeoLoc == 'azwins') { theCorrectionFactor = 1.07; theAnnualHours = 826; }
    else if (inGeoLoc == 'azyuma') { theCorrectionFactor = 1.69; theAnnualHours = 1881; }
    else if (inGeoLoc == 'arblyt') { theCorrectionFactor = 1.03; theAnnualHours = 874; }
    else if (inGeoLoc == 'arfsmi') { theCorrectionFactor = 1.22; theAnnualHours = 978; }
    else if (inGeoLoc == 'arlroc') { theCorrectionFactor = 1.03; theAnnualHours = 1009; }
    else if (inGeoLoc == 'caalam') { theCorrectionFactor = 0.66; theAnnualHours = 84; }
    else if (inGeoLoc == 'cabish') { theCorrectionFactor = 1.26; theAnnualHours = 1059; }
    else if (inGeoLoc == 'caedwa') { theCorrectionFactor = 1.35; theAnnualHours = 952; }
    else if (inGeoLoc == 'cafair') { theCorrectionFactor = 1.15; theAnnualHours = 454; }
    else if (inGeoLoc == 'calosa') { theCorrectionFactor = 0.63; theAnnualHours = 122; }
    else if (inGeoLoc == 'camerc') { theCorrectionFactor = 1.26; theAnnualHours = 831; }
    else if (inGeoLoc == 'camont') { theCorrectionFactor = 0.42; theAnnualHours = 19; }
    else if (inGeoLoc == 'canova') { theCorrectionFactor = 0.69; theAnnualHours = 184; }
    else if (inGeoLoc == 'casacr') { theCorrectionFactor = 1.22; theAnnualHours = 724; }
    else if (inGeoLoc == 'casber') { theCorrectionFactor = 1.26; theAnnualHours = 837; }
    else if (inGeoLoc == 'casdie') { theCorrectionFactor = 0.57; theAnnualHours = 69; }
    else if (inGeoLoc == 'casjos') { theCorrectionFactor = 0.69; theAnnualHours = 102; }
    else if (inGeoLoc == 'cayuba') { theCorrectionFactor = 1.35; theAnnualHours = 827; }
    else if (inGeoLoc == 'cocolo') { theCorrectionFactor = 0.87; theAnnualHours = 381; }
    else if (inGeoLoc == 'codenv') { theCorrectionFactor = 0.90; theAnnualHours = 412; }
    else if (inGeoLoc == 'cogjun') { theCorrectionFactor = 1.03; theAnnualHours = 684; }
    else if (inGeoLoc == 'copueb') { theCorrectionFactor = 1.07; theAnnualHours = 668; }
    else if (inGeoLoc == 'cotrin') { theCorrectionFactor = 0.93; theAnnualHours = 554; }
    else if (inGeoLoc == 'cnhart') { theCorrectionFactor = 0.80; theAnnualHours = 250; }
    else if (inGeoLoc == 'dcwash') { theCorrectionFactor = 0.90; theAnnualHours = 560; }
    else if (inGeoLoc == 'dedove') { theCorrectionFactor = 0.90; theAnnualHours = 487; }
    else if (inGeoLoc == 'dewilm') { theCorrectionFactor = 0.90; theAnnualHours = 484; }
    else if (inGeoLoc == 'flfmye') { theCorrectionFactor = 0.93; theAnnualHours = 1775; }
    else if (inGeoLoc == 'flfwal') { theCorrectionFactor = 0.93; theAnnualHours = 1321; }
    else if (inGeoLoc == 'fljack') { theCorrectionFactor = 1.00; theAnnualHours = 1198; }
    else if (inGeoLoc == 'flkeyw') { theCorrectionFactor = 0.84; theAnnualHours = 2879; }
    else if (inGeoLoc == 'flmelb') { theCorrectionFactor = 0.84; theAnnualHours = 1644; }
    else if (inGeoLoc == 'flmiab') { theCorrectionFactor = 0.84; theAnnualHours = 2031; }
    else if (inGeoLoc == 'florla') { theCorrectionFactor = 0.97; theAnnualHours = 1404; }
    else if (inGeoLoc == 'flpana') { theCorrectionFactor = 0.84; theAnnualHours = 1424; }
    else if (inGeoLoc == 'flpens') { theCorrectionFactor = 0.90; theAnnualHours = 1433; }
    else if (inGeoLoc == 'fltamp') { theCorrectionFactor = 0.90; theAnnualHours = 1677; }
    else if (inGeoLoc == 'gaalba') { theCorrectionFactor = 1.07; theAnnualHours = 1204; }
    else if (inGeoLoc == 'gaatla') { theCorrectionFactor = 0.97; theAnnualHours = 802; }
    else if (inGeoLoc == 'gaaugu') { theCorrectionFactor = 1.07; theAnnualHours = 1023; }
    else if (inGeoLoc == 'gabrun') { theCorrectionFactor = 0.93; theAnnualHours = 1045; }
    else if (inGeoLoc == 'gacolu') { theCorrectionFactor = 1.00; theAnnualHours = 977; }
    else if (inGeoLoc == 'gamaco') { theCorrectionFactor = 1.11; theAnnualHours = 1008; }
    else if (inGeoLoc == 'gasava') { theCorrectionFactor = 0.93; theAnnualHours = 1093; }
    else if (inGeoLoc == 'gavald') { theCorrectionFactor = 1.03; theAnnualHours = 1165; }
    else if (inGeoLoc == 'idbois') { theCorrectionFactor = 1.03; theAnnualHours = 526; }
    else if (inGeoLoc == 'ididaf') { theCorrectionFactor = 0.81; theAnnualHours = 288; }
    else if (inGeoLoc == 'idlewi') { theCorrectionFactor = 1.03; theAnnualHours = 446; }
    else if (inGeoLoc == 'idmoun') { theCorrectionFactor = 1.15; theAnnualHours = 601; }
    else if (inGeoLoc == 'idpoca') { theCorrectionFactor = 0.97; theAnnualHours = 445; }
    else if (inGeoLoc == 'ilarli') { theCorrectionFactor = 0.90; theAnnualHours = 415; }
    else if (inGeoLoc == 'ilbell') { theCorrectionFactor = 0.97; theAnnualHours = 686; }
    else if (inGeoLoc == 'ilcham') { theCorrectionFactor = 1.00; theAnnualHours = 481; }
    else if (inGeoLoc == 'ilchic') { theCorrectionFactor = 0.87; theAnnualHours = 426; }
    else if (inGeoLoc == 'ilmoli') { theCorrectionFactor = 0.93; theAnnualHours = 529; }
    else if (inGeoLoc == 'ilspri') { theCorrectionFactor = 0.97; theAnnualHours = 651; }
    else if (inGeoLoc == 'inclar') { theCorrectionFactor = 0.97; theAnnualHours = 730; }
    else if (inGeoLoc == 'incolu') { theCorrectionFactor = 1.00; theAnnualHours = 602; }
    else if (inGeoLoc == 'inevan') { theCorrectionFactor = 1.00; theAnnualHours = 782; }
    else if (inGeoLoc == 'infway') { theCorrectionFactor = 0.90; theAnnualHours = 491; }
    else if (inGeoLoc == 'inindi') { theCorrectionFactor = 0.90; theAnnualHours = 548; }
    else if (inGeoLoc == 'inkoko') { theCorrectionFactor = 0.87; theAnnualHours = 446; }
    else if (inGeoLoc == 'insben') { theCorrectionFactor = 0.87; theAnnualHours = 413; }
    else if (inGeoLoc == 'interr') { theCorrectionFactor = 1.00; theAnnualHours = 566; }
    else if (inGeoLoc == 'iadesm') { theCorrectionFactor = 0.97; theAnnualHours = 493; }
    else if (inGeoLoc == 'iamaso') { theCorrectionFactor = 0.84; theAnnualHours = 374; }
    else if (inGeoLoc == 'iasiou') { theCorrectionFactor = 1.00; theAnnualHours = 527; }
    else if (inGeoLoc == 'ksdodg') { theCorrectionFactor = 1.18; theAnnualHours = 758; }
    else if (inGeoLoc == 'ksfril') { theCorrectionFactor = 1.15; theAnnualHours = 707; }
    else if (inGeoLoc == 'ksgood') { theCorrectionFactor = 1.15; theAnnualHours = 599; }
    else if (inGeoLoc == 'kskans') { theCorrectionFactor = 1.15; theAnnualHours = 809; }
    else if (inGeoLoc == 'kstope') { theCorrectionFactor = 1.03; theAnnualHours = 631; }
    else if (inGeoLoc == 'kswich') { theCorrectionFactor = 1.18; theAnnualHours = 723; }
    else if (inGeoLoc == 'kycovi') { theCorrectionFactor = 0.90; theAnnualHours = 593; }
    else if (inGeoLoc == 'kyeliz') { theCorrectionFactor = 0.90; theAnnualHours = 641; }
    else if (inGeoLoc == 'kyloui') { theCorrectionFactor = 1.00; theAnnualHours = 752; }
    else if (inGeoLoc == 'laalex') { theCorrectionFactor = 1.00; theAnnualHours = 1210; }
    else if (inGeoLoc == 'lalcha') { theCorrectionFactor = 1.00; theAnnualHours = 1285; }
    else if (inGeoLoc == 'lanorl') { theCorrectionFactor = 0.93; theAnnualHours = 1244; }
    else if (inGeoLoc == 'lashre') { theCorrectionFactor = 1.15; theAnnualHours = 1113; }
    else if (inGeoLoc == 'mebang') { theCorrectionFactor = 0.72; theAnnualHours = 154; }
    else if (inGeoLoc == 'mebrun') { theCorrectionFactor = 0.69; theAnnualHours = 106; }
    else if (inGeoLoc == 'mecari') { theCorrectionFactor = 0.66; theAnnualHours = 79; }
    else if (inGeoLoc == 'meport') { theCorrectionFactor = 0.74; theAnnualHours = 179; }
    else if (inGeoLoc == 'mepres') { theCorrectionFactor = 0.66; theAnnualHours = 143; }
    else if (inGeoLoc == 'mdbalt') { theCorrectionFactor = 0.90; theAnnualHours = 588; }
    else if (inGeoLoc == 'mdlexi') { theCorrectionFactor = 0.90; theAnnualHours = 577; }
    else if (inGeoLoc == 'mabost') { theCorrectionFactor = 0.87; theAnnualHours = 305; }
    else if (inGeoLoc == 'mafalm') { theCorrectionFactor = 0.66; theAnnualHours = 124; }
    else if (inGeoLoc == 'maspri') { theCorrectionFactor = 0.90; theAnnualHours = 315; }
    else if (inGeoLoc == 'miausa') { theCorrectionFactor = 0.77; theAnnualHours = 191; }
    else if (inGeoLoc == 'mibatt') { theCorrectionFactor = 0.90; theAnnualHours = 381; }
    else if (inGeoLoc == 'midetr') { theCorrectionFactor = 0.87; theAnnualHours = 313; }
    else if (inGeoLoc == 'milans') { theCorrectionFactor = 0.84; theAnnualHours = 315; }
    else if (inGeoLoc == 'mimarq') { theCorrectionFactor = 0.66; theAnnualHours = 134; }
    else if (inGeoLoc == 'mimusk') { theCorrectionFactor = 0.72; theAnnualHours = 228; }
    else if (inGeoLoc == 'misaul') { theCorrectionFactor = 0.66; theAnnualHours = 99; }
    else if (inGeoLoc == 'mitrav') { theCorrectionFactor = 0.81; theAnnualHours = 242; }
    else if (inGeoLoc == 'mndulu') { theCorrectionFactor = 0.69; theAnnualHours = 119; }
    else if (inGeoLoc == 'mninte') { theCorrectionFactor = 0.69; theAnnualHours = 150; }
    else if (inGeoLoc == 'mnminn') { theCorrectionFactor = 0.90; theAnnualHours = 357; }
    else if (inGeoLoc == 'mnsclo') { theCorrectionFactor = 0.87; theAnnualHours = 247; }
    else if (inGeoLoc == 'msbilo') { theCorrectionFactor = 0.97; theAnnualHours = 1501; }
    else if (inGeoLoc == 'mscolu') { theCorrectionFactor = 1.00; theAnnualHours = 1026; }
    else if (inGeoLoc == 'msgree') { theCorrectionFactor = 1.00; theAnnualHours = 1273; }
    else if (inGeoLoc == 'msjack') { theCorrectionFactor = 1.03; theAnnualHours = 1130; }
    else if (inGeoLoc == 'msmeri') { theCorrectionFactor = 1.07; theAnnualHours = 1021; }
    else if (inGeoLoc == 'mocolu') { theCorrectionFactor = 1.07; theAnnualHours = 686; }
    else if (inGeoLoc == 'mofleo') { theCorrectionFactor = 0.97; theAnnualHours = 602; }
    else if (inGeoLoc == 'mokans') { theCorrectionFactor = 1.15; theAnnualHours = 809; }
    else if (inGeoLoc == 'moroll') { theCorrectionFactor = 0.97; theAnnualHours = 698; }
    else if (inGeoLoc == 'mospri') { theCorrectionFactor = 1.03; theAnnualHours = 687; }
    else if (inGeoLoc == 'moslou') { theCorrectionFactor = 1.07; theAnnualHours = 757; }
    else if (inGeoLoc == 'mtbill') { theCorrectionFactor = 0.97; theAnnualHours = 391; }
    else if (inGeoLoc == 'mtcutb') { theCorrectionFactor = 0.77; theAnnualHours = 199; }
    else if (inGeoLoc == 'mtglas') { theCorrectionFactor = 0.90; theAnnualHours = 276; }
    else if (inGeoLoc == 'mtgrea') { theCorrectionFactor = 0.87; theAnnualHours = 309; }
    else if (inGeoLoc == 'mthele') { theCorrectionFactor = 0.87; theAnnualHours = 253; }
    else if (inGeoLoc == 'mtmiss') { theCorrectionFactor = 0.90; theAnnualHours = 263; }
    else if (inGeoLoc == 'negran') { theCorrectionFactor = 1.07; theAnnualHours = 561; }
    else if (inGeoLoc == 'nenort') { theCorrectionFactor = 1.07; theAnnualHours = 502; }
    else if (inGeoLoc == 'neomah') { theCorrectionFactor = 0.97; theAnnualHours = 527; }
    else if (inGeoLoc == 'nescot') { theCorrectionFactor = 1.00; theAnnualHours = 485; }
    else if (inGeoLoc == 'nvelyy') { theCorrectionFactor = 0.81; theAnnualHours = 374; }
    else if (inGeoLoc == 'nvfall') { theCorrectionFactor = 1.11; theAnnualHours = 679; }
    else if (inGeoLoc == 'nvlasv') { theCorrectionFactor = 1.64; theAnnualHours = 1439; }
    else if (inGeoLoc == 'nvreno') { theCorrectionFactor = 0.87; theAnnualHours = 407; }
    else if (inGeoLoc == 'nvtono') { theCorrectionFactor = 0.97; theAnnualHours = 632; }
    else if (inGeoLoc == 'nvwinn') { theCorrectionFactor = 1.03; theAnnualHours = 634; }
    else if (inGeoLoc == 'nhmanc') { theCorrectionFactor = 0.87; theAnnualHours = 345; }
    else if (inGeoLoc == 'nhport') { theCorrectionFactor = 0.81; theAnnualHours = 235; }
    else if (inGeoLoc == 'njnewa') { theCorrectionFactor = 0.97; theAnnualHours = 471; }
    else if (inGeoLoc == 'njtren') { theCorrectionFactor = 0.87; theAnnualHours = 463; }
    else if (inGeoLoc == 'nmalam') { theCorrectionFactor = 1.11; theAnnualHours = 1014; }
    else if (inGeoLoc == 'nmalbu') { theCorrectionFactor = 1.03; theAnnualHours = 790; }
    else if (inGeoLoc == 'nmclay') { theCorrectionFactor = 1.00; theAnnualHours = 511; }
    else if (inGeoLoc == 'nmclov') { theCorrectionFactor = 1.00; theAnnualHours = 723; }
    else if (inGeoLoc == 'nmfarm') { theCorrectionFactor = 1.00; theAnnualHours = 676; }
    else if (inGeoLoc == 'nmrosw') { theCorrectionFactor = 1.18; theAnnualHours = 1069; }
    else if (inGeoLoc == 'nmsilv') { theCorrectionFactor = 1.00; theAnnualHours = 926; }
    else if (inGeoLoc == 'nmzuni') { theCorrectionFactor = 0.84; theAnnualHours = 496; }
    else if (inGeoLoc == 'nyalba') { theCorrectionFactor = 0.87; theAnnualHours = 319; }
    else if (inGeoLoc == 'nybing') { theCorrectionFactor = 0.72; theAnnualHours = 175; }
    else if (inGeoLoc == 'nynyor') { theCorrectionFactor = 0.90; theAnnualHours = 432; }
    else if (inGeoLoc == 'nynewb') { theCorrectionFactor = 0.84; theAnnualHours = 366; }
    else if (inGeoLoc == 'nyniag') { theCorrectionFactor = 0.81; theAnnualHours = 283; }
    else if (inGeoLoc == 'nyplat') { theCorrectionFactor = 0.72; theAnnualHours = 144; }
    else if (inGeoLoc == 'nyrome') { theCorrectionFactor = 0.77; theAnnualHours = 258; }
    else if (inGeoLoc == 'nysyra') { theCorrectionFactor = 0.84; theAnnualHours = 324; }
    else if (inGeoLoc == 'nywham') { theCorrectionFactor = 0.72; theAnnualHours = 152; }
    else if (inGeoLoc == 'nccher') { theCorrectionFactor = 0.90; theAnnualHours = 796; }
    else if (inGeoLoc == 'nceliz') { theCorrectionFactor = 0.93; theAnnualHours = 721; }
    else if (inGeoLoc == 'ncfaye') { theCorrectionFactor = 0.97; theAnnualHours = 868; }
    else if (inGeoLoc == 'ncgold') { theCorrectionFactor = 0.97; theAnnualHours = 801; }
    else if (inGeoLoc == 'ncgree') { theCorrectionFactor = 0.93; theAnnualHours = 667; }
    else if (inGeoLoc == 'ndbism') { theCorrectionFactor = 1.00; theAnnualHours = 354; }
    else if (inGeoLoc == 'ndgfor') { theCorrectionFactor = 0.87; theAnnualHours = 263; }
    else if (inGeoLoc == 'ndmino') { theCorrectionFactor = 0.90; theAnnualHours = 293; }
    else if (inGeoLoc == 'ndwill') { theCorrectionFactor = 0.87; theAnnualHours = 442; }
    else if (inGeoLoc == 'ohakro') { theCorrectionFactor = 0.81; theAnnualHours = 319; }
    else if (inGeoLoc == 'ohcinc') { theCorrectionFactor = 0.90; theAnnualHours = 570; }
    else if (inGeoLoc == 'ohdayt') { theCorrectionFactor = 0.87; theAnnualHours = 527; }
    else if (inGeoLoc == 'ohtole') { theCorrectionFactor = 0.84; theAnnualHours = 402; }
    else if (inGeoLoc == 'okaltu') { theCorrectionFactor = 1.26; theAnnualHours = 1092; }
    else if (inGeoLoc == 'okclin') { theCorrectionFactor = 1.18; theAnnualHours = 875; }
    else if (inGeoLoc == 'okenid') { theCorrectionFactor = 1.31; theAnnualHours = 937; }
    else if (inGeoLoc == 'oklawt') { theCorrectionFactor = 1.22; theAnnualHours = 1038; }
    else if (inGeoLoc == 'okokla') { theCorrectionFactor = 1.18; theAnnualHours = 859; }
    else if (inGeoLoc == 'oktuls') { theCorrectionFactor = 1.22; theAnnualHours = 1009; }
    else if (inGeoLoc == 'orburn') { theCorrectionFactor = 0.87; theAnnualHours = 296; }
    else if (inGeoLoc == 'oreuge') { theCorrectionFactor = 0.90; theAnnualHours = 262; }
    else if (inGeoLoc == 'orklam') { theCorrectionFactor = 0.84; theAnnualHours = 316; }
    else if (inGeoLoc == 'ormedf') { theCorrectionFactor = 1.11; theAnnualHours = 456; }
    else if (inGeoLoc == 'orpend') { theCorrectionFactor = 1.07; theAnnualHours = 420; }
    else if (inGeoLoc == 'orport') { theCorrectionFactor = 0.81; theAnnualHours = 174; }
    else if (inGeoLoc == 'paharr') { theCorrectionFactor = 0.97; theAnnualHours = 503; }
    else if (inGeoLoc == 'paphil') { theCorrectionFactor = 0.93; theAnnualHours = 514; }
    else if (inGeoLoc == 'papitt') { theCorrectionFactor = 0.81; theAnnualHours = 371; }
    else if (inGeoLoc == 'pascra') { theCorrectionFactor = 0.84; theAnnualHours = 318; }
    else if (inGeoLoc == 'pawill') { theCorrectionFactor = 0.90; theAnnualHours = 396; }
    else if (inGeoLoc == 'riprov') { theCorrectionFactor = 0.81; theAnnualHours = 237; }
    else if (inGeoLoc == 'scchar') { theCorrectionFactor = 0.93; theAnnualHours = 950; }
    else if (inGeoLoc == 'scgree') { theCorrectionFactor = 0.93; theAnnualHours = 800; }
    else if (inGeoLoc == 'scmyrt') { theCorrectionFactor = 0.87; theAnnualHours = 873; }
    else if (inGeoLoc == 'scsumt') { theCorrectionFactor = 1.00; theAnnualHours = 931; }
    else if (inGeoLoc == 'sdhuro') { theCorrectionFactor = 1.03; theAnnualHours = 460; }
    else if (inGeoLoc == 'sdrapi') { theCorrectionFactor = 1.07; theAnnualHours = 408; }
    else if (inGeoLoc == 'sdsiou') { theCorrectionFactor = 0.97; theAnnualHours = 436; }
    else if (inGeoLoc == 'tnbris') { theCorrectionFactor = 0.87; theAnnualHours = 598; }
    else if (inGeoLoc == 'tnknox') { theCorrectionFactor = 0.97; theAnnualHours = 767; }
    else if (inGeoLoc == 'tnmemp') { theCorrectionFactor = 1.00; theAnnualHours = 974; }
    else if (inGeoLoc == 'tnmurf') { theCorrectionFactor = 1.07; theAnnualHours = 795; }
    else if (inGeoLoc == 'txabil') { theCorrectionFactor = 1.22; theAnnualHours = 1165; }
    else if (inGeoLoc == 'txamar') { theCorrectionFactor = 1.11; theAnnualHours = 820; }
    else if (inGeoLoc == 'txaust') { theCorrectionFactor = 1.15; theAnnualHours = 1375; }
    else if (inGeoLoc == 'txbspr') { theCorrectionFactor = 1.18; theAnnualHours = 1151; }
    else if (inGeoLoc == 'txbrow') { theCorrectionFactor = 0.97; theAnnualHours = 1991; }
    else if (inGeoLoc == 'txbrya') { theCorrectionFactor = 1.11; theAnnualHours = 1538; }
    else if (inGeoLoc == 'txcorp') { theCorrectionFactor = 0.90; theAnnualHours = 2150; }
    else if (inGeoLoc == 'txdall') { theCorrectionFactor = 1.26; theAnnualHours = 1374; }
    else if (inGeoLoc == 'txdelr') { theCorrectionFactor = 1.18; theAnnualHours = 1680; }
    else if (inGeoLoc == 'txelpa') { theCorrectionFactor = 1.18; theAnnualHours = 1204; }
    else if (inGeoLoc == 'txfwor') { theCorrectionFactor = 1.22; theAnnualHours = 1290; }
    else if (inGeoLoc == 'txharl') { theCorrectionFactor = 1.03; theAnnualHours = 1961; }
    else if (inGeoLoc == 'txhous') { theCorrectionFactor = 1.03; theAnnualHours = 1308; }
    else if (inGeoLoc == 'txlare') { theCorrectionFactor = 1.26; theAnnualHours = 2039; }
    else if (inGeoLoc == 'txlubb') { theCorrectionFactor = 1.11; theAnnualHours = 926; }
    else if (inGeoLoc == 'txmarf') { theCorrectionFactor = 1.00; theAnnualHours = 795; }
    else if (inGeoLoc == 'txmidl') { theCorrectionFactor = 1.18; theAnnualHours = 1240; }
    else if (inGeoLoc == 'txsang') { theCorrectionFactor = 1.22; theAnnualHours = 1493; }
    else if (inGeoLoc == 'txsant') { theCorrectionFactor = 1.15; theAnnualHours = 1351; }
    else if (inGeoLoc == 'txsher') { theCorrectionFactor = 1.18; theAnnualHours = 1108; }
    else if (inGeoLoc == 'txtemp') { theCorrectionFactor = 1.18; theAnnualHours = 1232; }
    else if (inGeoLoc == 'txvict') { theCorrectionFactor = 1.11; theAnnualHours = 1761; }
    else if (inGeoLoc == 'txwaco') { theCorrectionFactor = 1.22; theAnnualHours = 1399; }
    else if (inGeoLoc == 'txwich') { theCorrectionFactor = 1.31; theAnnualHours = 1264; }
    else if (inGeoLoc == 'utceda') { theCorrectionFactor = 0.93; theAnnualHours = 593; }
    else if (inGeoLoc == 'utdugw') { theCorrectionFactor = 1.15; theAnnualHours = 756; }
    else if (inGeoLoc == 'utmilf') { theCorrectionFactor = 1.00; theAnnualHours = 748; }
    else if (inGeoLoc == 'utogde') { theCorrectionFactor = 0.93; theAnnualHours = 543; }
    else if (inGeoLoc == 'utwend') { theCorrectionFactor = 1.07; theAnnualHours = 709; }
    else if (inGeoLoc == 'vtburl') { theCorrectionFactor = 0.77; theAnnualHours = 216; }
    else if (inGeoLoc == 'vaalex') { theCorrectionFactor = 0.90; theAnnualHours = 607; }
    else if (inGeoLoc == 'vablac') { theCorrectionFactor = 0.97; theAnnualHours = 681; }
    else if (inGeoLoc == 'vanorf') { theCorrectionFactor = 0.93; theAnnualHours = 614; }
    else if (inGeoLoc == 'varich') { theCorrectionFactor = 1.00; theAnnualHours = 693; }
    else if (inGeoLoc == 'varoan') { theCorrectionFactor = 0.93; theAnnualHours = 617; }
    else if (inGeoLoc == 'waever') { theCorrectionFactor = 0.55; theAnnualHours = 40; }
    else if (inGeoLoc == 'wamose') { theCorrectionFactor = 1.07; theAnnualHours = 464; }
    else if (inGeoLoc == 'waseat') { theCorrectionFactor = 0.69; theAnnualHours = 105; }
    else if (inGeoLoc == 'waspok') { theCorrectionFactor = 0.93; theAnnualHours = 311; }
    else if (inGeoLoc == 'wataco') { theCorrectionFactor = 0.72; theAnnualHours = 115; }
    else if (inGeoLoc == 'wvchar') { theCorrectionFactor = 0.90; theAnnualHours = 589; }
    else if (inGeoLoc == 'wvelki') { theCorrectionFactor = 0.72; theAnnualHours = 265; }
    else if (inGeoLoc == 'wvhunt') { theCorrectionFactor = 0.97; theAnnualHours = 593; }
    else if (inGeoLoc == 'wigree') { theCorrectionFactor = 0.77; theAnnualHours = 235; }
    else if (inGeoLoc == 'wilacr') { theCorrectionFactor = 0.87; theAnnualHours = 348; }
    else if (inGeoLoc == 'wimadi') { theCorrectionFactor = 0.87; theAnnualHours = 360; }
    else if (inGeoLoc == 'wycasp') { theCorrectionFactor = 0.90; theAnnualHours = 427; }
    else if (inGeoLoc == 'wychey') { theCorrectionFactor = 0.81; theAnnualHours = 285; }
    else if (inGeoLoc == 'wyland') { theCorrectionFactor = 0.87; theAnnualHours = 232; }
    else if (inGeoLoc == 'wyrspr') { theCorrectionFactor = 0.72; theAnnualHours = 222; }
    else if (inGeoLoc == 'wysher') { theCorrectionFactor = 0.97; theAnnualHours = 406; }
    
    theSubTotal*=theCorrectionFactor;
    
    //Step (7) Heat from people
    var thePeopleHeat = inPeople * 600;
    
    //Step (8/9) Heat from appliances/kitchen
    var theAddedHeat=inAddedHeat*3;
    if(inKitchen=="yes")
      theAddedHeat=4000;
    
    //TOTAL COOLING LOAD (to the nearest 100)
    var theTotalLoad = theSubTotal+thePeopleHeat+theAddedHeat;
    var theTotalLoadErr = ACCalculator.ACCapacityError(theTotalLoad);
    
    var theCapacity = {
      load : theTotalLoad,
      loadError : theTotalLoadErr,
      annualHours : theAnnualHours
    }
    return theCapacity;
  },
  
  ACCost: function(inCapacity, inRate, inAnnualHours, inERRStart, inERREnd, inERRStep) {
   
    var theCostTable= new Array();
    for (var i=inERRStart; i<=inERREnd;i+=inERRStep)
    theCostTable[i]=inCapacity*inRate*inAnnualHours/100000/i;
    return theCostTable;
  },

  ACCapacityError: function(inCapacity) {
    return inCapacity*.05;	
  }
 
};

//todo: page specific setup, these hard-coded element names should be set from the calling page
function ACCalculatorReport(inCalculateMode) {
	
	var theIDs=new Array();
	theIDs[0]="location";
	theIDs[1]="wallshade";
	theIDs[2]="walloth";
	theIDs[3]="wallint";
	theIDs[4]="wallframe";
	theIDs[5]="ceilheight";
	theIDs[6]="ceilarea";
	theIDs[7]="ceiltype";
	theIDs[8]="floor";
	theIDs[9]="doorarch";
	theIDs[10]="neshade";
	theIDs[11]="newin";
	theIDs[12]="neorn";
	theIDs[13]="eshade";
	theIDs[14]="ewin";
	theIDs[15]="eorn";
	theIDs[16]="seshade";
	theIDs[17]="sewin";
	theIDs[18]="seorn";
	theIDs[19]="sshade";
	theIDs[20]="swin";
	theIDs[21]="sorn";
	theIDs[22]="sweshade";
	theIDs[23]="swwin";
	theIDs[24]="sworn";
	theIDs[25]="wshade";
	theIDs[26]="wwin";
	theIDs[27]="worn";
	theIDs[28]="nwshade";
	theIDs[29]="nwwin";
	theIDs[30]="nworn";
	theIDs[31]="nwin";
	theIDs[32]="norn";
	theIDs[33]="numppl";
	theIDs[34]="kitchen";
	theIDs[35]="watts";
	theIDs[36]="nightuse";
	theIDs[37]="nightuseonly";

	var theResID="worksheet-results"; 
	var theResCapacityID="capacity";	
	var theResUsageID="annual-hours";
	var theResRangeID="error-range";
	var theResRateID="rate";
	var theLowCapacityID="low-capacity";
	var theHighCapacityID="high-capacity";
	var theNewCapacityID="in-capacity";	
	var theNewUsageID="in-annualhours";
	var theNewRateID="in-rate";

	var theResElement = document.getElementById(theResID);
	var theResCapacity = document.getElementById(theResCapacityID);
	var theResUsage = document.getElementById(theResUsageID);
	var theResRange = document.getElementById(theResRangeID);
	var theResRate = document.getElementById(theResRateID);
	var theLowCapacity = document.getElementById(theLowCapacityID);
	var theHighCapacity = document.getElementById(theHighCapacityID);
	
	var theNewCapacity = document.getElementById(theNewCapacityID);
	var theNewUsage = document.getElementById(theNewUsageID);
	var theNewRate = document.getElementById(theNewRateID);

	var theERRIDPrefix="err";
	var theCostIDPrefix="cost";
	
	var theFromData=DOMExtractor.extractPropertiesFromFormElements(document,theIDs)	;
	
	var theGeoLoc=theFromData.getProperty("location");
	var theWalls={frame:theFromData.getProperty("wallframe"), shaded:parseFloat(theFromData.getProperty("wallshade")), interior:parseFloat(theFromData.getProperty("wallint")), other:parseFloat(theFromData.getProperty("walloth"))};
	var theCeil={height:parseFloat(theFromData.getProperty("ceilheight")), area:parseFloat(theFromData.getProperty("ceilarea")),type:theFromData.getProperty("ceiltype")};
	var theFloor=parseFloat(theFromData.getProperty("floor"));
	var theDoor=parseFloat(theFromData.getProperty("doorarch"));
	var theWindows = new Object;
	theWindows.NE={shades:theFromData.getProperty("neshade"),glass:theFromData.getProperty("newin"),area:parseFloat(theFromData.getProperty("neorn"))};
	theWindows.E={shades:theFromData.getProperty("eshade"),glass:theFromData.getProperty("ewin"),area:parseFloat(theFromData.getProperty("eorn"))};
	theWindows.SE={shades:theFromData.getProperty("seshade"),glass:theFromData.getProperty("sewin"),area:parseFloat(theFromData.getProperty("seorn"))};
	theWindows.S={shades:theFromData.getProperty("sshade"),glass:theFromData.getProperty("swin"),area:parseFloat(theFromData.getProperty("sorn"))};
	theWindows.SW={shades:theFromData.getProperty("swshade"),glass:theFromData.getProperty("swwin"),area:parseFloat(theFromData.getProperty("sworn"))};
	theWindows.W={shades:theFromData.getProperty("wshade"),glass:theFromData.getProperty("wwin"),area:parseFloat(theFromData.getProperty("worn"))};
	theWindows.NW={shades:theFromData.getProperty("nwshade"),glass:theFromData.getProperty("nwwin"),area:parseFloat(theFromData.getProperty("nworn"))};
	theWindows.N={shades:theFromData.getProperty("nshade"),glass:theFromData.getProperty("nwin"),area:parseFloat(theFromData.getProperty("norn"))};
	var thePeople=parseFloat(theFromData.getProperty("numppl"));
	var theKitchen="no";
	if(document.getElementById("kitchen") && document.getElementById("kitchen").checked)
	  theKitchen="yes";
	var theAddedHeat=parseFloat(theFromData.getProperty("watts"));
	var theNightUseOnly="no";
	if(document.getElementById("nightuseonly") && document.getElementById("nightuseonly").checked)
	  theNightUseOnly="yes";
	
	var res= new Object();
	if(inCalculateMode=="recalculate") {
	  res.load=theNewCapacity.value;
	  res.loadError= ACCalculator.ACCapacityError(res.load);
	  res.annualHours=theNewUsage.value;
	} else 
	 res= ACCalculator.ACCapacity(theGeoLoc,theWalls,theCeil,theFloor,theDoor,theWindows,thePeople,theKitchen,theAddedHeat,theNightUseOnly);

	//todo: validate elements != null 
		
	theResElement.style.display="";
	theResCapacity.innerHTML=Math.round(res.load/100)*100;
	theResUsage.innerHTML=res.annualHours;
	theResRange.innerHTML=Math.round(res.loadError/100)*100;
	theResRate.innerHTML=theNewRate.value;
	if(res.load<5000) {
	  theLowCapacity.style.display="";
	  theHighCapacity.style.display="none";
	} 
	else if (res.load>12000) {
	  theLowCapacity.style.display="none";
	  theHighCapacity.style.display="";
	}
	else {
	  theLowCapacity.style.display="none";
	  theHighCapacity.style.display="none";
	}
	theNewCapacity.value = Math.round(res.load/100)*100;
	theNewUsage.value = Math.round(res.annualHours);

	var cost = ACCalculator.ACCost(res.load,parseFloat(theNewRate.value),res.annualHours,8.1,12,.10);
	var j=1;
	var theElement;
	var theRoundedERR;
	for (var i in cost) {
	  theElement=document.getElementById(theERRIDPrefix+"-"+j);
	  theRoundedERR=Math.round(i*10)/10;
	  if(theRoundedERR.toFixed)
	    theRoundedERR=theRoundedERR.toFixed(1);
	  if(theElement)
	    theElement.innerHTML=theRoundedERR;
	  theElement=document.getElementById(theCostIDPrefix+"-"+j);
	  if(theElement)
	    theElement.innerHTML="$"+Math.round(cost[i]);
	  j++;
	}
	
};
