
<!-- hide script from old browsers




function swapImage() {

switch (intImage) {
 
 case 1:
     //document.frmone.IMG1a.src = src="images/WALK_IN_COOLERS2.jpg"
     $('#IMG1b').hide(); 
     $('#IMG1a').attr("src","images/WALK_IN_COOLERS2.jpg");
     $('#IMG1a').fadeIn(1600);
     return(false);
    
case 2:
   //document.frmone.IMG1b.src = src="images/reach_in_cooler_glass.jpg"
   
   $('#IMG1a').hide(); 
   $('#IMG1b').attr("src","images/reach_in_cooler_glass.jpg");
   $('#IMG1b').fadeIn(1600);
   return(false);
 }
}
function swapImage2() {
switch (intImage) {
 case 1:
   // document.frmone.IMG2a.src = src="images/CDSLogo150.jpg"
   document.frmone.IMG2a.height= height="57"
   $('#IMG2b').hide(); 
   $('#IMG2a').fadeIn(1600);
   return(false);
 case 2:
   //document.frmone.IMG2b.src = src="images/AnthonyGlass.jpg"
   document.frmone.IMG2b.height= height="57"
   $('#IMG2a').hide(); 
   $('#IMG2b').fadeIn(1600);
  return(false);
 }
}
function load()
{
   /* set constants */
   boxMarkup=1.05
   leaseMaxAmount=3000000
   leaseMaxAmountText="$3000000"
   GlassDoorCost=575.00
   WalkinDoorCost=750.00
   AnthonyGlassCost=562.00
   CDSDoorsCost=525.00
   oneWalkinDoor=WalkinDoorCost
   BTUPerDoor=900.00
   BTURate=15
   Markup=1.25
   SquareFootRate=8.50
   CostPerRamp=350.00
   Ambient100=1.12
  /*             */
   $('#IMG1b').hide();  $('#IMG1a').hide();
  document.frmone.accessory[1].checked=true
  document.frmone.Summary.value="" //remove error message about the need for javascript
 //alert("load function calls resetbox")
 
 document.frmone.measurement[0].checked =true;
 checkCoolerType();
 document.frmone.fHeight.value=6 //inches
 document.frmone.iHeight.value=0
 document.frmone.fWidth.value=4
 document.frmone.iWidth.value=6
 document.frmone.fLength.value=5
 document.frmone.iLength.value=0
 savefHeight=Number(document.frmone.fHeight.value);
 saveiHeight=Number(document.frmone.iHeight.value);
 savefWidth=Number(document.frmone.fWidth.value);
 saveiWidth=Number(document.frmone.iWidth.value);
 savefLength=Number(document.frmone.fLength.value);
 saveiLength=Number(document.frmone.iLength.value);
                                           
 document.frmone.mHeight.value=1829  //millimeters
 document.frmone.mWidth.value=1372
 document.frmone.mLength.value=1524
 savemHeight=Number(document.frmone.mHeight.value)
 savemWidth=Number(document.frmone.mWidth.value)
 savemLength=Number(document.frmone.mLength.value)
   
 resetBox()
 resetDoorCount=1
 resetExtraDoors(resetDoorCount)
 ExtraDoorsCost=0
 frontBTU=0
 sideBTU=0
 dmsg=""
 frontdmsg=""
 sidedmsg=""
 rmsg=""
 document.frmone.Floor.checked = false
 checkFloorStatus()
 checkRefrigerationStatus()
 calculate()
 createRateTable()
 document.frmone.type[0].checked = true
 if (document.frmone.type[0].checked == true) {
        intImage=1
 } else {
        intImage=2
 }  
 swapImage()
 //alert("load intImage = " + intImage)
 FirstTimeExtraDoors=1
/*
document.frmone.glassDoor[0].checked = true
 if (document.frmone.glassDoor[0].checked == true) {
        intImage=1
        GlassDoorCost=CDSDoorsCost
 } else {
        intImage=2
        GlassDoorCost=AnthonyGlassCost
 }
 swapImage2()
 //alert("load intImage = " + intImage)
 */
}
YesNoMsg="Click OK for YES, click Cancel for NO"

showDialogClicked=0      //confirm box dimensions
showDialogClicked2=0     //confirm glass door vendor
// end of load


