<!--
//Made by Vijay Bhagwandas, Lenntech BV
var t, p //tap-water,cost

function rain(){
	var l = document.forms[0].l.value //length
	var w = document.forms[0].w.value //width
	var A = document.forms[0].A.value //surface
	var e = document.forms[0].e.value //cost per liter
	
	if(A == "" && l != "" && w == ""){
		alert("fill in the width")
		clearForm()
		return
	}
	
	if(A == "" && w != "" && l == ""){
		alert("fill in the length")
		clearForm()
		return
	}
	
	if(A != "" && l != "" && w == ""){
		alert("is you area " +A+ " m2 or what!")
		clearForm()
		return
	}
	
	if(A != "" && w != "" && l == ""){
		alert("is you area " +A+ " m2 or what!")
		clearForm()
		return
	}	
	
	if(A != "" && w != "" && l != ""){
		alert("What do you want!\r\rGive the area, and if you don't know it:\r\rGive the length or widh")
		clearForm()
		return
	}	
	
	if(A == "" && w == "" && l == ""){
		alert("You'll have to fill an area or the length and width,\rso the area can be calculated")
		return
	}
		
	if(e == ""){
		alert("Wat do you think")
		alert("That tap-water is for free")
		alert("Fill the cost of one m3 water in")
		return
	}
		
	if(l == "" && w == ""){
		document.forms[0].t.value = Math.round(document.forms[0].A.value*document.forms[0].a.value*1e-3)
		t = document.forms[0].t.value
	}
	else{
		A = l*w
		document.forms[0].t.value = Math.round(A*document.forms[0].a.value*1e-3)
		t = document.forms[0].t.value
	}
	
	document.forms[0].p.value = (document.forms[0].t.value*document.forms[0].e.value).toFixed(2)
	p = document.forms[0].p.value
	if(e != 0)
		setTimeout("alert(\"You can save \" +t+\" m3 water in a year and €\" +p)", 2000)
	else
		alert("Tap-water is for free, so you can't save money")
}

function clearForm(){
	var form = window.document.forms[0]
	for(var i = 0; i < form.elements.length; i++){
		if(i == 3){
			continue
		}
		if(form.elements[i].type == "text"){
			form.elements[i].value = ""
		}
	}
}

function al(){
	alert("Yes it is true,\rit rains more in england than on the continent in general!")
}

document.onkeypress = keyhandler;
function keyhandler(e) {
	Key = (document.layers)?e.which:window.event.keyCode;;
	if( Key == 13 || Key == 32 ){ //13 is ascii value for Enter key
		rain(); 
	}

	if( Key == 27){ //27 is ascii value for escape key
		clearForm(); 
	}
}
//-->