/*
********************************************************************************************************
*    THIS SOFTWARE IS SOLELY OWNED BY AMERICAN ARCHITECTURAL METAL MANUFACTURERS INC.                  *
*    of ALLENTOWN PA., U.S.A.                                                                          *
*    IT IS PROPRIETARY --- COPYING/DUPLICATION BY ANY OTHER PERSON(s), COMPANY, ORGANIZATION or ENTITY *
*    is FORBIDDEN WITHOUT EXPRESS PERMISSION OF THE OWNER.                                                 *
********************************************************************************************************
*/
/* 
STILL NEED TO DO --- 

CLEAN UP ARRAYS when NOT IN USE (delete)

PRINT BUTTON - ASK USER for PROJECT INFO ...
  Proj ID, Proj Location, DATE of PRINTING ... 


   3) match Hurricane prone regions from table 6.3 in chap 9 to COUNTY where table
     location falls.

   9) COMPARE RESULTS to Metal-Era, FM and SPRI Wind Calculators.
      When comparing, see if ALL K factor values must be entered before doing the
      Kzt calculation.

    SEE if negative values can be entered for topographical features.


    META-TAGS ON EACH PAGE !!!!!



*/

// GLOBAL VARS - known to all functions

// Home directory
  var AAMMIHome="http://www.americanarch.com";
//Blank page
  var AAMMIBlank="./WDCBlank.html";

//Array holding user values as entered from html page
  var userValues = new Array(11);

//var to track if calc has been performed at least once already.
  var alreadyCalcd = 0;

//var to track if this is a hurricane prone region (default is not hurricane prone)
  var isHurrProne = 0;

// var calcMode is set to 1 when the calculate button is clicked (see getInputs)
  var calcMode = 0;

//var horzPull holds the calculated horizontal Design Pull calculation
  var horzPull = 0;

//var vertPull holds the calculated vertical Design Pull calculation
  var vertPull = 0;

// var to check if County page has been loaded
  var countyFrameLoaded = 0;

// var to check that State has been highlighted
  var iStateChecked = 0;

//Global var to hold county list in string form
  var countyString = new String();

//Global var arrCounties holds counties based on State
  var arrCounties = new Array();

//Global var arrWindSpeeds holds wind speed of each county in arrCounties
  var arrWindSpeed = new Array();

//Global var arrSpecWindReg holds the Special Wind Region status of each county in arrCounties
  var arrSpecWindReg = new Array();

//Global var qString holds the Query String when HRESwitch is called (or when a REFRESH is performed)
// note that buildQueryString is called in getInputs.

  var qString = new String();

//Global var highSpeed holds the highest wind speed based on State (in case User
//  does not enter a county name
  var highSpeed = 0;

//Global var bwS holds the Basic Wind Speed 
  var bwS = 0;

//Global var isSpecial holds whether this is a special wind region (if County is entered by User)
  var isSpecial = 0;

//Global var hasSpecial holds whether there are ANY special wind region in this state
// (if User does NOT enter County)
  var hasSpecial = 0;

//Global var whichPanel holds which panel is loaded in leftHalfFrame
  var whichPanel = "P1";

//Global var to modify color of output panel
  var outColorIter=0;

// Global var arrCompList holds the component list that meets specifications
// it is only used when the Print button is selected
  var arrCompList = new Array();
  
// Global var arrCompCounter holds the count of items in arrCompList
  var arrCompCounter = 0;

//constants to set node types (IE does not set these constant names, so create
//  the constant names and set them to values [IE only keeps the values]).
//  other browsers set the constant names, but this does not create conflict.

/* not presently used
  var myNodeTypes = {
    ELEMENT_NODE: 1,
    ATTRIBUTE_NODE: 2,
    TEXT_NODE: 3,
    CDATA_SECTION_NODE: 4,
    ENTITY_REFERENCE_NODE: 5,
    ENTITY_NODE: 6,
    PROCESSING_INSTRUCTION_NODE: 7,
    COMMENT_NODE: 8,
    DOCUMENT_NODE: 9,
    DOCUMENT_TYPE_NODE: 10,
    DOCUMENT_FRAGMENT_NODE: 11,
    NOTATION_NODE: 12
  }
*/


function calcBasicWindSpeed(inState, inCounty, inputChk) {

//NOTE:  **** THIS FUNCTION IS NOT COMPLETE!!!!!
//   MUST CALCULATE WIND SPEEDS and other FACTORS for Hurricane Prone regions (hurrAdj)
//   and for variations on Basic Wind Speed for regions.
//  based on COUNTY. [MUST PASS COUNTY (userValues[6]) to this function!

 var i = 0;

//highSpeed for each State is loaded in fillCounties();

 bwS = (-1)*99;

// If inputChk = 4 then User did not enter a county name, so we will
//  use the HIGHEST wind speed for that State.

// adjustment for hurricane prone regions (sqrt(1.6) = 1.265).
// this value is NOT presently used.  Keep for future.
 var hurrAdj = 1.265;

// flag for Hurricane Prone regions (global var)
// start with non-hurricane prone.

 isHurrProne = 0;

//logic for bWS:
//  default bWS to HIGHEST speed in the state, so if User does not put in a county,
//   the values reflected will be those of the WORST CASE for the state.
// check value of inCounty:
//   if found in switch(inCounty) list, then set to the specific value, else
//   leave at highSpeed.

//we call fillCountyInfo here because if the user refreshes the page, then the
// values for arrCounties, arrWindSpeed, etc are NOT RELOADED.
// we must reload them.
//fillCountyInfo also populates arrWindSpeed, which we will use.

    fillCountyInfo(inState);

  if (inputChk == 4) {
//if user does not even select the Name of County text box, then highSpeed is never
// assigned for the State. We must assign it here.
    bwS = highSpeed;
//Set isSpecial = 1 so that a note is made to user.
    isSpecial = 1;
//NOTE: return in middle of function !!!

    return bwS;
  }


  var countyIndex = -1;

  for (i=0;i<arrCounties.length;i++) {

    if (arrCounties[i].indexOf(inCounty) >= 0) {
      countyIndex = i;
      bwS = arrWindSpeed[i];
//set GLOBAL var isSpecial to 1 or 0 depending on whether this is a Special Wind region.
      isSpecial = arrSpecWindReg[i];
      break;
    }
  }

  if (bwS == -99) {  
    bwS = highSpeed;
  }
//bwS=-99;



return bwS;

}


function calcExpBqz(bldgHeight, basWindSpeed) {

  var arrBldgHeightBC = new Array(17);

//array of Buidling Heights (for exposures B&C)

  arrBldgHeightBC[0]=0;
  arrBldgHeightBC[1]=60;
  arrBldgHeightBC[2]=70;
  arrBldgHeightBC[3]=80;
  arrBldgHeightBC[4]=90;
  arrBldgHeightBC[5]=100;
  arrBldgHeightBC[6]=120;
  arrBldgHeightBC[7]=140;
  arrBldgHeightBC[8]=160;
  arrBldgHeightBC[9]=180;
  arrBldgHeightBC[10]=200;
  arrBldgHeightBC[11]=250;
  arrBldgHeightBC[12]=300;
  arrBldgHeightBC[13]=350;
  arrBldgHeightBC[14]=400;
  arrBldgHeightBC[15]=450;
  arrBldgHeightBC[16]=500;

  var heightGroup = 0;
  var i=0;
/*
  alert("EXPOSURE B bldgHeight= \"" + bldgHeight + "\"\n" +
       "basWindSpeed = \"" + basWindSpeed + "\"");
*/

//First we must get the bldg Height group into which bldgHeight falls.
//e.g. if User enters 55, then heightGroup=60, since 55 is between 0 and 60 (first category).
//Find corresponding building height
  for (i=0;i<arrBldgHeightBC.length;i++) {
    j=i+1;
    if ((bldgHeight > arrBldgHeightBC[i]) && (bldgHeight <= arrBldgHeightBC[j])) {
      heightGroup = arrBldgHeightBC[j];
    }
  }   
//If building height <=0 then use index 1.
  if (bldgHeight <= arrBldgHeightBC[0]) {
    heightGroup = arrBldgHeightBC[1];
  }
//If building height > highest building height, then use highest building height.
  if (bldgHeight > arrBldgHeightBC[arrBldgHeightBC.length-1]) {
    heightGroup = arrBldgHeightBC[arrBldgHeightBC.length-1]; 
  }

//Now we must do the same grouping thing with Wind Speeds.

  var tblWindSpeed = new Array(11);

  tblWindSpeed[0]=0;
  tblWindSpeed[1]=85;
  tblWindSpeed[2]=90;
  tblWindSpeed[3]=100;
  tblWindSpeed[4]=110;
  tblWindSpeed[5]=120;
  tblWindSpeed[6]=130;
  tblWindSpeed[7]=140;
  tblWindSpeed[8]=150;
  tblWindSpeed[9]=160;
  tblWindSpeed[10]=170;

  var windSpeedGroup = 0; 
  var windSpeedGroupIndex = 0;

  for (i=0;i<tblWindSpeed.length;i++) {
    j=i+1;
  //Find corresponding wind speed group
    if ((basWindSpeed > tblWindSpeed[i]) && (basWindSpeed <= tblWindSpeed[j])) {
      windSpeedGroup = tblWindSpeed[j];
      windSpeedGroupIndex = j;
    }
  }

//If Basic Wind speed is less than or equal to lowest speed, use index 1.
  if (basWindSpeed <= tblWindSpeed[0]) {
    windSpeedGroup = tblWindSpeed[1];
    windSpeedGroupIndex = 1;
  }
//If Basic Wind speed is greater than highest speed, use highest speed.

  if (basWindSpeed > tblWindSpeed[tblWindSpeed.length-1]) {

    windSpeedGroup = tblWindSpeed[tblWindSpeed.length-1];
    windSpeedGroupIndex = tblWindSpeed.length-1;

  }

 var tblQz = new Array(11);
 var qz = 0;

//Now we build tblQz depending on heightGroup
 switch (heightGroup) {
   case 60: 
           tblQz[0]=0.00;
           tblQz[1]=16.00;
           tblQz[2]=18.00;
           tblQz[3]=22.00;
           tblQz[4]=26.00;
           tblQz[5]=31.00;
           tblQz[6]=37.00;
           tblQz[7]=43.00;
           tblQz[8]=49.00;
           tblQz[9]=56.00;
           tblQz[10]=63.00;
           break;
   case 70: 
           tblQz[0]=0.00;
           tblQz[1]=17.00;
           tblQz[2]=19.00;
           tblQz[3]=23.00;
           tblQz[4]=28.00;
           tblQz[5]=33.00;
           tblQz[6]=39.00;
           tblQz[7]=45.00;
           tblQz[8]=51.00;
           tblQz[9]=58.00;
           tblQz[10]=66.00;
           break;
   case 80: 
           tblQz[0]=0.00;
           tblQz[1]=17.00;
           tblQz[2]=19.00;
           tblQz[3]=24.00;
           tblQz[4]=29.00;
           tblQz[5]=34.00;
           tblQz[6]=40.00;
           tblQz[7]=47.00;
           tblQz[8]=53.00;
           tblQz[9]=61.00;
           tblQz[10]=69.00;
           break;
   case 90: 
           tblQz[0]=0.00;
           tblQz[1]=18.00;
           tblQz[2]=20.00;
           tblQz[3]=25.00;
           tblQz[4]=30.00;
           tblQz[5]=35.00;
           tblQz[6]=41.00;
           tblQz[7]=48.00;
           tblQz[8]=55.00;
           tblQz[9]=63.00;
           tblQz[10]=71.00;
           break;
   case 100: 
           tblQz[0]=0.00;
           tblQz[1]=18.00;
           tblQz[2]=20.00;
           tblQz[3]=25.00;
           tblQz[4]=31.00;
           tblQz[5]=36.00;
           tblQz[6]=43.00;
           tblQz[7]=50.00;
           tblQz[8]=57.00;
           tblQz[9]=65.00;
           tblQz[10]=73.00;
           break;
   case 120: 
           tblQz[0]=0.00;
           tblQz[1]=19.00;
           tblQz[2]=22.00;
           tblQz[3]=27.00;
           tblQz[4]=32.00;
           tblQz[5]=38.00;
           tblQz[6]=45.00;
           tblQz[7]=52.00;
           tblQz[8]=60.00;
           tblQz[9]=69.00;
           tblQz[10]=77.00;
           break;
   case 140: 
           tblQz[0]=0.00;
           tblQz[1]=20.00;
           tblQz[2]=23.00;
           tblQz[3]=28.00;
           tblQz[4]=34.00;
           tblQz[5]=40.00;
           tblQz[6]=47.00;
           tblQz[7]=55.00;
           tblQz[8]=63.00;
           tblQz[9]=71.00;
           tblQz[10]=80.00;
           break;
   case 160: 
           tblQz[0]=0.00;
           tblQz[1]=21.00;
           tblQz[2]=23.00;
           tblQz[3]=29.00;
           tblQz[4]=35.00;
           tblQz[5]=42.00;
           tblQz[6]=49.00;
           tblQz[7]=57.00;
           tblQz[8]=65.00;
           tblQz[9]=74.00;
           tblQz[10]=84.00;
           break;
   case 180: 
           tblQz[0]=0.00;
           tblQz[1]=22.00;
           tblQz[2]=24.00;
           tblQz[3]=30.00;
           tblQz[4]=36.00;
           tblQz[5]=43.00;
           tblQz[6]=51.00;
           tblQz[7]=59.00;
           tblQz[8]=67.00;
           tblQz[9]=77.00;
           tblQz[10]=86.00;
           break;
   case 200: 
           tblQz[0]=0.00;
           tblQz[1]=22.00;
           tblQz[2]=25.00;
           tblQz[3]=31.00;
           tblQz[4]=37.00;
           tblQz[5]=44.00;
           tblQz[6]=52.00;
           tblQz[7]=60.00;
           tblQz[8]=69.00;
           tblQz[9]=79.00;
           tblQz[10]=89.00;
           break;
   case 250: 
           tblQz[0]=0.00;
           tblQz[1]=24.00;
           tblQz[2]=27.00;
           tblQz[3]=33.00;
           tblQz[4]=40.00;
           tblQz[5]=47.00;
           tblQz[6]=56.00;
           tblQz[7]=64.00;
           tblQz[8]=74.00;
           tblQz[9]=84.00;
           tblQz[10]=95.00;
           break;
   case 300: 
           tblQz[0]=0.00;
           tblQz[1]=25.00;
           tblQz[2]=28.00;
           tblQz[3]=35.00;
           tblQz[4]=42.00;
           tblQz[5]=50.00;
           tblQz[6]=59.00;
           tblQz[7]=68.00;
           tblQz[8]=78.00;
           tblQz[9]=89.00;
           tblQz[10]=100.00;
           break;
   case 350: 
           tblQz[0]=0.00;
           tblQz[1]=26.00;
           tblQz[2]=29.00;
           tblQz[3]=36.00;
           tblQz[4]=44.00;
           tblQz[5]=52.00;
           tblQz[6]=61.00;
           tblQz[7]=71.00;
           tblQz[8]=81.00;
           tblQz[9]=93.00;
           tblQz[10]=105.00;
           break;
   case 400: 
           tblQz[0]=0.00;
           tblQz[1]=27.00;
           tblQz[2]=30.00;
           tblQz[3]=38.00;
           tblQz[4]=45.00;
           tblQz[5]=54.00;
           tblQz[6]=64.00;
           tblQz[7]=74.00;
           tblQz[8]=85.00;
           tblQz[9]=96.00;
           tblQz[10]=109.00;
           break;
   case 450: 
           tblQz[0]=0.00;
           tblQz[1]=28.00;
           tblQz[2]=31.00;
           tblQz[3]=39.00;
           tblQz[4]=47.00;
           tblQz[5]=56.00;
           tblQz[6]=66.00;
           tblQz[7]=76.00;
           tblQz[8]=87.00;
           tblQz[9]=100.00;
           tblQz[10]=112.00;
           break;
   case 500: 
           tblQz[0]=0.00;
           tblQz[1]=29.00;
           tblQz[2]=32.00;
           tblQz[3]=40.00;
           tblQz[4]=48.00;
           tblQz[5]=58.00;
           tblQz[6]=68.00;
           tblQz[7]=79.00;
           tblQz[8]=90.00;
           tblQz[9]=103.00;
           tblQz[10]=116.00;
           break;

 }

qz=tblQz[windSpeedGroupIndex];


return qz;

}

