
function calculate () { 

	//Initialise variables
	var errorMsg = "";


	//Check for DIMM quantity
	var capacity = 1*document.f1.capacity.value;
	var usage = 1*document.f1.usage.value;
	var growth = 1*document.f1.growth.value;

	if (capacity < 100)	{
		errorMsg += "\n Total Power Capacity should be greater than 100";	
	} else if (capacity > 3000000)	{
		errorMsg += "\n Total Power Capacity should be lesser than 3000000";	
	} else if (parseInt( capacity ) != capacity )	{
		errorMsg += "\n Enter an integer value for the Total Power Capacity";	
	}

	if (usage < 100)	{
		errorMsg += "\n Current Power Usage should be greater than 100";	
	} else if (usage > 3000000)	{
		errorMsg += "\n Current Power Usage should be lesser than 3000000";	
	} else if (parseInt( usage ) != usage )	{
		errorMsg += "\n Enter an integer value for the Current Power Usage";	
	}

	if (growth < -90)	{
		errorMsg += "\n Business Growth should be greater than -90";	
	} else if (growth > 1000)	{
		errorMsg += "\n Business Growth Usage should be lesser than 1000";	
	} else if (parseInt( growth ) != growth )	{
		errorMsg += "\n Enter an integer value for the Business Growth";	
	}
	
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your request has not been processed because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}

	var d = usage +  (usage*growth*.01)
    var e = d + (d*growth*.01)

    if ((usage +  (usage*growth*.01)) > capacity)  {
		document.f1.result.value = "2009";
    } else if ((d + (d*growth*.01)) > capacity)  {
		document.f1.result.value = "2010";
    } else if ((e + (e*growth*.01)) > capacity)  {
		document.f1.result.value = "2011";
    } else {
		document.f1.result.value = "2012 or beyond";
		alert("You appear to have enough capacity until at least 2012.");
	}
}



