<!--: hide JavaScript from old browsers

/*************************************
 *                                   *
 *         Gregory Muske             *
 *                                   *
 *     www.BestDeckSite.com          *
 *                                   *
 *        Copyright 2002             *
 *     All Rights Reserved           *
 *                                   *
 *    You may NOT use this code      *
 *    without written permission     *
 *                                   *
 *************************************/

var dataFlag = 0;
var volumePads = 0;
var volumeCyls = 0;
var volumeTubes = 0;
var volumeTubeBases =0;
var padLength = 0;
var padWidth = 0;
var padHeight = 0;
var cylDiameter = 0;
var cylHeight = 0;
var tubeDiameter = 0;
var tubeHeight = 0;
var totalCubicFeet = 0;
var totalCubicYards = 0;



function findVolume() {
	
	with (window.document.concreteForm) {
		
		padLength = parseFloat(pad_lFeet.value) + (parseFloat(pad_lInches.value) / 12);
		padWidth = parseFloat(pad_wFeet.value) + (parseFloat(pad_wInches.value) / 12);
		padHeight = parseFloat(pad_hFeet.value) + (parseFloat(pad_hInches.value) / 12);
		
		cylRadius = (parseFloat(cyl_dFeet.value) + (parseFloat(cyl_dInches.value) / 12)) / 2;
		cylHeight = parseFloat(cyl_hFeet.value) + (parseFloat(cyl_hInches.value) / 12);
		
		tubeRadius = (parseFloat(tube_dFeet.value) + (parseFloat(tube_dInches.value) / 12)) / 2;
		tubeHeight = parseFloat(tube_hFeet.value) + (parseFloat(tube_hInches.value) / 12);
		
		volumePads = (padLength * padWidth * padHeight) * parseFloat(numEachPad.value);
		volumeCyls = (cylHeight * Math.PI * (Math.pow(cylRadius ,2))) * parseFloat(numEachCyl.value);
		volumeTubeBases =  parseFloat(tubeBaseID.value) * parseFloat(numTubeBase.value);
		volumeTubes = (tubeHeight * Math.PI * (Math.pow(tubeRadius ,2))) * parseFloat(numEachTube.value);
		totalCubicFeet = (Math.round((volumePads + volumeCyls + volumeTubeBases + volumeTubes) * 100)) / 100;
		totalCubicYards = Math.round(((volumePads + volumeCyls + volumeTubeBases + volumeTubes) / 27) * 100) / 100;
		
		if (dataCheck() == 1) {		
			cubicFeet.value = totalCubicFeet;
			cubicYards.value = totalCubicYards;
			bags60.value = (Math.round((totalCubicFeet * 2) * 10)) / 10;
			bags80.value = (Math.round((totalCubicFeet / 2 * 3) * 10)) / 10;
		}
		
	}	
}
		

function dataCheck() {
  with (window.document.concreteForm) {

  dataFlag = 1; // The next five if-then statements check data

  if (totalCubicYards > 100) {
	alert("Results are too large to display.");
	cubicFeet.value = 0;
	cubicYards.value = 0;
	bags60.value = 0;
	bags80.value = 0;
	dataFlag = 0;
	}

  if ((volumePads == 0 & numEachPad.value != 0) || (volumePads == 0 & (padLength != 0 || padWidth != 0 || padHeight != 0))) {
	alert("Please check the rectangular footing values.\nYou've forgotten to enter in dimensions or the number of footings.");
	dataFlag = 0;
	}

  if ((volumeCyls == 0 & numEachCyl.value !=0) || (volumeCyls == 0 & (cylRadius != 0 || cylHeight != 0))) {
	alert("Please check the cylindrical footing values.\nYou've forgotten to enter in dimensions or the number of footings.");
	dataFlag = 0;
	}

  if ((volumeTubeBases == 0 & numTubeBase.value != 0) || (volumeTubeBases == 0 & tubeBaseID.value != 0)) {
	alert("Please check the TubeBase footing values.\nYou've forgotten to enter in the type or the number of footings.");
	dataFlag = 0;
	}

  if ((volumeTubes == 0 & numEachTube.value !=0) || (volumeTubes == 0 & (tubeRadius != 0 || tubeHeight != 0))) {
	alert("Please check the sonotube values.\nYou've forgotten to enter in dimensions or the number of sonotubes.");
	dataFlag = 0;
	}

  return (dataFlag);
  }
}



function clearAll() {
 with (window.document.concreteForm) {
 	pad_lFeet.value = 0;
 	pad_lInches.value = 0;
 	pad_wFeet.value = 0;
 	pad_wInches.value = 0;
 	pad_hFeet.value = 0;
 	pad_hInches.value = 0;
 	cyl_dFeet.value = 0;
 	cyl_dInches.value = 0;
 	cyl_hFeet.value = 0;
 	cyl_hInches.value = 0;
 	tube_dFeet.value = 0;
 	tube_dInches.value = 0;
 	tube_hFeet.value = 0;
 	tube_hInches.value = 0;
	numEachPad.value = 0;
	numEachCyl.value = 0;
	tubeBaseID.value = 0;
	numTubeBase.value = 0;
	numEachTube.value = 0;
	cubicFeet.value = 0;
	cubicYards.value = 0;
	bags60.value = 0;
	bags80.value = 0;
	}
}



function clearBox(boxObject) {
	boxObject.value = "";
}



function inputCheck(boxObject) {

 // Need to check that only integers are entered

	if (boxObject.value != "") {  // User may have click on box, clicked of box, then click on box again
	
		if ((boxObject.value != parseInt(boxObject.value, 10)) || ((parseInt(boxObject.value)) < 0)) {
		alert('Lengths must be positive integers like 1,2,3....');
		boxObject.value = 0;
		}
	}
	else boxObject.value = 0;
}



function denyChange() {

	alert("The value in this box may not be changed.");
}


// end hiding JavaScript -->