// JavaScript Document
// add each course price times number of seats to find total cost


function updateCost() {
	var t_cost = 0;
	var t_seats = 0;
	var t_form = document.seatsForm.elements;
	for (var i = 0; i < t_form.length; i++) {
			if (t_form[i].name.indexOf("p") == 0) {
				var cost = 0;
				var cname = "c" + t_form[i].name.substring(1, t_form[i].name.length);
				var seats = eval("document.seatsForm." + cname + ".value");
				cost = seats * t_form[i].value;
				t_cost = t_cost + cost;
				if (seats.length > 0) {
					t_seats = t_seats + parseInt(seats);
				}
			}
	}
	if (t_cost.toFixed) {
		t_cost = t_cost.toFixed(2);
	}
	document.seatsForm.tCost.value=t_cost;
	document.seatsForm.tSeats.value=t_seats;
}