function calcExpCqz(bldgHeight, basWindSpeed) {

  var arrBldgHeightBC = new Array(17);

//array of Buidling Heights (for exposures B&C)

  arrBldgHeightBC[0]=0;
  arrBldgHeightBC[1]=60;
  arrBldgHeightBC[2]=70;
  arrBldgHeightBC[3]=80;
  arrBldgHeightBC[4]=90;
  arrBldgHeightBC[5]=100;
  arrBldgHeightBC[6]=120;
  arrBldgHeightBC[7]=140;
  arrBldgHeightBC[8]=160;
  arrBldgHeightBC[9]=180;
  arrBldgHeightBC[10]=200;
  arrBldgHeightBC[11]=250;
  arrBldgHeightBC[12]=300;
  arrBldgHeightBC[13]=350;
  arrBldgHeightBC[14]=400;
  arrBldgHeightBC[15]=450;
  arrBldgHeightBC[16]=500;

  var heightGroup = 0;
  var i=0;

/*
  alert("EXPOSURE C bldgHeight= \"" + bldgHeight + "\"\n" +
       "basWindSpeed = \"" + basWindSpeed + "\"");
*/

//First we must get the bldg Height group into which bldgHeight falls.
//e.g. if User enters 55, then heightGroup=60, since 55 is between 0 and 60 (first category).
//Find corresponding building height
  for (i=0;i<arrBldgHeightBC.length;i++) {
    j=i+1;
    if ((bldgHeight > arrBldgHeightBC[i]) && (bldgHeight <= arrBldgHeightBC[j])) {
      heightGroup = arrBldgHeightBC[j];
    }
  }   
//If building height <=0 then use index 1.
  if (bldgHeight <= arrBldgHeightBC[0]) {
    heightGroup = arrBldgHeightBC[1];
  }
//If building height > highest building height, then use highest building height.
  if (bldgHeight > arrBldgHeightBC[arrBldgHeightBC.length-1]) {
    heightGroup = arrBldgHeightBC[arrBldgHeightBC.length-1]; 
  }

//Now we must do the same grouping thing with Wind Speeds.

  var tblWindSpeed = new Array(11);

  tblWindSpeed[0]=0;
  tblWindSpeed[1]=85;
  tblWindSpeed[2]=90;
  tblWindSpeed[3]=100;
  tblWindSpeed[4]=110;
  tblWindSpeed[5]=120;
  tblWindSpeed[6]=130;
  tblWindSpeed[7]=140;
  tblWindSpeed[8]=150;
  tblWindSpeed[9]=160;
  tblWindSpeed[10]=170;


  var windSpeedGroup = 0; 
  var windSpeedGroupIndex = 0;

  for (i=0;i<tblWindSpeed.length;i++) {
    j=i+1;
  //Find corresponding wind speed group
    if ((basWindSpeed > tblWindSpeed[i]) && (basWindSpeed <= tblWindSpeed[j])) {
      windSpeedGroup = tblWindSpeed[j];
      windSpeedGroupIndex = j;
    }
  }

//If Basic Wind speed is less than or equal to lowest speed, use index 1.
  if (basWindSpeed <= tblWindSpeed[0]) {
    windSpeedGroup = tblWindSpeed[1];
    windSpeedGroupIndex = 1;
  }
//If Basic Wind speed is greater than highest speed, use highest speed.

  if (basWindSpeed > tblWindSpeed[tblWindSpeed.length-1]) {

    windSpeedGroup = tblWindSpeed[tblWindSpeed.length-1];
    windSpeedGroupIndex = tblWindSpeed.length-1;

  }

 var tblQz = new Array(11);
 var qz = 0;

//Now we build tblQz depending on heightGroup
 switch (heightGroup) {
   case 60: 
           tblQz[0]=0.00;
           tblQz[1]=21.00;
           tblQz[2]=24.00;
           tblQz[3]=29.00;
           tblQz[4]=35.00;
           tblQz[5]=42.00;
           tblQz[6]=49.00;
           tblQz[7]=57.00;
           tblQz[8]=65.00;
           tblQz[9]=74.00;
           tblQz[10]=84.00;
           break;
   case 70: 
           tblQz[0]=0.00;
           tblQz[1]=22.00;
           tblQz[2]=24.00;
           tblQz[3]=30.00;
           tblQz[4]=36.00;
           tblQz[5]=43.00;
           tblQz[6]=51.00;
           tblQz[7]=59.00;
           tblQz[8]=68.00;
           tblQz[9]=77.00;
           tblQz[10]=87.00;
           break;
   case 80: 
           tblQz[0]=0.00;
           tblQz[1]=22.00;
           tblQz[2]=25.00;
           tblQz[3]=31.00;
           tblQz[4]=37.00;
           tblQz[5]=45.00;
           tblQz[6]=52.00;
           tblQz[7]=61.00;
           tblQz[8]=70.00;
           tblQz[9]=79.00;
           tblQz[10]=89.00;
           break;
   case 90: 
           tblQz[0]=0.00;
           tblQz[1]=23.00;
           tblQz[2]=26.00;
           tblQz[3]=32.00;
           tblQz[4]=38.00;
           tblQz[5]=46.00;
           tblQz[6]=54.00;
           tblQz[7]=62.00;
           tblQz[8]=71.00;
           tblQz[9]=81.00;
           tblQz[10]=92.00;
           break;
   case 100: 
           tblQz[0]=0.00;
           tblQz[1]=23.00;
           tblQz[2]=26.00;
           tblQz[3]=32.00;
           tblQz[4]=39.00;
           tblQz[5]=47.00;
           tblQz[6]=55.00;
           tblQz[7]=64.00;
           tblQz[8]=73.00;
           tblQz[9]=83.00;
           tblQz[10]=94.00;
           break;
   case 120: 
           tblQz[0]=0.00;
           tblQz[1]=24.00;
           tblQz[2]=27.00;
           tblQz[3]=34.00;
           tblQz[4]=41.00;
           tblQz[5]=48.00;
           tblQz[6]=57.00;
           tblQz[7]=66.00;
           tblQz[8]=76.00;
           tblQz[9]=86.00;
           tblQz[10]=97.00;
           break;
   case 140: 
           tblQz[0]=0.00;
           tblQz[1]=25.00;
           tblQz[2]=28.00;
           tblQz[3]=35.00;
           tblQz[4]=42.00;
           tblQz[5]=50.00;
           tblQz[6]=59.00;
           tblQz[7]=68.00;
           tblQz[8]=78.00;
           tblQz[9]=89.00;
           tblQz[10]=101.00;
           break;
   case 160: 
           tblQz[0]=0.00;
           tblQz[1]=26.00;
           tblQz[2]=29.00;
           tblQz[3]=36.00;
           tblQz[4]=43.00;
           tblQz[5]=52.00;
           tblQz[6]=60.00;
           tblQz[7]=70.00;
           tblQz[8]=80.00;
           tblQz[9]=92.00;
           tblQz[10]=103.00;
           break;
   case 180: 
           tblQz[0]=0.00;
           tblQz[1]=26.00;
           tblQz[2]=30.00;
           tblQz[3]=37.00;
           tblQz[4]=44.00;
           tblQz[5]=53.00;
           tblQz[6]=62.00;
           tblQz[7]=72.00;
           tblQz[8]=83.00;
           tblQz[9]=94.00;
           tblQz[10]=106.00;
           break;
   case 200: 
           tblQz[0]=0.00;
           tblQz[1]=27.00;
           tblQz[2]=30.00;
           tblQz[3]=37.00;
           tblQz[4]=45.00;
           tblQz[5]=54.00;
           tblQz[6]=63.00;
           tblQz[7]=73.00;
           tblQz[8]=84.00;
           tblQz[9]=96.00;
           tblQz[10]=108.00;
           break;
   case 250: 
           tblQz[0]=0.00;
           tblQz[1]=28.00;
           tblQz[2]=32.00;
           tblQz[3]=39.00;
           tblQz[4]=48.00;
           tblQz[5]=57.00;
           tblQz[6]=66.00;
           tblQz[7]=77.00;
           tblQz[8]=88.00;
           tblQz[9]=101.00;
           tblQz[10]=114.00;
           break;
   case 300: 
           tblQz[0]=0.00;
           tblQz[1]=30.00;
           tblQz[2]=33.00;
           tblQz[3]=41.00;
           tblQz[4]=49.00;
           tblQz[5]=59.00;
           tblQz[6]=69.00;
           tblQz[7]=80.00;
           tblQz[8]=92.00;
           tblQz[9]=105.00;
           tblQz[10]=118.00;
           break;
   case 350: 
           tblQz[0]=0.00;
           tblQz[1]=30.00;
           tblQz[2]=34.00;
           tblQz[3]=42.00;
           tblQz[4]=51.00;
           tblQz[5]=61.00;
           tblQz[6]=71.00;
           tblQz[7]=83.00;
           tblQz[8]=95.00;
           tblQz[9]=108.00;
           tblQz[10]=122.00;
           break;
   case 400: 
           tblQz[0]=0.00;
           tblQz[1]=31.00;
           tblQz[2]=35.00;
           tblQz[3]=43.00;
           tblQz[4]=52.00;
           tblQz[5]=62.00;
           tblQz[6]=73.00;
           tblQz[7]=85.00;
           tblQz[8]=98.00;
           tblQz[9]=111.00;
           tblQz[10]=125.00;
           break;
   case 450: 
           tblQz[0]=0.00;
           tblQz[1]=32.00;
           tblQz[2]=36.00;
           tblQz[3]=44.00;
           tblQz[4]=54.00;
           tblQz[5]=64.00;
           tblQz[6]=75.00;
           tblQz[7]=87.00;
           tblQz[8]=100.00;
           tblQz[9]=114.00;
           tblQz[10]=129.00;
           break;
   case 500: 
           tblQz[0]=0.00;
           tblQz[1]=33.00;
           tblQz[2]=37.00;
           tblQz[3]=45.00;
           tblQz[4]=55.00;
           tblQz[5]=65.00;
           tblQz[6]=77.00;
           tblQz[7]=89.00;
           tblQz[8]=102.00;
           tblQz[9]=116.00;
           tblQz[10]=131.00;
           break;

 }

qz=tblQz[windSpeedGroupIndex];

return qz;

}

function calcExpDqz(bldgHeight, basWindSpeed) {
//array of Building Heights (for exposure D)

  var arrBldgHeightD = new Array(22);

  arrBldgHeightD[0]=0;
  arrBldgHeightD[1]=15;
  arrBldgHeightD[2]=20;
  arrBldgHeightD[3]=30;
  arrBldgHeightD[4]=40;
  arrBldgHeightD[5]=50;
  arrBldgHeightD[6]=60;
  arrBldgHeightD[7]=70;
  arrBldgHeightD[8]=80;
  arrBldgHeightD[9]=90;
  arrBldgHeightD[10]=100;
  arrBldgHeightD[11]=120;
  arrBldgHeightD[12]=140;
  arrBldgHeightD[13]=160;
  arrBldgHeightD[14]=180;
  arrBldgHeightD[15]=200;
  arrBldgHeightD[16]=250;
  arrBldgHeightD[17]=300;
  arrBldgHeightD[18]=350;
  arrBldgHeightD[19]=400;
  arrBldgHeightD[20]=450;
  arrBldgHeightD[21]=500;

  var heightGroup = 0;
  var i=0;

/*
  alert("EXPOSURE D bldgHeight= \"" + bldgHeight + "\"\n" +
       "basWindSpeed = \"" + basWindSpeed + "\"");
*/

//First we must get the bldg Height group into which bldgHeight falls.
//e.g. if User enters 55, then heightGroup=60, since 55 is between 0 and 60 (first category).
//Find corresponding building height
  for (i=0;i<arrBldgHeightD.length;i++) {
    j=i+1;
    if ((bldgHeight > arrBldgHeightD[i]) && (bldgHeight <= arrBldgHeightD[j])) {
      heightGroup = arrBldgHeightD[j];
    }
  }   
//If building height <=0 then use index 1.
  if (bldgHeight <= arrBldgHeightD[0]) {
    heightGroup = arrBldgHeightD[1];
  }
//If building height > highest building height, then use highest building height.
  if (bldgHeight > arrBldgHeightD[arrBldgHeightD.length-1]) {
    heightGroup = arrBldgHeightD[arrBldgHeightD.length-1]; 
  }

//Now we must do the same grouping thing with Wind Speeds.

  var tblWindSpeed = new Array(11);

  tblWindSpeed[0]=0;
  tblWindSpeed[1]=85;
  tblWindSpeed[2]=90;
  tblWindSpeed[3]=100;
  tblWindSpeed[4]=110;
  tblWindSpeed[5]=120;
  tblWindSpeed[6]=130;
  tblWindSpeed[7]=140;
  tblWindSpeed[8]=150;
  tblWindSpeed[9]=160;
  tblWindSpeed[10]=170;


  var windSpeedGroup = 0; 
  var windSpeedGroupIndex = 0;

  for (i=0;i<tblWindSpeed.length;i++) {
    j=i+1;
  //Find corresponding wind speed group
    if ((basWindSpeed > tblWindSpeed[i]) && (basWindSpeed <= tblWindSpeed[j])) {
      windSpeedGroup = tblWindSpeed[j];
      windSpeedGroupIndex = j;
    }
  }

//If Basic Wind speed is less than or equal to lowest speed, use index 1.
  if (basWindSpeed <= tblWindSpeed[0]) {
    windSpeedGroup = tblWindSpeed[1];
    windSpeedGroupIndex = 1;
  }
//If Basic Wind speed is greater than highest speed, use highest speed.

  if (basWindSpeed > tblWindSpeed[tblWindSpeed.length-1]) {

    windSpeedGroup = tblWindSpeed[tblWindSpeed.length-1];
    windSpeedGroupIndex = tblWindSpeed.length-1;

  }

 var tblQz = new Array(11);
 var qz = 0;

//Now we build tblQz depending on heightGroup
 switch (heightGroup) {

   case 15: 
           tblQz[0]=0.00;
           tblQz[1]=19.00;
           tblQz[2]=21.00;
           tblQz[3]=26.00;
           tblQz[4]=32.00;
           tblQz[5]=38.00;
           tblQz[6]=45.00;
           tblQz[7]=52.00;
           tblQz[8]=59.00;
           tblQz[9]=68.00;
           tblQz[10]=76.00;
           break;
   case 20: 
           tblQz[0]=0.00;
           tblQz[1]=20.00;
           tblQz[2]=22.00;
           tblQz[3]=28.00;
           tblQz[4]=34.00;
           tblQz[5]=40.00;
           tblQz[6]=47.00;
           tblQz[7]=54.00;
           tblQz[8]=62.00;
           tblQz[9]=71.00;
           tblQz[10]=80.00;
           break;
   case 30: 
           tblQz[0]=0.00;
           tblQz[1]=21.00;
           tblQz[2]=24.00;
           tblQz[3]=30.00;
           tblQz[4]=36.00;
           tblQz[5]=43.00;
           tblQz[6]=50.00;
           tblQz[7]=58.00;
           tblQz[8]=67.00;
           tblQz[9]=76.00;
           tblQz[10]=86.00;
           break;
   case 40: 
           tblQz[0]=0.00;
           tblQz[1]=23.00;
           tblQz[2]=25.00;
           tblQz[3]=31.00;
           tblQz[4]=38.00;
           tblQz[5]=45.00;
           tblQz[6]=53.00;
           tblQz[7]=61.00;
           tblQz[8]=70.00;
           tblQz[9]=80.00;
           tblQz[10]=90.00;
           break;
   case 50: 
           tblQz[0]=0.00;
           tblQz[1]=23.00;
           tblQz[2]=26.00;
           tblQz[3]=33.00;
           tblQz[4]=39.00;
           tblQz[5]=47.00;
           tblQz[6]=55.00;
           tblQz[7]=64.00;
           tblQz[8]=73.00;
           tblQz[9]=83.00;
           tblQz[10]=94.00;
           break;

   case 60: 
           tblQz[0]=0.00;
           tblQz[1]=24.00;
           tblQz[2]=27.00;
           tblQz[3]=34.00;
           tblQz[4]=41.00;
           tblQz[5]=48.00;
           tblQz[6]=57.00;
           tblQz[7]=66.00;
           tblQz[8]=76.00;
           tblQz[9]=86.00;
           tblQz[10]=97.00;
           break;
   case 70: 
           tblQz[0]=0.00;
           tblQz[1]=25.00;
           tblQz[2]=28.00;
           tblQz[3]=34.00;
           tblQz[4]=42.00;
           tblQz[5]=50.00;
           tblQz[6]=58.00;
           tblQz[7]=68.00;
           tblQz[8]=78.00;
           tblQz[9]=88.00;
           tblQz[10]=100.00;
           break;
   case 80: 
           tblQz[0]=0.00;
           tblQz[1]=25.00;
           tblQz[2]=29.00;
           tblQz[3]=35.00;
           tblQz[4]=43.00;
           tblQz[5]=51.00;
           tblQz[6]=60.00;
           tblQz[7]=69.00;
           tblQz[8]=79.00;
           tblQz[9]=90.00;
           tblQz[10]=102.00;
           break;
   case 90: 
           tblQz[0]=0.00;
           tblQz[1]=26.00;
           tblQz[2]=29.00;
           tblQz[3]=36.00;
           tblQz[4]=44.00;
           tblQz[5]=52.00;
           tblQz[6]=61.00;
           tblQz[7]=71.00;
           tblQz[8]=81.00;
           tblQz[9]=92.00;
           tblQz[10]=104.00;
           break;
   case 100: 
           tblQz[0]=0.00;
           tblQz[1]=27.00;
           tblQz[2]=30.00;
           tblQz[3]=37.00;
           tblQz[4]=44.00;
           tblQz[5]=53.00;
           tblQz[6]=62.00;
           tblQz[7]=72.00;
           tblQz[8]=83.00;
           tblQz[9]=94.00;
           tblQz[10]=106.00;
           break;
   case 120: 
           tblQz[0]=0.00;
           tblQz[1]=27.00;
           tblQz[2]=31.00;
           tblQz[3]=38.00;
           tblQz[4]=46.00;
           tblQz[5]=55.00;
           tblQz[6]=64.00;
           tblQz[7]=74.00;
           tblQz[8]=85.00;
           tblQz[9]=97.00;
           tblQz[10]=109.00;
           break;
   case 140: 
           tblQz[0]=0.00;
           tblQz[1]=28.00;
           tblQz[2]=32.00;
           tblQz[3]=39.00;
           tblQz[4]=47.00;
           tblQz[5]=56.00;
           tblQz[6]=66.00;
           tblQz[7]=76.00;
           tblQz[8]=88.00;
           tblQz[9]=100.00;
           tblQz[10]=112.00;
           break;
   case 160: 
           tblQz[0]=0.00;
           tblQz[1]=29.00;
           tblQz[2]=32.00;
           tblQz[3]=40.00;
           tblQz[4]=48.00;
           tblQz[5]=57.00;
           tblQz[6]=67.00;
           tblQz[7]=78.00;
           tblQz[8]=90.00;
           tblQz[9]=102.00;
           tblQz[10]=115.00;
           break;
   case 180: 
           tblQz[0]=0.00;
           tblQz[1]=29.00;
           tblQz[2]=33.00;
           tblQz[3]=41.00;
           tblQz[4]=49.00;
           tblQz[5]=59.00;
           tblQz[6]=69.00;
           tblQz[7]=80.00;
           tblQz[8]=91.00;
           tblQz[9]=104.00;
           tblQz[10]=117.00;
           break;
   case 200: 
           tblQz[0]=0.00;
           tblQz[1]=30.00;
           tblQz[2]=34.00;
           tblQz[3]=41.00;
           tblQz[4]=50.00;
           tblQz[5]=60.00;
           tblQz[6]=70.00;
           tblQz[7]=81.00;
           tblQz[8]=93.00;
           tblQz[9]=106.00;
           tblQz[10]=120.00;
           break;
   case 250: 
           tblQz[0]=0.00;
           tblQz[1]=31.00;
           tblQz[2]=35.00;
           tblQz[3]=43.00;
           tblQz[4]=52.00;
           tblQz[5]=62.00;
           tblQz[6]=73.00;
           tblQz[7]=84.00;
           tblQz[8]=97.00;
           tblQz[9]=110.00;
           tblQz[10]=124.00;
           break;
   case 300: 
           tblQz[0]=0.00;
           tblQz[1]=32.00;
           tblQz[2]=36.00;
           tblQz[3]=44.00;
           tblQz[4]=54.00;
           tblQz[5]=64.00;
           tblQz[6]=75.00;
           tblQz[7]=87.00;
           tblQz[8]=100.00;
           tblQz[9]=114.00;
           tblQz[10]=128.00;
           break;
   case 350: 
           tblQz[0]=0.00;
           tblQz[1]=33.00;
           tblQz[2]=37.00;
           tblQz[3]=46.00;
           tblQz[4]=55.00;
           tblQz[5]=66.00;
           tblQz[6]=77.00;
           tblQz[7]=89.00;
           tblQz[8]=103.00;
           tblQz[9]=117.00;
           tblQz[10]=132.00;
           break;
   case 400: 
           tblQz[0]=0.00;
           tblQz[1]=34.00;
           tblQz[2]=38.00;
           tblQz[3]=47.00;
           tblQz[4]=56.00;
           tblQz[5]=67.00;
           tblQz[6]=79.00;
           tblQz[7]=92.00;
           tblQz[8]=105.00;
           tblQz[9]=120.00;
           tblQz[10]=135.00;
           break;
   case 450: 
           tblQz[0]=0.00;
           tblQz[1]=34.00;
           tblQz[2]=39.00;
           tblQz[3]=48.00;
           tblQz[4]=58.00;
           tblQz[5]=69.00;
           tblQz[6]=81.00;
           tblQz[7]=93.00;
           tblQz[8]=107.00;
           tblQz[9]=122.00;
           tblQz[10]=138.00;
           break;
   case 500: 
           tblQz[0]=0.00;
           tblQz[1]=35.00;
           tblQz[2]=39.00;
           tblQz[3]=49.00;
           tblQz[4]=59.00;
           tblQz[5]=70.00;
           tblQz[6]=82.00;
           tblQz[7]=95.00;
           tblQz[8]=109.00;
           tblQz[9]=124.00;
           tblQz[10]=140.00;
           break;

 }


qz=tblQz[windSpeedGroupIndex];

return qz;

}

