function ClassTheParentList( listClass, parentClass )
{
	/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
	   | Assigns the parentClass to every list          |
	   | containing a list element of class "listClass" |
	   | [example: /visit/Champlain/]                   |
	   +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ */
	if ( document.getElementById )
	{
		var lists = document.getElementById("content").getElementsByTagName("li");
		
		for ( var i=0; i < lists.length; i++ )
		{
			if ( lists[i].className==listClass )
				lists[i].parentNode.className = parentClass;
		}
	}
}

function setIndexLength()
{
	/* Sets the length of the dropdown index.
	   Best used in the onload() and onresize() events of a document.
	   [example: /sites/antiquities/fullMap.htm]
	*/

	if ( document.getElementById )
	{
		var intLength = (document.all) ? document.body.clientHeight : window.innerHeight;

		document.getElementById("index").style.height = intLength - 150;
	}
}

function showLayer(numLayer)
{
	/* Toggles the display of <div> layers contained in a "mapLayer"
	   [example: /sites/antiquities/fullMap.htm]
	*/

	if ( document.getElementById )
	{
		/* First, search through all the <div>s in the mapLayer 
		   until you find the last visible one...
		*/
		var divisions = document.getElementById("mapLayer").getElementsByTagName("div");

		for ( var i=0; i < divisions.length; i++ )
		{
			if ( divisions[i].style.display != "none" )
			{
				/* ...then turn it off. */
				divisions[i].style.display = "none";
			}
		}

		/* Then show the specified layer. */
		document.getElementById(numLayer).style.display = "block";
	}
}

function showDot(intDot)
{
	/* Toggles the background image of <a>s contained in a "dots" layer
	   [example: /sites/antiquities/fullMap.htm]
	*/

	if ( document.getElementById )
	{
		/* First, search through all the <a>s in the dots layer 
		   until you find the one whose background image is not transparent...
		*/
		var dots = document.getElementById("dots").getElementsByTagName("a");

		for ( var i=0; i < dots.length; i++ )
		{
			if ( dots[i].style.backgroundImage != "url(../../images/spacer.gif)" )
			{
				/* ...then make it transparent. */
				dots[i].style.backgroundImage = "url(../../images/spacer.gif)";
			}
		}

		/* Then change the image of the specified <a>. */	
		document.getElementById(intDot).style.backgroundImage = "url(images/" + intDot + ".gif)";
	}
}

/* +------------------+
   | Cookie functions |
   +------------------+ */

function CanCreateCookie()
{
	/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
	   | Tests whether the client's browser can handle cookies, |
	   |  returning true if it can.                             |
	   +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ */

	document.cookie = "testCookie=Yes;";

	if ( GetCookie("testCookie")==null )
		return false;
	else
		return true;	
}

function GetCookie(cookieName)
{
	/* +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
	   | Returns the value of the cookie         |
	   | whose name you pass as an argument,     |
	   | or returns null if it can't.            |
	   | [example: ...] |
	   +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ */

	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");	// semicolons and spaces separate cookies in the cookie string

	if (cookieStartsAt==-1)		// then maybe the cookie you want is first in the object, in which case there would be no space
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");

	if (cookieStartsAt==-1)		// then your cookie doesn't exist and/or cookies have been disabled
		cookieValue = null;
	else				// otherwise...
	{				// ...capture the value
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;	// the start will be the first equal sign after the beginning of our cookie
		var cookieEndsAt = cookieValue.indexOf(";",cookieStartsAt);	// the end will be the first semicolon

		if (cookieEndsAt==-1)	// unless there were no more semicolons...
			cookieEndsAt = cookieValue.length;	// ...meaning that the cookie is at the end of the string
								// (string's length = index of last string character)

		cookieValue = cookieValue.substring(cookieStartsAt, cookieEndsAt);
	}

	return cookieValue;
}

function isChildOf(event)
{
	/* courtesy of Dr. Lawrence W. Haynes */

	var parent = event.target || event.srcElement;
	var obj = event.relatedTarget || event.toElement;

	while (obj)
	{
		if (obj == parent)
			return true;

		obj = obj.parentNode;
	}

	return false;
}

/* These functions are only used in within this document.
   They simplify the process of swapping images. 
*/

function imageOn(imgName)
{
	if (document.images)
		document.images[imgName].src = onImgArray[imgName].src;
}

function imageOff(imgName)
{
	if (document.images)
		document.images[imgName].src = offImgArray[imgName].src;
}