function calc_camp_fees(a) {

a.adultcost.value=a.adults.value*adultprice; 
a.kidcost.value=a.kids.value*kidprice; 
a.yocost.value=a.youngandold.value*youngandoldprice;
a.total.value=addcampers(a.adultcost.value, a.kidcost.value,a.yocost.value);
a.totalwreg.value=addcampers(a.total.value, regfee, 0); 
a.totalh.value=addcampers(a.totalwreg.value*a.hmul.value, a.hadj.value, 0);
if (a.fcsf.value>0);else a.fcsf.value=0;
if (a.lpdf.value>0);else a.lpdf.value=0;
a.totalpay.value=addcampers(a.totalh.value, a.fcsf.value, a.lpdf.value);  
a.deposit.value=addcampers(a.adults.value*100, a.kids.value*100,a.youngandold.value*100);
a.deposit.value=addcampers(a.deposit.value,regfee,0);
a.balancedue.value=addcampers(a.totalpay.value,a.deposit.value*-1,0);
a.housingtype.value=housingval();
createCookie("Camptotal",a.totalpay.value,0);
createCookie("Campdeposit",a.deposit.value,0);

}

function addcampers(one, two, three) {
	sum=eval(one)+eval(two)+eval(three)
	return sum
}

function housingval() {
	for (i=0;i<document.forms[0].housing.length;i++) {
		if (document.forms[0].housing[i].checked) {
			user_input = document.forms[0].housing[i].value;
		}
	}
	
	return user_input
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function display_fees() {
        if (readCookie("Camptotal")>0) {
                return "<br>Your total camp fees are $"+readCookie("Camptotal")+"<br>Your minimum deposit is $"+readCookie("Campdeposit");
        } 
}