function chooseImpFactor(occCatg, wS) {
//return Importance Factor.

  var retVal = 0;
  switch (occCatg) {
    case "I":
      retVal=0.87;
//check if wS > 100
      if (wS > 100) {
        retVal=0.77;
      }        
      break;
//for cat II, III, IV values are the same regardless of wS
    case "II":
      retVal=1.00;     
      break;
    case "III":
      retVal=1.15;
      break; 
    case "IV":
      retVal=1.15;
      break;
  }

return retVal;
}

function chooseGCp(inHeight, inDirection) {

  if (inHeight <= 60) {
    switch (inDirection) {
      case "HORZ":
        retVal = 1.1;
        break;
      case "VERT":
        retVal = 1.8;
        break;
    }
  } else {
    switch (inDirection) {
      case "HORZ":
        retVal = 0.9;
        break;
      case "VERT":
        retVal = 2.3;
        break;
    }
  }
 return retVal;
}

function isANumber(myInVal) {
//checks if a user value is numeric
//allow - and . (minus and decimal)
  var myNumbers = new String("1234567890-.");
//if indexOf returns -1, return 0 else return 1 (1 is good)
  var retVal = myNumbers.indexOf(myInVal) > -1 ? 1 : 0;
  return retVal;
}

function isAString(myInVal) {
//checks if a user value is alphabetic or space
  var myLetters = new String(" ABCDEFGHIJKLMNOPQRSTUVWXYZ");
//if indexOf returns -1, return 0 else return 1 (1 is good)
  var retVal = myLetters.indexOf(myInVal) > -1 ? 1 : 0;
  return retVal;
}

function chkInputs(inState) {

//This function will return a zero if there are no problems with
// inputs.
// otherwise it will return different values depending on the error.

  var probNum = 0;
  var i = 0;

//place global array values into local vars
  var bldgHeight = userValues[2].value;
  var inCounty = userValues[6].value;
  
// check bldgHeight as existing and numeric
//does it exist? no? return 1 else return 0 if exists

  if (bldgHeight == "") {
    alert("You MUST enter a value for BUILDING HEIGHT");
    probNum = 1;  
//NOTE RETURN in middle of function!!
    return probNum;
  }

//is it numeric?  no? return 2 else return 0 if numeric
  for (i=0;i<bldgHeight.length;i++) {
    probNum = (isANumber(bldgHeight.substring(i,i+1)) == 1) ? 0 : 2;
    if (probNum == 2) {
      alert("Please use NUMBERS ONLY for BUILDING HEIGHT");
      break;
    }
  }

//is it > 0? no? return 2 else return 0
  if (bldgHeight <= 0) {
    probNum=2;
    alert("BUILDING HEIGHT MUST be GREATER than zero");
  }

//NOTE RETURN in middle of function - we don't return from inside the
//  previous FOR loop - that might create stack errors.

  if (probNum == 2) {
    return probNum;  
  }   

//check that a STATE has been selected
  if (inState == "SLCT") {
    alert("You MUST select a STATE from the 'State Location' drop-down list");
    probNum = 3;
//NOTE RETURN in middle of function!!
    return probNum;
  }
// check county as existing and alphabetic

// missing county is not a reason to completely stop.
// does it exist? no? return 4 else return 0 if it exists.
// if not, then let user know that Highest wind speed will be used.
//  also, here is where we use parameter inState as part of the message.
//  EXCEPT for DC --- no counties are in DC.

  if ( (inCounty == "") && (inState != "DC") ) {
    alert("COUNTY was NOT entered, so the HIGHEST Wind Speed for State [" + inState + "] will be used." + 
          "\n" + "This may over-estimate the Pressure Design for your actual location." + 
          "\n" + "For best results, please specify the County and re-calculate.");
    probNum = 4;
//NOTE RETURN in middle of function!!
    return probNum;
  }

//is it alphabetic?  no?  return 5 else return 0 if alphabetic
  for (i=0;i<inCounty.length;i++) {
    probNum = (isAString(inCounty.substring(i,i+1)) == 1) ? 0 : 5;
    if (probNum == 5) {
      alert("Please use ONLY LETTERS or SPACES for COUNTY NAME");
      break;
    }
  }
//NOTE RETURN in middle of function - we don't return from inside the
//   previous FOR loop - that might create stack errors.

  if (probNum == 5) {
    return probNum;  
  }   

//Check that the COUNTY NAME is found in the list of counties for that state.
//  it might be mis-spelled.  
// NOTE that a partial match ALREADY WORKS in indexOf.  It will match the FIRST 
// occurance of the county name.  TEST 'BURG', 'FIELD' in South Carolina and see that
// ORANGEBURG is returned, NOT SPARTANBURG, and CHESTERFIELD is returned before EDGEFIELD.

//first call fillCountyInfo to fill the arrCounties array.
  fillCountyInfo(inState);

  var countyIndex = -1;

  for (i=0;i<arrCounties.length;i++) {

    if (arrCounties[i].indexOf(inCounty) >= 0) {
      countyIndex = i;
      break;
    }
  }

//if countyIndex < 0 then county was not found. RETURN probnum=6.
  if (countyIndex < 0) {
    alert("COUNTY [" + inCounty + "] NOT FOUND in State [" + inState + "]. Please CHECK SPELLING.")
    probnum = 6;
    return probnum;
  } else {
//Since a PARTIAL match works in the indexOf command, we will place the ENTIRE 
// name of a partially matched COUNTY name into the Name of County text box.
    userValues[6].value = arrCounties[countyIndex];
  }

  if (whichPanel == "P2") {

    var hillShape = userValues[7].value;
    var lVal = userValues[8].value;
    var crestDist = userValues[9].value;
    var hillHeight = userValues[10].value;

    if (hillShape == "SLCT") {
      alert("PLEASE SELECT a HILL SHAPE -OR- UNCHECK the HILL, RIDGE or ESCARPMENT check box.");
      probnum = 7;
      return probnum;
    }
//check L Value is greater than 0.
    if (lVal == 0) {
      alert("L Value MUST be GREATER than zero.");
      probnum = 8;
      return probnum;
    }

//is lVal numeric?  no? return 8 else return 0 if numeric
    for (i=0;i<lVal.length;i++) {
      probNum = (isANumber(lVal.substring(i,i+1)) == 1) ? 0 : 8;
      if (probNum == 8) {
        alert("PLEASE use NUMBERS ONLY for L VALUE.");
        break;
      }
    }

    if (probNum == 8) {
      return probNum;  
    }   

//check Crest Distance is greater than 0.
    if (crestDist == 0) {
      alert("CREST DISTANCE MUST be GREATER than zero.");
      probnum = 9;
      return probnum;
    }

//is crestDist numeric?  no? return 9 else return 0 if numeric
    for (i=0;i<crestDist.length;i++) {
      probNum = (isANumber(crestDist.substring(i,i+1)) == 1) ? 0 : 9;
      if (probNum == 9) {
        alert("PLEASE use NUMBERS ONLY for CREST DISTANCE.");
        break;
      }
    }

    if (probNum == 9) {
      return probNum;  
    }   

//check Hill Height is greater than 0.
    if (hillHeight <= 0) {
      alert("HILL HEIGHT MUST be GREATER than zero.");
      probnum = 10;
      return probnum;
    }

//is hillHeight numeric?  no? return 10 else return 0 if numeric
    for (i=0;i<hillHeight.length;i++) {
      probNum = (isANumber(hillHeight.substring(i,i+1)) == 1) ? 0 : 10;
      if (probNum == 10) {
        alert("PLEASE use NUMBERS ONLY for HILL HEIGHT.");
        break;
      }
    }

    if (probNum == 10) {
      return probNum;  
    }   


  } // if whichPanel == "P2"
 
  
  return probNum;
}


function clrOutputs() {
//Clears the Wind Speed, Vertical and Horiz pull values from output frame.


//get LABEL Table Data TEXT section lblBasWindSpeed from leftHalfFrame
//  var lbl_basWindSpeed = document.getElementById("lblBasWindSpeed");
//get LABEL Table Data TEXT section rlblBasWindSpeed from RightFrame
  var lbl_basWindSpeed = parent.frames[1].document.getElementById("rlblBasWindSpeed");

//  var zzz = parent.frames[1].document.getElementById("rbasWindSpeed");
//  alert("zzz = " + zzz.firstChild.nodeValue);
// zzz.firstChild.nodeValue = "ZZZ";


//get TABLE DATA section basWindSpeed from rightFrameTop
  var ext_basWindSpeed = parent.frames[1].document.getElementById("rbasWindSpeed");

//get LABEL tabel data TEXT section rlblvPullPress from rightFrameTop
  var lbl_vPullPress = parent.frames[1].document.getElementById("rlblvPullPress");

// get TABLE DATA section vPullPress from rightFrameTop
  var ext_vPullPress = parent.frames[1].document.getElementById("rvPullPress");

//get LABEL tabel data TEXT section rlblhPullPress from rightFrameTop
  var lbl_hPullPress = parent.frames[1].document.getElementById("rlblhPullPress");

// get TABLE DATA section hPullPress from rightFrameTop
  var ext_hPullPress = parent.frames[1].document.getElementById("rhPullPress");

// get LABEL special Notes rDispSpecNotes from rightFrameTop
  var lbl_specNotes = parent.frames[1].document.getElementById("rDispSpecNotes");

  lbl_basWindSpeed.firstChild.nodeValue = "  ";
  ext_basWindSpeed.firstChild.nodeValue = "  ";
  lbl_vPullPress.firstChild.nodeValue = "  ";
  ext_vPullPress.firstChild.nodeValue = "  ";
  lbl_hPullPress.firstChild.nodeValue = "  ";
  ext_hPullPress.firstChild.nodeValue = "  ";
  lbl_specNotes.firstChild.nodeValue = "  ";
}


