<!--

/* ------------------------------------------------------------------------------------------------------ */

/* 
	Cache all rollover images for those with slower internet connections.
*/
function cacheImages()
{
	if( !(document.cookie === "imagesCached=true") )
	{
		document.cookie = "imagesCached=true";
		
		(new Image()).src = "assets/images/home/mn_about_on.gif";	// These paths are relative to the web page this code is executed in.
		(new Image()).src = "assets/images/home/mn_tools_on.gif";
		(new Image()).src = "assets/images/home/mn_stories_on.gif";
		(new Image()).src = "assets/images/home/mn_cowboy_on.gif";
		(new Image()).src = "assets/images/tn_about_on.gif";	
		(new Image()).src = "assets/images/tn_tools_on.gif";
		(new Image()).src = "assets/images/tn_stories_on.gif";
		(new Image()).src = "assets/images/tn_cowboy_on.gif";
	}
}			
	
/* ------------------------------------------------------------------------------------------------------ */
	
/*
	Given a path to an image (i.e., imageURL), this function opens a new window (with little GUI 
	decorations) displaying the image along with a "Close" link at the bottom of the image.  The
	parameter borderWidth is used to place a black border around the image in the window.  Typically
	passed values are 0 (for no border) and 1 (for a 1px wide black border). 
*/
function imageViewer(imageURL, borderWidth)
{
	var winWidth = 780;		// The fixed width of the image popup window, assume 800x600 screen.
	var winHeight = 580;	// The fixed height of the image popup window, assume 800x600 screen.
	var win, winContent;
	
	// Open a window with no chrome:
	win = window.open('', 'imagePopup', 'width=' + winWidth + ', height=' + winHeight + ', status=no, resizable=yes, scrollbars=yes');		

	winContent = 	
		'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
		'<html xmlns="http://www.w3.org/1999/xhtml">' +
		'<head>' +
			'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />' +
			'<title>Back at the Ranch | Image Viewer</title>' +
			'<link rel="stylesheet" href="css/base.css" type="text/css" media="screen" />' +
			'<link rel="stylesheet" href="css/print.css" type="text/css" media="print" />' +
		'</head>' +
		'<body id="imageViewerPopup">' +
			'<div>' +
				'<img src="' + imageURL + '" border="' + borderWidth + '" />' +
				'<br /><br />' +
				'<strong><a href="javascript: self.close();" target="_self">Close</a></strong>' +
			'</div>' +
		'</body>' +
		'</html>';

	// Write content to new window:
	win.document.writeln(winContent);
	
	// Flush content to window:
	win.document.close();	
	
	// Place the window in front of all other windows:
	win.focus();	
}
	
/* ------------------------------------------------------------------------------------------------------ */

function transcriptViewer(htmURL)
{
	var winWidth = 780;		// The fixed width of the image popup window, assume 800x600 screen.
	var winHeight = 580;	// The fixed height of the image popup window, assume 800x600 screen.
	
	// Open a window with no chrome and load the page pointed to via htmURL:
	window.open(htmURL, 'transcriptPopup', 'width=' + winWidth + ', height=' + winHeight + ', status=no, resizable=yes, scrollbars=yes');		
}

/* ------------------------------------------------------------------------------------------------------ */

/*
	This function processes the left navigational system.
*/
function leftNavHighlighter(highlightID)
{
	// BEGIN: Left nav highlight styles.
	var fontColor = "#5C7452";																// The same color as all the other links in the site.
	var fontWeight = "bold";																// To unbold, set this to "normal".
	var textDecoration = "none";															// The highlighted first-tier and second-tier <LI> items should not appear to be links (i.e., this is functioning as a bread-crumb list).
	var firstTierBulletImage = "";															// The path to the bullet graphic for first-tier list items - there is not first-tier list item graphic for this particular site.
	var secondTierBulletImage = "no-repeat url(assets/images/leftnav_triangle.gif) 0% 50%";	// The path to the bullet graphic for second-tier list items - this must be %'s for cross-compatibility reasons.
	// END: Left nav highlight styles.
	
	// Get pointers to nearby HTML elements:
	var curr = document.getElementById(highlightID);  	// "curr" could point to a either an outer <UL>, first-tier <LI>, or second-tier <LI>.
	var child = curr.firstChild;						// The first child of the current element.
	var sibling = child.nextSibling;					// The child's next brother.
	var par = curr.parentNode;							// The parent element of the current element.
	var gpar = par.parentNode;							// The grand parent element of the current element.
	var ggpar = gpar.parentNode;						// The great grand parent element of the current element.
	
	
	if (curr.className === "firstTierUL") 
	{
		// Assert: the current element is an outer <UL> (which does not get a bullet graphic).
		
		curr.style.display = "block";	// Make the appropriate section of the left-nav visible.
	}
	else if (par.className === "firstTierUL")
	{
		// Assert: the current element is a first-tier <LI>.
		
		// Display the first-tier UL block (i.e., display the outer left-nav):
		par.style.display = "block";
		
		// Change the style of the <A> tag within the first-tier <LI> tag:
		child.style.color = fontColor;	
		// child.style.fontWeight = fontWeight;
		child.removeAttribute("href");
		child.style.textDecoration = textDecoration;	// Stripping out the "href" attribute doesn't kill the global CSS anchor tag underline style, so set it to none here.				

		if (sibling)	// Test to see if a sibling exists, this avoids trying to access a property in the next statement that doesn't exist (and thus trhowing an error).
		{
			if (sibling.nextSibling)	// Test to see if the next sibling exists, this avoids trying to access a property in the next statement that doesn't exist (and thus trhowing an error).
			{
				if ( (sibling.nextSibling).className === "secondTierUL" )	// We can safely look at the .className property without fear of throwing an error.
				{
					// Assert: A second-tier UL block exists within this <LI> block.
					
					// Display the second-tier UL block (i.e., display the sub left-nav).
					(sibling.nextSibling).style.display = "block";	
				}
			}
		}
		// Place the bullet graphic for the current (i.e., first-tier) <LI> tag:
		// curr.style.background = firstTierBulletImage;
	}
	else if (par.className === "secondTierUL")
	{
		// Assert: the current element is a second-tier <LI> element.
		
		// Display the first-tier UL block (i.e., display the outer left-nav):
		ggpar.style.display = "block";	

		// Change the style of the <A> tag within the first-tier <LI> tag:
		(gpar.firstChild).style.color = fontColor;	
		// alert( (gpar.firstChild).nodeName );

		// Display the second-tier UL block (i.e., display the sub left-nav).
		par.style.display = "block";	
		// alert( par.nodeName );
		
		// Place the bullet graphic for the current (i.e., first-tier) <LI> tag:
		// curr.style.background = firstTierBulletImage;

		// Change the style of the <A> tag within the second-tier <LI> tag:
		child.style.color = fontColor;	
		// child.style.fontWeight = fontWeight;
		child.removeAttribute("href");
		child.style.textDecoration = textDecoration;	// Stripping out the "href" attribute doesn't kill the global CSS anchor tag underline style, so set it to none here.				
		
		// Place the bullet graphic for the current (i.e., second-tier) <LI> tag:
		curr.style.background = secondTierBulletImage;
	}
}

/* ------------------------------------------------------------------------------------------------------ */

//-->
