/* -------------------------------------------------------------------------- */
/*
   (c) 2004-2005 U.S. Robotics Corporation.
*/
/* -------------------------------------------------------------------------- */


/* --------------------------------------------------------------------------

	Page header and footer functions

*/

/*
	This function returns the filename of the current page.
	It looks for both slash and backward slash.

	N.B.:	It returns the filename in lowercase because
			comparisons shouldn't be case-sensitive.
*/
function getPageFilename()
{
	var strFilename = document.URL;
	var ixSeparator = strFilename.lastIndexOf("/");
	var ixSeparator2 = strFilename.lastIndexOf("\\");
	if (ixSeparator2 > ixSeparator)
		ixSeparator = ixSeparator2;
	if (ixSeparator != -1)
		strFilename = strFilename.substr(ixSeparator + 1);
	return strFilename.toLowerCase();
}

/*
	This writes out a page's header, including the optional menu bar.
	The title parameter is optional. If passed, it's written out
	as the header text.

	Example:

	<img id="idImgHeader" src="banner.gif">
	<div id="idHeader">Wireless <i>MAX</i>g PC Card and PCI Adapter User Guide</div>

	<div id="idMenu">
		<span class="clsMenuItemActive">Home</span>
		<a class="clsMenuItemInactive" href="two.html">Installation</a>
		<a class="clsMenuItemInactive" href="eleven.html">Router</a>
		<a class="clsMenuItemInactive" href="nine.html">Warranty</a>
	</div>
	<div id="idMenu2">
		<span class="clsMenuItemActive">Status</span>
		<a class="clsMenuItemInactive" href="lan.html">LAN</a>
		<a class="clsMenuItemInactive" href="device.html">Device</a>
	</div>
*/
function writeHeader()
{
	var strFilename = getPageFilename();		  /* get filename of current page */

	document.write("<img id=\"idImgHeader\" src=\"images/banner.gif\">");
	document.write("<img height=70 id=\"idImgHeader\" src=\"images/device.gif\">");
	document.write("<div id=\"idHeader\">" + strTitle + "<\/div>");

	document.write("<div id=\"idMenu\">");
	var menuSub = null;
	for (var i = 0; i < menuMain.length; ++i)
	{
		/*
			Determine if this is the current page.
			First, compare this filename with the current main menu item.
			If that's not it, check any of the current item's sub-menu items.
		*/
		var bCurrentPage = false;
		if (menuMain[i].strFilename == strFilename)
			bCurrentPage = true;
		else if (menuMain[i].menuSub != null)
		{
			for (var j = 0; j < menuMain[i].menuSub.length; ++j)
			{
				if (menuMain[i].menuSub[j].strFilename == strFilename)
				{
					bCurrentPage = true;
					break;
				}
			}
		}

		// the newline is required for there to be space between the tabs
		if (bCurrentPage)
		{
			document.write("<span class=\"clsMenuItemActive\">" + menuMain[i].strTitle + "<\/span>\n");
			menuSub = menuMain[i].menuSub;
		}
		else
			document.write("<a class=\"clsMenuItemInactive\" href=\"" + menuMain[i].strFilename + "\" title=\"" + menuMain[i].strDescription + "\">" + menuMain[i].strTitle + "<\/a>\n");
	}
	document.write("<\/div>");

	/*
		If the current menu item has a sub-menu, output it too.
	*/
	if (menuSub != null)
	{
		document.write("<div id=\"idMenu2\">");
		for (var i = 0; i < menuSub.length; ++i)
		{
			if (menuSub[i].strFilename == strFilename)
				document.write("<span class=\"clsMenuItemActive\">" + menuSub[i].strTitle + "<\/span>\n");
			else
				document.write("<a class=\"clsMenuItemInactive\" href=\"" + menuSub[i].strFilename + "\" title=\"" + menuSub[i].strDescription + "\">" + menuSub[i].strTitle + "<\/a>\n");
		}
		document.write("<\/div>");
	}

	document.write("<div id=\"idContent\">");
}


function writeFooter()
{
	document.write("<\/div>");

   document.write("<p id=\"idCopyright\">&copy; 2004-" + (new Date).getFullYear() + " U.S. Robotics Corporation.<\/p>");
}