function doCalcsAndPutOutputs(inputChkVal) {
//  errOff();


//alert(parent.frames[1].document.name);
  
//assign userValues[0] (radio button) value to isCoping
  var isCoping = userValues[0].checked;
//isFascia not required - use boolean switch on isCoping to investigate
//assign userValues[1] (radio button) value to isFascia
//  var isFascia = userValues[1].checked;

//get LABEL Table Data TEXT section rlblBasWindSpeed from rightFrameTop
  var lbl_basWindSpeed = parent.frames[1].document.getElementById("rlblBasWindSpeed");

//get TABLE DATA section basWindSpeed from rightFrameTop
  var ext_basWindSpeed = parent.frames[1].document.getElementById("rbasWindSpeed");

//get LABEL tabel data TEXT section rlblvPullPress from rightFrameTop
  var lbl_vPullPress = parent.frames[1].document.getElementById("rlblvPullPress");

// get TABLE DATA section vPullPress from rightFrameTop
  var ext_vPullPress = parent.frames[1].document.getElementById("rvPullPress");

//get LABEL tabel data TEXT section rlblhPullPress from rightFrameTop
  var lbl_hPullPress = parent.frames[1].document.getElementById("rlblhPullPress");

// get TABLE DATA section hPullPress from rightFrameTop
  var ext_hPullPress = parent.frames[1].document.getElementById("rhPullPress");

//get HEADER TABLE DATA outputHeader
  var lbl_outputHeader = parent.frames[1].document.getElementById("outputHeader");

// get LABEL special Notes rDispSpecNotes from rightFrameTop
  var lbl_specNotes = parent.frames[1].document.getElementById("rDispSpecNotes");

//assign Building Exposure (local) from global array;
  var exposure = userValues[3].value;
//assign Building Height
  var bldgHeight = userValues[2].value;
//assign State (html bldgLocale - js userValues[5])
  var inState = userValues[5].value;
//assign County (html bldgCounty - js userValues[6])
  var inCounty = userValues[6].value;

//create an array to change colors of output display when it is clicked.

  var zbColors = new Array();
  zbColors = ["lime", "yellow", "lightblue"];
  
// call calcBasicWindSpeed. pass STATE, COUNTY, and inputChkVal
//  inputChkVal = 4 if User did not enter a county name,
//  so calcBasicWindSpeed will return the HIGHEST wind speed for that state.

  var baseWindSpeed = 0;
  baseWindSpeed = calcBasicWindSpeed(inState, inCounty, inputChkVal);



//calculate qz based on Exposure
  switch(exposure) {
    case "B":
      var qz = calcExpBqz(bldgHeight, baseWindSpeed);
      break;
    case "C":
      var qz = calcExpCqz(bldgHeight, baseWindSpeed);
      break;
    case "D":
      var qz = calcExpDqz(bldgHeight, baseWindSpeed);
      break;
  }    

//assign Occupancy Category 
  var occCatg = userValues[4].value;

//calculate Importance Factor (I) based on occCatg and baseWindSpeed
  var importanceFactor = chooseImpFactor(occCatg, baseWindSpeed);

//calculate adjustedVelocity based on qz * importanceFactor
  var adjustedVelocity = qz * importanceFactor;

// calculate External Pressure Coefficient (GCp) based on bldgHeight and direction of pull.
  var GCpVert = chooseGCp(bldgHeight, "VERT");
  var GCpHorz = chooseGCp(bldgHeight, "HORZ");

//calculate vertical and horizontal pull values based on adjustedVelocity and GCp
  vertPull = (adjustedVelocity*GCpVert);
  horzPull = (adjustedVelocity*GCpHorz);


// HERE is where we calculate Topographical (HRE) factors.
// if whichPanel == "P1" calcKzt returns 1.00;
  var Kzt=calcKzt();

  vertPull=Math.round(vertPull*Kzt);
  horzPull=Math.round(horzPull*Kzt);

//Output values to page
//Output Basic Wind speed via lbl_basWindSpeed & ext_basWindSpeed.


//change the color of the header (visual cue to user)
  lbl_outputHeader.style.backgroundColor = zbColors[outColorIter];

  lbl_basWindSpeed.style.backgroundColor = "white";
  lbl_basWindSpeed.style.border = "black groove 1px";

//Determine Messages that will be displayed to user
// if there is some GENERAL malfunction in calculations
  if (bwS == -99) {
    lbl_basWindSpeed.firstChild.nodeValue = " **** THERE IS A PROBLEM WITH CALCULATIONS -- CHECK INPUTS **** ";
//NOTE RETURN in middle of function!!!
    return;
  } else {
//if inputChkVal = 4 then user did not enter a county, so we are
//  using the HIGHEST wind speed for that state.  Notify user.
    if (inputChkVal == 4) {
      lbl_basWindSpeed.firstChild.nodeValue = "*using HIGHEST Basic Wind Speed for State [" + inState + "] :";
//If there are special wind regions in this state (when user has not entered a county name)
//  Global var hasSpecial is assigned in fillCountyInfo().
      if (hasSpecial == 1) {
        lbl_specNotes.firstChild.nodeValue = ">>>NOTE: This State contains Special Wind Regions.  (Check local authorities for Special Wind Regions in this State)";
      } else {
        lbl_specNotes.firstChild.nodeValue = "No Special Wind Regions exist in this State.";
      }  
    } else {
//Wash DC is a particular case ... no counties, no special wind regions
      if (inState == "DC") { 
        lbl_basWindSpeed.firstChild.nodeValue = "Basic Wind Speed used for State [" + inState + "]:";
        lbl_specNotes.firstChild.nodeValue = " ";
      } else {
// basic wind speed LABEL
        lbl_basWindSpeed.firstChild.nodeValue = "Basic Wind Speed used for State [" + inState + "], County [" + inCounty + "]:";
//if this county is considered a Special Wind Region.
// Global var isSpecial is assigned in calcBasicWindSpeed()
        if (isSpecial == 1) {
          lbl_specNotes.firstChild.nodeValue = ">>>NOTE: This IS a SPECIAL WIND REGION. (Check local authorities for Wind Speeds in this region)";
        } else {
          lbl_specNotes.firstChild.nodeValue = " ";
        }
      }
    }
  }

//Output basic Wind Speed Values to ext_basWindSpeed    
  ext_basWindSpeed.style.backgroundColor = zbColors[outColorIter];
  ext_basWindSpeed.style.border = "black groove 2px";
  ext_basWindSpeed.firstChild.nodeValue = " " + Math.round(baseWindSpeed) + " mph.";

//Output label display to lbl_vPullPress
    lbl_vPullPress.style.backgroundColor = "white";
    lbl_vPullPress.style.border = "black groove 1px";
    lbl_vPullPress.firstChild.nodeValue = "Vertical (upward) Design Pressure : ";

//Ouput calculated values to page via ext_vPullPress and ext_hPullPress
//If isCoping then display vertical pull (vertical pull does not apply to fascia)

  ext_vPullPress.style.border = "black groove 2px";
  ext_vPullPress.style.backgroundColor = zbColors[outColorIter];

  if (isCoping == true) {
    ext_vPullPress.firstChild.nodeValue = " " + vertPull + " lbs/sq.ft.";
  } else {
    lbl_vPullPress.firstChild.nodeValue = "Vertical (upward) Design Pressure: (fascia does not apply) ";
    ext_vPullPress.firstChild.nodeValue = "n/a";
//set vertPull to "na" for any future processing (such as listProds())
    vertPull="na";
  }

  lbl_hPullPress.style.backgroundColor = "white";
  lbl_hPullPress.style.border = "black groove 1px";
  lbl_hPullPress.firstChild.nodeValue = "Horizontal (outward) Design Pressure : ";

  ext_hPullPress.style.backgroundColor = zbColors[outColorIter];
  ext_hPullPress.style.border = "black groove 2px";
  ext_hPullPress.firstChild.nodeValue = " " + horzPull + " lbs/sq.ft.";

//set flag to show that calculation has been done at least once.
  alreadyCalcd = 1;

//Iterate the colors of the output side
  outColorIter++;
  if (outColorIter >= 3) { outColorIter=0 }

  parent.frames[1].scroll(0,0);

//-----------------------------------------------------------------------------------
/*
 ==> NOTE: Define PART TYPES
  This If statement MUST be modified if new Component Types are added.
define prdString depending on part type
 HERE is where we can assign multiple parts types (coping, fascia, gutter, etc.)
 so listProds() can deal with them ( SEE function listProds() ).
*/

  if (isCoping == true) {
    var prdString = "Coping";
  } else {
    if (isFascia = true) {
      var prdString = "Fascia";
    }
  }

//Now call listProds to list products that meet specifications
  listProds(prdString, vertPull, horzPull);

//----------------------------------------------------------------------------------
 
}


function getInputs() {
//CALLED DIRECTLY from HTML when user clicks CALCULATE button.
// see WDCUserInputs.html.


// example to get elements from rightFrameTop
//  var zzz = parent.frames[1].document.getElementById("rbasWindSpeed");
//  alert("zzz = " + zzz.firstChild.nodeValue);
//  zzz.firstChild.nodeValue = "ZZZ";

//clear output values from frame rightFrameTop
  if (alreadyCalcd == 1) {
    clrOutputs();
  }

//retrieve user inputs from leftHalfFrame
  userValues[0]=document.getElementById("isCoping");
  userValues[1]=document.getElementById("isFascia");
  userValues[2]=document.getElementById("bldgHeight");
  userValues[3]=document.getElementById("bldgExpCat");
  userValues[4]=document.getElementById("bldgOccCat");
  userValues[5]=document.getElementById("bldgLocale");
  userValues[6]=document.getElementById("bldgCounty");

//if UserInputsP2.html is loaded in leftHalfFrame, then get the HRE values.

  if (whichPanel == "P2") {
    userValues[7]=document.getElementById("hillShape");
    userValues[8]=document.getElementById("lValue");
    userValues[9]=document.getElementById("crestDist");
    userValues[10]=document.getElementById("hillHeight");
  }

// make bldgCounty to Upper Case.
  userValues[6].value = userValues[6].value.toUpperCase();
  userValues[6].value = trim(userValues[6].value);
  userValues[2].value = trim(userValues[2].value);


//  test of values
/*
  alert("getInputs()\n" +
        "userValues[0](isCoping = " + userValues[0].checked + "\n" +
        "userValues[1](isFascia = " + userValues[1].checked + "\n" +
        "userValues[2](bldgHeight = " + userValues[2].value + "\n" +
        "userValues[3](bldgExpCat = " + userValues[3].value + "\n" +
        "userValues[4](bldgOccCat = " + userValues[4].value + "\n" +
        "userValues[5](bldgLocale = " + userValues[5].value + "\n" +
        "userValues[6](bldgCounty = " + userValues[6].value + "\n");

        "userValues[7](hillShape = " + userValues[7].value + "\n" +
        "userValues[8](LValue = " + userValues[8].value + "\n" +
        "userValues[9](crestDist = " + userValues[9].value + "\n" +
        "userValues[10](hillHeight = " + userValues[10].value);
*/


//problemInputs will be set to a value depending on the problem.
  var problemInputs = 0;

//call chkInputs.  Pass the state in case a message is displayed that 
//  the user did not enter the County name.
//  see function chkInputs.

  problemInputs = chkInputs(userValues[5].value);       

//If problemInputs is zero then they're ok  
// otherwise a number is returned that reflects which field has the input
//  problem.  set focus to that field.

    switch(problemInputs) {
//case 0 - no problems.
      case 0:
        doCalcsAndPutOutputs(problemInputs);
        qString=buildQueryString();
         calcMode = 1;
        break;
//case 1 is Building Height missing
      case 1:
//case 2 is Building Height non-numeric
      case 2:
        clrOutputs();
        calcMode = 0;
        userValues[2].focus();
        userValues[2].select();
        break;
//case 3 is STATE not selected
      case 3:
        clrOutputs();
        calcMode = 0;
        userValues[5].focus();
        break;
//case 4 is for missing County - not a show-stopper, just uses different
//                               values and notifies user.
      case 4:
        doCalcsAndPutOutputs(problemInputs);
        qString=buildQueryString();
        calcMode = 1;
        break;
//case 5 is for non-alphabetic county
      case 5:
        clrOutputs();
        calcMode = 0;
        userValues[6].focus();
        userValues[6].select();
        break;
//case 6 is that County was entered by user, but not found in list of counties
//  for that state (could be mis-spelled).
      case 6:
        clrOutputs();
        calcMode = 0;
        userValues[6].focus();
        userValues[6].select();
        break;
//Panel 2 checks
//case 7 is that Hill Shape not selected.
      case 7:
        clrOutputs();
        calcMode = 0;
        userValues[7].focus();
//        userValues[7].select();
        break;
//case 8 is that L Value is invalid (<=0 or not numeric)
      case 8:
        clrOutputs();
        calcMode = 0;
        userValues[8].focus();
        userValues[8].select();
        break;
//case 9 us that Crest Distance is invalid (<=0 or not numeric)
      case 9:
        clrOutputs();
        calcMode = 0;
        userValues[9].focus();
        userValues[9].select();
        break;
//case 10 us that Hill Height is invalid (<=0 or not numeric)
      case 10:
        clrOutputs();
        calcMode = 0;
        userValues[10].focus();
        userValues[10].select();
        break;
   
    }

}

function rightFrameHelp(whichHelp) {

// CALLED DIRECTLY FROM HTML when user selects a HELP button.
// see WDCUserInputs.html

//set countyFrameLoaded to 0 so that if the user goes back to state or county
// we will reload the frame.

 countyFrameLoaded = 0;

//turn off calcMode
 calcMode = 0;

  switch(whichHelp) {
    case "Exposure":
      window.open("./WDCExposureHelp.html","rightFrameBot");
      break;

    case "Occupancy":
      window.open("./WDCOccupancyHelp.html","rightFrameBot");
      break;

    case "States":
      break;

    case "HillShape":
      window.open("./KmodifierDEF.html","rightFrameBot");
      break;      
    case "LVal":
    case "CrestDist":
    case "HillHeight":
      window.open("./KmodifierSYM.html","rightFrameBot");
      break;      
  }    
}

function chkErr(iMessage, iUrl, iLine) {
//  errOff();
  alert("An error occured :\n" + iMessage + "\n URL: " + iUrl + "\nLine Number: " + iLine);
  return true;
}

function displayHomePage() {
//CALLED DIRECTLY from HTML.
// see WDCUserInputs.html

/* if user selects the AAMMI logo to go to home page,
  we do not want the home page displayed inside leftHalfFrame, we want it
  displayed as a single page, so we replace the frame pages with a blank page, 
  then move to home location.

 EVEN THOUGH Netscape, Firefox, Mozilla do not use the "location" property, this
 WORKS.

*/
  calcMode = 0;

// isFrame0 should be allTop (main frameset)
   var isFrame0 = parent.parent.document;
//alert("isFrame0.name = " + isFrame0.name);
// not sure why this works, but it does ... !
  isFrame0.location = AAMMIBlank;
//  window.open(AAMMIBlank);
  isFrame0.location = AAMMIHome;
//  window.open(AAMMIHome);
}