function calculate() {
 document.frmone.debug.value="" 
 document.frmone.TotalExtraDoorsCost.value=""
 document.frmone.FrontExtraDoorsCost.value=""
 document.frmone.BackExtraDoorsCost.value=""
 document.frmone.RightExtraDoorsCost.value=""
 document.frmone.LeftExtraDoorsCost.value=""
 document.frmone.Summary.value="" 
hideLeaseArea()
hideMessageArea()

//**** start edit entry fields inches or millimeters
editError=1 //set edit error true
 calcCount=0;
 if (document.frmone.measurement[0].checked == true) { //inches 
    unit="inch"
    stdboxEdit();
 } else {
    unit="mm";
    metricboxEdit();                                   //millimeters
   //convert metric width and length to inches: mtotalw, mtotall,mtotalh
   totalh=Math.round(mtotalh * 0.03937008);
   totalw=Math.round(mtotalw * 0.03937008);
   totall=Math.round(mtotall * 0.03937008);
   //alert("converted totals= " + totalh + " " + totalw + " " + totall)
   
 }
 
 if (editError) return;
 calcCount++;
 //alert("calculate count= " + calcCount)
 
 //**** stop edit entry fields inches or millimeters
 
 /* calculate cost */


//totalh = (8 * 12) + 0
footprint= totalw * totall
//alert ("footprint = " + footprint)
ceiling= (footprint / 144) * SquareFootRate  // 144 inches per square foot; $8.50 per square foot
lside=((totalh * totall) / 144) * SquareFootRate
rside=lside
front=((totalh * totalw) / 144) * SquareFootRate
back=front


if (document.frmone.Floor.checked  == true) {
    floor=ceiling
    rfloor = Math.round(floor * 100) / 100
    txtfloor=1
    //alert ("floor costs " + floor)
} else {
   floor=0
   rfloor = Math.round(ceiling * 100) / 100
   txtfloor=0
}
rfloor=roundToPennies(rfloor)

/* recalculate front and/or side dimensions using the number of extra doors specified;
   then compare the dimensions to the original front and/or side dimensions.
   if user approves, replace the original dimensions with the new dimensions;
   then recalculate cooler cost and/or refrigeration cost
*/

oExtraDoorsCost=0
ExtraDoorsCost=0
FrontExtraDoorsCost=0
BackExtraDoorsCost=0
LeftExtraDoorsCost=0
RightExtraDoorsCost=0
msg=""

if (document.frmone.ExtraDoors.checked  == true) {
      editError=1
      editExtraDoors()
    
    if (editError) return;
	 
    // compare front dimensions entered by user (totalw) with front dimensions calculated by number of extra doors(Frontsize or Backsize)
    
     FrontDoor=0;BackDoor=0;LSideDoor=0;RSideDoor=0; //value of doors always zero if reachin type
     if (document.frmone.type[0].checked == true) {  // if walkin
        if (document.frmone.WDoorValue[0].checked == true) { FrontDoor=46}
        if (document.frmone.WDoorValue[1].checked == true) { BackDoor=46}
        if (document.frmone.WDoorValue[2].checked == true) { LSideDoor=46}
        if (document.frmone.WDoorValue[3].checked == true) { RSideDoor=46}
     }
     
     Frontsize=(Number(fwc) * 46)
     Frontsize=Frontsize + (Number(fgc) * 31) + 8 + FrontDoor
     //alert("Front in inches= " + Frontsize + " current Front size= " + totalw)
     Backsize=((Number(bwc) * 46) + (Number(bgc) * 31)) + 8 + BackDoor



     if ((Backsize > Frontsize) &&  (Backsize > totalw)) {
           //Feet=0
           Feet=Backsize / 12
           Feet=Math.floor(Feet)
           iFeet=Feet * 12
           Inches=Backsize - iFeet
           imsg ="Back extra doors require " + Feet + " feet " + Inches + " inches "
           
           if (unit == "mm") {
               Millimeters=Math.round(Backsize * 25.4);
               imsg ="Back extra doors require " + Millimeters + " millimeters";
           }
           
           //alert("Back extra doors feet= " + Feet + " inches= " + Inches + " vs Front feet= " + fw + " inches= " + iw)
           //alert("Back in inches= " + Backsize + " current Back size= " + totalw)
           //answer=confirm(imsg + " Is it ok to replace the Front dimensions with the Back extra doors dimensions?\n\n" + YesNoMsg)
          
          
          str=imsg  + ". Is it ok to replace the Front dimensions with the Back extra doors dimensions?\n\n"
	  strtitle="box dimension confirmation"
	            
	              
	  if (showDialogClicked == 1){
	      showDialogClicked=0;
	  } else {
	     answer=2
	     showDialog(str,strtitle)
	    // alert('display showDialog answer= ' + answer)
	  }
	          
	  if (answer == 2) return 
          // alert('display2 showDialog answer= ' + answer)
          
          if (answer == 1) {
               
               document.frmone.fWidth.value=Feet
               document.frmone.iWidth.value=Inches
               if (unit == "mm") {
                  document.frmone.mWidth.value=Millimeters;
               }
               document.frmone.Cost.value=""
               document.frmone.BackExtraDoorsCost.value=""
               document.frmone.Summary.value="press total cost button again to recalculate using new Front dimensions"
               // document.frmone.Summary.value="recalculate using new Front dimensions"
              // alert("press total cost button again to recalculate using new Front dimensions")
               return
              // calculate();
           } else {
             document.frmone.BWalkinCount.value=0
             document.frmone.BGlassCount.value=0
             document.frmone.Cost.value=""
             document.frmone.BackExtraDoorsCost.value=""
             document.frmone.Summary.value=(" you have chosen not to use the new Front dimensions")
             dmsg=""
             return
           }

     }

     else if (Frontsize > totalw) {
             Feet=Math.floor(Frontsize / 12)
             iFeet=Feet * 12
	    Inches=Frontsize - iFeet
            imsg ="Front extra doors require " + Feet + " feet " + Inches + " inches "		    
            //alert("Front extra doors require " + Feet + " feet " + Inches + " inches")
            //alert("Front in inches= " + Frontsize + " current Front size= " + totalw)
            
             if  (unit == "mm") {
	                   Millimeters=Math.round(Frontsize * 25.4);
	                   imsg ="Front extra doors require " + Millimeters + " millimeters";
             }
            
	    //answer=confirm(imsg + " Is it ok to replace the Front dimensions with the Front extra doors dimensions?\n\n" + YesNoMsg)
	    
	    str=imsg  + ". Is it ok to replace the Front dimensions with the Front extra doors dimensions?\n\n"
	    strtitle="box dimension confirmation"
	    	            
	    	              
	    if (showDialogClicked == 1){
	    	      showDialogClicked=0;
	    } else {
	    	     answer=2
	    	     showDialog(str,strtitle)
	    	    // alert('display showDialog answer= ' + answer)
	    }
	    	          
	    if (answer == 2) return 
          // alert('display2 showDialog answer= ' + answer)
	    
	    if (answer == 1) {
               document.frmone.fWidth.value=Feet
               document.frmone.iWidth.value=Inches
               if (unit == "mm") {
	            document.frmone.mWidth.value=Millimeters;
               }
               document.frmone.Cost.value=""
                document.frmone.FrontExtraDoorsCost.value=""
               document.frmone.Summary.value="press total cost button again to recalculate using new Front dimensions"
               //document.frmone.Summary.value="recalculate using new Front dimensions"
               //alert("press total cost button again to recalculate using new dimensions")
               return;
               //calculate();
	    } else {
		   document.frmone.FWalkinCount.value=0
		   document.frmone.FGlassCount.value=0
		   document.frmone.Cost.value=""
		   document.frmone.FrontExtraDoorsCost.value=""
		   document.frmone.Summary.value=(" you have chosen not to use the new Front dimensions")
		   return;
           }

     } else {
       // leave totalw alone
     } // end of front compare

     // compare side dimensions entered by user (totall) with side dimensions calculated by number of extra doors(Left or Right Side)

     LSidesize=(Number(lwc) * 46)
     LSidesize=LSidesize + (Number(lgc) * 31) + 8 + LSideDoor
    //alert("Left Side in inches= " + LSidesize + " current Side size= " + totall)
     RSidesize=((Number(rwc) * 46) + (Number(rgc) * 31)) + 8 + RSideDoor

     //alert("FrontDoor= " + FrontDoor + " BackDoor= " + BackDoor + " LSideDoor= " + LSideDoor + " RSideDoor= " + RSideDoor)


     if ((LSidesize > RSidesize) &&  (LSidesize > totall)) {
           //Feet=0
           Feet=LSidesize / 12
           Feet=Math.floor(Feet)
           iFeet=Feet * 12
           Inches=LSidesize - iFeet
           imsg ="Left side extra doors require " + Feet + " feet " + Inches + " inches "
           //alert("Left side extra doors feet= " + Feet + " inches= " + Inches + " vs Front feet= " + fl + " inches= " + il)
           //alert("Left side in inches= " + LSidesize + " current Side size= " + totall)
           
	    if (unit == "mm") {
	        Millimeters=Math.round(LSidesize * 25.4);
	        imsg ="Left side  extra doors require " + Millimeters + " millimeters";
	    }
           
         //answer=confirm(imsg + " Is it ok to replace the Side dimensions with the Left side extra doors dimensions?\n\n" + YesNoMsg)
          
          str=imsg  + ". Is it ok to replace the the Side dimensions with the Left side extra doors dimensions?\n\n"
          strtitle="box dimension confirmation"
	  	    	            
	  	    	              
	  if (showDialogClicked == 1){
	       showDialogClicked=0;
	  } else {
	       answer=2
	       showDialog(str,strtitle)
	      // alert('display showDialog answer= ' + answer)
	  }
	  	    	          
	  if (answer == 2) return 
          // alert('display2 showDialog answer= ' + answer)
          
          
          
          if (answer == 1) {
               document.frmone.fLength.value=Feet
               document.frmone.iLength.value=Inches
               if (unit == "mm") {
	       	   document.frmone.mLength.value=Millimeters;
               }
               document.frmone.Cost.value=""
               document.frmone.LeftExtraDoorsCost.value=""
               document.frmone.Summary.value="press total cost button again to recalculate using new Side dimensions"
               // document.frmone.Summary.value="recalculate using new Side dimensions"
               //alert("press total cost button again to recalculate using new Side dimensions")
               return;
             //calculate();
           } else {
             document.frmone.LWalkinCount.value=0
             document.frmone.LGlassCount.value=0
             document.frmone.Cost.value=""
              document.frmone.LeftExtraDoorsCost.value=""
             document.frmone.Summary.value=(" you have chosen not to use the new Side dimensions")
             dmsg=""
             return;
           }

     }

     else if (RSidesize > totall) {
            Feet=Math.floor(RSidesize / 12)
	    iFeet=Feet * 12
	    Inches=RSidesize - iFeet
	    imsg ="Right side extra doors require " + Feet + " feet " + Inches + " inches "
             //alert("Right side extra doors feet= " + Feet + " inches= " + Inches + " vs  Side feet= " + fl + " inches= " + il)
	       //alert("Right side in inches= " + RSidesize + " current Side size= " + totall)
	       
	    if (unit == "mm") {
	        Millimeters=Math.round(RSidesize * 25.4);
	        imsg ="Right side extra doors require " + Millimeters + " millimeters";
	    }
           
	   //answer=confirm(imsg + " Is it ok to replace the Side dimensions with the Right side extra doors dimensions?\n\n" + YesNoMsg)
	     str=imsg  + ". Is it ok to replace the the Side dimensions with the Right side extra doors dimensions?\n\n"
	     strtitle="box dimension confirmation"
	    	  	    	            
	    	  	    	              
	     if (showDialogClicked == 1){
	    	       showDialogClicked=0;
	     } else {
	    	       answer=2
	    	       showDialog(str,strtitle)
	    	      // alert('display showDialog answer= ' + answer)
	     }
	    	  	    	          
	    if (answer == 2) return 
          // alert('display2 showDialog answer= ' + answer)
	    
	    
	    
	    
	    if (answer == 1) {
                 document.frmone.fLength.value=Feet
                 document.frmone.iLength.value=Inches
                 if (unit == "mm") {
		    document.frmone.mLength.value=Millimeters;
                 }
                 document.frmone.Cost.value=""
                  document.frmone.RightExtraDoorsCost.value=""
                  document.frmone.Summary.value="press total cost button again to recalculate using new Side dimensions"
                  //document.frmone.Summary.value="recalculate using new Right side dimensions"
                 //alert("press total cost button again to recalculate using new dimensions")
                 return;
                  // calculate();
	     } else {
		document.frmone.RWalkinCount.value=0
		document.frmone.RGlassCount.value=0
	        document.frmone.Cost.value=""
	        document.frmone.RightExtraDoorsCost.value=""
	        document.frmone.Summary.value=(" you have chosen not to use the new Side dimensions")
	        return;
           }

     } else {
       // leave totall alone
     } // end of side compare


             /* calculate door and btu costs  for front and back */
              frontdmsg=""
	          frontBTU=0
	          fBTU=0
	          bBTU=0

	          ExtraDoorsCost=(fwc * WalkinDoorCost) + (fgc * GlassDoorCost)
	          oExtraDoorsCost=ExtraDoorsCost
	          //ExtraDoorsCost=roundToPennies(ExtraDoorsCost)
	          if (ExtraDoorsCost > 0 ) {
	             //frontdmsg=frontdmsg + " Front door(s) cost $" + ExtraDoorsCost + " also included. "
	             FrontExtraDoorsCost=ExtraDoorsCost
	          }
	          if (document.frmone.Refrigeration.checked  == true) {
	 		     fBTU = (fwc * BTUPerDoor) + (fgc * BTUPerDoor)
	 		     //alert("add front extra doors btu= " + fBTU)
	          }

	          ExtraDoorsCost=(bwc * WalkinDoorCost) + (bgc * GlassDoorCost)
	 		 oExtraDoorsCost=ExtraDoorsCost
	 		 //ExtraDoorsCost=roundToPennies(ExtraDoorsCost)
	 		 if (ExtraDoorsCost > 0 ) {
	 		    //frontdmsg=frontdmsg + " Back door(s) cost $" + ExtraDoorsCost + " also included. "
	 		    BackExtraDoorsCost=ExtraDoorsCost
	 		 }
	 		 if (document.frmone.Refrigeration.checked  == true) {
	 		    bBTU = (bwc * BTUPerDoor) + (bgc * BTUPerDoor)
	 		    //alert("add back extra doors btu= " + bBTU)
	 		 }
		     frontBTU=fBTU + bBTU
		     /* end of front and back door costs */

		     /* calculate door and btu costs  for left and right side */
			    sidedmsg=""
			    sideBTU=0
			    lBTU=0
			    rBTU=0

			    ExtraDoorsCost=(lwc * WalkinDoorCost) + (lgc * GlassDoorCost)
			    oExtraDoorsCost=ExtraDoorsCost
			    //ExtraDoorsCost=roundToPennies(ExtraDoorsCost)
			    if (ExtraDoorsCost > 0 ) {
			        //sidedmsg=sidedmsg + " Left side door(s) cost $" + ExtraDoorsCost + " also included. "
			        LeftExtraDoorsCost=ExtraDoorsCost
			    }
			 	if (document.frmone.Refrigeration.checked  == true) {
			 	 	lBTU = (lwc * BTUPerDoor) + (lgc * BTUPerDoor)
			 	 	//alert("add left side extra doors btu= " + lBTU)
			 	}

			 	ExtraDoorsCost=(rwc * WalkinDoorCost) + (rgc * GlassDoorCost)
			 	oExtraDoorsCost=ExtraDoorsCost
			 	//ExtraDoorsCost=roundToPennies(ExtraDoorsCost)
			 	if (ExtraDoorsCost > 0 ) {
			 	  //sidedmsg=sidedmsg + "  Right side door(s) cost $" + ExtraDoorsCost + " also included. "
			       RightExtraDoorsCost=ExtraDoorsCost
			 	}
			 	if (document.frmone.Refrigeration.checked  == true) {
			 	    rBTU = (rwc * BTUPerDoor) + (rgc * BTUPerDoor)
			 	   //alert("add right side extra doors btu= " + rBTU)
			   }
			 	sideBTU=lBTU + rBTU
		     /* end of left and side door costs */


} // end of extra doors true


 checkExtraDoorsStatus()

// end of extra doors


oBTUcost=0
BTUcost=0
rmsg=""
if (document.frmone.Refrigeration.checked  == true) {
   /* calculate surface area */
   sfloor=footprint
   sceiling=sfloor
   slside=totalh * totall
   srside=slside
   sfront=totalh * totalw
   sback=sfront
   totalSurfaceArea=(sfloor+sceiling+slside+srside+sfront+sback) / 144
   totalSurfaceArea=Math.round(totalSurfaceArea * 100) / 100
   //alert("total surface area = " + totalSurfaceArea + " square feet")
   //alert("front BTU= " + frontBTU + " side BTU= " + sideBTU)

   if (document.frmone.ExtraDoors.checked  == false) {
     BTU=0
     //alert("extra doors btu set to zero")
   }
   else if ((document.frmone.ExtraDoors.checked  == true)  && (dmsg == "")){
        BTU=frontBTU + sideBTU
        //alert("extra doors btu set to zero")
   } else {
        BTU=frontBTU + sideBTU
   }
   
  /* open up these alerts to troubleshoot table entries */
   
   //alert("extra doors BTU = " + BTU)
   tsaBTU=(totalSurfaceArea * BTURate)
   //alert("totalSurfaceArea BTU = " + tsaBTU)
   BTU=BTU + tsaBTU
   
   ambientTemp=Number(ambientTemp=isDegrees())
   if (ambientTemp == 100) {
         //alert("using ambient temp " + ambientTemp) 
         BTU=BTU * Ambient100
   } else {
        //alert("using ambient temp " + ambientTemp) 
   }
   
  // alert("total BTU = " + BTU)
   oBTUcost=getBTUcost(BTU)
   BTUcost=roundToPennies(oBTUcost);
   //alert("BTU cost =" + BTUcost)
   if (BTUcost > 0) {
     //rmsg="Refrigeration cost $" + BTUcost + " also included."
     rmsg=""
   } else {
      document.frmone.Summary.value ="unable to determine refrigeration cost"
      document.frmone.Cost.value = ""
      return
   }
   dmsg=""
   dmsg=frontdmsg + sidedmsg

} // end of refrigeration

BoxCost=ceiling + lside + rside + front + back + oneWalkinDoor
BoxCost = Math.round(BoxCost * 100) / 100      // round cost to the nearest penny
//alert("box cost before markup : " + BoxCost)
BoxCost = BoxCost * boxMarkup
//alert("box cost after markup : " + BoxCost)
newBoxCost=roundToPennies(BoxCost)
//alert("new box cost after rounding : " + newBoxCost)
document.frmone.stdBoxCost.value = "$" + newBoxCost
if (unit="mm") document.frmone.metricBoxCost.value = "$" + newBoxCost


BTUCost= oBTUcost
if (BTUCost > 0) {
   rmsg=""
   BTUCost = Math.round(BTUCost * 100) / 100      // round cost to the nearest penny
   BTUCost=roundToPennies(BTUCost)
   document.frmone.BTUCost.value = "$" + BTUCost
} else {
  document.frmone.BTUCost.value = ""
}
//document.frmone.BTUCost.disabled = true

if (FrontExtraDoorsCost > 0) {
   document.frmone.FrontExtraDoorsCost.value = "$" + roundToPennies(FrontExtraDoorsCost)
} else {
   document.frmone.FrontExtraDoorsCost.value = ""
}
//document.frmone.FrontExtraDoorsCost.disabled = true

if (BackExtraDoorsCost > 0) {
   document.frmone.BackExtraDoorsCost.value = "$" + roundToPennies(BackExtraDoorsCost)
} else {
   document.frmone.BackExtraDoorsCost.value = ""
}
//document.frmone.BackExtraDoorsCost.disabled = true

if (LeftExtraDoorsCost > 0) {
   document.frmone.LeftExtraDoorsCost.value = "$" + roundToPennies(LeftExtraDoorsCost)
} else {
   document.frmone.LeftExtraDoorsCost.value = ""
}
//document.frmone.LeftExtraDoorsCost.disabled = true

if (RightExtraDoorsCost > 0) {
   document.frmone.RightExtraDoorsCost.value = "$" + roundToPennies(RightExtraDoorsCost)
} else {
   document.frmone.RightExtraDoorsCost.value = ""
}
//document.frmone.RightExtraDoorsCost.disabled = true

ExtraDoorsCost=FrontExtraDoorsCost + BackExtraDoorsCost + LeftExtraDoorsCost + RightExtraDoorsCost

if (ExtraDoorsCost > 0) {
   document.frmone.TotalExtraDoorsCost.value = "$" + roundToPennies(ExtraDoorsCost)
} else {
   document.frmone.TotalExtraDoorsCost.value = ""
}

msg=""
RampCost=0
RampCT=Number(fwc) + Number(bwc) + Number(lwc)  + Number(rwc) + 1

if (document.frmone.Floor.checked  == true){
    //msg +="Floor $" + rfloor + " included in cost. "
    document.frmone.FloorCost.value="$" + rfloor
   // Cost=ceiling + floor + lside + rside + front + back + oneDoor +  oBTUcost + ExtraDoorsCost
   Cost=ceiling +  lside + rside + front + back + oneWalkinDoor +  oBTUcost + ExtraDoorsCost + RampCost
}
else {
 // msg +="Floor $" + rfloor + " not included in cost. "
  Cost=ceiling +  lside + rside + front + back + oneWalkinDoor +  oBTUcost + ExtraDoorsCost
  document.frmone.FloorCost.value=""
}
//document.frmone.FloorCost.disabled = true

if (document.frmone.Floor.checked  == true ){
  if (document.frmone.type[0].checked == true){
       RampCost = RampCT * CostPerRamp
     // alert("Interior Ramp cost =" + RampCost)
      document.frmone.RampCost.value="$" + roundToPennies(RampCost)
      document.frmone.RampCT.value=RampCT
      document.frmone.RampCost.disabled = false
  
  } else {
    document.frmone.RampCost.value=""
    document.frmone.RampCT.value=0
  }  
}
//** Cost=ceiling + floor + lside + rside + front + back + oneWalkinDoor +  oBTUcost + ExtraDoorsCost + RampCost
//** BoxCost=ceiling + lside + rside + front + back + oneWalkinDoor
Cost=BoxCost + floor +  oBTUcost + ExtraDoorsCost + RampCost
//alert("BoxCost=" + BoxCost + " floor="  + floor + " oBTUcost=" + oBTUcost)
//alert("ExtraDoorsCost=" + ExtraDoorsCost + " RampCost=" + RampCost) 
//alert("Cost before rounding = " + Cost)
Cost = Math.round(Cost * 100) / 100      // round cost to the nearest penny
//Cost = Cost * boxMarkup
Cost=roundToPennies(Cost)
newCost=formatCurrency(Cost)
//alert("new cost = " + newCost)
document.frmone.Cost.value ="$" +  newCost

//document.frmone.Cost.disabled = true

if (document.frmone.type[0].checked == true) {
    document.frmone.Cost.value="$" + newCost + "  for WALK-IN cooler"
} else {
    document.frmone.Cost.value="$" + newCost + "  for REACH-IN cooler"
}



/* end of calculate cost */

document.frmone.Summary.value =""
document.frmone.Summary.value =msg + dmsg + rmsg
if (Cost > leaseMaxAmount) {
   alert("box cost " + Cost + " exceeds threshold ")
   document.frmone.Summary.value="Box cost exceeds lease maximum amount of " + leaseMaxAmountText + " ,unable to calculate Lease"
   return
}
showLeaseArea()
showMessageArea()

//** save current box dimension;use when convert inches/millimeters radio button selected

if (document.frmone.measurement[0].checked == true) {   //inches
  savefHeight=Number(document.frmone.fHeight.value);   //Number function to convert string to number
  saveiHeight=Number(document.frmone.iHeight.value);
  savefWidth=Number(document.frmone.fWidth.value);
  saveiWidth=Number(document.frmone.iWidth.value);
  savefLength=Number(document.frmone.fLength.value);
  saveiLength=Number(document.frmone.iLength.value);
  
 // alert(" std h w l= " + savefHeight + " " + saveiHeight + " " + savefWidth + " " + saveiWidth + " " + savefLength + " " + saveiLength);
 // alert(" metric h w l= " + savemHeight + " " + savemWidth + " " + savemLength);
  //mLength
  temp=((savefHeight * 12) + saveiHeight) * 25.4
  fmillimeters=Math.round(temp)
  document.frmone.mHeight.value=fmillimeters
 //alert("mHeight= " + fmillimeters)
  
  //mWidth
  fmillimeters=Math.round(((savefWidth * 12) + saveiWidth) * 25.4)
  document.frmone.mWidth.value=fmillimeters
  // alert("mWidth= " + fmillimeters)              
   //mLength
   fmillimeters=Math.round(((savefLength * 12) + saveiLength) * 25.4)
   document.frmone.mLength.value=fmillimeters
  //  alert("mLength= " + fmillimeters)  
  }
  
  if (document.frmone.measurement[1].checked == true) {   //millimeters
    
    savemHeight=Number(document.frmone.mHeight.value);
    savemWidth=Number(document.frmone.mWidth.value);
    savemLength=Number(document.frmone.mLength.value);
   // alert(" std h w l= " + savefHeight + " " + saveiHeight + " " + savefWidth + " " + saveiWidth + " " + savefLength + " " + saveiLength);
   // alert(" metric h w l= " + savemHeight + " " + savemWidth + " " + savemLength);
    
    //fHeight,IHeight
    mInches=Math.round(savemHeight * 0.03937008)
    mFeet=Math.floor(mInches /12)
    mremainderInches=mInches - (mFeet * 12)
   // alert(" Height: mInches= " + mInches + " mFeet= " + mFeet + " mremainderInches= " + mremainderInches)
    document.frmone.fHeight.value=mFeet +""
    document.frmone.iHeight.value=mremainderInches + "" // add a string to number to convert number to string
           	   
     //fWidth,IWidth
     mInches=Math.round(savemWidth * 0.03937008)
     mFeet=Math.floor(mInches /12)
     mremainderInches=mInches - (mFeet * 12)
    // alert("Width: mInches= " + mInches + " mFeet= " + mFeet + " mremainderInches= " + mremainderInches)
     document.frmone.fWidth.value=mFeet+"" 
     document.frmone.iWidth.value=mremainderInches+""
           	   
     //fLength,ILength
     mInches=Math.round(savemLength * 0.03937008)
     mFeet=Math.floor(mInches /12)
     mremainderInches=mInches - (mFeet * 12)
   //  alert("Length: mInches= " + mInches + " mFeet= " + mFeet + " mremainderInches= " + mremainderInches)
     document.frmone.fLength.value=mFeet+""
     document.frmone.iLength.value=mremainderInches+""
  }

} // end of calculate

