function validateDrinkForm() {
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.drinkform.eventtype.length; counter++) {
		// If a radio button has been selected it will return true
		// (If not it will return false)
		if (document.drinkform.eventtype[counter].checked) {
			radio_choice = true;
		}
	}
    
	var numguests = document.drinkform.numguests.value;

    if (radio_choice == false) {
    	alert("You need to choose an event type");
    	return false;
    }
    else if (isNaN(numguests) || numguests == "") {
    	alert("You need to enter a valid number of guests");
    	return false;
    }
    else {
    	return true;
    }
}    
    	
function validateIcingForm() {
	var numcases = document.icingform.startingcases.value;
	var numxtracases = document.icingform.additionalcases.value;
				
	if (isNaN(numcases) || numcases == "") {
		alert("You need to enter a valid number of starting cases");
		return false;
	}
    else if (isNaN(numxtracases)) {
    	alert("You need to enter a valid number of additional cases");
    	return false;
	}
    else {
    	return true;
    }
}    
    	
function calculateDrinkForm() {
	if (validateDrinkForm()) {
    	var numguests = document.drinkform.numguests.value;

    	for (counter = 0; counter < document.drinkform.eventtype.length; counter++) {
			if (document.drinkform.eventtype[counter].checked) {
				var eventtype = document.drinkform.eventtype[counter].value;
			}
		}

		if (eventtype == "full")
			var amountice = (parseInt(Math.round(numguests * 1.2)));
		else if (eventtype == "fast")
			var amountice = (parseInt(Math.round(numguests * 1)));
		else if (eventtype == "cocktail") 
			var amountice = (parseInt(Math.round(numguests * 3.6)));
		else if (eventtype == "outdoor")
			var amountice = (parseInt(Math.round(numguests * 1.5)));
	
		var numbags = Math.ceil(amountice / 40);
				
		document.drinkform.approximation_drinks.value = numbags;
	}
}
				
function calculateIcingForm() {

	if (validateIcingForm()) {
		var numcases = document.icingform.startingcases.value;
		var numxtracases = document.icingform.additionalcases.value;

		var multiplier = 20;
		var xtramultiplier = multiplier / 2;
				
		var amountice = numcases * multiplier;
					
		var xtraamount = numxtracases * xtramultiplier;
					
		var amountice = amountice + xtraamount;

		var numbags = Math.ceil(amountice / 40);
				
		document.icingform.approximation_cans.value = numbags;
	}
}