function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode;
     else
          key = e.which;
     return (key != 13);
}

function getValueByName(name) {
	var temp;
	eval("temp = document.watercalc." + name + ".value");
	if (isNaN(temp)) {
		temp = 0;
		eval("document.watercalc." + name + ".value = '0'");
	}
	return temp;
}

function dowatercalc() {
	var annualrainfall = getValueByName("annualrainfall");
	var roofspace = getValueByName("roofspace");
	var numpeople = getValueByName("numpeople");
	var topload = getValueByName("topload");
	var frontload = getValueByName("frontload");
	var showers = getValueByName("showers");
	var baths = getValueByName("baths");
	var faucet = getValueByName("faucet");
	var ac = getValueByName("ac");
	var swamp = getValueByName("swamp");
	var citrus = getValueByName("citrus");
	var dwarf = getValueByName("dwarf");
	var velvet = getValueByName("velvet");
	var screwbean = getValueByName("screwbean");
	var acacia = getValueByName("acacia");
	var oleander = getValueByName("oleander");
	var deciduous = getValueByName("deciduous");
	var evergreen = getValueByName("evergreen");
	var pomegranate = getValueByName("pomegranate");
	var mission = getValueByName("mission");
	var additionalqty = getValueByName("additionalqty");
	var additionalgalpermonth = getValueByName("additionalgalpermonth");
	var garden = getValueByName("garden");
	var grass = getValueByName("grass");

	if (isNaN(roofspace)) {
		alert("You must enter a value for roof space.");
		document.watercalc.roofspace.focus();
	}
	var totalharvest = Math.round(roofspace *(annualrainfall/12)*0.9*7.48,0);
	document.getElementById('totalharvest').innerHTML = totalharvest + " gallons of rainwater per year of average rainfall. (" + (annualrainfall) + " inches)<br/>" + Math.round(roofspace * 0.083*0.9*7.48,0)  + " gallons of rainwater per inch of rainfall";
	
	var min = totalharvest * 2;
	var max = totalharvest * 4;
	document.getElementById('sizerange').innerHTML = "between " + min + " and  " + max + " gallons.";

	var resources = Math.round((totalharvest)+(4*35*topload)+(4*10*frontload)+(4*numpeople*showers*20)+(30*numpeople*10*baths)+(faucet*numpeople*30)+(ac*10*30)+(swamp*15*30),0);
	document.getElementById('totalavailable').innerHTML = resources + " gallons per month.";
	
	var totalneeds = Math.round((citrus*8000/12)+(dwarf*5000/12)+(velvet*3000/12)+(screwbean*4000/12)+(acacia*3000/12)+(oleander*1000/12)+(deciduous*350/12)+(evergreen*450/12)+(pomegranate*3300/12)+(mission*3000/12)+(garden*(3180/50/12))+(grass*25/12)+(additionalqty*additionalgalpermonth),0);
	document.getElementById('totalneeds').innerHTML = Math.round(totalneeds/12,0) + " gallons per month.";
	
	var netbudget = resources - totalneeds;
	document.getElementById('netbudget').innerHTML = Math.round(netbudget/12,0) + " gallons per month.";
	
	calcs = document.getElementById('calculations');
	calcs.style.display = "block";
	new Effect.Highlight('calculations');
}

