// JavaScript Document
// Project: Food Network Header
// Author: Mike Nelson 5/2007

	try {document.execCommand("BackgroundImageCache", false, true);} catch(err) {} // penicillin for a very bad IE6 browser bug
	
	var sTypeSel="recipe";  


function setSearchType(s_type){
	
	// Turn on active tab and set form radio checked value to which search is selected
	
	switch (s_type)
		{		
		case "recipe":				
				document.getElementById('site_input').style.backgroundPosition = "top";
				document.getElementById('recipe_input').style.backgroundPosition = "bottom";	
				document.getElementById('topics').style.backgroundPosition = "top";
				document.getElementById('recipes').style.backgroundPosition = "bottom";
				document.LnbSearchForm.searchType[0].checked = true;
				document.LnbSearchForm.searchType[1].checked = false;
				document.getElementById('recipe_input').style.cursor = "default";
				document.getElementById('site_input').style.cursor = "pointer";
				break;			
		case "site":
				document.getElementById('site_input').style.backgroundPosition = "bottom";
				document.getElementById('recipe_input').style.backgroundPosition = "top";	
				document.getElementById('topics').style.backgroundPosition = "bottom";
				document.getElementById('recipes').style.backgroundPosition = "top";
				document.LnbSearchForm.searchType[0].checked = false;
				document.LnbSearchForm.searchType[1].checked = true;		
				document.getElementById('recipe_input').style.cursor = "pointer";
				document.getElementById('site_input').style.cursor = "default";
				
				break;		
		default:
				break;		
		}
}



function flushTabs()
{
	// Flush tabs - set all tabs to inactive and enable all hover states
	
	document.getElementById("nav_link_home").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_home_norm_hover.gif)";
	document.getElementById("nav_link_cooking").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_cooking_norm_hover.gif)";
	document.getElementById("nav_link_holidays").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_holidays_norm_hover.gif)";
	document.getElementById("nav_link_quick").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_quick_norm_hover.gif)";
	document.getElementById("nav_link_healthy").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_healthy_norm_hover.gif)";
	document.getElementById("nav_link_tv").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_tv_norm_hover.gif)";
	document.getElementById("nav_link_shop").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_shop_norm_hover.gif)";
	document.getElementById("nav_link_videos").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_videos_norm_hover.gif)";
		
	document.getElementById("nav_link_home").style.cursor = "pointer";
	document.getElementById("nav_link_cooking").style.cursor = "pointer";
	document.getElementById("nav_link_holidays").style.cursor = "pointer";
	document.getElementById("nav_link_quick").style.cursor = "pointer";
	document.getElementById("nav_link_healthy").style.cursor = "pointer";
	document.getElementById("nav_link_tv").style.cursor = "pointer";
	document.getElementById("nav_link_shop").style.cursor = "pointer";
	document.getElementById("nav_link_videos").style.cursor = "pointer";	
	
	document.getElementById("recipe_box_login").style.visibility ="hidden";
}


function setNavActiveTab()
{
	// Set Navigation Active Tab	
	
	var activeTab = ""	
	if (document.globalSctnLineage) {
		//flushTabs();
		var tmpGlobalSctnLineage = document.globalSctnLineage + ",";
		activeTab = tmpGlobalSctnLineage.split(",");
	} 

	for (var i=0; i<activeTab.length; i++) {
		switch (activeTab[i])
		{		
			case "HOME":				
				document.getElementById("nav_link_home").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_home_active.gif)";	
				document.getElementById("nav_link_home").style.cursor = "default";
				break;	
			case "COOKING":
				document.getElementById("nav_link_cooking").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_cooking_active.gif)";
				document.getElementById("nav_link_cooking").style.cursor = "default";
				break;	
			case "ENTERTAINING":
				document.getElementById("nav_link_holidays").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_holidays_active.gif)";
				document.getElementById("nav_link_holidays").style.cursor = "default";
				break;
			case "LF_QUICK_EASY":
				document.getElementById("nav_link_quick").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_quick_active.gif)";
				document.getElementById("nav_link_quick").style.cursor = "default";
				break;	
			case "LF_HEALTH":
				document.getElementById("nav_link_healthy").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_healthy_active.gif)";
				document.getElementById("nav_link_healthy").style.cursor = "default";
				break;
			case "TV":
				document.getElementById("nav_link_tv").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_tv_active.gif)";
				document.getElementById("nav_link_tv").style.cursor = "default";
				break;				
			case "SHOP":				
				document.getElementById("nav_link_shop").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_shop_active.gif)";
				document.getElementById("nav_link_shop").style.cursor = "default";
				break;
			case "VIDEO_GUIDE":
				document.getElementById("nav_link_videos").style.backgroundImage = "url(http://images.foodnetwork.com/webfood/images/header/new_header_test/images/nav_videos_active.gif)";
				document.getElementById("nav_link_videos").style.cursor = "default";
				break;	
			case "MY_RECIPE_BOX":
				document.getElementById("recipe_box_login").style.visibility ="visible";				
				break;				
			case "":
				// do nothing because there is no indicating page variable present				
				break;			
			default:
				// do nothing
				break;
		}
	}
}


function set_fn_header_width () 
{
	
	if (document.getElementById('main_body_wrapper'))
	{
	main_body_wrapper_width = document.getElementById('main_body_wrapper').offsetWidth;
		//alert("main_body_wrapper_width = " + main_body_wrapper_width);
	if (main_body_wrapper_width < "800") {main_body_wrapper_width = "800"}; <!-- set a minimum width -->
	if (main_body_wrapper_width > "988") {main_body_wrapper_width = "988"}; <!-- set a maximum width -->
	document.getElementById('fn_header').style.width = main_body_wrapper_width;
		//alert("After checking for min and max widths, main_body_wrapper_width = " + main_body_wrapper_width);
		//alert("fn_header width = "+document.getElementById('fn_header').style.width);
	} else {
	// CSS already sets default width of 800px and/or other css rules may be in place
	}
	
}

