// dyamically changes the content of the page
function changeLink(whichone, whichDir, section)
	{
	whichFrame = whichDir + "Frame";
	whichImage = whichDir + "Image";
	root= whichDir+"/";
	rootLength=root.length;
	// extract the name of the page from the path name
	tr = whichone.substring(whichone.indexOf(root)+rootLength, whichone.lastIndexOf('.'));
	whichImage = "http://a248.g.akamai.net/f/1016/606/5m/image.pathfinder.com/rsn/microsites/unilever_homebasics/images/"+whichDir+"/" + tr + ".jpg";
	// change the image to the right of the iframe
	document.images["frameImage"].src = whichImage;
	// change the contents of the iframe
	frames[whichFrame].location.href=whichone;	
	// now go write a new mini navigation
	writeNav(tr, whichDir, section);
	}

// v 2.0 2006-07-10
// dynamically re-writes the mini-nav
function writeNav(whichPage, whichDir, section)
	{
	// set how many nav links appear per "section"
	var interval=4;
	/*  ------------ */
	if (!section) { section=0; }
	// one caveat about these arrays: the initial writing of content of the three
	// pages tied to this js, is hard coded on those respective pages: (recipes, household, and beauty) 
	// so if you change the order of the items in any of these arrays and you change the first item in
	// the list, make sure you go back and tweek any page to reflect the first item in these array lists.
	var recipesNav = new Array
		( 
		"chicken_veggie_wrap", 
		"asian_beef_salad", 
		"bean_chicken_salad", 
		"veggie_quesadilla", 
		"cheese_stuffed_meatballs", 
		"composed_cobb_salad", 
		"mango_salsa", 
		"garlic_grilled_steak", 
		"garlic_lime_shrimp", 
		"grilled_pork", 
		"grilled_shrimp_cocktail", 
		"magically_moist_chicken", 
		"skillet_chicken", 
		"marinade_italian_chicken", 
		"peanut_butter_apple_taco", 
		"peanut_butter_parfait", 
		"steak_gorgonzola_alfredo", 
		"pomegranate_tea_punch", 
		"pineapple_teriyaki_chicken", 
		"lemon_cooler", 
		"green_tea_pear_twist"
		/*, 
		"mango_peach_sangria", 
		"orange_lemon_tea_fizz", 
		"bavarian_cosmopolitan"
		*/
		);
	var beautyNav = new Array( "bathroom_remedies", "skin_exfoliate", "odor_protection", "protect_hair", "skin_moisterize" );
	var householdNav = new Array( "sort_it_all_out", "laundry_room", "pretreat" );
	// grabs the path name from the browser location window.
	page = location.href;
	// extracts the name of the page then strips everything else away
	// http://********/this_page_name.html
	// so whichDir = this_page_name
	whichDir = page.substring(page.lastIndexOf('/')+1, page.lastIndexOf('.'));
	// this is an exception as there are few beauty tips
	// if they add more, take this line out.
	if (whichDir == "beauty") { interval=5; }
	// determine which page is calling for content
	// put that navigation content into a temp
	temp = eval (whichDir +"Nav");
	totalPages = temp.length;
	if (interval > totalPages ) { interval = totalPages; }
	w = eval(whichDir + "Nav");
	if (!whichPage) {whichPage = w[0];}
	intervalStart = interval * section;
	previousLink = "";
	nextLink = "";
	// these set up the "next" and "previous" intervals
	t = intervalStart+interval;
	if ( t >=totalPages ) { intervalNext = totalPages;}
	else { intervalNext = intervalStart+interval; }
	t = intervalStart-interval;
	if ( t <interval ) { intervalPrevious = 0;}
	else { intervalPrevious = intervalStart-interval; }
	// parts of the navigation
	var p1="<a href=\""+whichDir+"/";
	var p2=".html\" onClick=\"changeLink(this.href, '";
	var p3="', ";
	var p4="); return false;\">";
	var previousArrow="&laquo;";
	var nextArrow="&raquo;"
	var p5="<\/a>";
	var pipe=" | ";
	var nav="";
	// creates the "previous" arrow (if one should be there)
	if ( section > 0)
		{
		previous = section-1;
		link = temp[intervalPrevious];		 
		previousLink=  p1 + link + p2 + whichDir + p3 + previous + p4 + previousArrow + p5 + pipe;
		}
	// creates the "next" arrow (if one should be there)
	if ( intervalNext < totalPages )
		{
		next = section+1;
		link = temp[intervalNext]; 
		nextLink= pipe + p1 + link + p2 + whichDir + p3 + next + p4 + nextArrow + p5;
		}
	// append the 'previous link' arrow onto the nav (if there is one)
	nav = nav + previousLink;
	link=0;
	for (x=intervalStart; x<intervalNext ; x++)
		{
		link = x + 1;
		// if not the last link then put a pipe between links
		pipe = (link < intervalNext )  ? " | " : "";
		// for all other pages (but the one you're on, create link
		if (temp[x] != whichPage) { nav = nav + p1 + temp[x] + p2 + whichDir + p3 + section + p4 + link + p5 + pipe; }
		// no link for the page you are on
		else { nav = nav + "<b>" + link + "<\/b>" + pipe; }
		}
	// append the 'next link' arrow onto the nav (if there is one)
	nav = nav + nextLink;
	document.getElementById("theNav").innerHTML = nav;
	}