function isValidNumber(inpString) {
   return /^[-+]?\d+(\.\d+)?$/.test(inpString); // check to see that text string contains only digits
}


/* */
function getBTUcost(BTU) {

/* old version
    var min = new Array(2220,4801,6481,8161,11521,14401,17281,22921,23281,24481,31081,35041,42241,50521,59641,68761);
    var max = new Array(4800,6480,8160,11520,14400,17280,22920,23280,24480,31080,35040,42240,50520,59640,68760,75600);
var costBTUStandard =     new Array(1471,1740,1825,2000.70,2350,2550,2760,2950,3020,3460,3760,3800.90,5200,5800,8335,8700);
var costBTUHighHumidity = new Array(1471,1740,1825,2000.70,2350,2550,2760,2950,3020,3460,3760,3800.90,5200,5800,8335,8700);
var costBTUReachin =      new Array(1471,1740,1825,2000.70,2350,2550,2760,2950,3020,3460,3760,3800.90,5200,5800,8335,8700);
*/
var min = new Array(2220,4801,6481,8161,11521,14401,17281,22921,23281,24481,31081,35041,42241,50521,59641,68761,75601);
var max = new Array(4800,6480,8160,11520,14400,17280,22920,23280,24480,31080,35040,42240,50520,59640,68760,75600,93600);
var costBTUStandard =     new Array(1471,1740,1825,2000.70,2350,2550,2760,2950,3020,3460,3760,3800.90,5200,5800,8335,8700,10700);
var costBTUHighHumidity = new Array(1880,2023,2160,2444,2665,2775,2910,3453,3760,4200,5736,6306,8653,10328,11255,11990,13887);
var costBTUReachin =      new Array(1701,1990,2082,2333,2550,2608,2887,3390,3690,4420,5500,6200,8400,9935,11000,11887,13556);


for (var i=0; i<17; i++) {
    if (((min[i] <= BTU) && (BTU <= max[i]))) {
        //walkin cooler
        if (document.frmone.type[0].checked == true) {       
           if (document.frmone.system[0].checked == true) {
               BTUcost=costBTUStandard[i]
             //  alert("using standard system btu cost")
           }    
           if (document.frmone.system[1].checked == true) {
             BTUcost=costBTUHighHumidity[i]
            // alert("using high humidity system btu cost")
           }
        } 
     
        // reachin cooler
        if (document.frmone.type[1].checked == true) {
          BTUcost=costBTUReachin[i]
          //alert("using reach-in cooler btu cost")
        }

        BTUcost=BTUcost * Markup
        BTUcost=Math.round(BTUcost * 100) / 100
        return BTUcost;
    }

 }

 //alert("unable to determine BTU cost");
 return 0;
}
function roundToPennies(dollar)
{
 /* floating point dollar when rounded sometimes truncates the pennies; for example dollar value 1234.00 becomes 1234 or 1234.50 becomes 1234.5;
    this function will preserve the pennies so that 1234 will become 1234.00 or 1234.5 will become 1234.50
 */
 pennies = dollar * 100;
 pennies = Math.round(pennies);
 strPennies = "" + pennies;
 len = strPennies.length;
 dollar=strPennies.substring(0, len - 2) + "." + strPennies.substring(len - 2, len);
 return dollar;
}

