// JavaScript Document
function getObj(elementID){
	return document.getElementById(elementID);
}

var LocationStr = document.location.href.toLowerCase()

//********************************* top nav script begins ******************************
var topnavID = new Array();

topnavID[0] = "products/"
topnavID[1] = "recipes/"
topnavID[2] = "cookingbaking/"
topnavID[3] = "childweight/"
topnavID[4] = "healthdiabetes/"
topnavID[5] = "newspromotions/"
topnavID[6] = "faqs/"
topnavID[7] = "sp_contest"
topnavID[8] = "vcrc/offers"
topnavID[9] = "vcrc/"


var LocationStr = document.location.href.toLowerCase()

function looptopnav() 
{
	
	var shown = false;
	for (var i = 0; i < topnavID.length; i++)
	{
		if (LocationStr.search(topnavID[i]) != -1) {
			if (i==7) {
				changetopnav("newspromotions");
			} else {
				if (i==8) {
					changetopnav("recipes");
				} else {
					var a = topnavID[i].replace("/","");
					changetopnav(a);
				}
			}
			break;
		} 
	}
}

function changetopnav(whichone)
{
	if (whichone == "vcrc")
	{
		whichone = "faqs";
	}
	if (whichone != "")
	{
		//alert(whichone);
		var divwhichone = "div" + whichone;
		//alert( divwhichone );
		document.getElementById(divwhichone).style.display="block";
		//alert( divwhichone );
		
		document.images[whichone].src='/images/splenda/topnav/global/' + whichone + '_on.gif';
		loop_leftnav(whichone);
	}
	
}

//********************************* top nav script ends    ******************************



//********************************* left nav script begins ******************************

var leftnavID = new Array();
leftnavID[0] = "products/packets"
leftnavID[1] = "products/granular"
leftnavID[2] = "products/blend"
leftnavID[3] = "products/dining"
leftnavID[4] = "products/stories"
leftnavID[5] = "recipes/library"
leftnavID[6] = "recipes/club"
leftnavID[7] = "cookingbaking/nocal_tips"
leftnavID[8] = "cookingbaking/sb_tips"
leftnavID[9] = "cookingbaking/cbfaq"
leftnavID[10] = "healthdiabetes/diabetesmain"
leftnavID[11] = "healthdiabetes/healthyeating"
leftnavID[12] = "healthdiabetes/whattoeat"
leftnavID[13] = "healthdiabetes/myths"
leftnavID[14] = "healthdiabetes/portionsizes"
leftnavID[15] = "healthdiabetes/healthfuleating"
leftnavID[16] = "healthdiabetes/diabetesrecipes"
leftnavID[17] = "newspromotions/press"
leftnavID[18] = "faqs/faqmain"
leftnavID[19] = "faqs/bsbblend"
leftnavID[20] = "faqs/nocalorie"
leftnavID[21] = "faqs/sugarblend"
leftnavID[22] = "faqs/qpack"
leftnavID[23] = "vcrc/callback/splendacallform"
leftnavID[24] = "vcrc/email/splendaemail"
leftnavID[25] = "vcrc/tellus/splendatellus"
leftnavID[26] = "recipes/additup"
leftnavID[27] = "childweight/main"
leftnavID[28] = "childweight/cutcalories"
leftnavID[29] = "childweight/brochures"
leftnavID[30] = "childweight/extrasteps"
leftnavID[31] = "childweight/foodlabels"
leftnavID[32] = "childweight/funrecipes"
leftnavID[33] = "recipes/calculator"
leftnavID[34] = "cookingbaking/additup"
leftnavID[35] = "cookingbaking/calculator"
leftnavID[36] = "faqs/everydayemails"
leftnavID[37] = "vcrc/offers/splendacampaign"
leftnavID[38] = "products/bsb_blend"
leftnavID[39] = "products/flavor_blends_coffee"
leftnavID[40] = "products/quick_pack"
leftnavID[41] = "products/cafe_stick"
leftnavID[42] = "products/flavor_accents"
leftnavID[43] = "products/flavor_minis"
leftnavID[44] = "cookingbaking/recipevideo"
leftnavID[45] = "splenda/conversion"
leftnavID[46] = "childweight/timeinkitchen"
leftnavID[47] = "cookingbaking/conversionchart"
leftnavID[48] = "products/fiber_packets"

function loop_leftnav(whichone) 
{
	if (whichone == "customerservice")
	{
		whichone = "vcrc";
	}
	for (var i = 0; i < leftnavID.length; i++)
	{
	if (LocationStr.search(leftnavID[i]) != -1) 
		{
			var a = leftnavID[i].replace(whichone,"");
			a = Replace( a, "/","");				
			changeproducts(a);
		}
	} 
}

function Replace( str, searchstr, replacestr )
{
	while(1==1)
	{
		if (str.search(searchstr) == -1)  break;
		str = str.replace( searchstr, replacestr );
	}
	return str;

}


function changeproducts(whichone)
{
	if (whichone == "vcrcemailsplendaemail")
	{
		whichone = "email";
	}else if (whichone == "everydayemails")
	{
		whichone = "email";	
	}else if (whichone == "vcrcofferssplendacampaign")
	{
		whichone = "";	
	}else if (whichone == "vcrccallbacksplendacallform")
	{
		whichone = "call";
	}else if (whichone == "vcrctellussplendatellus")
	{
		whichone = "rate";
	}
	

	turnoff= whichone + 'off'
	//alert(whichone);
	if (whichone != "")

	{
		document.getElementById(whichone).style.display="block"
		document.getElementById(turnoff).style.display="none"	
		//////////// Second Level Press Room Begins
		if (LocationStr.search('/newspromotions/press/') != -1)
		{
			document.getElementById('secondlevel').style.display="block";
			
			if (LocationStr.search('/newspromotions/press') != -1){
				if (LocationStr.search('/newspromotions/press/special_offer') != -1){
					document.getElementById('press_text2h').className="productnav_ontwo";
				}
				if(LocationStr.search('/newspromotions/press/release/09_21_2008') != -1){
					document.getElementById('press_text2a').className="productnav_ontwo";
				}
				if(LocationStr.search('/newspromotions/press/release/10_03_2008') != -1){
					document.getElementById('press_text2i').className="productnav_ontwo";
				}
			}
			
			if (LocationStr.search('/newspromotions/press/contactus') != -1)
				document.getElementById('press_text2b').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/nocal_facts') != -1)
				document.getElementById('press_text2c').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/blend_facts') != -1)
				document.getElementById('press_text2d').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/timelines') != -1)
				document.getElementById('press_text2e').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/productfamilies') != -1)
				document.getElementById('press_text2f').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/safety') != -1)
				document.getElementById('press_text2g').className="productnav_ontwo";
			if (LocationStr.search('/newspromotions/press/11_2_2006') != -1)
				document.getElementById('press_text2h').className="productnav_ontwo";
		}
		//////////// Second Level Press Room Ends
		
	}
}

//********************************* left nav script ends ******************************
