var findRecipeContent = '';

function switchPic(tab){
	var picRec = document.getElementById('findRecipe');
	var picFood = document.getElementById('nutritionLookup');
    var bot = document.getElementById ("hp_roundedBottom");
	var recipeSearchDiv = document.getElementById('recipeFood');

	if(tab == 'recipeOn'){
		picRec.src = '/diabetes/img/recipe/findaRecipe.jpg';
		picFood.src = '/diabetes/img/recipe/foodLookup.jpg';

        if (findRecipeContent.length != 0) {
            recipeSearchDiv.innerHTML = findRecipeContent;

        } else {
        	recipeSearchDiv.innerHTML = '<form name="" action="/dLife/diabetic-recipes/recipeResults.html" method="get">' +
        	'&nbsp;<b>Enter a keyword or ingredient:</b>&nbsp; ' +
	        '<input type="text" size="30" name="keyword" ' +
	        'style="font-size:11px;width: 160px; height:18px; color: #000; margin-top: 0px; padding-top: 0px;">' +
	        ' <input type="image" src="/diabetes/img/recipe/search.gif" align="middle" name="go" border="0"' + 
	        'alt="Find a Recipe" />&nbsp;<img id="arrow" style="cursor: hover" onclick="toggleAdvanced()" src="/diabetes/img/recipe/regSearch.gif"/> <a class="whitelinks" href="javascript:toggleAdvanced()">Advanced Search</a><div id="advancedArea"></div>' +
	        '<br/></form>';                
         }
        
        bot.src='/diabetes/img/recipe/greenBottom.gif';

		recipeSearchDiv.style.backgroundColor = '#849f04';

	}
	else if(tab == 'nutritionOn'){

		picRec.src = '/diabetes/img/recipe/findaRecipe2.jpg';
		picFood.src = '/diabetes/img/recipe/foodLookup2.jpg';
        findRecipeContent = document.getElementById ("recipeFood").innerHTML;

		recipeSearchDiv.innerHTML =  '<form name="" action="/dLife/diabetic-recipes/foodResults.html" method="get">' +
		 '<div id="foodfind_apple"><div style="padding-left: 45px;"><br /><br /><br /><br /><b class="indent">Enter a Food: </b> <input type="text" size="30" name="keyword" value="" style="font-size:11px;width: 160px; height:18px; color: #000; margin-top: 0px; padding-top: 0px;">' +
		 '<input type="image" align="middle" src="/diabetes/img/recipe/search.gif" align="middle" name="go" border="0" alt="Find a Food" /></div>' +
		 '</div></form>';

		recipeSearchDiv.style.backgroundColor = '#e17d0b';
		
		bot.src='/diabetes/img/recipe/orangeBottom.gif';
	}
}

function toggleAdvanced ()
{
    if (document.getElementById ('advancedArea').innerHTML == "") {
        document.getElementById ('advancedArea').innerHTML =  '<table cellpadding="5" cellspacing="10" width="598">' +
			'<tr><td colspan="3">Select as many of the options below to refine your search, then click "Search" above.</td></tr>'+
			'<tr><td colspan="3"><p>dietary</p></td></tr>'+
			'<tr><td width="33%"><input type="radio" name="carbTotal" value="30.4" />Carb Safe<br /><span class="smallAdvSearch">&le; 30g</span></td><td width="33%"><input type="radio" name="carbTotal" value="15.4" />Low Carb<br /><span class="smallAdvSearch">&le; 15g</span> </td><td width="33%"><input type="radio" name="carbTotal" value="3.4" />Very Low Carb<br /><span class="smallAdvSearch">&le; 3g</span> </td></tr>'+ 
			'<tr><td> <input type="checkbox" name="lowCholesterol" value="true" />Low Cholesterol<br /><span class="smallAdvSearch">&le; 60mg (main dish)</span><br /><span class="smallAdvSearch">&le; 20mg (all others)</span></td> <td><input type="checkbox" name="lowCalories" value="true" />Low Calorie<br /><span class="smallAdvSearch">&le; 360 calories (main dish)</span> <br /><span class="smallAdvSearch">&le; 120 calories (all others)  </span> </td><td><input type="checkbox" name="lowSatFat" value="true" />Low Saturated Fat<br /><span class="smallAdvSearch">&le; 3g (main dish)</span><br /><span class="smallAdvSearch">&le; 1g (all others)</span> </td></tr>'+
			'<tr><td colspan="3"><p>total time</p></td></tr>'+
			'<tr><td><input type="radio" name="time" value="10" /> &le; 10 minutes </td><td><input type="radio" name="time" value="20" /> &le; 20 minutes </td><td><input type="radio" name="time" value="30" /> &le; 30 minutes </td></tr>'+
			'<tr><td colspan="3"><p>Difficulty</p></td></tr>'+
			'<tr><td> <input type="radio" name="difficulty" value="1" />Easy</td><td> <input type="radio" name="difficulty" value="2" />Intermediate</td><td> <input type="radio" name="difficulty" value="3" />Difficult</td></tr>'+
		'</table>';
						
        document.getElementById ('advancedArea').style.display='block';
        document.getElementById ('arrow').src = '/diabetes/img/recipe/advSearch.gif';
    } else {
        document.getElementById ('advancedArea').innerHTML = "";
        document.getElementById ('advancedArea').style.display='none';
        document.getElementById ('arrow').src = '/diabetes/img/recipe/regSearch.gif';
        
    }
}