function calculateFeet()
{ 
  var calcNumber=0
  var SubTotal=0
  var newSubTotal=0; 
  var Inputs = document.EstimatorForm.elements;      
  var obj
  for (i=0; i<Inputs.length; i++)
    {
	obj = Inputs[i]
	if (obj.type == 'text' && obj.value != '') {
			var val=obj.value;
			if(isNaN(val))
			  {
				val=0;
				obj.value = ''
			  }
			var inputName=obj.name
			var beginCalc=inputName.indexOf(",");
			calcNumber=inputName.slice(beginCalc + 1);
			calcNumber=Number(calcNumber);   
			val=val * calcNumber;
			SubTotal=val;
			newSubTotal=newSubTotal + SubTotal;
		}
    } 
 
  //sendCalc(newSubTotal);          ///send value to calling page 	          
  newSubTotal=newSubTotal.toString();                 //convert to string
  var beginCalc=newSubTotal.indexOf(".");
  if (beginCalc > 0 ) newSubTotal=newSubTotal.slice(0, (beginCalc + 3));  //round to 2 decimals
  document.Results.CubicFeet.value = newSubTotal
  
	var sUnitSize = ''
	//calculate unit size
	if (newSubTotal > 4480) {
		sUnitSize = '13\' x 45\''
	} else if (newSubTotal > 4160) {
		sUnitSize = '14\' x 40\''
	} else if (newSubTotal > 3640) {
		sUnitSize = '13\' x 40\''
	} else if (newSubTotal > 3120) {
		sUnitSize = '13\' x 35\''
	} else if (newSubTotal > 2400) {
		sUnitSize = '13\' x 30\''
	} else if (newSubTotal > 2000) {
		sUnitSize = '10\' x 30\''
	} else if (newSubTotal > 1600) {
		sUnitSize = '10\' x 25\''
	} else if (newSubTotal > 1200) {
		sUnitSize = '10\' x 20\''
	} else if (newSubTotal > 800) {
		sUnitSize = '10\' x 15\''
	} else if (newSubTotal > 600) {
		sUnitSize = '10\' x 10\''
	} else if (newSubTotal > 400) {
		sUnitSize = '7.5\' x 10\''
	} else if (newSubTotal > 300) {
		sUnitSize = '5\' x 10\''
	} else if (newSubTotal > 200) {
		sUnitSize = '5\' x 7.5\''
	} else if (newSubTotal > 0) {
		sUnitSize = '5\' x 5\''
	}
	//if (newSubTotal > 2400) sUnitSize += ' Boat\\RV Unit'
  document.Results.StorageSize.value = sUnitSize
}

function sendCalc(a)
{
var indexSize;
var thisCubeFeet=a;
var sizeImgSrc
var indexSize
var sizeText
var thisSqareFeet
var numSTG
var numTrucks
var rndSTG
var rndTrucks

              
if (a != 0)
  {
    thisSquareFeet = a / 6;
	numTrucks = a/800;
	numSTG = a/280;
	rndSTG = Math.ceil(numSTG)
	rndTrucks = Math.ceil(numTrucks);
   }
   
if (a == 0 || a == "undefined")
   {
    thisSquareFeet=0   ///initialize variables when page loads
    thisCubeFeet =0;
	numTrucks = 0;
	numSTG = 0;
	rndSTG = 0;
	rndTrucks = 0;
	sizeText="none";
   }    
   
if (rndTrucks < 11 && rndSTG < 30 && thisSquareFeet < 7920)
{

   truckCounter.innerText = rndTrucks;
   STGCounter.innerText = rndSTG;
 
   if (thisSquareFeet == 0)
   {
	indexSize=0;
   } 
   if (thisSquareFeet > 0 && thisSquareFeet < 36)
   {
	indexSize=0;
	sizeText="extra small"
		      
   } 
   else if (thisSquareFeet > 35 && thisSquareFeet < 61)
   {  
	indexSize=1
	sizeText="small"
   } 
   else if (thisSquareFeet > 60 && thisSquareFeet < 89)
   {  
	 indexSize=2
	 sizeText="medium small"
   } 
   else if (thisSquareFeet > 88 && thisSquareFeet < 126)
   {  
	 indexSize=3
	 sizeText="medium"
   } 
   else if (thisSquareFeet >125 && thisSquareFeet < 176)
   {  
	 indexSize=4
	 sizeText="medium large"
   } 
   else if (thisSquareFeet > 175 && thisSquareFeet < 251)
   {  
	 indexSize=5
	 sizeText="large"
   } 
   else if (thisSquareFeet > 250 && thisSquareFeet < 401)
   {  
	 indexSize=6
	 sizeText="extra large"
   } 
   else if (thisSquareFeet > 400 && thisSquareFeet < 7920)
   {  
	 indexSize=7
	 sizeText="bulk"
   } 
   
  thisCubeFeet=thisCubeFeet.toString();                 //convert to string
  var beginCalc=thisCubeFeet.indexOf(".");          
  thisCubeFeet=thisCubeFeet.slice(0, (beginCalc + 3));  //round to 2 decimals
  
  
  thisSquareFeet=thisSquareFeet.toString();                 //convert to string
  var beginSqftCalc=thisSquareFeet.indexOf(".");          
  thisSquareFeet=thisSquareFeet.slice(0, (beginSqftCalc + 3));  //round to 2 decimals
                      
  
  
  Counter.innerText= thisCubeFeet  
  storageCounter.innerHTML = "<nobr>" + sizeText + "<img id='STGImg' SRC='file:///Q|/www/images/estimator/estimator_icon_units.gif' WIDTH=72 HEIGHT=40 border=0 alt='Storage Units' align='middle'></nobr>";
  sqftCounter.innerText = thisSquareFeet;
/*
  CounterText.innerText= thisCubeFeet  
  storageCounterText.innerText = sizeText;
  sqftCounterText.innerText = thisSquareFeet;
*/
 }
  
  
}