function fillCountyInfo(inState) {
//fills up array arrCounties based on the parameter inState


  switch(inState) {

    case "CT":
      arrCounties = [ "FAIRFIELD", "HARTFORD", "LITCHFIELD", "MIDDLESEX", "NEW HAVEN", "NEW LONDON", "TOLLAND", "WINDHAM" ];
      arrWindSpeed = [ 105, 99, 94, 110, 108, 115, 100, 105 ];
      arrSpecWindReg = [ 0, 0, 1, 0, 0, 0, 0, 0 ];
      highSpeed = 115;
      hasSpecial=1;
      break;

    case "DE":
      arrCounties = [ "KENT", "NEW CASTLE", "SUSSEX" ];
      arrWindSpeed = [ 96, 90, 107 ];
      arrSpecWindReg = [ 0, 0, 0 ];
      highSpeed = 107;
      hasSpecial=0;
      break;

    case "DC":
//      arrCounties = ["no counties in DC"];
      arrCounties = [""];
      arrWindSpeed = [ 90 ];
      arrSpecWindReg = [ 0 ];
      highSpeed = 90;
      hasSpecial=0;
      break;

    case "ME":
      arrCounties = [ "ANDROSCOGGIN", "AROOSTOOK", "CUMBERLAND", "FRANKLIN", "HANCOCK", "KENNEBEC", "KNOX", "LINCOLN", "OXFORD", "PENOBSCOT", "PISCATAQUIS", "SAGADAHOC", "SOMERSET", "WALDO", "WASHINGTON", "YORK"];
      arrWindSpeed = [ 92, 90, 94, 90, 91, 91, 97, 97, 90, 90, 90, 99, 90, 93, 90, 96 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 99;
      hasSpecial=0;
      break;

    case "MD":
      arrCounties = [ "ALLEGANY", "ANNE ARUNDEL", "BALTIMORE", "CALVERT", "CAROLINE", "CARROLL", "CECIL", "CHARLES", "DORCHESTER", "FREDERICK", "GARRETT", "HARFORD", "HOWARD", "KENT", "MONTGOMERY", "PRINCE GEORGE'S", "QUEEN ANNE'S", "ST. MARY'S", "SOMERSET", "TALBOT", "WASHINGTON", "WICOMICO", "WORCESTER"];
      arrWindSpeed = [ 90, 90, 90, 90, 94, 90, 90, 90, 96, 90, 90, 90, 90, 90, 90, 90, 90, 90, 110, 91, 90, 109, 115 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 115;
      hasSpecial=0;
      break;

    case "MA":
      arrCounties = [ "BARNSTABLE", "BERKSHIRE", "BRISTOL", "DUKES", "ESSEX", "FRANKLIN", "HAMPDEN", "HAMPSHIRE", "MIDDLESEX", "NANTUCKET", "NORFOLK", "PLYMOUTH", "SUFFOLK", "WORCESTER"];
      arrWindSpeed = [ 115, 90, 110, 118, 104, 90, 95, 93, 100, 118, 105, 112, 105, 97 ];
      arrSpecWindReg = [ 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 118;
      hasSpecial=1;
      break;

    case "NH":
      arrCounties = [ "BELKNAP", "CARROLL", "CHESHIRE", "COOS", "GRAFTON", "HILLSBOROUGH", "MERRIMACK", "ROCKINGHAM", "STRAFFORD", "SULLIVAN"];
      arrWindSpeed = [ 90, 90, 90, 90, 90, 93, 90, 97, 95, 90 ];
      arrSpecWindReg = [ 0, 0, 1, 1, 1, 0, 0, 0, 0, 1 ];
      highSpeed = 97;
      hasSpecial=1;
      break;

    case "NJ":
      arrCounties = [ "ATLANTIC", "BERGEN", "BURLINGTON", "CAMDEN", "CAPE MAY", "CUMBERLAND", "ESSEX", "GLOUCESTER", "HUDSON", "HUNTERDON", "MERCER", "MIDDLESEX", "MONMOUTH", "MORRIS", "OCEAN", "PASSAIC", "SALEM", "SOMERSET", "SUSSEX", "UNION", "WARREN"];
      arrWindSpeed = [ 110, 100, 100, 94, 112, 100, 100, 94, 102, 90, 95, 99, 109, 90, 110, 92, 91, 91, 90, 99, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 112;
      hasSpecial=0;
      break;

    case "NY":
      arrCounties = [ "ALBANY", "ALLEGANY", "BRONX", "BROOME", "CATTARAUGUS", "CAYUGA", "CHAUTAUQUA", "CHEMUNG", "CHENANGO", "CLINTON", "COLUMBIA", "CORTLAND", "DELAWARE", "DUTCHESS", "ERIE", "ESSEX", "FRANKLIN", "FULTON", "GENESEE", "GREENE", "HAMILTON", "HERKIMER", "JEFFERSON", "KINGS", "LEWIS", "LIVINGSTON", "MADISON", "MONROE", "MONTGOMERY", "NASSAU", "NEW YORK", "NIAGARA", "ONEIDA", "ONONDAGA", "ONTARIO", "ORANGE", "ORLEANS", "OSWEGO", "OTSEGO", "PUTNAM", "QUEENS", "RENSSELAER", "RICHMOND", "ROCKLAND", "ST. LAWRENCE", "SARATOGA", "SCHENECTADY", "SCHOHARIE", "SCHUYLER", "SENECA", "STEUBEN", "SUFFOLK", "SULLIVAN", "TIOGA", "TOMPKINS", "ULSTER", "WARREN", "WASHINGTON", "WAYNE", "WESTCHESTER", "WYOMING", "YATES" ];
      arrWindSpeed = [ 90, 90, 102, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 108, 90, 90, 90, 90, 90, 112, 102, 90, 90, 90, 90, 90, 90, 90, 90, 92, 110, 90, 102, 93, 90, 90, 90, 90, 90, 90, 90, 116, 90, 90, 90, 90, 90, 90, 90, 96, 90, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 ];
      highSpeed = 116;
      hasSpecial=1;
      break;

    case "NC":
      arrCounties = [ "ALAMANCE", "ALEXANDER", "ALLEGHANY", "ANSON", "ASHE", "AVERY", "BEAUFORT", "BERTIE", "BLADEN", "BRUNSWICK", "BUNCOMBE", "BURKE", "CABARRUS", "CALDWELL", "CAMDEN", "CARTERET", "CASWELL", "CATAWBA", "CHATHAM", "CHEROKEE", "CHOWAN", "CLAY", "CLEVELAND", "COLUMBUS", "CRAVEN", "CUMBERLAND", "CURRITUCK", "DARE", "DAVIDSON", "DAVIE", "DUPLIN", "DURHAM", "EDGECOMBE", "FORSYTH", "FRANKLIN", "GASTON", "GATES", "GRAHAM", "GRANVILLE", "GREENE", "GUILFORD", "HALIFAX", "HARNETT", "HAYWOOD", "HENDERSON", "HERTFORD", "HOKE", "HYDE", "IREDELL", "JACKSON", "JOHNSTON", "JONES", "LEE", "LENOIR", "LINCOLN", "MCDOWELL", "MACON", "MADISON", "MARTIN", "MECKLENBURG", "MITCHELL", "MONTGOMERY", "MOORE", "NASH", "NEW HANOVER", "NORTHAMPTON", "ONSLOW", "ORANGE", "PAMLICO", "PASQUOTANK", "PENDER", "PERQUIMANS", "PERSON", "PITT", "POLK", "RANDOLPH", "RICHMOND", "ROBESON", "ROCKINGHAM", "ROWAN", "RUTHERFORD", "SAMPSON", "SCOTLAND", "STANLY", "STOKES", "SURRY", "SWAIN", "TRANSYLVANIA", "TYRRELL", "UNION", "VANCE", "WAKE", "WARREN", "WASHINGTON", "WATAUGA", "WAYNE", "WILKES", "WILSON", "YADKIN", "YANCEY" ];
      arrWindSpeed = [ 90, 90, 90, 93, 90, 90, 109, 100, 108, 131, 90, 90, 90, 90, 109, 132, 90, 90, 90, 90, 103, 90, 90, 114, 115, 98, 114, 123, 90, 90, 109, 90, 96, 90, 92, 90, 99, 90, 90, 102, 90, 93, 95, 90, 90, 95, 96, 121, 90, 90, 96, 115, 92, 106, 90, 90, 90, 90, 102, 90, 90, 90, 93, 94, 129, 92, 122, 90, 121, 108, 120, 105, 90, 103, 90, 90, 94, 103, 90, 90, 90, 102, 97, 90, 90, 90, 90, 90, 115, 90, 90, 93, 90, 107, 90, 101, 90, 97, 90, 90 ];
      arrSpecWindReg = [ 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ];
      highSpeed = 132;
      hasSpecial=1;
      break;

    case "OH":
      arrCounties = [ "ADAMS", "ALLEN", "ASHLAND", "ASHTABULA", "ATHENS", "AUGLAIZE", "BELMONT", "BROWN", "BUTLER", "CARROLL", "CHAMPAIGN", "CLARK", "CLERMONT", "CLINTON", "COLUMBIANA", "COSHOCTON", "CRAWFORD", "CUYAHOGA", "DARKE", "DEFIANCE", "DELAWARE", "ERIE", "FAIRFIELD", "FAYETTE", "FRANKLIN", "FULTON", "GALLIA", "GEAUGA", "GREENE", "GUERNSEY", "HAMILTON", "HANCOCK", "HARDIN", "HARRISON", "HENRY", "HIGHLAND", "HOCKING", "HOLMES", "HURON", "JACKSON", "JEFFERSON", "KNOX", "LAKE", "LAWRENCE", "LICKING", "LOGAN", "LORAIN", "LUCAS", "MADISON", "MAHONING", "MARION", "MEDINA", "MEIGS", "MERCER", "MIAMI", "MONROE", "MONTGOMERY", "MORGAN", "MORROW", "MUSKINGUM", "NOBLE", "OTTAWA", "PAULDING", "PERRY", "PICKAWAY", "PIKE", "PORTAGE", "PREBLE", "PUTNAM", "RICHLAND", "ROSS", "SANDUSKY", "SCIOTO", "SENECA", "SHELBY", "STARK", "SUMMIT", "TRUMBULL", "TUSCARAWAS", "UNION", "VAN WERT", "VINTON", "WARREN", "WASHINGTON", "WAYNE", "WILLIAMS", "WOOD", "WYANDOT" ];
      arrWindSpeed = [ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 90;
      hasSpecial=0;
      break;

    case "PA":
      arrCounties = [ "ADAMS", "ALLEGHENY", "ARMSTRONG", "BEAVER", "BEDFORD", "BERKS", "BLAIR", "BRADFORD", "BUCKS", "BUTLER", "CAMBRIA", "CAMERON", "CARBON", "CENTRE", "CHESTER", "CLARION", "CLEARFIELD", "CLINTON", "COLUMBIA", "CRAWFORD", "CUMBERLAND", "DAUPHIN", "DELAWARE", "ELK", "ERIE", "FAYETTE", "FOREST", "FRANKLIN", "FULTON", "GREENE", "HUNTINGDON", "INDIANA", "JEFFERSON", "JUNIATA", "LACKAWANNA", "LANCASTER", "LAWRENCE", "LEBANON", "LEHIGH", "LUZERNE", "LYCOMING", "MCKEAN", "MERCER", "MIFFLIN", "MONROE", "MONTGOMERY", "MONTOUR", "NORTHAMPTON", "NORTHUMBERLAND", "PERRY", "PHILADELPHIA", "PIKE", "POTTER", "SCHUYLKILL", "SNYDER", "SOMERSET", "SULLIVAN", "SUSQUEHANNA", "TIOGA", "UNION", "VENANGO", "WARREN", "WASHINGTON", "WAYNE", "WESTMORELAND", "WYOMING", "YORK"];
      arrWindSpeed = [ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 90;
      hasSpecial=0;
      break;

    case "RI":
      arrCounties = [ "BRISTOL", "KENT", "NEWPORT", "PROVIDENCE", "WASHINGTON"];
      arrWindSpeed = [ 111, 110, 116, 105, 119 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0 ];
      highSpeed = 119;
      hasSpecial=0;
      break;

    case "SC":
      arrCounties = [ "ABBEVILLE", "AIKEN", "ALLENDALE", "ANDERSON", "BAMBERG", "BARNWELL", "BEAUFORT", "BERKELEY", "CALHOUN", "CHARLESTON", "CHEROKEE", "CHESTER", "CHESTERFIELD", "CLARENDON", "COLLETON", "DARLINGTON", "DILLON", "DORCHESTER", "EDGEFIELD", "FAIRFIELD", "FLORENCE", "GEORGETOWN", "GREENVILLE", "GREENWOOD", "HAMPTON", "HORRY", "JASPER", "KERSHAW", "LANCASTER", "LAURENS", "LEE", "LEXINGTON", "MCCORMICK", "MARION", "MARLBORO", "NEWBERRY", "OCONEE", "ORANGEBURG", "PICKENS", "RICHLAND", "SALUDA", "SPARTANBURG", "SUMTER", "UNION", "WILLIAMSBURG", "YORK"];
      arrWindSpeed = [ 90, 94, 101, 90, 101, 98, 122, 121, 98, 129, 90, 90, 95, 104, 110, 98, 102, 110, 92, 92, 105, 126, 90, 90, 105, 119, 111, 95, 92, 90, 97, 94, 90, 108, 97, 90, 90, 100, 90, 95, 91, 90, 97, 90, 111, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 129;
      hasSpecial=0;
      break;

    case "VT":
      arrCounties = [ "ADDISON", "BENNINGTON", "CALEDONIA", "CHITTENDEN", "ESSEX", "FRANKLIN", "GRAND ISLE", "LAMOILLE", "ORANGE", "ORLEANS", "RUTLAND", "WASHINGTON", "WINDHAM", "WINDSOR"];
      arrWindSpeed = [ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 ];
      arrSpecWindReg = [ 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ];
      highSpeed = 90;
      hasSpecial=1;
      break;

    case "VA":
      arrCounties = [ "ACCOMACK", "ALBEMARLE", "ALLEGHANY", "AMELIA", "AMHERST", "APPOMATTOX", "ARLINGTON", "AUGUSTA", "BATH", "BEDFORD", "BLAND", "BOTETOURT", "BRUNSWICK", "BUCHANAN", "BUCKINGHAM", "CAMPBELL", "CAROLINE", "CARROLL", "CHARLES CITY", "CHARLOTTE", "CHESTERFIELD", "CLARKE", "CRAIG", "CULPEPER", "CUMBERLAND", "DICKENSON", "DINWIDDIE", "ESSEX", "FAIRFAX", "FAUQUIER", "FLOYD", "FLUVANNA", "FRANKLIN", "FREDERICK", "GILES", "GLOUCESTER", "GOOCHLAND", "GRAYSON", "GREENE", "GREENSVILLE", "HALIFAX", "HANOVER", "HENRICO", "HENRY", "HIGHLAND", "ISLE OF WIGHT", "JAMES CITY", "KING AND QUEEN", "KING GEORGE", "KING WILLIAM", "LANCASTER", "LEE", "LOUDOUN", "LOUISA", "LUNENBURG", "MADISON", "MATHEWS", "MECKLENBURG", "MIDDLESEX", "MONTGOMERY", "NELSON", "NEW KENT", "NORTHAMPTON", "NORTHUMBERLAND", "NOTTOWAY", "ORANGE", "PAGE", "PATRICK", "PITTSYLVANIA", "POWHATAN", "PRINCE EDWARD", "PRINCE GEORGE", "PRINCE WILLIAM", "PULASKI", "RAPPAHANNOCK", "RICHMOND", "ROANOKE", "ROCKBRIDGE", "ROCKINGHAM", "RUSSELL", "SCOTT", "SHENANDOAH", "SMYTH", "SOUTHAMPTON", "SPOTSYLVANIA", "STAFFORD", "SURRY", "SUSSEX", "TAZEWELL", "WARREN", "WASHINGTON", "WESTMORELAND", "WISE", "WYTHE", "YORK"];
      arrWindSpeed = [ 114, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 97, 90, 90, 90, 90, 90, 90, 90, 90, 90, 96, 93, 90, 90, 90, 97, 90, 90, 90, 90, 90, 103, 90, 96, 90, 90, 90, 113, 95, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 92, 90, 90, 92, 90, 90, 90, 90, 90, 90, 90, 96 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0 ];
      highSpeed = 114;
      hasSpecial=1;
      break;

    case "WV":
      arrCounties = [ "BARBOUR", "BERKELEY", "BOONE", "BRAXTON", "BROOKE", "CABELL", "CALHOUN", "CLAY", "DODDRIDGE", "FAYETTE", "GILMER", "GRANT", "GREENBRIER", "HAMPSHIRE", "HANCOCK", "HARDY", "HARRISON", "JACKSON", "JEFFERSON", "KANAWHA", "LEWIS", "LINCOLN", "LOGAN", "MCDOWELL", "MARION", "MARSHALL", "MASON", "MERCER", "MINERAL", "MINGO", "MONONGALIA", "MONROE", "MORGAN", "NICHOLAS", "OHIO", "PENDELTON", "PLEASANTS", "POCAHONTAS", "PRESTON", "PUTNAM", "RALEIGH", "RANDOLPH", "RITCHIE", "ROANE", "SUMMERS", "TAYLOR", "TUCKER", "TYLER", "UPSHUR", "WAYNE", "WEBSTER", "WETZEL", "WIRT", "WOOD", "WYOMING"];
      arrWindSpeed = [ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90 ];
      arrSpecWindReg = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
      highSpeed = 90;
      hasSpecial=0;
      break;

  }


}


function fillCountyString(inState) {
//fills the string countyString (global) with the county list of the 
// presently selected state

    countyString = "";
    for (i=0;i<arrCounties.length;i++) {
     countyString = countyString + arrCounties[i] + ", ";
    }
}


function chkCountyDisplayLoad(whichCall) {
//CALLED DIRECTLY from HTML when user selects the State OR County drop-downs.
// see WDCUserInputs.html.

  var tmpStr = "";
//turn off errors.  See ERROR NOTE below
//  errOff();

  calcMode = 0;

//get STATE user value
  var iState=document.getElementById("bldgLocale");
//get element bldgCounty 
  var iCounty=document.getElementById("bldgCounty");


//  if (countyFrameLoaded == 0)  {
     window.open("./CountiesPages/WDCCountiesStart.html","rightFrameBot");

    countyFrameLoaded = 1;
// alert("in chkCountyDisplay countyFrameLoaded = " + countyFrameLoaded);
//  }

//if called when focus is on the STATE select list
  if (whichCall.indexOf("state") >= 0) {

   iStateChecked = 1;

  //if County value is not null, then clear it.
  // since the user is selecting the state, we want to clear any previous county that
  //  was entered, to prepare for a new state.

    if (iCounty.value != "") {
      iCounty.value = "";
    }  

  }


//if called when focus is on the COUNTY text box

  if (whichCall.indexOf("county") >= 0) {

    if (iState.value == "SLCT") {
      window.open("./CountiesPages/WDCCountiesStart.html","rightFrameBot");
      iState.focus();
      iStateChecked = 1;
    } else {
      //select any contents that might be inside the Name of County text box
      iCounty.select();
      //fill array of  counties for state
      fillCountyInfo(iState.value);
      //display counties to frame
      fillCountyString(iState.value);  
      tmpStr = "./CountiesPages/WDCCounties" + iState.value + ".html";
      window.open(tmpStr,"rightFrameBot");
    }

  }


//  errOff();

}

function doNothing() { return true; }

function errOff() { window.onerror = doNothing; }

// Utility function to trim spaces from both ends of a string
function trim(inString) {
  var retVal = "";
  var start = 0;
  while ((start < inString.length) && (inString.charAt(start) == ' ')) {
    ++start;
  }
  var end = inString.length;
  while ((end > 0) && (inString.charAt(end - 1) == ' ')) {
    --end;
  }
//if start is >= end it means that white space has been entered but NO other characters.
//  so we are going to return a null.

  if (start >= end) {
    retVal = ""
  } else {
    retVal = inString.substring(start, end);
  }

  return retVal;
}




function junkFunc() {
/*

alert("PERFORMING SWITCH");
  switch (inState) {
    case "CT":
      bWS = 115;

      switch(inCounty) {
        case "FAIRFIELD":
          bWS=105;
          break;
        case "HARTFORD":
          bWS=99;
          break;
        case "LITCHFIELD":
          bWS=94;
          isHurrProne=1;
          break;
        case "MIDDLESEX":
          bWS=110;
          break;
        case "NEW HAVEN":
          bWS=108;
          break;
        case "NEW LONDON":
          bWS=115;
          break;
        case "TOLLAND":
          bWS=100;
          break;
        case "WINDHAM":
          bWS=105;
          break;
      }
      break;            
    case "DE":
      bWS=107;
      
//BOWERS BEACH Delaware
      if (inCounty.indexOf("BOW") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "DC":
      bWS=90;
      break;
    case "ME":
      bWS=97;
// Bar Harbor Maine
      if (inCounty.indexOf("BAR") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "MD":
      bWS=117;
      if (inCounty.indexOf("OCEAN") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "MA":
      bWS=106;
//Boston or Hyannis Massachussetts
      if ( (inCounty.indexOf("BOST") >= 0) || (inCounty.indexOf("HYA") >= 0) ) {
        isHurrProne = 1;
      }
      break;
    case "NH":
      bWS=102;
//Hampton Beach New Hampshire
      if (inCounty.indexOf("HAMP") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "NJ":
      bWS=114;
//Atlantic City NJ
      if (inCounty.indexOf("ATLA") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "NY":
      bWS=120;
//Southhampton NY
      if (inCounty.indexOf("HAMP") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "NC":
      bWS=132;
//Wrightsville, NC
      if (inCounty.indexOf("WRIGHT") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "OH":
//All of Ohio is 90mph
      bWS=90;
      break;
    case "PA":
//all of PA is 90mph
      bWS=90;
      break;
    case "RI":
      bWS=117;
//Newport RI
      if (inCounty.indexOf("NEWPORT") >= 0) {
        isHurrProne = 1;
      } 
      break;
    case "SC":
      bWS=131;
//Folly Beach SC
      if (inCounty.indexOf("FOLLY") >= 0) {
        isHurrProne = 1;
      }   
      break;
    case "VT":
//All of VT is 90mph
      bWS=90;
      break;
    case "VA":
      bWS=114;
//Virginia Beach VA
      if (inCounty.indexOf("VIRGI") >= 0) {
        isHurrProne = 1;
      }
      break;
    case "WV":
//All of WV is 90
      bWS=90;
      break;
  }

if (isHurrProne == 1) {
  bWS = bWS * hurrAdj;
}

*/
}

function HRESwitch(htmlWhichPanel) {
//This function is called DIRECTLY from HTML when user checks/unchecks
// the Hill, Ridge or Escarpment checkbox topoChk.
// htmlWhichPanel is the panel that CALLED HRESwitch 
//  i.e. if called from WDCUserInputsP1.html then htmlWhichPanel = "1",
//       if called from WDCUserInputsP2.html then htmlWhichPanel = "2"

//change the color of the outputHeader back to the original white (visual cue)

//get HEADER TABLE DATA outputHeader
  var lbl_outputHeader = parent.frames[1].document.getElementById("outputHeader");
  lbl_outputHeader.style.backgroundColor = "white";

//Pick up any user entries thusfar, and pass them to the page when opening.
// pass using pagename?param=value&param=value&param=value.
// then strip apart the params using split and fill the text/select areas with the
// correct entry.

//

//  var qString = new String();

  calcMode = 0;

//If we are in Panel 1, then switch to Panel 2
  if (htmlWhichPanel == '1') {

//  alert("in HRESwtich loading P2");

//call buildQueryString to build the string to pass to WDCUserInputsP2.html
    qString=buildQueryString();

    window.open("./WDCUserInputsP2.html"+qString,"leftHalfFrame");
    whichPanel = "P2";

  } else {
//If we are in Panel 2, then switch to Panel 1
//  alert("in HRESwtich loading P1");

//call buildQueryString to build the string to pass to WDCUserInputsP1.html
    qString=buildQueryString();

    window.open("./WDCUserInputsP1.html"+qString,"leftHalfFrame");
    whichPanel = "P1";

  }

  window.open("./WDCCalcOutputs.html","rightFrameTop");

}

function fillParmsPassed(htmlWhichPanel) {

// This function is called DIRECTLY from HTML whenever the BODY 
// is loaded for WDCUserInputsP1.html or WDCUserInputsP2.html.

  calcMode = 0;

//First place the search.substring [?name=value&name=value ...] into ppQueryString. 
//NOTE that the VALUES of the search substring name/value pairs ALL EQUAL 'init'
// when this page is first run, that is, when WDCMAIN.html first calls
// WDCUserInputsP1.html.  Otherwise, they equal the parameters as passed.

  var ppQueryString = window.location.search.substring(1);

//create array where passed parameter VALUES will be stored
  var ppQSParm = new Array();

//create array based on SPLIT('&') of ppQueryString.
  var ppParms = ppQueryString.split('&');

//Now parse the Query string and place each Query String Value into ppQSParm elements
  for (var i=0; i<ppParms.length; i++) {
    var pos = ppParms[i].indexOf('=');
    if (pos > 0) {
      var iVal = ppParms[i].substring(pos+1);
      ppQSParm[i] = iVal;
    }  
  }


//retrieve which panel we are in place into GLOBAL var whichPanel
   whichPanel = htmlWhichPanel;
//alert("whichPanel = " + whichPanel);

// if ppQSParm[1] == "init" then this is the first loading of Panel P1. 
// do nothing in this case.

  if (ppQSParm[1] != "init") {
    
//get address location of inputs
    userValues[0]=document.getElementById("isCoping");
    userValues[1]=document.getElementById("isFascia");
    userValues[2]=document.getElementById("bldgHeight");
    userValues[3]=document.getElementById("bldgExpCat");
    userValues[4]=document.getElementById("bldgOccCat");
    userValues[5]=document.getElementById("bldgLocale");
    userValues[6]=document.getElementById("bldgCounty");

//if UserInputsP2.html is loaded in leftHalfFrame, then get the HRE values.

    if (whichPanel == "P2") {
      userValues[7]=document.getElementById("hillShape");
      userValues[8]=document.getElementById("lValue");
      userValues[9]=document.getElementById("crestDist");
      userValues[10]=document.getElementById("hillHeight");
      window.open("./WDCHREPageSwitch.html","rightFrameBot");
    } else {
//we do this in case the user uses the 'back' button to move back to panel 1
//  turn off the HRE check box topoChk and set focus to first userValues
//alert("turn off topoChk");
      var tVal=document.getElementById("topoChk");
      tVal.checked=false;
      window.open("./WDCHelpPageStart.html","rightFrameBot");
      userValues[0].focus();
    }    


//since the params evaluate to strings, the values true and false are not actually
// passed as boolean.  Check contents and set boolean values accordingly.
    if (ppQSParm[1] == "true") {
      userValues[0].checked = true;
    } else {
      userValues[0].checked = false;
    }
    if (ppQSParm[2] == "true") {
      userValues[1].checked = true;
    } else {
      userValues[1].checked = false;
    }

//load the rest of the values into the GLOBAL userValues array.
    userValues[2].value=ppQSParm[3];
    userValues[3].value=ppQSParm[4];
    userValues[4].value=ppQSParm[5];
    userValues[5].value=ppQSParm[6];
    userValues[6].value=ppQSParm[7];

    window.open("./WDCHelpPageStart.html","rightFrameBot");

  } else { // else ppQSParm[1] != "init"
      window.open("./WDCHelpPageStart.html","rightFrameBot");
  } //if ppQSParm != "init"

}


function buildQueryString() {


var retString = new String();

//get present inputs and place into GLOBAL userValues array.
  userValues[0]=document.getElementById("isCoping");
  userValues[1]=document.getElementById("isFascia");
  userValues[2]=document.getElementById("bldgHeight");
  userValues[3]=document.getElementById("bldgExpCat");
  userValues[4]=document.getElementById("bldgOccCat");
  userValues[5]=document.getElementById("bldgLocale");
  userValues[6]=document.getElementById("bldgCounty");

//build the string
  retString="?panelID=" + whichPanel;
  retString=retString + "&isC=" + userValues[0].checked;
  retString=retString + "&isF=" + userValues[1].checked;
  retString=retString + "&bH=" + userValues[2].value;
  retString=retString + "&exP=" + userValues[3].value;
  retString=retString + "&occCat=" + userValues[4].value;
  retString=retString + "&sLoc=" + userValues[5].value;
  retString=retString + "&sC=" + userValues[6].value;

  if (whichPanel == "P2") {
    userValues[7]=document.getElementById("hillShape");
    userValues[8]=document.getElementById("lValue");
    userValues[9]=document.getElementById("crestDist");
    userValues[10]=document.getElementById("hillHeight");

//build the rest of the string if whichPanel = P2
    retString=retString + "&hS=" + userValues[7].value;   
    retString=retString + "&lV=" + userValues[8].value;
    retString=retString + "&cD=" + userValues[9].value;
    retString=retString + "&hH=" + userValues[10].value;
  } else {
    retString=retString + "&hS=";   
    retString=retString + "&lV=";
    retString=retString + "&cD=";
    retString=retString + "&hH=";
  }    
    


//return the string
  return(retString);

}

function calcKzt() {
// to leave functio in middle of function
  var leaveFunc=0;

// calculates the Kzt factor for Hill, Ridge or Escarpment (HRE)

  var retKzt = 1.00;

//if whichPanel == "P1" then we are in the panel with NO HRE values.
// return retKzt as is (1.0).
//NOTE return in middle of function!

  if (whichPanel == "P1") {
    return retKzt;
  }

  var k1Ratio = 0.0;
  var k2Ratio = 0.0;
  var k3Ratio = 0.0;

//assign vars from userValues[]
  var hillShape = userValues[7].value;
  var lVal = userValues[8].value;
  var crestDist = userValues[9].value;
  var hillHeight = userValues[10].value; 
  var buildHeight = userValues[2].value;  
  var expose = userValues[3].value;  

//calculate ratios to be used.
  k1Ratio=(hillHeight/lVal);
  k2Ratio=(crestDist/lVal);
  k3Ratio=(buildHeight/lVal);

//alert("FIRST CALC - k1Ratio = " + k1Ratio + "  k2Ratio = " + k2Ratio + "   k3Ratio = " + k3Ratio);

//Only calculate Kzt if k1 ratio is greater than 0.20
  if (k1Ratio < 0.20) {
    leaveFunc=1;
  }

//Only calculate Kzt if:
// Exposure C & D: buildHeight >= 15ft.
// Exposure B: buildHeight >= 60ft.

  switch(expose) {
    case "B":
      if (buildHeight < 60) { leaveFunc=1; }
      break;
    case "C":
    case "D":
      if (buildHeight < 15) { leaveFunc=1; }
      break;
  }

  if (leaveFunc == 1) {
    return retKzt;
  }
    
//if k1Ratio (H/Lh) > 0.5, use 0.50 for k1Ratio, and substitue 2H for lval.
//  recalculate k2Ratio with new lVal.
//  (see figure 6-4 in ASCE-07-05).
  if (k1Ratio > 0.50) {
    k1Ratio = 0.50;
    lVal=2*hillHeight;
    k2Ratio=crestDist/lVal;
  }

//set k2Ratio to maximum if it's higher than maximum.
  if (k2Ratio > 4.00) {
    k2Ratio = 4.00;
  }

//set k3Ratio to maximum if it's higher than maximum.
  if (k3Ratio > 2.00) {
    k3Ratio = 2.00;
  }

  var k1RatioCatg = new Array();
  k1RatioCatg = [ 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50 ];
  var k2RatioCatg = new Array();
  k2RatioCatg = [ 0.00, 0.50, 1.00, 1.50, 2.00, 2.50, 3.00, 3.50, 4.00 ];
  var k3RatioCatg = new Array();
  k3RatioCatg = [ 0.00, 0.10, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.00, 1.50, 2.00 ];

  var k1Multiplier = new Array();
  var k2Multiplier = new Array();
  var k3Multiplier = new Array();

  switch (hillShape) {
    case "2-D_RI":
      k1Multiplier = [ 0.29, 0.36, 0.43, 0.51, 0.58, 0.65, 0.72 ];
      k2Multiplier = [ 1.00, 0.67, 0.33, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 ];
      k3Multiplier = [ 1.00, 0.74, 0.55, 0.41, 0.30, 0.22, 0.17, 0.12, 0.09, 0.07, 0.05, 0.01, 0.00 ];
    break;
    case "2-D_ES":
      k1Multiplier = [ 0.17, 0.21, 0.26, 0.30, 0.34, 0.38, 0.43 ];
      k2Multiplier = [ 1.00, 0.88, 0.75, 0.63, 0.50, 0.38, 0.25, 0.13, 0.00 ];
      k3Multiplier = [ 1.00, 0.78, 0.61, 0.47, 0.37, 0.29, 0.22, 0.17, 0.14, 0.11, 0.08, 0.02, 0.00 ];
    break;
    case "3-D_AX":
      k1Multiplier = [ 0.21, 0.26, 0.32, 0.37, 0.42, 0.47, 0.53 ];
      k2Multiplier = [ 1.00, 0.67, 0.33, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00 ];
      k3Multiplier = [ 1.00, 0.67, 0.45, 0.30, 0.20, 0.14, 0.09, 0.06, 0.04, 0.03, 0.02, 0.00, 0.00 ];
    break;
  }

  var k1Mult = 0.00;
  var k2Mult = 0.00;
  var k3Mult = 0.00;


//first, set k1Mult to highest multiplier
  k1Mult = k1Multiplier[k1Multiplier.length-1];
//now search through k1RatioCatg to find the correlating k1Ratio value.
//if k1Ratio is equal to highest k1RatioCatg, then we already have it, otherwise,
//if it falls between range, use TOP value in range (most effect)

  for (var i=1;i<k1RatioCatg.length-1;i++) {
    if ( (k1Ratio >= k1RatioCatg[i-1]) && (k1Ratio < k1RatioCatg[i]) ) {
      k1Mult = k1Multiplier[i];    
//alert("*K1 REPLACED");
      break;
    }
  }
//alert("*K1 - END Looping k1RatioCatg: k1Mult = " + k1Mult);

//first, set k2Mult to highest multiplier
  k2Mult = k2Multiplier[k2Multiplier.length-1];
//search through k2RatioCatg to find the correlating k2Ratio value.
//if it falls between range, use BOTTOM value in range (most effect)

  for (var i=1;i<k2RatioCatg.length-1;i++) {
    if ( (k2Ratio >= k2RatioCatg[i-1]) && (k2Ratio < k2RatioCatg[i]) ) {
      k2Mult = k2Multiplier[i-1];
//alert("**K2 REPLACED");
      break;
    }
  }
//alert("**K2 - END Looping k2RatioCatg: k2Mult = " + k2Mult);

  k3Mult = k3Multiplier[k3Multiplier.length-1];
//search through k3RatioCatg to find the correlating k3Ratio value.
//if it falls between range, use BOTTOM value in range (most effect)

  for (var i=1;i<k3RatioCatg.length-1;i++) {
    if ( (k3Ratio >= k3RatioCatg[i-1]) && (k3Ratio < k3RatioCatg[i]) ) {
      k3Mult = k3Multiplier[i-1];
//alert("***K3 REPLACED");
      break;
    }
  }
//alert("***K3 - END Looping k3RatioCatg: k3Mult = " + k3Mult);


  var hzt=(k1Mult*k2Mult*k3Mult);
  var hzt2=1+hzt;

  retKzt = Math.pow(hzt2,2);
//alert("retKzt = " + retKzt);
  return retKzt;
}



function listProds(inComponentType, inVertPull, inHorzPull) {

/*
  Function to list products that meet/exceed the wind design requirements.
  parameters passed: isCoping (if false then it's a fascia)
                     inVertPull (the Vertical pull rating [if applicable --- otherwise "na" -- example: not applicable to fascia ]
                     inHorzPull (the horizontal pull rating [ if applicable --- otherwise "na" ]

 SEE "==> NOTE: Define PART TYPES" in function DoCalcsandPutOutputs() ABOVE
    for MODIFICATIONS to that function when NEW COMPONENTS are added.

  Internal References:
    data arrays & variables are named starting with "comp".
    OUTPUT  variables are named using "Prod" (usually strProd...)

  External Data:
    DATA for the array compArr[] containing the Component Information is
     taken from EXCEL Workbook "
        "PARTS LIST w PULLTESTRATING.xls".  
  ===> SEE INSTRUCTIONS IN WORKBOOK for contructing the data.

  ==>  there IS A SWITCH-CASE BELOW THAT ** MUST BE MODIFIED **
  ==>  if *NEW component TYPES* are added.  See "NOTE inComponentType SWITCH-CASE:" below

*/

//alert("values passed to listProds (inComponentType:inVertPull:inHorzPull) = " + inComponentType + ":" + inVertPull + ":" + inHorzPull);

//open WDCComponentsStart.html in rightFrameBot
  window.open("WDCComponentsStart.html","rightFrameBot");

//get document object from "WDCComponentStart.html", now in rightFrameBot, 
// place into bod_Ouptut
  var bod_Output = parent.frames[2].document;

//array that holds component information
  var compArr = new Array();

// String data for display

  var strProdType = "";
  var strProdGrade = "";
  var strProdModel = "";
  var strProdDesc = "";
  var strProdAttach = "";

  var oString = "";

  var strProdGrp = "";
  var strProdType = "";
  var strMeasureOn = "";

//iteration variables
  var iterGrade = 0;
  var iterModel = 0;
  var iterArrRow = 0;
  var iterArrCol = 0;

// vars to hold Grade and Model info for comparisons while looping
  var prevGrade = "";
  var prevModel = "";

// Use as a switch.  Turned on when the first
//  part info is written.

  var partsWritten = 0;
  
//var holds whether part passes specifications (0=False, 1=True)
  var passSpecs = 0;

/*
--------------------------------------------------------------------------------------
 ==>  NOTE: 
inComponentType SWITCH-CASE: 

  MUST ADD new cases if new component types are added.
  First, we LOAD the array according to 
  Component Type parameter PASSED (inComponentType).  
  This saves memory so that we only load those components 
  that we'll be checking.
  See "==> NOTE New Component Types:" below    
*/

  switch(inComponentType) {

    case "Coping":

/*
 We populate the Array with coping part info
 This information compiled and copied from EXCEL workbook 
        "PARTS LIST w PULLTESTRATING.xls".  SEE INSTRUCTIONS IN WORKBOOK.

 Info is:  nRows x 15columns
                                            (Coping)/(Fascia)        Coping ONLY       Coping ONLY                      Coping ONLY            Coping ONLY            Coping & Fascia                             (If available)  (If available)
 "Component Type", "Grade", "Model Name", "Cap Size/Face Height", "Outer Leg Size", "Inner Leg Size", "Matl Spec", "SPRI Vertical Pull", "SPRI Horz Pull Inner", "SPRI Horz Pull Outer", "SPRI Attachment Type", "FM Rating", "FM Attachment Type"
*/

        compArr[0] = [ "Coping", "Premiun", "Talon Lock", "10", "6", "4", "0.050 Aluminum", "240", "147", "147", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip", "0", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip" ];
        compArr[1] = [ "Coping", "Premiun", "Talon Lock", "12", "6", "4", "0.050 Aluminum", "200", "122", "128", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip", "0", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip" ];
        compArr[2] = [ "Coping", "Premiun", "Talon Lock", "16", "6", "4", "0.050 Aluminum", "120", "73", "73", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip", "0", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip" ];
        compArr[3] = [ "Coping", "Premiun", "Talon Lock", "24", "6", "4", "0.050 Aluminum", "100", "61", "67", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip", "0", "Saddle: 18ga. Galvanized 5ft O.C. w 24ga. Spring Clip" ];
        compArr[4] = [ "Coping", "Standard", "Continuous Cleat", "8", "5", "3", "0.040 Aluminum", "250", "0", "250", "Cleat - 0.040 Aluminum 3in. height min.", "300", "Cleat - 0.050 Aluminum 3in. height min." ];
        compArr[5] = [ "Coping", "Standard", "Continuous Cleat", "8", "5", "3", "20oz. Copper", "220", "0", "220", "Cleat - 24ga. Stainless Steel 3in. height min.", "0", "NA" ];
        compArr[6] = [ "Coping", "Standard", "Continuous Cleat", "8", "5", "3", "24ga. Galvanized", "310", "0", "310", "Cleat - 22ga. Galvanized 3in. height min.", "210", "Cleat - 22ga. Galvanized 3in. height min." ];
        compArr[7] = [ "Coping", "Standard", "Continuous Cleat", "12", "5", "3", "0.040 Aluminum", "160", "0", "160", "Cleat - 0.040 Aluminum 3in. height min.", "285", "Cleat - 0.050 Aluminum 3in. height min." ];
        compArr[8] = [ "Coping", "Standard", "Continuous Cleat", "12", "5", "3", "0.050 Aluminum", "300", "0", "300", "Cleat - 0.050 Aluminum 3in. height min.", "300", "Cleat - 0.063 Aluminum 3in. height min." ];
        compArr[9] = [ "Coping", "Standard", "Continuous Cleat", "12", "5", "3", "20oz. Copper", "150", "0", "150", "Cleat - 24ga. Stainless Steel 3in. height min.", "0", "NA" ];
        compArr[10] = [ "Coping", "Standard", "Continuous Cleat", "12", "5", "3", "24ga. Galvanized", "190", "0", "190", "Cleat - 22ga. Galvanized 3in. height min.", "210", "Cleat - 22ga. Galvanized 3in. height min." ];
        compArr[11] = [ "Coping", "Standard", "Continuous Cleat", "12", "5", "3", "22ga. Galvanized", "290", "0", "290", "Cleat - 20ga. Galvanized 3in. height min.", "330", "Cleat - 20ga. Galvanized 3in. height min." ];
        compArr[12] = [ "Coping", "Standard", "Continuous Cleat", "18", "5", "3", "0.040 Aluminum", "300", "0", "300", "Cleat - 0.050 Aluminum 3in. height min.", "0", "NA" ];
        compArr[13] = [ "Coping", "Standard", "Continuous Cleat", "18", "5", "3", "24ga. Galvanized", "220", "0", "220", "Cleat - 22ga. Galvanized 3in. height min.", "0", "NA" ];
        compArr[14] = [ "Coping", "Standard", "Continuous Cleat", "24", "5", "3", "0.050 Aluminum", "230", "0", "230", "Cleat - 0.063 Aluminum 3in. height min.", "0", "NA" ];
        compArr[15] = [ "Coping", "Standard", "Continuous Cleat", "24", "5", "3", "24ga. Galvanized", "160", "0", "160", "Cleat - 22ga. Galvanized 3in. height min.", "0", "NA" ];
        compArr[16] = [ "Coping", "Flat Drip", "Continuous Cleat", "12", "5", "3", "0.040 Aluminum", "400", "0", "224", "Cleat - 0.040 Aluminum 3in. height min.", "0", "NA" ];
        compArr[17] = [ "Coping", "Flat Drip", "Continuous Cleat", "12", "5", "3", "24ga. Galvanized", "390", "0", "238", "Cleat - 22ga. Galvanized 3in. height min.", "0", "NA" ];
        compArr[18] = [ "Coping", "Flat Drip", "Continuous Cleat", "18", "5", "3", "0.040 Aluminum", "280", "0", "171", "Cleat - 0.050 Aluminum 3in. height min.", "0", "NA" ];
        compArr[19] = [ "Coping", "Flat Drip", "Continuous Cleat", "18", "5", "3", "24ga. Galvanized", "250", "0", "152", "Cleat - 22ga. Galvanized 3in. height min.", "0", "NA" ];
        compArr[20] = [ "Coping", "Flat Drip", "Continuous Cleat", "24", "5", "3", "0.050 Aluminum", "150", "0", "91", "Cleat - 0.063 Aluminum 3in. height min.", "0", "NA" ];
        compArr[21] = [ "Coping", "Flat Drip", "Continuous Cleat", "24", "5", "3", "24ga. Galvanized", "160", "0", "97", "Cleat - 22ga. Galvanized 3in. height min.", "0", "NA" ];

//      compArr[16] = [ "Coping", "DUMMY", "Some Dummy 1", "24", "5", "3", "FIRST DUMMY Matl Spec", "230", "0", "0", "Cleat - DUMMY 1", "0", "NA" ];
//      compArr[17] = [ "Coping", "DUMMY", "Some Dummy 2", "24", "5", "3", "SECOND DUMMY Matl Spec", "230", "0", "0", "Cleat - DUMMY 2", "0", "NA" ];
//      compArr[18] = [ "Coping", "DUMMY", "Some Other Dummy 1a", "24", "5", "3", "Matl Spec", "90", "0", "0", "Cleat - DUMMY 1a", "0", "NA" ];

//ASSIGN String used to display Product Type
      strProdType = "Coping";
      strMeasureOn = "Cap";

    break; //BREAK Case Coping

    case "Fascia":

//populate the array
/*
        compArr[0] = [ "Fascia", "Premium", "EZ Edge II", "5", "0", "0", "0.040 Aluminum", "0", "0", "230", "Clip - 24ga. Stainless steel 6in. wide. 5ft. o.c.", "0", "NA" ];
        compArr[1] = [ "Fascia", "Premium", "EZ Edge II", "5", "0", "0", "24ga. Galvanized", "0", "0", "280", "Clip - 24ga. Stainless steel 6in. wide. 5ft. o.c.", "0", "NA" ];
        compArr[2] = [ "Fascia", "Premium", "EZ Edge II", "7", "0", "0", "0.040 Aluminum", "0", "0", "310", "Clip - 24ga. Stainless steel 6in. wide. 5ft. o.c.", "0", "NA" ];
*/
        compArr[0] = [ "Fascia", "Standard", "Continuous Cleat", "8", "0", "0", "0.040 Aluminum", "0", "0", "140", "Cleat - 0.040 Aluminum 3in. height min.", "0", "NA" ];
        compArr[1] = [ "Fascia", "Standard", "Continuous Cleat", "8", "0", "0", "0.040 Aluminum", "0", "0", "230", "Cleat - 0.050 Aluminum 3in. height min.", "150", "Cleat - 0.050 Aluminum 3in. height min." ];
        compArr[2] = [ "Fascia", "Standard", "Continuous Cleat", "8", "0", "0", "24ga. Galvanized", "0", "0", "170", "Cleat - 22ga. Galvanized 3in. height min.", "150", "Cleat - 22ga. Galvanized 3in. height min." ];
        compArr[3] = [ "Fascia", "Flat Drip", "Continuous Cleat", "8", "0", "0", "0.040 Aluminum", "0", "0", "330", "Cleat - 0.040 Aluminum 3in. height min.", "0", "NA" ];
        compArr[4] = [ "Fascia", "Flat Drip", "Continuous Cleat", "8", "0", "0", "24ga. Galvanized", "0", "0", "250", "Cleat - 22ga. Galvanized 3in. height min.", "150", "Cleat - 22ga. Galvanized 3in. height min." ];

//ASSIGN String used to display Product TYPE
      strProdType = "Fascia";
      strMeasureOn = "Face";

    break;  //BREAK CASE Fascia

/*
==>NOTE New Component Types:
   IF NEW Component TYPES are added, then
   **MUST** add to this switch-case.
   For Example, if Gutter is added:
*/
    case "Gutter":
      compArr[0] = [ "Gutter", "Gutter GRADE", "Gutter MODEL", "99", "99", "99", "Gutter Matl Spec", "99", "99", "99", "Gutter Attachment Type", "99", "99" ];
      compArr[1] = [ "Gutter", "Gutter GRADE 2 ", "Gutter MODEL 2", "99", "99", "99", "Gutter Matl Spec", "99", "99", "99", "Gutter Attachment Type", "99", "99" ];
      strProdType = "Gutter";
      strMeasureOn = "Back";
    break;

  } // switch(inComponentType)

// --------------------------------------------------------------------------------------


/*
 FOURE THINGS ARE BEING PERFORMED in the NESTED LOOPS BELOW:
  1) We are performing comparisons to make sure we are looking at the correct 
     grade and model, since the DISPLAY ORDER is important here.
  2) We are performing a comparison of the WIND DESIGN SPECS for
      the matching grade/model to see if it MEETS SPECS.
  3) We are building our display strings AND our TABLE OUTPUTS
      to be written to the page.
  4) we are building array arrCompList to hold the component list for printing (see pPrintPages() )

  NOTICE that component TYPE is already selected, so we do not need to
    check component TYPE here.  We've built the array compArr[][] based on component Type.
*/

//re-set arrCompCounter to 0 
  arrCompCounter = 0;

// MAIN LOOP:
// Here we loop through compArr[] for EACH ROW
  for (iterArrRow=0;iterArrRow<compArr.length;iterArrRow++) {

/*
 DEGUGGING ONLY:
 Iteration Loop to check that all compArr is loading correctly. (USE FOR debugging only)
       for (iterArrCol=0;iterArrCol<compArr[iterArrRow].length;iterArrCol++) {
          alert("compArr[" + iterArrRow + "][" + iterArrCol + "] = " + compArr[iterArrRow][iterArrCol]);
       } // ARRAY COLUMNS - iterArrCol LOOP
*/

/*
NOW WE COMPARE THE WIND DESIGN / PULL SPECS
 we CALL FUNCTION checkSpecs
 NOW AT: HOW DO WE USE ONE FUNCTION FOR BOTH
   COPING AND FASCIA????  ALSO, HOW DO WE COMPARE
      SPRI vs. FM DESIGN SPECS?
*/

/*
 For Coping: Cap Size: compArr[][3]
             Outer Leg Size: compArr[][4]
             Inner Leg Size: compArr[][5]
             SPRI Vertical Pull in compArr[][7]: FM Rating in compArr[][11]
             SPRI Horizontal Pull INNER in compArr[][8]
             SPRI Horizontal Pull OUTER in compArr[][9]
// We check against OUTER horizontal pull
 For Fascia: Face Height: compArr[][3]
             Outer Leg Size: NA
             Inner Leg Size: NA
             SPRI Vertical Pull is NA
             SPRI Horizontal Pull INNER is NA.
             SPRI Horizontal Pull OUTER in compArr[][9]: FM Rating in compArr[][11]
*/

/*
 We send checkSpecs the following parameters: (10 in all)
   component Type (strProdType), Vertical Pull Requirement (inVertPull), Horizontal Pull Requirement (inHorzPull),
      Cap Size/Face Height (compArr[iterArrRow][3]), OUTER Leg Size (compArr[iterArrRow][4], INNER Leg Size (compArr[iterArrRow][5],
      SPRI Vertical Pull Rating (compArr[iterArrRow][7]), 
      SPRI Horizontal INNER Pull Rating (compArr[iterArrRow][8]), SPRI Horizontal OUTER Pull Rating (compArr[iterArrRow][9]),  
      FM Rating (compArr[iterArrRow][11])
*/
// var testString = compArr[iterArrRow][0] + ":" + compArr[iterArrRow][1] + ":" + compArr[iterArrRow][2] + ":" + compArr[iterArrRow][3] + ":" + compArr[iterArrRow][4] + ":" + compArr[iterArrRow][5] + ":" + compArr[iterArrRow][7] + ":" + compArr[iterArrRow][8] + ":" + compArr[iterArrRow][9] + ":" + compArr[iterArrRow][11];

//alert("TESTING checkSpecs on " + testString);

    passSpecs = checkSpecs(strProdType,inVertPull,inHorzPull,compArr[iterArrRow][3], compArr[iterArrRow][4], compArr[iterArrRow][5],compArr[iterArrRow][7], compArr[iterArrRow][8], compArr[iterArrRow][9], compArr[iterArrRow][11]);

//alert(testString + " passSpecs = " + passSpecs);


//output (display) portion

    switch(passSpecs) {

      case(true):

      switch(partsWritten) {
//case 0 is that no parts have yet been written
        case(0):
//open document for writing
          bod_Output.open();
//build the HTML for bod_Output page
          bod_Output.writeln("<html>");
          bod_Output.writeln("<head>");
          bod_Output.writeln("</head>");
          bod_Output.writeln('<body id="pPartsBody" name="pPartsBody">');
//write header
          bod_Output.writeln("<p align=left style='font-size:13.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'>");

          bod_Output.writeln("<b>Our Components Meeting or Exceeding these Wind Pressure Design Requirements:</b><br><br>");
//write Grade
          prevGrade = compArr[iterArrRow][1];
          strProdGrade = compArr[iterArrRow][1];
          bod_Output.writeln("<p align=left style='font-size:12.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'>");
          bod_Output.writeln("<b>" + strProdGrade + " " + strProdType + " Models </b><br>");
          arrCompList[arrCompCounter] = "<br><b><u>" + strProdGrade + " " + strProdType + " Models </u></b><br>";
          arrCompCounter = arrCompCounter + 1;
//start new table
          bod_Output.writeln("<table border=3>");
//start new row
          bod_Output.writeln("<tr>");

//write model to table Data
          prevModel = compArr[iterArrRow][2];
          strProdModel = compArr[iterArrRow][2];
          bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman;font-weight:bold'>" + strProdModel + " &nbsp&nbsp </td>");
          arrCompList[arrCompCounter] = "<b>" + strProdModel + ":</b><br>";
          arrCompCounter = arrCompCounter + 1;
 
//write description and attachment type to next table data
          strProdDesc = compArr[iterArrRow][3] + "in. " + strMeasureOn + "<b>:  </b>" + compArr[iterArrRow][6] + " &nbsp ";
          strProdAttach = compArr[iterArrRow][10];
          bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman'> &nbsp&nbsp&nbsp " + strProdDesc + "<br> &nbsp&nbsp&nbsp " + strProdAttach + " &nbsp </td>");
          arrCompList[arrCompCounter] = strProdDesc + " &nbsp " + strProdAttach + " <br>"
          arrCompCounter = arrCompCounter + 1;

//end row
          bod_Output.writeln("</tr>");
//set partsWritten = 1
          partsWritten = 1;

        break; // case 0 (partsWritten)
                              
//case 1 is that parts have already been written                           
        case(1):

//check to see if the Component GRADE has changed.
// If so, then we start a NEW TABLE and assign holdGrade the new Grade value
          if (compArr[iterArrRow][1] != prevGrade) {

//assign prevGrade to present Grade
            prevGrade = compArr[iterArrRow][1];
//close previous table
            bod_Output.writeln("</table>");
//write Grade
            strProdGrade = compArr[iterArrRow][1];
            bod_Output.writeln("<p align=left style='font-size:12.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'>");
            bod_Output.writeln("<br><b>" + strProdGrade + " " + strProdType + " Models </b><br>");
            arrCompList[arrCompCounter] = "<br><b><u>" + strProdGrade + " " + strProdType + " Models </u></b><br>";
            arrCompCounter = arrCompCounter + 1;

//start new table
            bod_Output.writeln("<table border=3>");
//start new row
            bod_Output.writeln("<tr>");

//assign prevModel to present model
            prevModel = compArr[iterArrRow][2];

//write Model to table Data
            strProdModel = compArr[iterArrRow][2];
            bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman;font-weight:bold'>" + strProdModel + " &nbsp&nbsp </td>");
            arrCompList[arrCompCounter] = "<b>" + strProdModel + ":</b><br>";
            arrCompCounter = arrCompCounter + 1;

//write Description and attachment type to next table data
            strProdDesc = compArr[iterArrRow][3] + "in. " + strMeasureOn + "<b>:  </b>" + compArr[iterArrRow][6] + " &nbsp ";
            strProdAttach = compArr[iterArrRow][10];
            bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman'> &nbsp&nbsp&nbsp " + strProdDesc + "<br> &nbsp&nbsp&nbsp " + strProdAttach + " &nbsp </td>");
            arrCompList[arrCompCounter] = strProdDesc + " &nbsp " + strProdAttach + " <br>"
            arrCompCounter = arrCompCounter + 1;

//end row
            bod_Output.writeln("</tr>");

//if this is NOT a new Grade
          } else {

//check to see if this is a new MODEL
// if so, then start a new row, assign prevModel to present Model
            if (compArr[iterArrRow][2] != prevModel) {
              prevModel=compArr[iterArrRow][2];
              strProdModel = compArr[iterArrRow][2];
//write new row
              bod_Output.writeln("<tr>");
//write Model to table Data
              bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman'>" + strProdModel + " &nbsp&nbsp </td>");
              arrCompList[arrCompCounter] = "<b>" + strProdModel + ":</b><br>";
              arrCompCounter = arrCompCounter + 1;

//write Description and attachment type to next Table data
              strProdDesc = compArr[iterArrRow][3] + "in. " + strMeasureOn + "<b>:  </b>" + compArr[iterArrRow][6] + " &nbsp ";
              strProdAttach = compArr[iterArrRow][10];
              bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman'> &nbsp&nbsp&nbsp " + strProdDesc + "<br> &nbsp&nbsp&nbsp " + strProdAttach + " &nbsp </td>");
              arrCompList[arrCompCounter] = strProdDesc + " &nbsp " + strProdAttach + " <br>"
              arrCompCounter = arrCompCounter + 1;

//end row
              bod_Output.writeln("</tr>");

//if this is NOT a new model
            } else {

//write new row
              bod_Output.writeln("<tr>");

//write BLANKS for Model to table data
              bod_Output.writeln("<td> &nbsp </td>");

//write Description and attacment type to next table data
              strProdDesc = compArr[iterArrRow][3] + "in. " + strMeasureOn + "<b>:  </b>" + compArr[iterArrRow][6] + " &nbsp ";
              strProdAttach = compArr[iterArrRow][10];
              bod_Output.writeln("<td style='font-size:12.0pt;font-family:Times New Roman'> &nbsp&nbsp&nbsp " + strProdDesc + "<br> &nbsp&nbsp&nbsp " + strProdAttach + " &nbsp </td>");
              arrCompList[arrCompCounter] = strProdDesc + " &nbsp " + strProdAttach + " <br>"
              arrCompCounter = arrCompCounter + 1;

//end row
              bod_Output.writeln("</tr>");

            } // elseif new Model

          } // elseif new Grade
                       
        break; // case 1 (partsWritten)
                       
      } // switch(partsWritten)
                         
      break; // case true (passSpecs)
                     
    } // switch(passSpecs)


  } // ARRAY ROWS - iterArrRow LOOP 

//Finish the output if any parts were written.
// if not, then no parts passed and we notify user
  if (partsWritten == 1) {
    bod_Output.writeln("</table>");
    bod_Output.writeln("</body>");
    bod_Output.close();
  } else {
    bod_Output.open();
    bod_Output.writeln(" SORRY - WE HAVE NO COMPONENTS <br>that meet or exceed these Wind Pressure Design requirements ");
    bod_Output.close();
  }

 var z=parent.frames[0].focus();

} //End Function listProds


function checkSpecs(inProdType, reqVertPull, reqHorzPull, capOrFaceSz, outLegSz, inLegSz, SPRIRateVert, SPRIHorzInRate, SPRIHorzOutRate, FMRate) {
/*

NOW AT: THIS FUNCTION is NOT COMPLETE!
   MUST ANSWER THIS QUESTION:
       for NRCA sub-listing COPINGS, what does the SPRI tested Pull Rate represent?
         does it represent the Vertical Pull value, or the Horizontal OUTSIDE Leg ?
         TALK TO SOMEONE at either ITS or NRCA.


  Parameters passed from listProds():
    inProdType: Product Type (Coping, Fascia, Gutter, etc.)
    reqVertPull: the REQUIRED vertical pull
    reqHorzPull: the REQUIRED horizontal pull
    capOrFaceSz: for Coping, the Cap size.  For Fascia, the Face size.
    outLegSz: for Coping, the Outer Leg Size, for Fascia, should be 0.
    inLegSz: for Coping, the Inner Leg size, for Fascia, should be 0.
    SPRIRateVert: for Coping, the Vertical Pull rating of this particular component (SPRI RATING)
    SPRIHorzInRate: for Coping, the horizontal pull rating on the inner leg of this particular component (might be 0 if not rated) (SPRI RATING)
    SPRIHorzOutRate: for Coping, the horizontal pull rating on the Outer leg of this particular component (might be 0 if not rated) (SPRI RATING)
                for Fascia, the horizontal pull rating of the Fascia (SPRI RATING)
    FMRate: the FM rating of this particular component
*/


/*
alert("inProdType = " + inProdType + "\n" + 
      "reqVertPull = " + reqVertPull + "  reqHorzPull = " + reqHorzPull + "\n" +
      "capOrFaceSz = " + capOrFaceSz + "  outLegSz = " + outLegSz + "  inLegSz = " + inLegSz + "\n" +
      "SPRIRateVert = " + SPRIRateVert + "  SPRIHorzInRate = " + SPRIHorzInRate + "  SPRIHorzOutRate = " + SPRIHorzOutRate + "\n" +
      "FMRate = " + FMRate);
*/

/*
NOW WE COMPARE THE WIND DESIGN  PULL SPECS
 we CALL FUNCTION checkSpecs

*/
  var retString = "";

/*
    vSPRIPF will hold the Pass/Fail test results against SPRI Vertical Pull requirements
    hSPRIPF is for Horizontal Pull results
    vFMPF is for FM vertical pull results
    hFMPF is for FM horizontal pull results
    0=Fail, 1=Pass
    Assume failure.  Values are changed by tests below.
*/

  var vSPRIPF = 0;
  var hSPRIPF = 0;
  var vFMPF = 0;
  var hFMPF = 0;
/*
var sqFt will hold the calculated sqFt ratio of the geometry being checked.
  ex: if a Coping, then first we check Cap Size, so we use capOrFaceSz and divide that size by 12
       to get the sqFt percentage.  if Cap was say 18, then sqFt = 1.5
*/

 var sqFt = 0;

/*var sqFtReqRate will hold the adjusted rating for the geometry being checked.
  ex: if a Coping, and we are checking the Vertical Pull, we take reqVertPull and multiply it by sqFt
      to get the actual rating required for this size geometry
*/

 var sqFtReqRate = 0;


  switch(inProdType) {

//test the Coping case
    case "Coping":

//Test Vertical Pull   
//test against SPRI requirements
      //get sqFt ratio
      sqFt=capOrFaceSz / 12;      
      sqFtReqRate=reqVertPull*sqFt;
      vSPRIPF=0;
      if (SPRIRateVert >= sqFtReqRate) { vSPRIPF=1; }   

//test against FM requirements
// NOTE that FM rating is based on Horizontal Pull: Vertical pull = FMRate * 1.7
//(sqFt and sqFtRate are the same as calculated in SPRI test above)
//if FMRate exists, it is > 0
      if (FMRate > 0) {
        vFMPF=0;
        if ((FMRate * 1.7) >= sqFtReqRate) { vFMPF=1; }
      } else {
//if No FM rating, set to 1
        vFMPF=1;        
      }
      
//Test Horizontal Pull Outer Leg
//if SPRIHorzOutRate == 0 then there is no rating available
      if (SPRIHorzOutRate > 0) {
        sqFt=outLegSz / 12;
        sqFtReqRate=reqHorzPull*sqFt;
        hFSPRIPF=0;
        if (SPRIHorzOutRate >= sqFtReqRate) { hSPRIPF=1; } 
      } else { 
// if no rating (SPRIHorzOutRate == 0) then assume it PASSES SPEC.
        hSPRIPF=1 
      }
//test FM rating
      if (FMRate > 0) {
        hFMPF=0;
        if (FMRate >= sqFtReqRate) { hFMPF=1; }
      } else {
        hFMPF=1;
      }

//Test Horizontal Pull Inner Leg
//SPRIHorzInRate == 0 means no rating available
      if (SPRIHorzInRate > 0) {
        sqFt=inLegSz / 12;
        sqFtReqRate=reqHorzPull*sqFt;
        hSPRIPF=0;
        if (SPRIHorzInRate >= sqFtReqRate) { hSPRIPF=1; } 
      } else { 
        hSPRIPF=1 
      }
    
    break; //break for Coping case

    case "Fascia":
      vSPRIPF=1;
      vFMPF=1;
      sqFt=capOrFaceSz / 12;
      sqFtReqRate=reqHorzPull*sqFt;
      hSPRIPF=0;
      if (SPRIHorzOutRate >= sqFtReqRate) { hSPRIPF=1; }

      if (FMRate > 0) {
        hFMPF=0;
        if (FMRate >= sqFtReqRate) { hFMPF=1; }
      } else {
        hFMPF=1;
      }
    break;

  }


return ((vSPRIPF && hSPRIPF && vFMPF && hFMPF) == 1);

                    
//return( ((vSPRIPF && hSPRIPF) == 1));
  
}


function pPrintPages() {

// This function should ONLY perform is calcMode == 1.
//alert("calcMode = " + calcMode);


  if (calcMode == 0) {

    alert("The PRINT button works when ALL CALCULATIONS and DISPLAY PANELS are AVAILABLE.  \n\n Some value or some display panel must have changed. \n\n Click the CALCULATE Button first, then click PRINT CALCS.");
    return;
  }

//  } else {
    var pPrintWindow = window.open("WDCBlank.html","pPrint","");
    var pPrintDoc = pPrintWindow.document;
//var h = pPrintWindow.printing.header;
//var f = pPrintWindow.printing.footer;

//pPrintWindow.printing.footer = "";

    pPrintDoc.open();
    pPrintDoc.writeln("<html>");
    pPrintDoc.writeln("<head>");
    pPrintDoc.writeln("<title>WIND DESIGN CALCULATOR Results - American Architectural Metal Manufacturers Inc.</title>");
    pPrintDoc.writeln("</head>");
    pPrintDoc.writeln("<body>");
    pPrintDoc.writeln("<p align=center style='font-size:12.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'><br>");
    pPrintDoc.writeln("<b>AMERICAN ARCHITECTURAL METAL MANUFACTURERS INC.<br>");
    pPrintDoc.writeln("575 Business Park Lane<br>Allentown, PA. 18109<br>phone:(610) 432-9787 &nbsp&nbsp fax:(610) 437-7030<br><br>");
    pPrintDoc.writeln("WIND PRESSURE DESIGN CALCULATIONS<br></b></p>");
    pPrintDoc.writeln("<p align=left style='font-size:10.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'><br>");
    pPrintDoc.writeln("<hr>");

    pPrintDoc.writeln("<p><span style='font-size:10.0pt;font-family:Arial'><b>");
    pPrintDoc.writeln("<b><u>Component Type & Building Specifications</u></b><br>");
    if (userValues[0].checked == true) {
      pPrintDoc.writeln("PART TYPE: COPING<br>");
    } else {
      pPrintDoc.writeln("PART TYPE: FASCIA<br>");
    }
    pPrintDoc.writeln("Building Height (ft.): " + userValues[2].value + "<br>");
    pPrintDoc.writeln("Exposure Category: " + userValues[3].value + "<br>");
    pPrintDoc.writeln("Occupancy Category: " + userValues[4].value + "<br>");
    pPrintDoc.writeln("State: " + userValues[5].value + "<br>");

    if (userValues[6].value != "") {
      pPrintDoc.writeln("County: " + userValues[6].value + "<br>");

      if (isSpecial == 1) {
        pPrintDoc.writeln(">>>NOTE: This IS a SPECIAL WIND REGION. <br> (Check local authorities for Wind Speeds in this region)<br>");
      } else {
        pPrintDoc.writeln("This is NOT a Special Wind Region.<br>");
      }
    } else {

      pPrintDoc.writeln("County: >>>NO COUNTY SELECTED.<br>Calculations are based on Highest Wind Speed for State.<br>");

      if (hasSpecial == 1) {
        pPrintDoc.writeln(">>>NOTE: This State contains Special Wind Regions. <br> (Check local authorities for Special Wind Regions in this State)<br>");
      } else {
        pPrintDoc.writeln("There are no Special Wind Regions in this State.<br>");
      }
    }
    pPrintDoc.writeln("<hr>");
    pPrintDoc.writeln("<p><span style='font-size:10.0pt;font-family:Arial'><b>");

    if (whichPanel == "P2") {
        pPrintDoc.writeln("<b><u>Topographical Features</u></b><br>");
        pPrintDoc.writeln("Hill Shape: &nbsp");

      switch(userValues[7].value) {
        case "2-D_RI":
          pPrintDoc.writeln("2-D RIDGE<br>");
          break;
        case "2-D_ES":
          pPrintDoc.writeln("2-D ESCARPMENT<br>");
          break;
        case "3-D_AX":
          pPrintDoc.writeln("3-D AXIS-SYMMETRICAL HILL<br>");
          break;
      }
      pPrintDoc.writeln("L Value (ft): " + userValues[8].value + "<br>");
      pPrintDoc.writeln("Crest Distance (ft): " + userValues[9].value + "<br>");
      pPrintDoc.writeln("Hill Height (ft): " + userValues[10].value + "<br>");
      
    } else {
      pPrintDoc.writeln("No Topographical Features selected (Hill, Ridge, Escarpment).<br>");
    }

    pPrintDoc.writeln("<hr><b><u>WIND DESIGN CALCULATIONS</u></b><br>");
    pPrintDoc.writeln("BASIC Wind Speed for Region: &nbsp" + bwS + " mph <br>");
    if (userValues[0].checked == true) {
      pPrintDoc.writeln("VERTICAL Design Pressure: &nbsp " + vertPull + " lbs/sq.ft.<br>");
    }
    pPrintDoc.writeln("HORIZONTAL Design Pressure: &nbsp " + horzPull + " lbs/sq.ft.<br>");


    pPrintDoc.writeln("<hr>");
    pPrintDoc.writeln("<p><span style='font-size:10.0pt;font-family:Arial'><b>");
    pPrintDoc.writeln("<b><u>Our Components Meeting or Exceeding these Wind Pressure Design requirements:</u></b><br>");

    for (var i=0;i<arrCompCounter;i++) {
      pPrintDoc.writeln(arrCompList[i]);
    }
    pPrintDoc.writeln("<br><br>");
    pPrintDoc.writeln("<p align=left style='font-size:9.0pt;font-family:Arial;margin-top:0in;margin-right:0in;margin-bottom:0in;margin-left:0in'>");

    pPrintDoc.writeln("<br><b> NOTE: No liability is accepted or implied by this provider for any information"); 
    pPrintDoc.writeln("<br> given here, or for decisions and/or actions taken based on said information.</b>");
    pPrintDoc.writeln("<br>Refer to Disclaimer on Wind Design Web Site");
    pPrintDoc.writeln("</p>");

    pPrintDoc.writeln("</body>");
//pPrintDoc.writeln("<footer> &nbsp </footer>");
    pPrintDoc.writeln("</html>");
    pPrintDoc.close();
    pPrintWindow.focus();
//    setTimeout("pPrintwindow.print()",10);

// UN-COMMENT THESE LINES WHEN READY TO INSTALL
    pPrintWindow.print();
    pPrintWindow.close();
//  }
//pPrintWindow.printing.header = h;
//pPrintWindow.printing.footer = f;

}

function resetCalc() {
  calcMode = 0;
  
}

function displayDisclaimer() {
  resetCalc();
  window.open("./WDCDisclaimer.html","rightFrameBot");
}
  
