var gallonsWaterSqAc = 27152;	/* Gallons of water that fall on one square acre of land per inch of measured rainfall */
var gallonsWaterSqFt = .62;	/* Gallons of water that fall on one square foot of land per inch of measured rainfall */
var selValue = 0;		/* Select value */
function annualRainFallToGallons() {
var numAnnualInches = parseFloat(document.getElementById("region_a").value);
if (numAnnualInches <= 0) { alert("ERROR:\nPlease enter the number of inches of annual rainfall a geographic region receives."); }
else {
      document.getElementById("region_a_calc_sqftweek").innerHTML = ((numAnnualInches * gallonsWaterSqFt) / 12) / 4;
      document.getElementById("region_a_calc_sqftmonth").innerHTML = (numAnnualInches * gallonsWaterSqFt) / 12;
      document.getElementById("region_a_calc_sqft").innerHTML = numAnnualInches * gallonsWaterSqFt;
      document.getElementById("region_a_calc_sqac").innerHTML = numAnnualInches * gallonsWaterSqAc;
     }
}
function annualRainFallToGallonSel() {
var numAnnualInches = selValue;
if (numAnnualInches <= 0) { alert("ERROR:\nPlease enter the number of inches of annual rainfall a geographic region receives."); }
else {
      document.getElementById("region_d_calc_sqftweek").innerHTML = ((numAnnualInches * gallonsWaterSqFt) / 12) / 4;
      document.getElementById("region_d_calc_sqftmonth").innerHTML = (numAnnualInches * gallonsWaterSqFt) / 12;
      document.getElementById("region_d_calc_sqft").innerHTML = numAnnualInches * gallonsWaterSqFt;
      document.getElementById("region_d_calc_sqac").innerHTML = numAnnualInches * gallonsWaterSqAc;
     }
}
function annualRainFallToGallonsDiff() {
var numAnnualInches_Source = parseFloat(document.getElementById("region_b_source").value);
var numAnnualInches_Destination = parseFloat(document.getElementById("region_b_destination").value);
if (numAnnualInches_Destination < numAnnualInches_Source) {
							   var inchesChange = numAnnualInches_Source - numAnnualInches_Destination;
							   document.getElementById("region_b_calc_sqftweek").innerHTML = ((inchesChange * gallonsWaterSqFt) / 12) / 4;
							   document.getElementById("region_b_calc_sqftmonth").innerHTML = (inchesChange * gallonsWaterSqFt) / 12;
							   document.getElementById("region_b_calc_sqft").innerHTML = inchesChange * gallonsWaterSqFt;
							   document.getElementById("region_b_calc_sqac").innerHTML = inchesChange * gallonsWaterSqAc;
							  }
else if (numAnnualInches_Destination > numAnnualInches_Source) { alert("MORE WATER:\nYour geographic region produces more annual rainfall than the geographic region the plant or tree normally lives in."); }
else if (numAnnualInches_Destination == numAnnualInches_Source) { alert("EQUAL WATER:\nYour geographic region produces the same annual rainfall as the geographic region the plant or tree normally lives in."); }
}
function annualRainFallToGallonsRoot() {
var numAnnualInches_Source = parseFloat(document.getElementById("region_c_source").value);
var numAnnualInches_Destination = parseFloat(document.getElementById("region_c_destination").value);
var rootRadiusFt = parseFloat(document.getElementById("region_c_radius").value);
if (rootRadiusFt < 1) { alert("ROOT RADIUS\nThe horizontal length of the root system from the tree or plant from one side (the radius) needs to be entered as a number of feet."); }
else {
      if (numAnnualInches_Destination < numAnnualInches_Source) {
							         var inchesChange = numAnnualInches_Source - numAnnualInches_Destination;
							         var rootArea = (rootRadiusFt * rootRadiusFt) * 3.14;
							         document.getElementById("region_c_calc_sqftweek").innerHTML = ((inchesChange * (gallonsWaterSqFt * rootArea)) / 12) / 4;
							         document.getElementById("region_c_calc_sqftmonth").innerHTML = (inchesChange * (gallonsWaterSqFt * rootArea)) / 12;
							         document.getElementById("region_c_calc_sqft").innerHTML = inchesChange * (gallonsWaterSqFt * rootArea);
							         document.getElementById("region_c_calc_sqftweek_1a").innerHTML = rootRadiusFt + " feet";
							         document.getElementById("region_c_calc_sqftmonth_1a").innerHTML = rootRadiusFt + " feet";
							         document.getElementById("region_c_calc_sqft_1a").innerHTML = rootRadiusFt + " feet";
							         document.getElementById("region_c_calc_sqftweek_1").innerHTML = (rootArea / 2) + " total square feet";
							         document.getElementById("region_c_calc_sqftmonth_1").innerHTML = (rootArea / 2) + " total square feet";
							         document.getElementById("region_c_calc_sqft_1").innerHTML = (rootArea / 2) + " total square feet";
							        }
      else if (numAnnualInches_Destination > numAnnualInches_Source) { alert("MORE WATER:\nYour geographic region produces more annual rainfall than the geographic region the plant or tree normally lives in."); }
      else if (numAnnualInches_Destination == numAnnualInches_Source) { alert("EQUAL WATER:\nYour geographic region produces the same annual rainfall as the geographic region the plant or tree normally lives in."); }
     }
}
function selGrab(value) { selValue = parseFloat(value); }