function checkFloorStatus() {
   document.frmone.Summary.value=""
   document.frmone.Cost.value=""
   
   hideLeaseArea()
   hideMessageArea()
   
   if (document.frmone.Floor.checked  == false) {
      // alert("floor check false")
       document.frmone.FloorCost.value=""
       /*
       document.frmone.ramp[0].checked = true
       document.frmone.ramp[0].disabled= true
       document.frmone.ramp[1].disabled= true
       document.frmone.RampCT.value= 0
       document.frmone.RampCT.disabled = false
       document.frmone.RampCost.value= ""
       */
       $('#ramps').hide()
       $('#floorText').hide()
       
  }
  
  if (document.frmone.Floor.checked  == true ) {
     // alert("floor check true ")
      if (document.frmone.type[1].checked == true) {
           document.frmone.ramp[0].disabled = true
           document.frmone.ramp[1].disabled= true
	   // alert("cooler type is reachin")
	   $('#ramps').hide();
       } else {
           document.frmone.ramp[0].disabled = false
	   document.frmone.ramp[1].disabled= false
	   $('#ramps').show();
	  // alert("cooler type is walkin")
       } // if cooler
       // alert("floor check true ")
       document.frmone.FloorCost.value="" 
       document.frmone.ramp[0].checked = true
       document.frmone.RampCT.value= 0
       document.frmone.RampCT.disabled = false
       document.frmone.RampCost.value= ""
        
        $('#floorText').show()
       
  }  // if Floor  true
}

function checkGlassDoor() {
    //alert("check glass doors")
    /*document.frmone.FWalkinCount.style.color = 'black'
	document.frmone.FGlassCount.style.color = 'black'
	document.frmone.BWalkinCount.style.color = 'black'
	document.frmone.BGlassCount.style.color = 'black'
	document.frmone.LWalkinCount.style.color = 'black'
	document.frmone.LGlassCount.style.color = 'black'
	document.frmone.RWalkinCount.style.color = 'black'
	document.frmone.RGlassCount.style.color = 'black'*/
	
	var doorInput=document.getElementById('doors').getElementsByTagName('input');
	for (i=0;i<doorInput.length;i++) {
	   if (doorInput[i].className=="doorcost") {
        // alert("doorcost field	for subscript " + i)
		 continue
	   }
	   doorInput[i].style.color = 'black'
	 } 
	 
  if (document.frmone.glassDoor[0].checked == true) {
       intImage=1
        GlassDoorCost=CDSDoorsCost
        
  } else {
       intImage=2
       GlassDoorCost=AnthonyGlassCost
  }
    // alert("intImage = " + intImage)
  swapImage2()
 /* alert ("fwc value = " + document.frmone.FWalkinCount.value + "fgc value = " + document.frmone.FGlassCount.value)*/
   
   doorCount=0
	for (i=0;i<doorInput.length;i++) {
	   if (doorInput[i].value > 0) {
        doorCount=1
		 break
	   }
	 } 
  if (doorCount) {
     // resetDoorCount=confirm(" Is it ok to reset door counts to zero?\n\n" + YesNoMsg)
      
      str="Is it ok to reset door counts to zero?\n\n"
      strtitle="reset door confirmation"
                     
                       
      if (showDialogClicked2 == 1){
          showDialogClicked2=0;
      } else {
          resetDoorCount=2
          showDialog2(str,strtitle)
          //alert('display showDialog2 resetDoorCount= ' + resetDoorCount)
      }
                   
      if (resetDoorCount == 2) return 
     // alert('display2 showDialog2 resetDoorCount= ' + resetDoorCount)
           
      
      
      if (resetDoorCount == 1) {
        fwc=0
        bwc=0
        lwc=0
        rwc=0
        fgc=0
        bgc=0
        lgc=0
        rgc=0 
      } else {
         resetDoorCount=0;
     }  
  }
  resetExtraDoors(resetDoorCount)
  document.frmone.ExtraDoors.checked  = true
}

function checkCoolerType() {
     
     hideLeaseArea()
     hideMessageArea()
     
     if (document.frmone.type[0].checked == true) {
       intImage=1
     } else {
       intImage=2
     }
    // alert("intImage = " + intImage)
    
     swapImage()
    
    // alert("enter cooler type")
    if (document.frmone.type[1].checked == true) {
       document.frmone.Floor.checked  =true
       $('#floorText').show()
       $('#ramps').hide()
       document.frmone.Floor.disabled =false
       document.frmone.FloorCost.value=""
       oneWalkinDoor=0 
       document.frmone.ramp[0].checked = true
       document.frmone.ramp[0].disabled= true
       document.frmone.ramp[1].disabled= true
       document.frmone.RampCT.value= 0
       document.frmone.RampCT.disabled = false
       document.frmone.RampCost.value= ""
       document.frmone.RampCost.disabled = false
       
       // alert("cooler type is reachin")
    } else {
       document.frmone.Floor.checked  = false
       $('#floorText').hide()
       $('#ramps').hide()
       document.frmone.Floor.disabled = false
       oneWalkinDoor=WalkinDoorCost 
       document.frmone.FloorCost.value=""
       //  alert("cooler type is walkin")
    }
    //alert("check cooler type function calls resetbox")
    // alert("one walkin door cost = " + oneWalkinDoor)
    resetBox()
    resetDoorCount=1
    resetExtraDoors(resetDoorCount)
    document.frmone.ExtraDoors.checked  = false
    checkExtraDoorsStatus()
   // checkRefrigerationStatus()
    document.frmone.stdBoxCost.value=""
    document.frmone.metricBoxCost.value=""
    document.frmone.Cost.value=""
    //document.frmone.FloorCost.value=""
    rfloor=0
    document.frmone.BTUCost.value=""
    document.frmone.Refrigeration.checked  = false
    checkRefrigerationStatus()
    document.frmone.Summary.value=""
    // alert("one walkin door cost = " + oneWalkinDoor)
    // alert("return cooler type")
    if (document.frmone.type[0].checked == true) {               //walkin
         if (document.frmone.measurement[0].checked == true) {   //inches
           $("#stdMsgs1").show();
           $("#stdMsgs2").show();
           $("#metricMsgs").hide();
           $("#stdbox").show();
           $("#metricbox").hide();
         } else {                                              //millimeters
           $("#stdMsgs1").show();
           $("#stdMsgs2").hide();
           $("#metricMsgs").show();
           $("#stdbox").hide();
           $("#metricbox").show();
         } 
         
    } 
    if (document.frmone.type[1].checked == true) {            //reachin
         $("#stdMsgs1").hide();
         
         if (document.frmone.measurement[0].checked == true) {  //inches
         
            $("#stdMsgs2").show();
            $("#metricMsgs").hide();
            $("#stdbox").show();
            $("#metricbox").hide();
         } else {                                               //millimeters
            $("#stdMsgs2").hide();
            $("#metricMsgs").show();
            $("#stdbox").hide();
           $("#metricbox").show();
         }
    }       
           
           /*    
           document.frmone.WDoorMsgCost.style.visibility="visible"
           document.frmone.WDoorMsgLocation.style.visibility="visible"
           document.frmone.WDoorValue[0].style.visibility="visible"
	   document.frmone.WDoorValue[1].style.visibility="visible"
	   document.frmone.WDoorValue[2].style.visibility="visible"
           document.frmone.WDoorValue[3].style.visibility="visible"
           var button= document.getElementById('FrontDoorText')     
	   button.style.display = 'inline'; //show it
	   var button= document.getElementById('BackDoorText')     
           button.style.display = 'inline'; 
           var button= document.getElementById('LSideDoorText')     
           button.style.display = 'inline'; 
           var button= document.getElementById('RSideDoorText')     
           button.style.display = 'inline'; 
           } else {
        
           //alert("reachin door at check cooler type")
           document.frmone.WDoorMsgCost.style.visibility="hidden"
	   document.frmone.WDoorMsgLocation.style.visibility="hidden"
           document.frmone.WDoorValue[0].style.visibility="hidden"
           document.frmone.WDoorValue[1].style.visibility="hidden"
           document.frmone.WDoorValue[2].style.visibility="hidden"
           document.frmone.WDoorValue[3].style.visibility="hidden"
           //alert("blank out values")
           var button= document.getElementById('FrontDoorText')     
           button.style.display = 'none'; //hide it
           var button= document.getElementById('BackDoorText')     
           button.style.display = 'none'; //hide it
           var button= document.getElementById('LSideDoorText')     
           button.style.display = 'none'; //hide it
           var button= document.getElementById('RSideDoorText')     
           button.style.display = 'none'; //hide it
         
     }*/
	$('#dsarea').hide();
	   if (document.frmone.type[0].checked == true) {
	   // alert("show/hide display accessories")
	    $('#dsarea').show();
	   document.frmone.accessory[1].checked=true
	   $('#dsa').hide();

	}
}
function checkMeasurementType() {

  /* document.frmone.Cost.value=""
   document.frmone.stdBoxCost.value=""
   document.frmone.metricBoxCost.value=""
   document.frmone.Summary.value="" */
   
   
   
  if (document.frmone.type[0].checked == true) {               //walkin
           if (document.frmone.measurement[0].checked == true) {   //inches
             $("#stdMsgs1").show();
             $("#stdMsgs2").show();
             $("#metricMsgs").hide();
             $("#stdbox").show();
             $("#metricbox").hide();
           } else {                                          //millimeters
             $("#stdMsgs1").show();
             $("#stdMsgs2").hide();
             $("#metricMsgs").show();
             $("#stdbox").hide();
             $("#metricbox").show();
           } 
           
	   
	   
           
      } 
       if (document.frmone.type[1].checked == true) {            //reachin
          $("#stdMsgs1").hide();
          
          if (document.frmone.measurement[0].checked == true) {  //inches
	      $("#stdMsgs2").show();
              $("#metricMsgs").hide();
	      $("#stdbox").show();
	      $("#metricbox").hide();
	  } else {                                               //millimeters
	      $("#stdMsgs2").hide();
              $("#metricMsgs").show();
	      $("#stdbox").hide();
	      $("#metricbox").show();
         }
         
      }  
}