/* begin image preloader */
if (document.images)
	{

	/* recipe images */

	asian_beef_salad = new Image();
	asian_beef_salad.src = "images/recipes/asian_beef_salad.jpg";

	bavarian_cosmopolitan = new Image();
	bavarian_cosmopolitan.src = "images/recipes/bavarian_cosmopolitan.jpg";

	bean_chicken_salad = new Image();
	bean_chicken_salad.src = "images/recipes/bean_chicken_salad.jpg";

	cheese_stuffed_meatballs = new Image();
	cheese_stuffed_meatballs.src = "images/recipes/cheese_stuffed_meatballs.jpg";

	chicken_veggie_wrap = new Image();
	chicken_veggie_wrap.src = "images/recipes/chicken_veggie_wrap.jpg";

	composed_cobb_salad = new Image();
	composed_cobb_salad.src = "images/recipes/composed_cobb_salad.jpg";

	garlic_grilled_steak = new Image();
	garlic_grilled_steak.src = "images/recipes/garlic_grilled_steak.jpg";

	garlic_lime_shrimp = new Image();
	garlic_lime_shrimp.src = "images/recipes/garlic_lime_shrimp.jpg";

	green_tea_pear_twist = new Image();
	green_tea_pear_twist.src = "images/recipes/green_tea_pear_twist.jpg";

	grilled_pork = new Image();
	grilled_pork.src = "images/recipes/grilled_pork.jpg";

	grilled_shrimp_cocktail = new Image();
	grilled_shrimp_cocktail.src = "images/recipes/grilled_shrimp_cocktail.jpg";

	lemon_cooler = new Image();
	lemon_cooler.src = "images/recipes/lemon_cooler.jpg";

	magically_moist_chicken = new Image();
	magically_moist_chicken.src = "images/recipes/magically_moist_chicken.jpg";

	mango_peach_sangria = new Image();
	mango_peach_sangria.src = "images/recipes/mango_peach_sangria.jpg";

	mango_salsa = new Image();
	mango_salsa.src = "images/recipes/mango_salsa.jpg";

	marinade_italian_chicken = new Image();
	marinade_italian_chicken.src = "images/recipes/marinade_italian_chicken.jpg";

	orange_lemon_tea_fizz = new Image();
	orange_lemon_tea_fizz.src = "images/recipes/orange_lemon_tea_fizz.jpg";

	peanut_butter_apple_taco = new Image();
	peanut_butter_apple_taco.src = "images/recipes/peanut_butter_apple_taco.jpg";

	peanut_butter_parfait = new Image();
	peanut_butter_parfait.src = "images/recipes/peanut_butter_parfait.jpg";

	pineapple_teriyaki_chicken = new Image();
	pineapple_teriyaki_chicken.src = "images/recipes/pineapple_teriyaki_chicken.jpg";

	pomegranate_tea_punch = new Image();
	pomegranate_tea_punch.src = "images/recipes/pomegranate_tea_punch.jpg";

	skillet_chicken = new Image();
	skillet_chicken.src = "images/recipes/skillet_chicken.jpg";

	steak_gorgonzola_alfredo = new Image();
	steak_gorgonzola_alfredo.src = "images/recipes/steak_gorgonzola_alfredo.jpg";

	veggie_quesadilla = new Image();
	veggie_quesadilla.src = "images/recipes/veggie_quesadilla.jpg";

	/* beauty images */
	
	skin_exfoliate = new Image();
	skin_exfoliate.src = "images/beauty/skin_exfoliate.jpg";

	odor_protection = new Image();
	odor_protection.src = "images/beauty/odor_protection.jpg";

	skin_moisterize = new Image();
	skin_moisterize.src = "images/beauty/skin_moisterize.jpg";

	protect_hair = new Image();
	protect_hair.src = "images/beauty/protect_hair.jpg";

	bathroom_remedies = new Image();
	bathroom_remedies.src = "images/beauty/bathroom_remedies.jpg";

	/* household images */
	
	pretreat = new Image();
	pretreat.src = "images/household/pretreat.jpg";

	laundry_room = new Image();
	laundry_room.src = "images/household/laundry_room.jpg";

	sort_it_all_out = new Image();
	sort_it_all_out.src = "images/household/sort_it_all_out.jpg";

	}

/* end image preloader */