function calculate_fee()
{
var f = document.forms["application"];

var plot1_fee = parseInt(f.elements["plot_fee1"].value);
if (isNaN(plot1_fee)) { plot1_fee = 0; }

var plot2_fee = parseInt(f.elements["plot_fee2"].value);
if (isNaN(plot2_fee)) { plot2_fee = 0; }

var membership_fee = parseInt(f.elements["membership_fee"].value);
if (isNaN(membership_fee)) { membership_fee = 0; }

var donation_fee = parseInt(f.elements["donation"].value);
if (isNaN(donation_fee)) { donation_fee = 0; }

var plot1_min = parseInt(f.elements["plot1_min"].value);
if (isNaN(plot1_min)) { plot1_min = 0; }
var plot1_max = parseInt(f.elements["plot1_max"].value);
if (isNaN(plot1_max)) { plot1_max = 0; }

if(plot1_fee < plot1_min)
	alert("You have entered a plot fee below the recommended level, you will be entered for a scholarship award");
else if (plot1_fee > plot1_max)
{
	alert("You have entered a plot fee above the recommended level, this amount will be entered as a donation");
	
	donation_fee = plot1_fee - plot1_max + donation_fee;
	f.elements["donation"].value = donation_fee;
	plot1_fee = plot1_max;
	f.elements["plot_fee1"].value = plot1_fee;
}

var plot2_min = parseInt(f.elements["plot2_min"].value);
if (isNaN(plot2_min)) { plot2_min = 0; }
var plot2_max = parseInt(f.elements["plot2_max"].value);
if (isNaN(plot2_max)) { plot2_max = 0; }

if(plot2_fee < plot2_min)
	alert("You have entered a plot fee below the recommended level, you will be entered for a scholarship award");
else if (plot2_fee > plot2_max)
{
	alert("You have entered a plot fee above the recommended level, this amount will be entered as a donation");
	
	donation_fee = plot2_fee - plot2_max + donation_fee;
	f.elements["donation"].value = donation_fee;
	plot2_fee = plot2_max;
	f.elements["plot_fee2"].value = plot2_fee;
}
		
var total = plot1_fee + plot2_fee + membership_fee + donation_fee;

f.elements["total"].value = total;

}

function calculate_event_fee()
{
var f = document.forms["registration"];

var donation_fee = parseInt(f.elements["donation"].value);
if (isNaN(donation_fee)) { donation_fee = 0; }

var event_fee = parseInt(f.elements["event_fee"].value);
if (isNaN(donation_fee)) { event_fee = 0; }
		
var total = event_fee + donation_fee;

f.elements["total"].value = total;

}

function add_plot1_fee(min_fee, max_fee)
{
var f = document.forms["application"];

add_member_fee();

// var garden = f.elements["community_garden1"][0].value;

f.elements["plot_fee1"].value = max_fee;
f.elements["plot1_max"].value = max_fee;
f.elements["plot1_min"].value = min_fee;

calculate_fee();
}

function add_plot2_fee(min_fee, max_fee)
{
var f = document.forms["application"];

f.elements["plot_fee2"].value = max_fee;
f.elements["plot2_max"].value = max_fee;
f.elements["plot2_min"].value = min_fee;

calculate_fee();
}

function add_member_fee()
{
var f = document.forms["application"];

f.elements["membership_fee"].value = 20;
}

function add_event_fee(fee)
{
var f = document.forms["registration"];

var cur = parseInt(f.elements["event_fee"].value);
fee = parseInt(fee);

var total = cur + fee;

f.elements["event_fee"].value = total;

calculate_event_fee();
}