function checkRefrigerationStatus() {
   
   hideLeaseArea()
   hideMessageArea()
   
   if (document.frmone.Refrigeration.checked  == false) {
       /*
       document.frmone.degrees[0].disabled=true 
       document.frmone.degrees[1].disabled=true 
       document.frmone.system[0].disabled=true 
       document.frmone.system[1].disabled=true 
      */
      $('#degrees').hide()
      $('#system').hide()
      $('#reeferText').hide()
   } 
   
   if (document.frmone.Refrigeration.checked  == true) { 
      /*           
       document.frmone.degrees[0].disabled=false 
       document.frmone.degrees[1].disabled=false 
       document.frmone.system[0].disabled=false 
       document.frmone.system[1].disabled=false 
       */
        $('#degrees').show()
        $('#system').show()
        $('#reeferText').show()
   }
    document.frmone.BTUCost.value=""
    document.frmone.Summary.value=""
    document.frmone.Cost.value=""
}
function checkExtraDoorsStatus() {

   hideLeaseArea()
   hideMessageArea()
   
   /*dcument.frmone.FWalkinCount.style.color = 'black'
	document.frmone.FGlassCount.style.color = 'black'
	document.frmone.BWalkinCount.style.color = 'black'
	document.frmone.BGlassCount.style.color = 'black'
	document.frmone.LWalkinCount.style.color = 'black'
	document.frmone.LGlassCount.style.color = 'black'
	document.frmone.RWalkinCount.style.color = 'black'
	document.frmone.RGlassCount.style.color = 'black'*/
	
	var doorInput=document.getElementById('doors').getElementsByTagName('input');
	for (i=0;i<doorInput.length;i++) {
	   if (doorInput[i].className=="doorcost") {
        // alert("doorcost field	for subscript " + i)
		 continue
	   }
	   doorInput[i].style.color = 'black'
	 } 
	 
   document.frmone.Summary.value=""
   document.frmone.Cost.value=""
   document.frmone.TotalExtraDoorsCost.value=""
   if (document.frmone.ExtraDoors.checked  == false) {
             //alert("check extra doors status function calls resetbox")
             //resetBox()
             resetDoorCount=1
             
             resetExtraDoors(resetDoorCount)
             $("td#doors").hide();
	    
              /*
             document.frmone.FGlassCount.disabled =true
             document.frmone.BGlassCount.disabled =true
             document.frmone.LGlassCount.disabled =true
             document.frmone.RGlassCount.disabled =true
             document.frmone.FWalkinCount.disabled =true
             document.frmone.BWalkinCount.disabled =true
             document.frmone.LWalkinCount.disabled =true
             document.frmone.RWalkinCount.disabled =true
            */
            // document.frmone.Refrigeration.checked  = false
            // checkRefrigerationStatus()
             document.frmone.BTUCost.value=""
             
  	     fwc=0
  	     bwc=0
  	     lwc=0
  	     rwc=0
  	     fgc=0
  	     bgc=0
  	     lgc=0
  	     rgc=0
             dmsg=""
             frontdmsg=""
             sidedmsg=""
             BTU=0
             FirstTimeExtraDoors=1

   } else {
        
	
	
        $("td#doors").show(); 
        
        /*
        document.frmone.FGlassCount.disabled =false
        document.frmone.BGlassCount.disabled =false
        document.frmone.LGlassCount.disabled =false
        document.frmone.RGlassCount.disabled =false
       */
       if (document.frmone.type[1].checked == true) {
              
            
              document.frmone.FWalkinCount.disabled =true
              document.frmone.BWalkinCount.disabled =true
              document.frmone.LWalkinCount.disabled =true
              document.frmone.RWalkinCount.disabled =true
            
              // alert("cooler type is reachin")
       } else {
             
          
             document.frmone.FWalkinCount.disabled =false
             document.frmone.BWalkinCount.disabled =false
             document.frmone.LWalkinCount.disabled =false
             document.frmone.RWalkinCount.disabled =false
          
             //  alert("cooler type is walkin")
       }
  
   } 
   
   if (document.frmone.ExtraDoors.checked  == true) {
             // alert("show glass vendor")
              $("td#vendor").show();
              /*
              document.frmone.GlassDoorMessage.style.visibility="visible"
              document.frmone.glassDoor[0].style.visibility="visible"
   	      document.frmone.glassDoor[1].style.visibility="visible"
              var button= document.getElementById('CDSDoorText')     
   	      button.style.display = 'inline'; //show it
   	      var button= document.getElementById('AnthonyDoorText')     
              button.style.display = 'inline' 
              document.frmone.IMG2.style.visibility="visible"
              */
              if( FirstTimeExtraDoors) {
                 document.frmone.glassDoor[0].checked = true
                 FirstTimeExtraDoors=0
              } 
              
              if (document.frmone.glassDoor[0].checked == true) {
	         intImage=1
	         GlassDoorCost=CDSDoorsCost
	      } else {
	         intImage=2
	         GlassDoorCost=AnthonyGlassCost
	      }
	      swapImage2()
  } else {
            //  alert("hide glass vendor")
               $("td#vendor").hide(); 
               /*
              document.frmone.GlassDoorMessage.style.visibility="hidden"
	      document.frmone.glassDoor[0].style.visibility="hidden"
   	      document.frmone.glassDoor[1].style.visibility="hidden"
              var button= document.getElementById('CDSDoorText')     
	      button.style.display = 'none'; //hide it
   	      var button= document.getElementById('AnthonyDoorText')     
              button.style.display = 'none'
              document.frmone.IMG2.style.visibility="hidden"
              */
                          
  }
}
// Checks the  ambient temperature
function isDegrees(){  
      if (document.frmone.degrees[0].checked == true) {
        ambientTemp=document.frmone.degrees[0].value
       } else {
          ambientTemp=document.frmone.degrees[1].value
       }
      // alert("ambient temp = " + ambientTemp)
       return ambientTemp;   
}
function resetBox() {
   
   hideLeaseArea()
   hideMessageArea()
   
 //alert("reset box dimensions")
 if (document.frmone.measurement[0].checked == true) { //inches
  
  /*document.frmone.fHeight.style.color = 'black'
    document.frmone.iHeight.style.color = 'black'
	document.frmone.fWidth.style.color = 'black'
	document.frmone.iWidth.style.color = 'black'
	document.frmone.fLength.style.color = 'black'
	document.frmone.iLength.style.color = 'black' */
	
	var stdboxInput=document.getElementById('stdbox').getElementsByTagName('input');
	for (i=0;i<stdboxInput.length;i++) {
	   if (stdboxInput[i].name=="stdBoxCost") {
         continue
	   }
	   stdboxInput[i].style.color = 'black'
	 
     /*document.frmone.fHeight.value=6
     document.frmone.iHeight.value=0
     document.frmone.fWidth.value=4
     document.frmone.iWidth.value=6
     document.frmone.fLength.value=5
     document.frmone.iLength.value=0*/
	 switch(stdboxInput[i].name) {
		   case "fHeight":
		         stdboxInput[i].value=6
				 break
			case "iHeight":
		         stdboxInput[i].value=0
				 break	
		    case "fWidth":
		         stdboxInput[i].value=4
				 break
			case "iWidth":
		         stdboxInput[i].value=6
				 break	
            case "fLength":
		         stdboxInput[i].value=5
				 break
			case "iLength":
		         stdboxInput[i].value=0
				 break	
		    
		}   
   }  		
 } else {  //millimeters
 
   /*document.frmone.mHeight.style.color = 'black'
     document.frmone.mWidth.style.color = 'black'
	 document.frmone.mLength.style.color = 'black' */
	 
	 var metricboxInput=document.getElementById('metricbox').getElementsByTagName('input');
	for (i=0;i<metricboxInput.length;i++) {
	   if (metricboxInput[i].name=="metricBoxCost") {
        		 continue
	   }
	   metricboxInput[i].style.color = 'black'
	 
     /*document.frmone.mHeight.value=1829
     document.frmone.mWidth.value=1372
     document.frmone.mLength.value=1524*/
	 switch(metricboxInput[i].name) {
		   case "mHeight":
		         metricboxInput[i].value=1829
				 break
			
		    case "mWidth":
		         metricboxInput[i].value=1372
				 break
			
            case "mLength":
		         metricboxInput[i].value=1524
				 break
			 
		} 
    }
 }    
 
   document.frmone.Cost.value=""
   document.frmone.stdBoxCost.value=""
   document.frmone.metricBoxCost.value=""
   document.frmone.Summary.value=""
   
   resetExtraDoors(1)
   checkExtraDoorsStatus()
}

function resetExtraDoors(resetDoorCount){
 document.frmone.ExtraDoors.checked  = false
 if (resetDoorCount) {
  document.frmone.FWalkinCount.value=0
  document.frmone.BWalkinCount.value=0
  document.frmone.LWalkinCount.value=0
  document.frmone.RWalkinCount.value=0
  document.frmone.FGlassCount.value=0
  document.frmone.BGlassCount.value=0
  document.frmone.LGlassCount.value=0
  document.frmone.RGlassCount.value=0
 }
 document.frmone.TotalExtraDoorsCost.value=""
 document.frmone.FrontExtraDoorsCost.value=""
 document.frmone.BackExtraDoorsCost.value=""
 document.frmone.RightExtraDoorsCost.value=""
 document.frmone.LeftExtraDoorsCost.value=""
 document.frmone.Summary.value=""
 document.frmone.Cost.value=""
} 

