function addIngredient(){
	ingredientsDropDown = document.getElementById("ingredients")
	if(ingredientsDropDown.selectedIndex == 0) return
	selectedIngredientsBox = document.getElementById("selected_ingredients_box")
	ingredientToAdd = ingredientsDropDown.options[ingredientsDropDown.selectedIndex];
	if(isIngredientSelected(ingredientToAdd.value))
		return
	var newOption = document.createElement("option");
	newOption.text = ingredientToAdd.text;
	newOption.value = ingredientToAdd.value;

	selectedIngredientsBox.options.add(newOption);         
}
function removeIngredient(){
	ingredientsDropDown = document.getElementById("ingredients")
	ingredientToRemove = ingredientsDropDown.options[ingredientsDropDown.selectedIndex].value
	if(!isIngredientSelected(ingredientToRemove))
		return;
	selectedIngredientsBox = document.getElementById("selected_ingredients_box")
	selectedIngredientsBox.remove(indexInSelectedIngredients(ingredientToRemove))
}
function isIngredientSelected(ingredient){
	return indexInSelectedIngredients(ingredient) != -1
}
function indexInSelectedIngredients(ingredient){
	selectedIngredientsBox = document.getElementById("selected_ingredients_box")
	for(i=0; i<selectedIngredientsBox.options.length; i++){
		if(selectedIngredientsBox.options[i].value == ingredient)
			return i
	}
	return -1
}
function updateSelectedIngredients(){
	selectedIngredients = ""
	selectedIngredientsBox = document.getElementById("selected_ingredients_box")
	for(i=0; i<selectedIngredientsBox.length; i++){
		selectedIngredients += selectedIngredientsBox.options[i].value
		if( selectedIngredientsBox.length-1 != i)
			selectedIngredients += ","
	}
	document.getElementById("selected_ingredients").value = selectedIngredients
}


function addIngredient_notContain(){
	ingredientsDropDown = document.getElementById("ingredients_notContain")
	if(ingredientsDropDown.selectedIndex == 0)
		return
	selectedIngredientsBox = document.getElementById("selected_ingredients_box_notContain")
	ingredientToAdd = ingredientsDropDown.options[ingredientsDropDown.selectedIndex];
	if(isIngredientSelected_notContain(ingredientToAdd.value))
		return
	var newOption = document.createElement("option");
	newOption.text = ingredientToAdd.text;
	newOption.value = ingredientToAdd.value;

	selectedIngredientsBox.options.add(newOption);         
}
function removeIngredient_notContain(){
	ingredientsDropDown = document.getElementById("ingredients_notContain")
	ingredientToRemove = ingredientsDropDown.options[ingredientsDropDown.selectedIndex].value
	if(!isIngredientSelected_notContain(ingredientToRemove))
		return;
	selectedIngredientsBox = document.getElementById("selected_ingredients_box_notContain")
	selectedIngredientsBox.remove(indexInSelectedIngredients_notContain(ingredientToRemove))
}
function isIngredientSelected_notContain(ingredient){
	return indexInSelectedIngredients_notContain(ingredient) != -1
}
function indexInSelectedIngredients_notContain(ingredient){
	selectedIngredientsBox = document.getElementById("selected_ingredients_box_notContain")
	for(i=0; i<selectedIngredientsBox.options.length; i++){
		if(selectedIngredientsBox.options[i].value == ingredient)
			return i
	}
	return -1
}
function updateSelectedIngredients_notContain(){
	selectedIngredients = ""
	selectedIngredientsBox = document.getElementById("selected_ingredients_box_notContain")
	for(i=0; i<selectedIngredientsBox.length; i++){
		selectedIngredients += selectedIngredientsBox.options[i].value
		if( selectedIngredientsBox.length-1 != i)
			selectedIngredients += ","
	}
	document.getElementById("selected_ingredients_notContain").value = selectedIngredients
}
function resultOver(id) {
	id.style.backgroundColor = "#ffe5e6";
}
function resultOut(id) {
	id.style.backgroundColor = "#ffffff";
}