function CalculateYesNoTotal(dropdown, price, totalFieldId) {
	var totalField = document.getElementById(totalFieldId);

	if (dropdown.value == "Yes") {
		totalField.value = price;
	} else {
		totalField.value = 0;
	}
	CalculateTotal();
}

function CalculateFieldTotal(textbox, price, totalFieldId) {
	var totalField = document.getElementById(totalFieldId);
	textbox.style.backgroundColor = 'White';
	if (textbox.value == "") {
		return;
	}
	var value = parseInt(textbox.value);
	if (isNaN(value)) {
		textbox.style.backgroundColor = 'Pink';
		alert("Please enter a valid number");
	} else {
		totalField.value = value * price;
		CalculateTotal();
	}
}

function CalculateTotal() {
	var allTotals = new Array("cost_players", "cost_bbq", "cost_fri_cottage",
			"cost_fri_tents", "cost_fri_sites", "cost_fri_group",
			"cost_sat_cottage", "cost_sat_tents", "cost_sat_sites",
			"cost_sat_group");
	var total = 0;
	var nextNum;
	for ( var i = 0; i < allTotals.length; i++) {
		nextNum = parseInt(document.getElementById(allTotals[i]).value);
		if (isNaN(nextNum)) {
			document.getElementById("total_cost").value = "#ERROR#";
			return;
		}
		total += nextNum;
	}
	document.getElementById("total_cost").value = total;
}

function ValidateInputs() {
	var allTextQuantityInputs = new Array("no_players", "no_bbq",
			"no_fri_tents", "no_fri_sites", "no_fri_group", "no_sat_tents",
			"no_sat_sites", "no_sat_group");
	var currentNode;
	var invalidFound = false;
	for ( var i = 0; i < allTextQuantityInputs.length; i++) {
		currentNode = document.getElementById(allTextQuantityInputs[i]);
		if (isNaN(parseInt(currentNode.value))) {
			invalidFound = true;
			currentNode.style.backgroundColor = 'Pink';
		}
	}
	if (invalidFound) {
		alert("Please fill out all necessary fields.");
		return false;
	}
	return true;
}