// lease functions 
function hideLeaseArea() {
       
       //alert("enter hideLeaseArea function")
	   $("td#LAMsg1").hide()
	   $("td#LABtn").hide()
	   $("td#LAMsg2").hide()
	   
	   /*
       document.frmone.buyoutMessage.style.visibility= "hidden"
       document.frmone.buyoutRB[0].style.visibility= "hidden"
       document.frmone.buyoutRB[1].style.visibility= "hidden"
       var button= document.getElementById('Text1d')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('Text10p')     
       button.style.display = 'none'; //hide it
       
       document.frmone.monthMessage.style.visibility= "hidden"
       document.frmone.monthRB[0].style.visibility= "hidden"
       document.frmone.monthRB[1].style.visibility= "hidden"
       document.frmone.monthRB[2].style.visibility= "hidden"
       var button= document.getElementById('Text36')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('Text48')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('Text60')     
       button.style.display = 'none'; //hide it
       
       document.frmone.leaseButton.style.visibility = "hidden"
       document.frmone.leaseMessage.style.visibility = "hidden"
       var button= document.getElementById('leaseMessagesText')     
       button.style.display = 'none'; //hide it
	   */
}

function showLeaseArea() {
       //alert("enter showLeaseArea function")
           $("td#LAMsg1").show()
       	   $("td#LABtn").show()
       	   $("td#LAMsg2").show()
	   
	     
		/* 
       document.frmone.buyoutMessage.style.visibility= "visible"
       document.frmone.buyoutRB[0].style.visibility= "visible"
       document.frmone.buyoutRB[1].style.visibility= "visible"
       var button= document.getElementById('Text1d')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('Text10p')     
       button.style.display = 'inline'; //show it
       
       document.frmone.monthMessage.style.visibility= "visible"
       document.frmone.monthRB[0].style.visibility= "visible"
       document.frmone.monthRB[1].style.visibility= "visible"
       document.frmone.monthRB[2].style.visibility= "visible"
       var button= document.getElementById('Text36')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('Text48')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('Text60')     
       button.style.display = 'inline'; //show it
      
       document.frmone.leaseButton.style.visibility = "visible"
       document.frmone.leaseMessage.style.visibility = "visible"
       var button= document.getElementById('leaseMessagesText')     
       button.style.display = 'inline'; //show it
	    */
       document.frmone.leaseMessage.value=""
 }
 
function setBuyoutIndex() {
    var buyout=9 
    if (document.frmone.buyoutRB[0].checked == true) buyout=0
    if (document.frmone.buyoutRB[1].checked == true) buyout=1
   // alert("buyout index= " + buyout)
   return buyout
}

function setMonthIndex() {
    var month=9 
    if (document.frmone.monthRB[0].checked == true) month=0
    if (document.frmone.monthRB[1].checked == true) month=1
    if (document.frmone.monthRB[2].checked == true) month=2
   // alert("month index= " + month)
   return month
}


function setCostIndex() {
 var cost=9
 if (Cost < 25001) {cost=0}
 else if (Cost < 50001)    {cost=1}
 else if (Cost < 100001)   {cost=2}
 else if (Cost < 150001)   {cost=3}
 else if (Cost < 200001)   {cost=4}
 else {cost=5}
// alert("cost index= " + cost)
 return cost
 
}

function calculateLease() {
  document.frmone.leaseMessage.value=""
  var buyout= setBuyoutIndex()
  if (buyout == 0) buyoutOption="$1 buyout"
  if (buyout == 1)  buyoutOption="10 % buyout"
  var month=  setMonthIndex()
  if (month == 0) months=36
  if (month == 1) months=48
  if (month == 2) months=60
  var cost=   setCostIndex()
  var rate = rateTable[buyout][cost][month]
  //alert("lease rate= " + rate)
  var leaseCostPerMonth=(Cost * rate)
  //alert("leaseCostpermonth=" + leaseCostPerMonth) 
  leaseCostPerMonth=Math.round(leaseCostPerMonth * 100)/100
  //alert("leaseCostpermonth=" + leaseCostPerMonth)
  leaseCostPerMonth=roundToPennies(leaseCostPerMonth) //converted to string variable
  leaseCostPerMonth=formatCurrency(leaseCostPerMonth)
  //alert("leaseCostpermonth=" + leaseCostPerMonth)
  document.frmone.leaseMessage.value="Lease will cost $" + leaseCostPerMonth + " per month if " + buyoutOption + " selected for " + months + " months"
 // showMessageArea()
}

function createRateTable() {
//currently the maximum box cost is about $80000

 rateTable =        new Array(2) //buyout
 rateTable[0] =     new Array(6) //cost
 rateTable[1] =     new Array(6)
 rateTable[0][0] =  new Array(3) //month
 rateTable[0][1] =  new Array(3)  
 rateTable[0][2] =  new Array(3)  
 rateTable[1][0] =  new Array(3) 
 rateTable[1][1] =  new Array(3)
 rateTable[1][2] =  new Array(3) 

// buyout $1 
 rateTable[0][0][0]=.03449 // <  25001 Month 36
 rateTable[0][0][1]=.02717 //                48
 rateTable[0][0][2]=.02280 //                60 
 
 rateTable[0][1][0]=.03336 // <  50001 Month 36
 rateTable[0][1][1]=.02612 //                48 
 rateTable[0][1][2]=.02180 //                60
 
 rateTable[0][2][0]=.03299 // < 100001 Month 36
 rateTable[0][2][1]=.02580 //                48 
 rateTable[0][2][2]=.02140 //                60
 
 //buyout 10% 
 rateTable[1][0][0]=.03200 // <  25001 Month 36
 rateTable[1][0][1]=.02539 //                48        
 rateTable[1][0][2]=.02145 //                60
 
 rateTable[1][1][0]=.03084 // <  50001 Month 36
 rateTable[1][1][1]=.02427 //                48 
 rateTable[1][1][2]=.02035 //                60
  
 rateTable[1][2][0]=.03044 // < 100001 Month 36
 rateTable[1][2][1]=.02390 //                48 
 rateTable[1][2][2]=.02000 //                60
 
} 

 // message functions
 
 function hideMessageArea() {
      $("td#MAVisit").hide()
      $("td#MAMail").hide()
      $("td#MAMsg").hide()
	  /*
       document.frmone.visitor.style.visibility= "hidden"
       document.frmone.visitormail.style.visibility= "hidden"
       document.frmone.attention.style.visibility= "hidden"
       //document.frmone.notes.style.visibility= "hidden"
       document.frmone.sendMail.style.visibility= "hidden"
       document.frmone.mailMessage.style.visibility= "hidden"
       var button= document.getElementById('visitorText')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('visitormailText')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('attentionText')     
       button.style.display = 'none'; //hide it
       var button= document.getElementById('mailMessagesText')     
       button.style.display = 'none'; //hide it
       */

}
 
 function showMessageArea() {   
       
      $("td#MAVisit").show()
      $("td#MAMail").show()
      $("td#MAMsg").show()
	  /*
       document.frmone.visitor.style.visibility= "visible"
       document.frmone.visitormail.style.visibility= "visible"
       document.frmone.attention.style.visibility= "visible"
       //document.frmone.notes.style.visibility= "visible"
       document.frmone.sendMail.style.visibility= "visible"
       document.frmone.mailMessage.style.visibility= "visible"
       var button= document.getElementById('visitorText')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('visitormailText')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('attentionText')     
       button.style.display = 'inline'; //show it
       var button= document.getElementById('mailMessagesText')     
       button.style.display = 'inline'; //show it
	   */
       document.frmone.visitor.value=""
       document.frmone.visitormail.value=""
       document.frmone.USphone.value=""
       document.frmone.companyName.value=""
       document.frmone.companyStreet.value=""
       document.frmone.companyCity.value=""
       document.frmone.companyState.value=""
       document.frmone.companyZip.value=""
       document.frmone.companyPhone.value=""
       document.frmone.attention.value="Ready to buy or lease cooler"
       document.frmone.mailMessage.value=""
}
 
  
function pause(milliseconds) {
	var dt = new Date();
	while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}

