function removeIngredient(divID) {
	
	var numIngredients = $("#ingredients td.field div").length;
	if (numIngredients > 1) {
		var obj = $("#"+divID);
		obj.empty();
		obj.remove();
	}	
}

function addIngredientField() {
	
	/*Get the id for the next field.*/
	lastInput = $("#ingredients input:last");
	split = lastInput.attr("id").split("-");
	nextNum = parseInt(split[1]) + 1;
	
	/*Create the new form field inside a div.*/
	$("#ingredients td:last").append('<div id="formField-'+nextNum+'"><input type="text" id="ingredients-'+nextNum+'" name="ingredients-'+nextNum+'" value="" /> <a href=\"javascript:removeIngredient(\'formField-'+nextNum+'\');\">X</a></div>');

}

