// JavaScript Document

$(document).ready(function(){
	
var meal='lunch';	
temp=0;
tm = true;
$("#meal_pre").css('display','none');
for(i=0;i<5;i++)	
$("#recipe").append("<option value=\'"+lunch[i][0]+"\'>"+lunch[i][0]+"</option>");	
$("#meal_name").text(lunch[0][0]);
$("#meal_data").text(lunch[0][1]);
$("#meal_img").attr('src','/images/recipe_'+lunch[0][2]+'.jpg');

$("#lunch").click(function(){
meal = 'lunch';
$("#recipe").html('');
for(i=0;i<5;i++)	
$("#recipe").append("<option value=\'"+lunch[i][0]+"\'>"+lunch[i][0]+"</option>");	
$("#recipe").trigger('change');
});

$("#dinner").click(function(){
meal = 'dinner';
$("#recipe").html('');
for(i=0;i<3;i++)	
$("#recipe").append("<option value=\'"+dinner[i][0]+"\'>"+dinner[i][0]+"</option>");		
$("#recipe").trigger('change');
});	

$("#recipe").change(function(){
$("#meal_ne").css('display','block');
$("#meal_pre").css('display','block');
var val=$("#recipe").val();
if(meal=='lunch')
{
for(k=0;k<5;k++)
if(lunch[k][0]==val)
{
$("#meal_name").text(lunch[k][0]);
$("#meal_data").text(lunch[k][1]);
$("#meal_img").attr('src','/images/recipe_'+lunch[k][2]+'.jpg');	
temp=k;
}
if(temp==3)
$("#meal_ne").css('display','none');
}
else
{
for(u=0;u<3;u++)
if(dinner[u][0]==val)
{
$("#meal_name").text(dinner[u][0]);
$("#meal_data").text(dinner[u][1]);
$("#meal_img").attr('src','/images/recipe_'+dinner[u][2]+'.jpg');
temp=u;	
}
if(temp==2)
$("#meal_ne").css('display','none');	
}
if(temp==0)
$("#meal_pre").css('display','none');
});

$("#meal_pre").click(function(){
$("#meal_ne").css('display','block');
if(temp!=0)
{
temp-=1;	
if(meal=='lunch')
{
$("#recipe").val(lunch[temp][0]);
$("#meal_name").text(lunch[temp][0]);
$("#meal_data").text(lunch[temp][1]);
$("#meal_img").attr('src','/images/recipe_'+lunch[temp][2]+'.jpg');	
}
else
{
$("#recipe").val(dinner[temp][0]);
$("#meal_name").text(dinner[temp][0]);
$("#meal_data").text(dinner[temp][1]);
$("#meal_img").attr('src','/images/recipe_'+dinner[temp][2]+'.jpg');
}	
}
if(temp==0)
$(this).css('display','none');
});

$("#meal_ne").click(function(){
$("#meal_pre").css('display','block');
if(meal=='lunch')
{
if(temp<3)
{
temp+=1;
$("#recipe").val(lunch[temp][0]);
$("#meal_name").text(lunch[temp][0]);
$("#meal_data").text(lunch[temp][1]);
$("#meal_img").attr('src','/images/recipe_'+lunch[temp][2]+'.jpg');		
}
if(temp==3)
$(this).css('display','none');
}
else
{
if(temp<2)
{temp+=1;
$("#recipe").val(dinner[temp][0]);
$("#meal_name").text(dinner[temp][0]);
$("#meal_data").text(dinner[temp][1]);
$("#meal_img").attr('src','/images/recipe_'+dinner[temp][2]+'.jpg');		
}
if(temp==2)
$(this).css('display','none');
}
});


$("#tools_foodSwap").css('display','none');
$("#tools_step9 a").click(function(){
if(tm==true)
{
$("#tools_foodSwap").slideDown('slow');	
tm=false;
}
else
{
$("#tools_foodSwap").slideUp('fast');	
tm=true;	
}
return false;
})
})








var lunch =	new Array(
new Array('Grilled Steak Salad', 'In a large saucepan, cook beans. In a bowl, mix beans, tomatoes and spoonfuls of yogurt. Place in a serving dish. In a bowl, mix cumin, salt and pepper and spread it over meat on both sides. Heat oil in a pan and fry meat for a few minutes. Once cooked, cut meat into strips and mix with beans, tomatoes and yogurt. Drizzle lemon juice over it all and add chopped onions and cheese.','1'),
new Array('Pasta & Tuna Salad', 'Cook pasta and drain it. In a bowl, mix pasta, tuna, onion, yogurt, chopped olives and artichoke hearts. Mix well and refrigerate. Add tomato and grated cheese and mix.','2'),
new Array('Lentils with Vegetables Bolognese', 'Heat oil in a frying pan and fry onions until brown. Add garlic, carrots, mushrooms and peppers and cook for a few minutes. Add tomatoes, tomato puree, lentils and stock. Bring to a boil, lower heat and simmer until lentils are tender. Serve with spaghetti.','3'),
new Array('Grilled Salmon with Leek & Rice', 'Heat oil in a pan and cook leeks, with rice and garlic over a medium heat for a few minutes until rice is brown. Add broth and heat until boiling, reduce heat and cook until rice is tender. Remove from heat, cover and let it sit. Meanwhile, place salmon on a previously greased grill, until done on both sides. Add parsley and grated cheese to rice and place salmon next to rice.','4'),
new Array('Roast Beef Sandwich', 'In a small bowl, mix in yogurt, mayonnaise and horseradish. Spread bread with this mixture. Heat up a pan and put some vegetables, like onion and peppers, and meat to fry. When done add this mixture of vegetables and meat to bread. Finally, add blue cheese inside the sandwich.','5')
	);
	
var dinner = 	new Array(
new Array('Vegetable Soup with Meatballs', 'Wash vegetables and chop into medium pieces. In a large saucepan heat some oil then fry vegetables well for about 5 minutes, stirring constantly. Add Tabasco; simmer with broth for about 30 minutes. Meanwhile, chop the other vegetables to small pieces and add to soup. Cook for about 15 minutes. Meatballs: Mix sausage meat with egg, salt and pepper until you have a smooth dough. Add breadcrumbs. With a small spoon make meatballs and drop them into pot of soup. Boil for 10 more minutes.','6'),
new Array('Chicken with Lemon & Roasted Vegetables', 'Put oil in a frying pan to heat. When hot, add carrots, pumpkin, onion, lemon zest, garlic and red peppers. Fry until golden. Meanwhile mix chicken with lemon juice and sprinkle with salt, pepper and basil. Place vegetables in a baking tray and place chicken on top. Bake for 20-25 minutes at 170 degrees, or until chicken is cooked and vegetables tender.','7'),
new Array('Rice with Chicken & Vegetables', 'Peel and dice the garlic cloves. Finely chop the onions, courgette, carrots and peppers. Blanch the tomatoes, remove skin and cut into small pieces. Add the oil to pan. When the oil is hot, fry the onions, courgette, peppers and carrots. Add the chopped tomatoes. Add the green beans and stir. Cut the chicken into pieces and season with salt, pepper and diced garlic cloves. Add to pan and fry with the vegetables.','8')
	);