function ltrim(str) {
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}
function rtrim(str) {
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}
function trim(str) {
	return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
}
// Get the HTTP Object
       function getHTTPObject(){
        //alert("create http object")
        if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
        else if (window.XMLHttpRequest) return new XMLHttpRequest();
             else {
                  alert("Your browser does not support AJAX.");
                  return null;
             }

        }


  function sendMail2() {
             // alert("enter sendMail2 function in coolercost.js")
               document.frmone.mailMessage.value=""
              
              //contact information  is required (billing/shipping infromation is optional)
  	       
  	       visitor=document.frmone.visitor.value
	       visitormail=document.frmone.visitormail.value
	       document.getElementById('mail').style.color = 'red'
	       visitor = ltrim(rtrim(visitor));
	       if(!(visitor.length > 0)) {
	         document.frmone.mailMessage.value="Name is missing"
	         return;
	       }    			     
	       NEWvisitor=visitor.toLowerCase();
	       //alert("newvisitor = " + NEWvisitor)
	       document.frmone.visitor.value=NEWvisitor
			       	    
			       	    
		visitormail = ltrim(rtrim(visitormail));
		var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!(visitormail.match(emailRegEx))){
		  document.frmone.mailMessage.value="Invalid e-mail address format";
		  return;
		}
		 NEWvisitormail=visitormail.toLowerCase();	                         
		 //alert("newvisitormail  = " + NEWvisitorvisitor)	       	                                
		 document.frmone.visitormail.value=NEWvisitormail	       	                                
	         
	         USphone=document.frmone.USphone.value
	        // alert('USphone=' + USphone)
	         USphone=ltrim(rtrim(USphone))
	          var phoneRegEx = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/ 
                 if(!(USphone.match(phoneRegEx))){
	  	   document.frmone.mailMessage.value="Invalid US phone format: must be (999) 999-9999 or (999)999-9999"
	  	   return;
		}
	      // end of contact information  
	      
                 document.getElementById('mail').style.color = 'black'
  		 httpObject = getHTTPObject()
  		// alert("httpObject= " + httpObject)		     		      
  		 if (httpObject != null) {		 	
  			document.getElementById('mail').style.color = 'red';	 	        
  			document.frmone.mailMessage.value="your e-mail message is pending"	 	        
  			pause(3000) // 3 second pause	 	        
  			var url = "sendCostMail.php"	 	        
  		        queryString=buildQueryString(visitor,visitormail,USphone)	 	         
  			
  			//alert("queryString= " + queryString) 	 	        
  			//post method: Send the proper header information along with the request 	         
  			httpObject.open("POST", url, true)	 		
  			httpObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded")	 		
  		        httpObject.setRequestHeader("Connection", "close")	 		
  			httpObject.send(queryString)	 		
  			httpObject.onreadystatechange = function (){	 		
  			// alert("ready state= " + httpObject.readyState)	 		
  			   if(httpObject.readyState == 4){	 		 
  				document.frmone.debug.value = httpObject.responseText		 
  				document.getElementById('mail').style.color = 'blue'	
  			        document.frmone.mailMessage.value="your e-mail message has been sent"		 
  			   } 	       
  			}// onreadystatechange	 	       
  		 } // httpObject		 	       
  	
             // alert("exit sendMail2 function")
          }
          
          
          function buildQueryString(visitor,visitormail,USphone) {
          
          queryString=""
          
                      
          //reefer type
             if (document.frmone.type[0].checked == true) {  //walkin
                reefer="unit is a walk-in cooler with a $750 door "
                if (document.frmone.WDoorValue[0].checked == true) { side="in the front"}
  	        if (document.frmone.WDoorValue[1].checked == true) { side="in the back"}
  	        if (document.frmone.WDoorValue[2].checked == true) { side="on the left side"}
  	        if (document.frmone.WDoorValue[3].checked == true) { side="on the right side"}
                reefer=reefer + side
            } else {         
                reefer="unit is a reach-in cooler"
               
            }
            
           //box dimensions
            if (document.frmone.measurement[0].checked == true) {   //inches
  	    fHeight=document.frmone.fHeight.value  
  	    iHeight=document.frmone.iHeight.value
  	    height="height is " + fHeight + " feet and " + iHeight + " inches"
  	    
  	    fWidth=document.frmone.fWidth.value
  	    iWidth=document.frmone.iWidth.value
  	    front="front is " + fWidth + " feet and " + iWidth + " inches"
  	    
  	    fLength=document.frmone.fLength.value
  	    iLength=document.frmone.iLength.value
  	    side="side is " + fLength + " feet and " + iLength + " inches"
  	   
  	    boxCost="box cost "+ document.frmone.stdBoxCost.value + " without a floor"
  	    
            } else {           //millimeters
              mHeight=document.frmone.mHeight.value  
              height="height is " + mHeight + " millimeters"
             
              mWidth=document.frmone.mWidth.value
              front="front is " + mWidth + " millimeters"
              
              mLength=document.frmone.mLength.value
              side="side is " + mLength + " millimeters"
             
             boxCost="box cost "+ document.frmone.metricCost.value + " without a floor"
            }
            
           
            
            //extra doors 
             if ((document.frmone.ExtraDoors.checked  == true)  && (document.frmone.TotalExtraDoorsCost.value != "")) {
                if (document.frmone.glassDoor[0].checked == true) { //CDS vendor
                   glassVendor="CDS"
                } else {
                   glassVendor="Anthony"
                }
                
               extraDoors="extra doors include the following:\n"
               + document.frmone.FWalkinCount.value  + " front walk-in doors and " + document.frmone.FGlassCount.value + " glass doors made by " + glassVendor + "\n"
               + document.frmone.BWalkinCount.value  + " back walk-in doors and " + document.frmone.BGlassCount.value + " glass doors made by "  + glassVendor + "\n"
               + document.frmone.LWalkinCount.value  + " left walk-in doors and " + document.frmone.LGlassCount.value + " glass doors made by " + glassVendor + "\n"
               + document.frmone.RWalkinCount.value  + " right walk-in doors and " + document.frmone.RGlassCount.value + " glass doors made by " + glassVendor + "\n"
               + "for a total cost of " + document.frmone.TotalExtraDoorsCost.value
            } else {
              
               extraDoors="extra doors not included"
             }
             
  
            //floor
             if (document.frmone.Floor.checked  == true ) {
                if (document.frmone.ramp[0].checked == true) { //interior
                 ramps=" interior"
                } else {
                 ramps=" exterior"
                }
                 floor="floor cost " + document.frmone.FloorCost.value 
                 + " with " + document.frmone.RampCT.value + ramps + " ramps at a cost of " + document.frmone.RampCost.value
             } else {
              
             
               floor="floor not included"
             }
             
             //refrigeraion
              if (document.frmone.Refrigeration.checked  == true) {
                if (document.frmone.system[0].checked == true) {
                  system="Standard" 
                } else {
                  system="High Humidity"
                }
                
                if (document.frmone.degrees[0].checked == true) {
  	          ambientTemp=document.frmone.degrees[0].value
  	      } else {
  	          ambientTemp=document.frmone.degrees[1].value
                }
                
                
                 refrigeration="refrigeration cost " + document.frmone.BTUCost.value + " using a " + system 
                                + " system with an ambient temperature of " + ambientTemp + " degrees"
               
               } else {
               
                 refrigeration="refrigeration not included"
               }
               
               //lease
               if (document.frmone.leaseMessage.value != "") {
                  leasemsg=document.frmone.leaseMessage.value
               } else {
                  leasemsg="lease not included"
               }
            
             
  	     
  	   // billing/shipping is optional
  	   
  	   if (document.frmone.companyName.value != "") {
	       Coname=document.frmone.companyName.value
	   } else {
	       Coname="billing name not entered"
           }
  	   
  	   if (document.frmone.companyStreet.value != "") {
	   	Costreet=document.frmone.companyStreet.value
	   } else {
	   	Costreet="billing street not entered"
           }
           
           if (document.frmone.companyCity.value != "") {
	   	Cocity=document.frmone.companyCity.value
	   } else {
	   	Cocity="billing city not entered"
           }
           if (document.frmone.companyState.value != "") {
	   	Costate=document.frmone.companyState.value
	   } else {
	   	Costate="billing state not entered"
           }
           
           if (document.frmone.companyZip.value != "") {
	       Cozip=document.frmone.companyZip.value
	   } else {
	       Cozip="billing zip not entered"
           }
           
           if (document.frmone.companyPhone.value != "") {
	       Cophone=document.frmone.companyPhone.value
	   } else {
	       Cophone="billing phone not entered"
           }
           
           
           attention=document.frmone.attention.value
  	   totalcostmsg=document.frmone.Cost.value
  	  
  	  queryString =   "Reefer=" + reefer + 
  	                  "&Height=" + height + 
  	                  "&Front=" + front + 
  	                  "&Side=" + side +
  	                  "&Boxcost=" + boxCost +
  	                  "&Extradoors=" + extraDoors +
  	                  "&Floor=" + floor +
  	                  "&Refrigeration=" + refrigeration +
  	                  "&Visitor=" + visitor + 
  	                  "&Visitormail=" + visitormail + 
  	                  "&Visitorphone=" + USphone +
  	                  "&Coname=" + Coname +
  	                  "&Costreet=" + Costreet +
  	                  "&Cocity=" + Cocity +
  	                  "&Costate=" + Costate +
  	                  "&Cozip=" + Cozip +
  	                  "&Cophone=" + Cophone +
  	                  "&Totalcostmsg=" + totalcostmsg + 
  	                  "&Leasemsg=" + leasemsg + 
  	                  "&Attn=" + attention
  	  //alert("queryString= " + queryString)  
            return queryString
        }


  function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
    num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
    cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    num = num.substring(0,num.length-(4*i+3))+','+
    num.substring(num.length-(4*i+3));
    // return (((sign)?'':'-') + '$' + num + '.' + cents);
    return (((sign)?'':'-') +  num + '.' + cents);
  }
  
  
  function stdboxEdit() {
   // ********** edit feet and inches fields 
   
  /*  document.frmone.fHeight.style.color = 'black'
    document.frmone.iHeight.style.color = 'black'
	document.frmone.fWidth.style.color = 'black'
	document.frmone.iWidth.style.color = 'black'
	document.frmone.fLength.style.color = 'black'
	document.frmone.iLength.style.color = 'black' 
	
   fh = document.frmone.fHeight.value
   if (!isValidNumber(fh)) {
        //alert("height in feet is not a valid number!")
        document.frmone.Summary.value ="Height in feet is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.fHeight.style.color = 'red'
        return
   } else {
       document.frmone.fHeight.style.color = 'black'
       
   }
   
   ih = document.frmone.iHeight.value
   if (!isValidNumber(ih)) {
        //alert("height in inches is not a valid number!")
        document.frmone.Summary.value ="Height in inches is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.iHeight.style.color = 'red'
   	return
   } else {
   	 document.frmone.iHeight.style.color = 'black'
   }
   
   fw = document.frmone.fWidth.value
   if (!isValidNumber(fw)) {
        //alert("width in feet is not a valid number!")
        document.frmone.Summary.value ="Front in feet is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.fWidth.style.color = 'red'
        return
   } else {
       document.frmone.fWidth.style.color = 'black'
   }
   
   iw = document.frmone.iWidth.value
   if (!isValidNumber(iw)) {
        //alert("width in inches is not a valid number!")
        document.frmone.Summary.value ="Front in inches is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.iWidth.style.color = 'red'
   	return
   } else {
   	 document.frmone.iWidth.style.color = 'black'
   }
   
   fl = document.frmone.fLength.value
   if (!isValidNumber(fl)) {
        //alert("length in feet is not a valid number!")
        document.frmone.Summary.value ="Side in feet is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.fLength.style.color = 'red'
        return
   } else {
   	 document.frmone.fLength.style.color = 'black'
   }
   
   
   il = document.frmone.iLength.value
   if (!isValidNumber(il)) {
        //alert("length in inches is not a valid number!")
        document.frmone.Summary.value ="Side in inches is not a valid number"
        document.frmone.Cost.value = ""
        document.frmone.iLength.style.color = 'red'
        return 
   } else {
   	 document.frmone.iLength.style.color = 'black'
   }
   */
   //document.frmone.Summary.value =""
    var stdboxInput=document.getElementById('stdbox').getElementsByTagName('input');
	
	for (i=0;i<stdboxInput.length;i++) {
	   if (stdboxInput[i].name=="stdBoxCost") {
        
		 continue
	   }
	   stdboxInput[i].style.color = 'black'
	   var stdboxDim=stdboxInput[i].value
	  // var errorString=""
	   if (!isValidNumber(stdboxDim)) {
	     
	     switch(stdboxInput[i].name) {
		   case "fHeight":
		         errorString="Height in feet "
				 break
			case "iHeight":
		         errorString="Height in inches "
				 break	
		    case "fWidth":
		         errorString="Front in feet "
				 break
			case "iWidth":
		         errorString="Front in inches "
				 break	
            case "fLength":
		         errorString="Side in feet "
				 break
			case "iLength":
		         errorString="Side in inches "
				 break	
		   	default:
			     alert("stdbox error default, subscript= " + i)
				 alert("stdbox name= " + stdboxInput[i].value)
          }  				 
	  
	     document.frmone.Summary.value =errorString + "is not a valid number"
	     document.frmone.Cost.value = ""
	     stdboxInput[i].style.color = 'red'
	     return
	    } 
		switch(stdboxInput[i].name) {
		   case "fHeight":
		         fh=stdboxInput[i].value
				 break
			case "iHeight":
		         ih=stdboxInput[i].value
				 break	
		    case "fWidth":
		         fw=stdboxInput[i].value
				 break
			case "iWidth":
		         iw=stdboxInput[i].value
				 break	
            case "fLength":
		         fl=stdboxInput[i].value
				 break
			case "iLength":
		         il=stdboxInput[i].value
				 break	
		    default:
			     alert("stdbox dimension default, subscript= " + i)
		}     		
		
	}
     
   // ********** test dimensions against thresholds  
   
   
   
   footh = Number(fh)
   inchh = Number(ih)
   if (inchh > 11) {
        //alert("width in inches must be less than 12 inches")
        document.frmone.Summary.value ="Height in inches must be less than 12 inches"
        document.frmone.Cost.value = ""
        document.frmone.iHeight.style.color = 'red'
        return
   } else {
   	 document.frmone.iHeight.style.color = 'black'
   }
   
   footw = Number(fw)
   inchw = Number(iw)
   if (inchw > 11) {
        //alert("width in inches must be less than 12 inches")
        document.frmone.Summary.value ="Front in inches must be less than 12 inches"
        document.frmone.Cost.value = ""
        document.frmone.iWidth.style.color = 'red'
        return
   } else {
   	 document.frmone.iWidth.style.color = 'black'
   }
   
   footl = Number(fl)
   inchl = Number(il)
   if (inchl > 11) {
        //alert("length in inches must be less than 12 inches")
        document.frmone.Summary.value ="Side in inches must be less than 12 inches"
        document.frmone.Cost.value = ""
        document.frmone.iLength.style.color = 'red'
        return
   } else {
   	 document.frmone.iLength.style.color = 'black'
   }
   
   totalw = (footw * 12) + inchw            // convert feet to inches and add to inches
   totall = (footl * 12) + inchl
   // size of cooler must be at least the minumum size of 4' x 5' or 5' x 4'
   
   if (((totalw > 53) && (totall > 59)) || ((totalw > 59) && (totall > 53))) {
     // do nothing
   } else {
     //alert("cooler must be at least 4 feet,6 inches wide by 5 feet long or 5 feet wide by 4 feet,6 inches long")
     document.frmone.Cost.value = ""
     document.frmone.Summary.value ="cooler must be at least 4 feet,6 inches wide by 5 feet long or vice versa"
     return
   }
   
   totalh = (footh * 12) + inchh
   if (totalh < 72) {
      document.frmone.Cost.value = ""
      document.frmone.Summary.value ="cooler must be at least 6 feet high"
     return
   } 
   
   if (totalh > 240) {
      document.frmone.Cost.value = ""
      document.frmone.Summary.value ="exceeds cooler maximum height of 20 feet"
     return
   } 
  // end of using inches for box
     editError=0 
     return
  }
  
  function metricboxEdit() {
   /*  document.frmone.mHeight.style.color = 'black'
     document.frmone.mWidth.style.color = 'black'
	 document.frmone.mLength.style.color = 'black'
   
   // ********** edit millimeters fields 
      mh = document.frmone.mHeight.value
      if (!isValidNumber(mh)) {
           //alert("height in millimeters is not a valid number!")
           document.frmone.Summary.value ="Height in millimeters is not a valid number"
           document.frmone.Cost.value = ""
           document.frmone.mHeight.style.color = 'red'
           return
      } else {
          document.frmone.mHeight.style.color = 'black'
          
      }
      
      
      
      mw = document.frmone.mWidth.value
      if (!isValidNumber(mw)) {
           //alert("width in millimeters is not a valid number!")
           document.frmone.Summary.value ="Front in millimeters is not a valid number"
           document.frmone.Cost.value = ""
           document.frmone.mWidth.style.color = 'red'
           return
      } else {
          document.frmone.mWidth.style.color = 'black'
      }
      
      
      
      ml = document.frmone.mLength.value
      if (!isValidNumber(ml)) {
           //alert("length in millimeters is not a valid number!")
           document.frmone.Summary.value ="Side in millimeters is not a valid number"
           document.frmone.Cost.value = ""
           document.frmone.mLength.style.color = 'red'
           return
      } else {
      	 document.frmone.mLength.style.color = 'black'
      }
      */
	  //document.frmone.Summary.value =""
      var metricboxInput=document.getElementById('metricbox').getElementsByTagName('input');
	  
	for (i=0;i<metricboxInput.length;i++) {
	   if (metricboxInput[i].name=="metricBoxCost") {
        
		 continue
	   }
	   metricboxInput[i].style.color = 'black'
	   var metricboxDim=metricboxInput[i].value
	   
	   if (!isValidNumber(metricboxDim)) {
	     switch(metricboxInput[i].name) {
		   case "mHeight":
		         errorString="Height in millimeters "
				 break
			
		    case "mWidth":
		         errorString="Front in millimeters "
				 break
			
            case "mLength":
		         errorString="Side in millimeters "
				 break
			default:
			     alert("metricbox error default, subscript= " + i)
          }  				 
	  
	     document.frmone.Summary.value =errorString + "is not a valid number"
	     document.frmone.Cost.value = ""
	     metricboxInput[i].style.color = 'red'
	     return
	    } 
		switch(metricboxInput[i].name) {
		   case "mHeight":
		         mh=metricboxInput[i].value
				 break
			
		    case "mWidth":
		         mw=metricboxInput[i].value
				 break
			
            case "mLength":
		         ml=metricboxInput[i].value
				 break
			 default:
			     alert("metricbox dimension default, subscript= " + i)
		}     		
		
	}
      
      // ********** test dimensions against thresholds  
      
      meterh = Number(mh)
      meterw = Number(mw)
      meterl = Number(ml)
            
      
      
      mtotalw = meterw       
      mtotall = meterl
      // size of cooler must be at least the minumum size of 4',6" x 5' or 5' x 4',6"
      
      if (((mtotalw > 1371) && (mtotall > 1523)) || ((mtotalw > 1523) && (mtotall > 1371))) {
        // do nothing
      } else {
        //alert("cooler must be at least 4 feet,6 inches wide by 5 feet long or 5 feet wide by 4 feet,6 inches long")
        document.frmone.Cost.value = ""
        document.frmone.Summary.value ="cooler must be at least 1372 mm wide by 1524 mm long or vice versa"
        return
      }
      
      mtotalh = meterh   // 6 feet high or greater
      if (mtotalh < 1829) {
         document.frmone.Cost.value = ""
         document.frmone.Summary.value ="cooler must be at least 1829 millimeters high"
        return
      } 
      
      if (mtotalh > 6096) {     // less than 20 feet high
         document.frmone.Cost.value = ""
         document.frmone.Summary.value ="exceeds cooler maximum height of 6096 millimeters"
        return
      } 
     // end of using millimeters for box
     
     editError=0 
     return
  
  }
 function showDialog(str,strtitle) //confirm box dimensions
  {
      
      if(!strtitle) strtitle='Error message';
      $('#dialog').dialog("destroy");
      $('#dialog').show();
      $('#dialog').html(str);
  
      $("#dialog").dialog({
          resizable: false,
          modal: true,
          overlay: {
             // backgroundColor: black,
              // opacity: 1.1
          },
          title:strtitle,
          buttons: {
  
              'No': function() {
                  answer=0;
                 
                  $(this).dialog("close");
                   //alert('set showDialog answer= ' + answer);
                   showDialogClicked=1;
                   calculate();
                   
              },
              'Yes': function() {
                  answer=1;
  		  $('#dialog').dialog("close");
  		   //alert('set showDialog answer= ' + answer);
                   showDialogClicked=1;
                   calculate();	                
  
              }
          }
      });
     // alert('exit showDialog')
 }  
 
  function showDialog2(str,strtitle)  //confirm glass door vendor
  {
      
      if(!strtitle) strtitle='Error message';
      $('#dialog').dialog("destroy");
      $('#dialog').show();
      $('#dialog').html(str);
  
      $("#dialog").dialog({
          resizable: false,
          modal: true,
          overlay: {
             // backgroundColor: '#000',
             // opacity: 0.9
          },
          title:strtitle,
          buttons: {
  
              'No': function() {
                  resetDoorCount=0;
                 
                  $(this).dialog("close");
                   //alert('set showDialog2 resetDoorCount= ' + resetDoorCount);
                   showDialogClicked2=1;
                   checkGlassDoor();
                   
              },
              'Yes': function() {
                  resetDoorCount=1;
  		  $('#dialog').dialog("close");
  		  // alert('set showDialog2 resetDoorCount= ' + resetDoorCount);
                   showDialogClicked2=1;
                   checkGlassDoor() ;              
  
              }
          }
      });
     // alert('exit showDialog2')
     
  
}
function editExtraDoors () {

    // first verify that extra door entry fields contain only numbers

    
	//alert("edit extra doors")
	document.frmone.Summary.value=""
	 var doorInput=document.getElementById('doors').getElementsByTagName('input');
	 var errorString=""
	for (i=0;i<doorInput.length;i++) {
	   if (doorInput[i].className=="doorcost") {
        // alert("doorcost field	for subscript " + i)
		 continue
	   }
	   doorInput[i].style.color = 'black'
	   var doorCount=doorInput[i].value
	   //alert("door count= " + doorInput[i].value)
	   if (!isValidNumber(doorCount)) {
	     switch(doorInput[i].name) {
		   case "FWalkinCount":
		         errorString="Front Walk-in "
				 break
			case "FGlassCount":
		         errorString="Front Glass "
				 break	
		    case "BWalkinCount":
		         errorString="Back Walk-in "
				 break
			case "BGlassCount":
		         errorString="Back Glass "
				 break	
            case "LWalkinCount":
		         errorString="Left Side Walk-in "
				 break
			case "LGlassCount":
		         errorString="Left Side Glass "
				 break	
		    case "RWalkinCount":
		         errorString="Right Side Walk-in "
				 break
			case "RGlassCount":
		         errorString="Right Side Glass "
				 break		
          }  				 
	  
	     document.frmone.Summary.value =errorString + "is not a valid number"
	     document.frmone.Cost.value = ""
	     doorInput[i].style.color = 'red'
	     return
	    } 
		switch(doorInput[i].name) {
		   case "FWalkinCount":
		         fwc=doorInput[i].value
				 break
			case "FGlassCount":
		         fgc=doorInput[i].value
				 break	
		    case "BWalkinCount":
		         bwc=doorInput[i].value
				 break
			case "BGlassCount":
		         bgc=doorInput[i].value
				 break	
            case "LWalkinCount":
		         lwc=doorInput[i].value
				 break
			case "LGlassCount":
		         lgc=doorInput[i].value
				 break	
		    case "RWalkinCount":
		         rwc=doorInput[i].value
				 break
			case "RGlassCount":
		         rgc=doorInput[i].value
				 break		
          }  		
		
	}
     editError=0;
	 return 
}


// end hiding script from old browsers -->