// when testing locally, turn off full pathname
includeAkamai = false;

var akamai = ( includeAkamai ) ? "http://a248.g.akamai.net/f/1016/606/5m/image.pathfinder.com/rsn/microsites/homebasics/" : "";

/* -------------- */

// when naming html pages and arrays
// use same name for array
// as this engine uses the page name 
// (see below: page = location.href)
// to dynamically determine the appropriate array name
// for example if page name is
// recipes.html then array should be recipesNav()
// pagename + .html 
// and 
// pagename + Nav

var recipesNav = new Array
	( 
	"best_ever_peanut_butter_oatmeal", 
	"carrot_cake", 
	"marbled_peanut_butter_brownies", 
	"oven_roasted_potatoes", 
	"ragu_nofrying_chicken_parmesan", 
	"pecan_coconut_chocolte_cake", 
	"veggie_noboiling_lasagna", 
	"slow_cooker_beef_stroganoff", 
	"honey_orangemini_cakes", 
	"panroasted_chicken_au_jus"
	);

var beautyNav = new Array
	( 
	"caress_exocitoil", 
	"lever2000"
	);

var householdNav = new Array( "snuggle_exhilarations", "wisk", "Lipton_Scaleright" );

/* -------------- */

// 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('.'));

// transfer array to new array so don't need alot of if/then statements for each new section added
// new array is only array needed and used in functions below
// that way if more sections are added, don't
// have to rewrite pages, can just keep adding sections (above)
tempArray = eval(whichDir + "Nav");
whichFrame = whichDir + "Frame";
//whichImage = whichDir + "Image";
totalPages = tempArray.length;

// dynamically write iframe.
// this way to change order of pages,
// only need to change order of elements in array.
function writeIFrame()
	{
	var iFrame = '<iframe src="' +  whichDir + '/'+tempArray[0]+'.html" id="'+whichFrame+'" name="'+whichFrame+'" frameborder=0 scrolling=auto class="'+whichFrame+'"><\/if'+'rame>';
	document.write(iFrame);
	}

// dynamically write first image
// same reason as above
function writeImage()
	{
	/*
	beauty=250
	house=250
	recipe=177
	*/
	var width = ( whichDir=="recipes" ) ? 192 : 300;	
	var firstImage = '<img src="'+ akamai +'ima'+'ges/'+ whichDir +'/'+ tempArray[0] +'.jpg" alt="" width="'+width+'" border="0" name="frameImage">';
	document.write(firstImage);
	}

// dyamically changes the content of the page
function changeLink(whichone, section)
	{
	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 = akamai + "images/"+whichDir+"/" + tr + ".jpg";
	// change the image located 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, section);
	}

// v 3.0 2006-10-01
// finally upgrade to dynamically write
// initial frame and initial image; see top of page
// v 2.0 2006-07-10
// dynamically re-writes the mini-nav
function writeNav(whichPage, section)
	{
	// set how many nav links appear per "section"
	var interval=4;
	/*  ------------ */
	if (!section) { section=0; }

	// 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
	if (interval > totalPages ) { interval = totalPages; }
	//w = eval(whichDir + "Nav");
	if (!whichPage) {whichPage = tempArray[0];} /* tempArray formerly 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 = tempArray[intervalPrevious];		 
		previousLink=  p1 + link + p2 + previous + p4 + previousArrow + p5 + pipe;
		}
	// creates the "next" arrow (if one should be there)
	if ( intervalNext < totalPages )
		{
		next = section+1;
		link = tempArray[intervalNext]; 
		nextLink= pipe + p1 + link + p2 + 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 (tempArray[x] != whichPage) { nav = nav + p1 + tempArray[x] + p2 + 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 */

	warm_peanut_butter_dip = new Image();
	warm_peanut_butter_dip.src = "images/recipes/warm_peanut_butter_dip.jpg";

	spinich_walnut_chicken = new Image();
	spinich_walnut_chicken.src = "images/recipes/spinich_walnut_chicken.jpg";

	southwest_chicken_salsa = new Image();
	southwest_chicken_salsa.src = "images/recipes/southwest_chicken_salsa.jpg";

	shrimp_pasta_florentine = new Image();
	shrimp_pasta_florentine.src = "images/recipes/shrimp_pasta_florentine.jpg";

	pb_energy_bars = new Image();
	pb_energy_bars.src = "images/recipes/pb_energy_bars.jpg";

	grilled_steak_gorgonzola = new Image();
	grilled_steak_gorgonzola.src = "images/recipes/grilled_steak_gorgonzola.jpg";

	golden_citrus_cake = new Image();
	golden_citrus_cake.src = "images/recipes/golden_citrus_cake.jpg";

	citrus_steak_tomato_salad = new Image();
	citrus_steak_tomato_salad.src = "images/recipes/citrus_steak_tomato_salad.jpg";

	chicken_pasta_primavera = new Image();
	chicken_pasta_primavera.src = "images/recipes/chicken_pasta_primavera.jpg";

	beef_loaded_potato = new Image();
	beef_loaded_potato.src = "images/recipes/beef_loaded_potato.jpg";

	aloha_pork = new Image();
	aloha_pork.src = "images/recipes/aloha_pork.jpg";

	alfredo_noodle_paella = new Image();
	alfredo_noodle_paella.src = "images/recipes/alfredo_noodle_paella.jpg";


	/* beauty images */
	
	dove_energyglow = new Image();
	dove_energyglow.src = "images/beauty/dove_energyglow.gif";

	vaseline_cocoabutter = new Image();
	vaseline_cocoabutter.src = "images/beauty/vaseline_cocoabutter.gif";

	healthy_hair = new Image();
	healthy_hair.src = "images/beauty/healthy_hair.gif";

	beautiful_skin = new Image();
	beautiful_skin.src = "images/beauty/beautiful_skin.gif";

	skin_moisterize = new Image();
	skin_moisterize.src = "images/beauty/skin_moisterize.gif";

	take_challenge = new Image();
	take_challenge.src = "images/beauty/take_challenge.gif";

	radiant_skin = new Image();
	radiant_skin.src = "images/beauty/radiant_skin.gif";

	lever2000 = new Image();
	lever2000.src = "images/beauty/lever2000.gif";

	qtips = new Image();
	qtips.src = "images/beauty/qtips.gif";

	skin_care = new Image();
	skin_care.src = "images/beauty/skin_care.gif";

	hand_wash = new Image();
	hand_wash.src = "images/beauty/hand_wash.gif";


	/* household images */
	
	closet_calm = new Image();
	closet_calm.src = "images/household/closet_calm.gif";
	
	Lipton_Scaleright = new Image();
	Lipton_Scaleright.src = "images/household/Lipton_Scaleright.gif";
	
	wisk = new Image();
	wisk.src = "images/household/wisk.gif";

	pretreater = new Image();
	pretreater.src = "images/household/pretreater.gif";

	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";

	snuggle_exhilarations = new Image();
	snuggle_exhilarations.src = "images/household/snuggle_exhilarations.jpg";



	}

/* end image preloader */ 