/* Template JavaScript functions for Duke University's OIT's Office of Web services (OWS) generated templates */

function pickRandom(range) {
	/* A random number/image generation function */
	if (Math.random) {
		return Math.round(Math.random() * (range-1));
	} else {
		var now = new Date();
		return (now.getTime() / 1000) % range;
	}
}

function randomImage(linkIndicator,locationIndicator,multipleImageIndicator,captionIndicator, level) {
	/* This function plays double-duty.  For pages that want only a single image, it generates a random number from 1 to the number of images in the imageArray, and then displays that image on the page calling the function. If 'withLargerImageLink' is passed as the linkIndicator, then the random image will also have a hyperlink that generates a pop-up window with a larger (higher-res) version of the image. If "twoColumn" is passed for "locationIndicator", then the randomImage size used will be "randomImageHeightTwoColumn" and "randomImageWidthTwoColumn"; otherwise the OneColumn sizes will be used (these values are defined in the companion javascript_definitions.js" file).  For pages that want captions for their images, "useCaptions" will be passed for captionIndicator--this will write out the alt text as a caption below the image ("noCaptions" is the default option).  Please note that you really shouldn't specify multiple images with captions, since the captions are written directly after the image code is written, spoiling the slidestrip behavior that's intended for multiple images.
	// For pages that want multiple images (i.e. if multipleImageIndicator has a numeric value greater than 1), then the function writes code for each of the random images it identifies from imageArray.  Both versions of the function put imageArray members into a single randomImage array (so that we can minimize code duplication by simply iterating across the array and generating the html code for each image in the randomImage array).
	// IF YOU'RE USING THE multipleImageIndicator, MAKE SURE THE imageArray HAS AT LEAST AS MANY MEMBERS AS the value of multipleImageIndicator!!!*/
	// First create the randomImage array, which will contain the required member identifier(s) for the imageArray.
	var randomImage = new Array();
	// First determine whether we're dealing with one or many images
	if (Number(multipleImageIndicator) > 1) {
		// For multiple random images, we need to do something more complicated than with single random images.  Basically, we need to ensure that each of the values that will be pushed into the randomImage array are unique, since these numbers correspond to the imageArray image members that will be displayed side-by-side.  (We certainly don't want two of the same image on a page!)  To accomplish this, I first experimented with a splicing technique that basically removed array members form a temporary array so that the subsequent selections of random images wouild be from an array that didn't have the previously-selected members.  Unfortunately, javascript's array deletion is pretty primitive, and I was running into difficulties with getting random numbers for members that had already been deleted (which ended up giving "undefined" indexes for imageArray).  So the next best solution is to randomly shuffle the temporary array's members and pick the first "n" members from the shuffled array using the multipleImageIndicator as "n" (the members' values will be used to pick the imageArray members).  We can still assure no duplicates!
		var temporaryArray = new Array();
		// Now populate the temporaryArray with a sequence that corresponds to the indexes of the imageArray (basically, 0 to the count of imageArray)
		for (var i = 0; i < imageArray.length; i++) {
			temporaryArray[i] = i;
		}
		// Now shuffle the temporaryArray members, (this was taken from a cards shuffling example at <http://www.brainjar.com/js/cards/default2.asp>
		var randomNumber = 0; // This is just a variable that will hold randomly-generated numbers in the for loop below.
		var numberPlaceholder = 0; // This is a placeholder for the shuffle routine (it holds an array member's value while that member's value is being replaced by another random array member's value
		for (var j = 0; j < temporaryArray.length; j++) {
			randomNumber = pickRandom(temporaryArray.length); // Generate the random number
			numberPlaceholder = temporaryArray[j]; // Push the value of the current temporaryArray member into the numberPlaceholder
			temporaryArray[j] = temporaryArray[randomNumber]; // Replace the current array member's value with the value from the randomNumber array member
			temporaryArray[randomNumber] = numberPlaceholder; // Finish the shuffle step by replacing the randomNumber array member's value with the numberPlaceholder's value. 
		}
		// Now pick a random starting point (at least multipleImageIndicator number of members away from the end), and pick the next multipleImageIndicator number of members from the shuffled array.
		var randomStartingPoint = pickRandom(temporaryArray.length - Number(multipleImageIndicator));
	
		// And now fill in randomImage with the appropriate multipleImageIndicator number of values from temporaryArray, using randomStartingPoint as the starting point..
		for (var k = 0; k < multipleImageIndicator; k++) {
			randomImage[k] = temporaryArray[randomStartingPoint + k];
		}
	} else {
		// For single images, just push a single random number into the randomImage array by generating the random mumber from the range of possible random images using the pickRandom() function
		randomImage[0] = pickRandom(imageArray.length);
	}
	// Now we need to loop through randomImage and generate the right HTML for each image that the randomImage member is pointing to in imageArray.
	var htmlCode = "";
	for (imageIndex in randomImage) {
		var imageChoice = randomImage[imageIndex];
		// Now check to see whether 'withLargerImageLink' was passed, and if so, then generate the added HTML code needed to make the imaged linked.
		if (linkIndicator == "withLargerImageLink") {
			var imageNameWithoutExtension = imageArray[imageChoice]["src"].slice(0,imageArray[imageChoice]["src"].indexOf(".jpg"));
			if (level == 2)
			{
				var openingLinkTag = '<a href="javascript:popUpWindow(\'../' + imageNameWithoutExtension + '_big.jpg\',\'popUp\',\'' + imageArray[imageChoice]["altTag"] + '\',\'840\',\'600\');">';
			}
			else
			{
				var openingLinkTag = '<a href="javascript:popUpWindow(\'' + imageNameWithoutExtension + '_big.jpg\',\'popUp\',\'' + imageArray[imageChoice]["altTag"] + '\',\'840\',\'600\');">';
			}
			var closingLinkTag = '</a>';
		} else {
			var openingLinkTag = "";
			var closingLinkTag = "";
		}
		if (locationIndicator == "twoColumn") {
			var imageHeight = randomImageHeightTwoColumn;
			var imageWidth = randomImageWidthTwoColumn;
		} else {
			var imageHeight = randomImageHeightOneColumn;
			var imageWidth = randomImageWidthOneColumn;
		}
		var captionCode = ""; // This is the default for most images (no captions), only overwritten with a "useCaption" value for captionIndicator
		if (captionIndicator == "useCaption") {
			captionCode = '<div class="caption">' + imageArray[imageChoice]["altTag"] + '</div>';
		}
		if (level == 2)
		{
			htmlCode += openingLinkTag + '<img src="../' + imageArray[imageChoice]["src"] + '" height="' + imageHeight + '" width="' + imageWidth + '" border="0"' + ' alt="' + imageArray[imageChoice]["altTag"] + '" />' + closingLinkTag + captionCode;
		}
		else
		{
			htmlCode += openingLinkTag + '<img src="' + imageArray[imageChoice]["src"] + '" height="' + imageHeight + '" width="' + imageWidth + '" border="0"' + ' alt="' + imageArray[imageChoice]["altTag"] + '" />' + closingLinkTag + captionCode;
		}
	}
	// Lastly, we want to write out the code to the document.  We need to determine whether we're dealing with a single image or multiple images and whether we're dealing with oneColumn or twoColumn image placement, since this will determine how to display the htmlCode string (right aligned or straight across).  If there are multiple images, or we're dealing with twoColumn entries, then just write out the images.  If we're dealing with a single image in a oneColumn page, then encapsultae the image in a rightfloat div.
	var imageContainerOpenTag = ""; // This is the default value, only overriden with a <div> tag for oneColumn single images
	var imageContainerCloseTag = ""; // This is the default value, only overriden with a <div> tag for oneColumn single images
	if ((randomImage.length <= 1) && (locationIndicator == "oneColumn")) {
		imageContainerOpenTag = '<div class="rightfloat">';
		imageContainerCloseTag = "</div>";
	}
	htmlCode = imageContainerOpenTag + htmlCode + imageContainerCloseTag + '\n'; // This is the final compiled HTML tag
	document.write(htmlCode); // Write it out!
	document.close(); // Close the document!

	/* The following line could be inserted in the HTML template after the <script> tag that calls randomImage() for single images:
	<noscript><div class="rightfloat"><img src="images/spacer.gif" height="1" width="1" border="0" class="rightfloat" alt="spacer image in place of random image" /></div></noscript> */
}

function findPage(pageIdentifier,matchingArray) {
	// This function basically parses through the passed-in matchingArray (which will likely be the siteArray) and finds the individual array member (or sub-members) that corresponds to the document's passed pageIdentifier. It then returns that array member back to whatever called the function.  If there is no match, then "false" is passed back (which won't match with anything).  For every top-level array member in the matchingArray array, the function runs the findUniqueId recursive function, which then takes over and recursively traverses the matchingArray array member's possible subcategory arrays.  If a match is ever found, the top-level matchingArray array member is passed back to the function caller.
	// It would be nice to have this function return context-based information for every level of the menu and submenus along with the top-level array member, but until this is needed it won't get developed....
	// First set the default results value to "false", so that no match is made by default
	var results = false;
	// Now loop through the matchingArray array, checking for a match on each top-level array member (using the findUniqueId recursive function).
	for (var arrayMember in matchingArray) {
		results = findUniqueId(pageIdentifier,matchingArray[arrayMember],matchingArray[arrayMember]);
		// For each top-level array member, check to see if the findUniqueId function found a match with the pageIdentifier and the top-level or subcategory array members (if there's a match, then the findUniqueId function will return an array object, changing the type of results from "boolean" to "object").
		if (typeof(results) == "object") {
			return results;
		}
	}
	return results; // This will only happen if no match was found
}

function findUniqueId(pageIdentifier,arrayMember,originalMatchingArrayMember) {
	// This recursive function takes an array member passed to it from the findPage function, and first checks to see if the passed-in pageIdentifier string matches the arrayMember's "unique_id" member value.  If so, then it stops checking other things and returns the originalMatchingArrayMember back to findPage, which will also end that function's looping.  If no match is found on the current arrayMember's member values, then it checks for possible subcategory arrays, and runs those arrays through itself again.  Each time this function is called, whenever a match is found, the function breaks out of its loop and returns an array member to the parent function.  Otherwise, the result set is false and it keeps checking...
	var results = false;
	if (arrayMember["unique_id"] == pageIdentifier) {
		 return originalMatchingArrayMember;
	} else if (typeof(arrayMember['subcategories']) == "object") {
		for (var subcategory in arrayMember['subcategories']) {
			results = findUniqueId(pageIdentifier,arrayMember['subcategories'][subcategory],originalMatchingArrayMember);
			if (typeof(results) == "object") {
				return results;
			}
		}
	}
	return results;
}




function generateBreadcrumb(pageIdentifier,breadcrumbLocation, level) {
	/* This function does one of two diffferent things, depending on what's passed as breadcrumbLoaction.  For a "tabImage" passed value, it finds and writes in the appropriate tab image (containing high-level breadcrumb text) to the breadcrumbs_bar part of the template.  For a "breadCrumbs" passed value, it writes out text representations of the ful breadcrumbs path (menu and any submenu listings).  It uses the document's unique pageIdentifier strings, and calls that against the siteArray[member]['unique_id'] array member, and when it matches, it pulls out the appropriate values from that array member, using the "tab_image" array members (filename, width, height, alt text, etc.) for "tabImage", and using the link_name values for the arrayMember and its possible subcategories for the "breadCrumbs" option. */
	// Find matching array member (if there is no match, then false is returned to this variable)
	var matchingArray = findPage(pageIdentifier,siteArray);
	var breadcrumbsCode = ""; // Just set this to blank (in case we have problems later identifying the appropriate breadcrumbs code to write, at least it wil be defined and blank)
	var siteLevelLink = ""; // Set to empty as a default
	var topLevelLink = ""; // Set to empty as a default
	var subcategoryLevelLink = ""; // Set to empty as a default
	var subSubcategoryLevelLink = ""; // Set to empty as a default
	var subSubSubcategoryLevelLink = ""; // Set to empty as a default
	var breakIndicator = "no"; // Set this to "no" so that various routines below will run until this variable is set to "yes"
	// And now use the matchingArray members to determine the correct navigation tab image or breadcrumb text (depending on breadcrumbLocation.  1/21/04: Note the use of typeof() to detect an array member's presence.  Netscape 4.x does not like the use of straight existence test (e.g. "if(matchingArray)" in the line below).  Stupid Netscape...)
	if (typeof(matchingArray) == "object") {
		// First figure out if we're dealing with "tabImage" or "breadCrumbs", and assign the appropriate HTML code for the respective breadcrumb element.  We'll start with tabImage, because it's more straightforward.
		if (breadcrumbLocation == "tabImage") {
			//if (navigator.appName=="Microsoft Internet Explorer"){
			var linkStartCode = '';
			var linkEndCode = '';
			if (matchingArray["link"].length > 0) {
				if (level == 2)
				{
					linkStartCode = '<a href="../' + rootRelativePath + matchingArray["link"] + '">';
				}
				else
				{
					linkStartCode = '<a href="' + rootRelativePath + matchingArray["link"] + '">';
				}
				linkEndCode = '</a>';
			}
			
				breadcrumbsCode = '<p class="navigationtab">' + linkStartCode + '<img src="images/white.gif" border="0" alt="whitespace" height="19" width="10" /><img src="images/tab_corner_lower_left.gif" alt="bordered blue and white tab edge" border="0" width="9" height="19" /><img src="' + imagesDirectory + matchingArray["tab_image"] + '" alt="' + matchingArray["tab_alt"] + '" border="0" width="' + matchingArray["tab_image_width"] + '" height="' + matchingArray["tab_image_height"] + '" />' + linkEndCode  + '</p>';
			
			/*}
			else {
				breadcrumbsCode = '<img src="images/white.gif" border="0" alt="whitespace" height="19" width="10" /><img src="images/tab_corner_lower_left.gif" alt="bordered blue and white tab edge" border="0" width="9" height="19" /><img src="' + imagesDirectory + matchingArray["tab_image"] + '" alt="' + matchingArray["tab_alt"] + '" border="0" width="' + matchingArray["tab_image_width"] + '" height="' + matchingArray["tab_image_height"] + '" />';
			} */
		} else if (breadcrumbLocation == "breadCrumbs") {
			// First thing to do is to start writing out the links to the object.  We'll do this using a hard-coded routine that progressively delves down into the array member and its subcategories to find the array member whose "unique_id" member value matches the pageIdentifier.  It only goes four levels down, unfortunately, because I couldn't figure out a nice way to have this done recursively (Javascript arrays don't deal with the concept of "parent" arrays)
			siteLevelLink = '<a href="' + rootRelativePath + '">' + siteName + '</a>'; // This can be a static-defined link to the home page
			topLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;<a href="' + rootRelativePath + matchingArray["link"] + '">' + matchingArray["title"] + '</a>'; // By default, we'll have a linked listing for the top-level matching array member (changed only if we have a match at the top-level
			if(matchingArray['unique_id'] == pageIdentifier) {
				// For matching top-level entries, make the breadcrumb a listing for the top-level (instead of a link) and set the breakIndicator to "yes".
				topLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;' + matchingArray["title"];
				breakIndicator = "yes"; 
			}
			if ((typeof(matchingArray['subcategories']) == "object") && (breakIndicator != "yes")) {
				// For matchingArrays that have subcategories and for whom we haven't yet matched the pageIndicator to a particular array member (i.e. the breakIndicator isn't "yes"), then loop through the subcategory array, trying to find a match (and through any possible sub-arrays as well).  Lather, rinse, repeat...
				for (var subcategory in matchingArray['subcategories']) {
					// The first test is to see if we have a match (breakIndicator = "yes"), and if so, break out of this loop.  (This is more applicable for the second and subsequent loops through the subcategory array, since on the first entry to the subcategory array breakIndicator is clearly set to "no" (or we wouldn't be here).
					if (breakIndicator == "yes") {
						break;
					}
					// Since we haven't found a match yet, set the subcategoryLevelLink to the current cubcategory array member (it will become a listing only if there's a match at this level). 
					subcategoryLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;<a href="' + rootRelativePath + matchingArray['subcategories'][subcategory]["link"] + '">' + matchingArray['subcategories'][subcategory]["title"] + '</a>';
					if (matchingArray['subcategories'][subcategory]["unique_id"] == pageIdentifier) {
						// For matching subcategory pages, make the subcategoryLevelLink a listing rather than a link, and set the breakIndicator to "yes".
						subcategoryLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;' + matchingArray['subcategories'][subcategory]["title"];
						subSubcategoryLevelLink = ''; // Make sure to clear any possible leftover levels
						subSubSubcategoryLevelLink = ''; // Make sure to clear any possible leftover levels
						breakIndicator = "yes";
					}
					// Before we leave for the next subcategory, let's check to see if the current subcategory has a subcategory array, and do the same routine.
					if ((typeof(matchingArray['subcategories'][subcategory]['subcategories']) == "object") && (breakIndicator != "yes")) {
						// For matchingArrays that have sub-subcategories and for whom we haven't yet matched the pageIndicator to a particular array member or subcategory array member(i.e. the breakIndicator isn't "yes"), then loop through the sub-subcategory array, trying to find a match.  Lather, rinse, repeat...
						for (var subSubcategory in matchingArray['subcategories'][subcategory]['subcategories']) {
							// The first test is to see if we have a match (breakIndicator = "yes"), and if so, break out of this loop.  (This is more applicable for the second and subsequent loops through the sub-subcategory array, since on the first entry to the sub-subcategory array breakIndicator is clearly set to "no" (or we wouldn't be here).
							if (breakIndicator == "yes") {
								break;
							}
							// Since we haven't found a match yet, set the subSubcategoryLevelLink to be a link to the current sub-subcategory array member (it will become a listing only with a match). 
							subSubcategoryLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;<a href="' + rootRelativePath + matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]["link"] + '">' + matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]["title"] + '</a>';
							if (matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]["unique_id"] == pageIdentifier) {
								subSubcategoryLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;' + matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]["title"];
								subSubSubcategoryLevelLink = ''; // Make sure to clear any possible leftover subSubSubcategoryLevel entries
								// For matching subcategory pages, set the breakIndicator to "yes".
								breakIndicator = "yes";
							}
							// Before we leave for the next subSubcategory, let's check to see if the current subSubcategory has a subSubSubcategory array, and do the same routine.
							if ((typeof(matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]['subcategories']) == "object") && (breakIndicator != "yes")) {
								// For matchingArrays that have sub-subcategories and for whom we haven't yet matched the pageIndicator to a particular array member or subcategory array member(i.e. the breakIndicator isn't "yes"), then loop through the sub-subcategory array, trying to find a match.  Lather, rinse, repeat...
								for (var subSubSubcategory in matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]['subcategories']) {
									// The first test is to see if we have a match (breakIndicator = "yes"), and if so, break out of this loop.  (This is more applicable for the second and subsequent loops through the sub-subcategory array, since on the first entry to the sub-subcategory array breakIndicator is clearly set to "no" (or we wouldn't be here).
									if (breakIndicator == "yes") {
										break;
									}
									// Since we haven't found a match yet, set the subSubcategoryLevelLink to be a listing of the current sub-subcategory array member (it will stay as a listing because we're not traversing further down than this). 
									subSubSubcategoryLevelLink = '&nbsp;&nbsp;&gt;&gt;&nbsp;' + matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]['subcategories'][subSubSubcategory]["title"];
									if (matchingArray['subcategories'][subcategory]['subcategories'][subSubcategory]['subcategories'][subSubSubcategory]["unique_id"] == pageIdentifier) {
										// For matching subSubSubcategory pages, set the breakIndicator to "yes".
										breakIndicator = "yes";
									}
								}
							}

						}
					}
				}
			}
			// Now at this point we have values for all levels of the breadcrumbs (some possibly blank, some possibly links, one possible a listing).  So now we need to generate the breadcrumbs HTML code for the page, but only if breakIndicator is set to "yes" (if not, then the full breadcrumbs path wasn't found).  As long as a valid path is found, the breadcrumbs will contain a linked listing for the home page (siteLevlLink), and will contain either a listing for the current menu option (if that's where we're at) or else a linked listing of the menu option (topLevelLink), plus possibly a listing or link for the appropriate subcategory below it (subcategoryLevelLink), and possibly a listing for the appropriate.sub-subcategory (subSubategoryLevelLink).
			if (breakIndicator == "yes") {
				var breadcrumbsCode = '<p class="breadcrumbs">' + siteLevelLink + topLevelLink + subcategoryLevelLink + subSubcategoryLevelLink + subSubSubcategoryLevelLink + '</p>';
			}

			
			/*
			// For all "breadCrumbs" breadcrumbLocation values (presumably the only other value passed), check for possible subcategories, then generate the HTML code for a full breadcrumb.  If there are subcategories, loop through the subcategory values and try to match against the pageIdentifier to get a very specific breadcrumb.  Note that the resulting breadcrumb fragment will be text-based, so this is only applicable to the "breadCrumbs" version of breadcrumbLocation.
			var subcategoryCrumb = "";
			var menuLinkTag = "";
			var menuLinkEndTag = "";
			if ((typeof(matchingArray['subcategories']) == "object") && (breadcrumbLocation == "breadCrumbs")) {
				for (subcategories in matchingArray['subcategories']) {
					if (matchingArray['subcategories'][subcategories]["unique_id"] == pageIdentifier) {
						// For matching subcategory pages, generate the HTML code for displaying the link_name of the subcategory page, as well as the right code to provide links to the subcategory page's parent menu page
						subcategoryCrumb = '&nbsp;&nbsp;&gt;&gt;&nbsp;' + matchingArray["subcategories"][subcategories]["title"];
						menuLinkTag = '<a href="' + rootRelativePath + matchingArray["link"] + '">';
						menuLinkEndTag = "</a>";
						break;
					}
				}
			}
			// Now generate the breadcrumbs HTML code for the page.  The breadcrumbs will always contain a linked listing for the home page, and will contain either a listing for the current menu option (if that's where we're at), or else a linked listing of the menu option, plus a listing of the subcategory where we're at.

			breadcrumbsCode = '<p class="breadcrumbs"><a href="' + rootRelativePath + '">' + siteName + '</a> &gt;&gt; ' + menuLinkTag + matchingArray["link_alt"] + menuLinkEndTag + subcategoryCrumb + '</p>';
			*/
		}
	} else {
	// If there is no matchingArray, then figure out whether we're dealing with a tabImage r a breadCrumbs parameter.  For the former, just write in a blank space where the navigation tab should be.  For the latter, just provide a link to the Home page.
		if (breadcrumbLocation == "tabImage") {
			if (level == 2)
			{
				breadcrumbsCode = '<img src="../images/spacer.gif" alt="___" border="0" width="1" height="19" />';
			}
			else
			{
				breadcrumbsCode = '<img src="images/spacer.gif" alt="___" border="0" width="1" height="19" />';
			}
		} else if (breadcrumbLocation == "breadCrumbs") {
			if (level == 2)
			{
				breadcrumbsCode = '<p class="breadcrumbs"><a href="../' + rootRelativePath + '">' + siteName + '</a></p>';
			}
			else
			{
				breadcrumbsCode = '<p class="breadcrumbs"><a href="' + rootRelativePath + '">' + siteName + '</a></p>';
			}
		}
	}
	document.write(breadcrumbsCode);
	document.close();
}


function imagePreloader() {
	/* This is a quick function that iterates through the siteArray and prelaods the "on" state images for all of the graphical leftside menus.  It gives each "on" image a name that matches the unique_id of whatever siteArray array member that image correpsonds to.  This image is then specified by generateLeftMenu, so that the preloaded image is called upon. */
	for (arrayMember in siteArray) {
		// only preload images for array members that use images for the left-side nav (check on whether the 'link_image_name' member exists).
		if (typeof(siteArray[arrayMember]['link_image_name']) == "string") {
			self[siteArray[arrayMember]['unique_id']] = new Image();
			self[siteArray[arrayMember]['unique_id']].src = siteArray[arrayMember]['link_image_name'] + "_over." + siteArray[arrayMember]['link_image_extension'];
		}
	}
}

function generateLeftMenu(pageIdentifier, level) {
	/* This function writes out the left-side navigation menu using the MenuMaker functions defined below.  It uses the passed-in pageIdentifier to figure out which main category is the owner (or parent) of the particular page calling this function, and makes sure that that menu item is highlighted as "selected".  It uses each of the siteArray array members to determine the text/image names (and sizes) for the "on", "off", and "selected" states, as well as any possible subcategories.*/
	// First determine whether we have a menu divider line, and figure out its necessary HTML code.  This divider line will appear below every menu item, as well as below the leftsideHomeLink (if provided).  The only test for whether this divider line exists is whether leftsideMenuDividerName has a non-empty value.
	var leftsideMenuDivider = "";
	if (leftsideMenuDividerName.length > 0) {
		if (level == 2)
		{
		leftsideMenuDivider = '<br /><img src="../' + imagesDirectory + leftsideMenuDividerName + '" width="' + leftsideMenuDividerWidth + '" height="' + leftsideMenuDividerHeight + '" border="0" alt="grey divider" /><br />';
		}
		else 
		{
			leftsideMenuDivider = '<br /><img src="' + imagesDirectory + leftsideMenuDividerName + '" width="' + leftsideMenuDividerWidth + '" height="' + leftsideMenuDividerHeight + '" border="0" alt="grey divider" /><br />';
		}
	}
	// Now write out out the main left-side nav page link (that contains the name of the site).  Test to see if text links are being used (leftsideHomeLinkText has a non-empty strign value) or if graphic links are being used for the top link (leftsideHomeLinkImageName has a non-empty string value).
	if (leftsideHomeLinkImageName.length > 0) {
		if (level == 2)
		{
			var leftSideNavFirstLine = '<a href="../' + rootRelativePath + '"><img src="../' + imagesDirectory + leftsideHomeLinkImageName + '" height="' + leftsideHomeLinkImageHeight + '" width="' + leftsideHomeLinkImageWidth + '" border="0" alt="' + siteName + '" /></a>' + leftsideMenuDivider;
		}
		else
		{
			var leftSideNavFirstLine = '<a href="' + rootRelativePath + '"><img src="' + imagesDirectory + leftsideHomeLinkImageName + '" height="' + leftsideHomeLinkImageHeight + '" width="' + leftsideHomeLinkImageWidth + '" border="0" alt="' + siteName + '" /></a>' + leftsideMenuDivider;
		}
	} else if (leftsideHomeLinkText.length > 0) {
		var leftSideNavFirstLine = '<a href="' + rootRelativePath + '">' + leftsideHomeLinkText + '</a>' + leftsideMenuDivider;
	} else {
		var leftSideNavFirstLine = ''; // Just in case the site owner forgot to set up anything for the top leftnav link, a blank string will be used (this could be used to customize the left-nav look to remove the top listing...).
	}
	document.writeln(leftSideNavFirstLine);
	// Now match up the pageIdentifier to its appropriate siteArray member.  (If there is no match, then matchingArray is false)
	var matchingArray = findPage(pageIdentifier,siteArray);
	// Now sort and then iterate through the siteArray, writing out a line for each of the main-level array members.  The matchingArray member must have the "selected" image passed in to the MenuMaker--all others just have the "off" value passed in.  The submenuInvoker is the MM function call to show submenus for leftside nav menus that have subcategories.  Right now we're just going to use a simple sort() method, not using the "order" sub-key member. 11/24/2003 NOTE: Apparently Netscape 7.0 (Mozilla 1.0.1) doesn't support the sort() method and silently ignores the array, so for now we won't even implement siteArray.sort() . Netscape 7.1 does support sort(), so if you don't care about Mozilla bugs (bug #157652 in this case), then implement the sort() method.  For now this is acceptable, because the site array was defined in order.

	var lastItemIndicator = ""; // This is a dummy variable to hold the last id of the siteArray that has valid submenus (subcategory arrays with entries that are meant to display submenus)  (since Javascript's a bit kludgy when it comes to associative arrays, and you can't just use length() to find out how long the associative array is (and besides, not all arrays elements may have subcategories, and not all subcategory arrays are supposed to be submenus--some may just have lists of associated pages)
	var submenuEntry = 0; // this is a dummy variable that wil be used indicates whether any particular siteArray member has any subcategories that need to show up as a submenu.
	for (var arrayMember in siteArray) {
		// The first test is to see if the current arrayMember is the current page (or parent page)
		if ((siteArray[arrayMember] == matchingArray) && typeof(matchingArray) == "object") {
			var offOrSelected = "_sel.";
		} else {
			var offOrSelected = ".";
		}
		// The next test is to see if the arrayMember has subcategories (submenus), and if so, then to invoke the mmLoadMenus function for each subcategory, and then to code in the necessary code for calling submenus on the page.  If there are no subcategories, then leave submenuInvoker as an empty string.
		var submenuInvoker = "";
		if ((typeof(siteArray[arrayMember]['submenuName']) == "string") && (typeof(siteArray[arrayMember]['subcategories']) == "object")) {
			// First invoke the submenu generator, and populate "submenuEntry" with the result of the function call (this will be used later).  submenuEntry will be either 0 (no members of the subcategory array are intended to show as submenus) or 1 (the subcategory array has entries intended for submenus.).
			submenuEntry = mmLoadMenus(siteArray[arrayMember]);
			// If submenuEntry is > 0, then write out the code for that submenu
			if (submenuEntry > 0) {
				submenuInvoker = "MM_showMenu(window." + siteArray[arrayMember]['submenuName'] + "," + (siteArray[arrayMember]['link_image_width'] || leftsideMenuWidth) + ",0,null,'" + siteArray[arrayMember]['unique_id'] + "');";
				// Now assign the current arrayMember to the lastItemIndicator.  This will be used to invoke writeMenus() at the end of this function.
				lastItemIndicator = arrayMember;
			}
		}
		// the last step of the for loop is to actually write out the necessary HTML that codes in the menus and submenus for that particular arrayMember (the syntax for the MM functions is from Macromedia).  Make sure to write the correct code based on whether the link is an image or text, though... (1/23/04 NOTE: Currently the implementation of text submenus is not functional...)
		// Let's first define default empty values for non-links
		var mouseoverCommands = "";
		var linkAnchorCodeStart = "";
		var linkAnchorCodeEnd = "";
		if (typeof(siteArray[arrayMember]['link_text']) == "string") {
			// Check to see if a link is provided in this arrayMember (if not, then it's probably a spacer, and no <a> element is needed either)
			if (siteArray[arrayMember]['link'] != '') {
				mouseoverCommands = "MM_swapImage('" + siteArray[arrayMember]["unique_id"] + "','','" + "something" + "',1);";
				linkAnchorCodeStart = '<a href="' + siteArray[arrayMember]["link"] + '" onmouseover="' + mouseoverCommands + submenuInvoker + '" onmouseout="MM_swapImgRestore();MM_startTimeout()">';
				linkAnchorCodeEnd = "</a>";
			}
			var linkTextOrImage = siteArray[arrayMember]["link_text"];
		} else if (typeof(siteArray[arrayMember]['link_image_name']) == "string") {
			// Check to see if a link is provided in this arrayMember (if not, then it's probably a spacer, and no <a> element is needed either)
			if (siteArray[arrayMember]['link'] != '') {
				mouseoverCommands = "MM_swapImage('" + siteArray[arrayMember]["unique_id"] + "','','" + imagesDirectory + siteArray[arrayMember]["link_image_name"] + "_over." + siteArray[arrayMember]["link_image_extension"] + "',1);";
				if (level == 2)
				{
					linkAnchorCodeStart = '<a href="../' + siteArray[arrayMember]["link"] + '" onmouseover="' + mouseoverCommands + submenuInvoker + '" onmouseout="MM_swapImgRestore();MM_startTimeout()">';
				}
				else
				{
					linkAnchorCodeStart = '<a href="' + siteArray[arrayMember]["link"] + '" onmouseover="' + mouseoverCommands + submenuInvoker + '" onmouseout="MM_swapImgRestore();MM_startTimeout()">';
				}
				linkAnchorCodeEnd = "</a>";
			}
			if (level == 2)
			{
				var linkTextOrImage = '<img src="' + '../' + imagesDirectory + siteArray[arrayMember]["link_image_name"] + offOrSelected + siteArray[arrayMember]["link_image_extension"] +'" name="' + siteArray[arrayMember]["unique_id"] + '" width="' + siteArray[arrayMember]["link_image_width"] + '" height="' + siteArray[arrayMember]["link_image_height"] + '" border="0" id="' + siteArray[arrayMember]["unique_id"] + '" alt="' + siteArray[arrayMember]["link_alt"] + '" />';
			}
			else
			{
			var linkTextOrImage = '<img src="' + imagesDirectory + siteArray[arrayMember]["link_image_name"] + offOrSelected + siteArray[arrayMember]["link_image_extension"] +'" name="' + siteArray[arrayMember]["unique_id"] + '" width="' + siteArray[arrayMember]["link_image_width"] + '" height="' + siteArray[arrayMember]["link_image_height"] + '" border="0" id="' + siteArray[arrayMember]["unique_id"] + '" alt="' + siteArray[arrayMember]["link_alt"] + '" />';
			}
		}
		// Last check: see if linkTextOrImage contains anything in it.  If not, then presumably this is an array memebr that's not intended to have a visible presence in the leftside menu.
		if (linkTextOrImage.length > 0) {
				document.write(linkAnchorCodeStart + linkTextOrImage + linkAnchorCodeEnd + leftsideMenuDivider);
		}
	}
	document.close();
	// As the final step, we need to write out the submenus, but only if we have an entry for lastItemIndicator (which has the last valid submenu).  MM Menu appears to need us to do this just once, and do it from the last submenu id given. (I imagine it could be any valid submenu entry, but this seemed the safest way to do it.)
	// 2-20-2004 NOTE: FOR SOME REASON NETSCAPE 4.X IS UNABLE TO RETURN FROM THE writeMenus() call, and thus fails completely to do anything else in the function once the writeMenus() function is called.  So the easy solution is to put this routine at the end.  I wasted several hours trying to trace the problem, but Netscape wouldn't give an error--it just wouldn't return from the writeMenus() function.  All other browsers do just fine....
	if (lastItemIndicator.length > 0) {
		self[siteArray[lastItemIndicator]['submenuName']].writeMenus();
	}
}

function popUpWindow(linkURL, windowName, windowTitle, windowWidth, windowHeight) {
	// The following code snippet provides the pop-up window functionality for external links.  The basic idea is that the function opens a smaller window (without address bar) and then turns the focus onto it.  By default it's meant for opening up pop-ups of images, but if you set windowTitle to "noImage", then it will open up the pop-up using the linkURL.
	if (windowTitle != "noImage") {
		var popUpWin = window.open('', windowName, "menubar,resizable,noscrollbars,width=" + windowWidth + ",height=" + windowHeight);
		var popUpDoc = popUpWin.document;
		popUpDoc.write('<html><head><title>' + windowTitle + '</title></head><body><p><img src="' + linkURL + '" border="0" alt="' + windowTitle + '" /></p></body></html>');
		popUpDoc.close();
	} else {
		var popUpWin = window.open(unescape(linkURL), windowName, "menubar,resizable,scrollbars,width=" + windowWidth + ",height=" + windowHeight);
		popUpWin.focus();
	}
	return false;
}

function imageLoader(imageURL, windowName, windowTitle) {
	// 12-1-03 NOTE: This function is not used, because of incompatibilities with Safari and IE on Macs (the former doesn't accept onload events, the latter doesn't seem to implement it properly, and Safari and Opera users will still be blocked with their default settings).
	// This is a very small function that simply (pre)loads up an image and then calls the following function, popUpImageWindow, after the image is loaded.  It's very useful for the following function (popUpImageWindow) because having this function's statements run separately from the main popUpImageWindow() function forces the script and browser to _wait_ until the image is loaded, and thus avoids timing issues in which the function proceeds before actually loading the image and retrieving the dimensions of the image.  It's basically a preload function.  Note that you need to create new methods/attributes for the imageObject image, so that all the necessary attributes are passed through via the "onload" event handler (you can't pass stuff like "windowName" and "windowTitle" to popUpImageWindow through normal function arguments (e.g. calling "popUpImageWindow(image,windowName,windowTitle)"), because the onload event handler requires a special evt call of a function.
	// PLEASE NOTE: Because this function uses the "onload" event handler, some programs may perceive this pop-up call as a prohibited action (too similar to ad pop-ups), so sometimes users will not be able to see the pop-up window at all because it's been suppressed by the browser or an add-in program.  For OWS testing purposes, the only browser that exhibits this behavior is Opera 7, when "refuse pop-up windows" or "allow requested pop-up windows only" is selected.  For this reason, this function will tell Opera users about this behavior (assuming that the users have set their Opera browsers to report themselves as Opera browsers, not as some other form).
	//alert("ImageLoader intiated");
	imageObject = new Image();
	imageObject.src = imageURL;
	imageObject.windowName = windowName;
	imageObject.windowTitle = windowTitle;
	imageObject.onload = popUpImageWindow;
	//alert("you've made it past the hard stuff--onload, src("+imageObject.src+"), windowName("+imageObject.windowName+"), windowTitle("+imageObject.windowTitle+")");
	// Lastly, check to see if the browser is reporting that it's an Opera browser.  If it is, then tell the user that they may not be able to see the pop-up if they have restricted pop-ups in their browser.
	//if(navigator.appName.indexOf("Opera") >= 0) {
	//	alert("Attention Opera User:\n\nYou may not be able to see the pop-up window you have just selected, depending on your browser settings.  If you have chosen \"Refuse pop-up windows\" or \"Open requested pop-up windows only\" in your preferences settings, then the image you just clicked on will probably not display in a separate window.\n\nTo see the pop-up image, you will want to change your preferences to allow pop-up windows (in Opera 7, you can control this using the F12 key).\n\nWe apologize for any inconvenience.");
	//}
}

function popUpImageWindow(evt) {
	// The following code snippet provides a pop-up window functionality for images (jpegs, gifs).  The basic idea is that the function opens a window slightly larger than the image (without address bar) and then turns the focus onto it.
	// First get the image and get its attributes, calling the preloader imageLoader() function
	var popUpImageWidth = this.width + 50; // provide a slight cushion left and right to account for scroll and window bars
	var popUpImageHeight = this.height + 40; // provide a slight cushion top and bottom to account for status and file menu bars
	//alert("popUpImage attributes:\n\nwidth: " + this.width + "\n(popUpImageWidth: " + popUpImageWidth + ")\n\nheight: " + this.height + "\n(popUpImageHeight: " + popUpImageHeight + ")\n\n(Got zeros?  Don't understand...)");
	// Now open up a new window and write in the code that will show the image and provide the windowTitle as the title of the window
	var popUpWin = window.open('', this.windowName, "menubar,resizable,noscrollbars,width=" + popUpImageWidth + ",height=" + popUpImageHeight);
	// Now write out the document source code (we need to do this so that we can manually set the Title of the window (if we used the popUpWindow function, then the image filename would be the window's title)
	var popUpDoc = popUpWin.document;
	popUpDoc.write('<html><head><title>' + this.windowTitle + '</title></head><body><p><img src="' + this.src + '" border="0" width="' + this.width + '" height="' + this.height + '" alt="' + this.windowTitle + '" /></p></body></html>');
	popUpDoc.close();
	popUpWin.focus();
}

/* Now the fun part, defining the submenus using the siteArray values !!! */
function mmLoadMenus(siteArrayMember) {
	// This is a modified macromedia function that defines all the possible menus on a page.  It appears to simply create floating variables on the window, using text and link strings passed to it.  This has been modified for the Duke templated sites by having individual siteArray members passed to it, and then iterating across the subcategory array members for the siteArray member.  All the submenu aesthetic definitions are done in the "static definitions" section of the javascript.
	// Define the submenuname
	var submenuName = siteArrayMember['submenuName']
	// Now define the validSubmenuIndicator, which is the value passed back to the mmLoadMenus function caller.  This variable indicates whether a valid submenu exists (value of 1);  a "valid submenu" is defined as one in which at least one subcategory member has a page defined for its "link_name" key.
	var validSubmenuIndicator = 0;
	// First step, check to see if the menu already exists (if it's been defined).  Assuming it doesn't already exist, figure out the maximum length of the subcategory link_names (so you can figure out how wide the submenu needs to be), and then define the new floating variable, using the siteArray's submenuName.  Most of these values are just default MM Menu values, but can be modified in the "static definitions" portion of the javascript.
	if (!self[submenuName]) {
		// To figure out the maximum length of the subcategory entries, do a quick loop through the subcategories array and bubble-sort out the longest entry.  This must also check to see if the particular subcategory is actually meant to appear in the menu--that is, if the "link_name" member is somethig other than "".  Then do a quick math formula to determine the right width (based on the assumption that the menu width will be defined in pixels--if we want to use ems (which is really better), then a lot more logic needs to be written in to the whole routine, since the MM maker routines are hard coded to deal with pixels).
		var maximumSubcategoryWidth = 0;
		for (subcategories in siteArrayMember['subcategories']) {
			if (siteArrayMember['subcategories'][subcategories]["link_name"].length > maximumSubcategoryWidth) {
				maximumSubcategoryWidth = siteArrayMember['subcategories'][subcategories]["link_name"].length;
			}
		}
		// Check to see if there are any subcategories (maximumSubcategoryWidth is greater than 0).  If so, then generate the appropriate menu, and remember to make validSubmenuIndicator equal to 1 (since we've got a valid submenu).
		if (maximumSubcategoryWidth > 0) {
			submenuWidth = Math.ceil((maximumSubcategoryWidth * (submenusFontSize * (2 / 3)) + (submenusPadding * 2)));
			self[submenuName] = new Menu("root",submenuWidth,submenuPixelHeight,submenusFontFamily,submenusFontSize,submenusLinkFontColor,submenusHoverLinkFontColor,submenusIndividualMenuAreaBackgroundColor,submenusHoverBackgroundColor,submenusHorizontalAlignment,submenusVerticalAlignment,submenusPadding,submenusSpacing,submenusHidingTimeOut,submenusXaxisOffset,submenusYaxisOffset,submenusRelativeToItem,submenusOpaque,submenusVerticalIndicator,submenusItemIndent,true,true);
			for (subcategories in siteArrayMember['subcategories']) {
				if (siteArrayMember['subcategories'][subcategories]["link_name"] != "") {
					self[submenuName].addMenuItem(siteArrayMember['subcategories'][subcategories]['link_name'],"location='" + siteArrayMember['subcategories'][subcategories]['link'] + "'");
				}
			}
			// Now do the rest of the customization (used from the default MM Menu values)
			self[submenuName].hideOnMouseOut = true;
			self[submenuName].bgColor = submenusInteriorAndRightandBottomBorderColors;
			self[submenuName].menuBorder = 1;
			self[submenuName].menuLiteBgColor = submenusLeftAndTopBorderColors;
			self[submenuName].menuBorderBgColor = submenusBaseLayerBackgroundColor;
			// self[submenuName].writeMenus();
			validSubmenuIndicator = 1;
		}
	}
	return validSubmenuIndicator;
}

function getCurrentYear() {
	// This is a small function that returns the current year, based on the time provided by the current browser's machine.
	document.writeln((new Date()).getFullYear());
	document.close();
}

function getLastModified() {
	// This is a small function that returns the last modified date of the current document.  We need to use the Date() function to get the document's lastModified date, so that we can display the date consistently across browsers.
	var lastModifiedDate = new Date(document.lastModified);
	var lastModifiedDateString = (lastModifiedDate.getMonth() + 1) + "/" + lastModifiedDate.getDate() + "/" + lastModifiedDate.getFullYear();
	document.write("This page was last modified: " + lastModifiedDateString + "<br />\n");
	document.close();
}

function submenuIterator() {
	// This is just a small iterating function that gives all the non-function attributes of the submenus defined by mmLoadMenus (above).  It's used purely for diagnostic purposes, and the function call must be hand-inserted into a page to show up (using a document.writeln(submenuIterator()); script call).  It shows quite a bit of useful information about the submenus' attributes.
	results = "";
	for (arrayMember in siteArray) {
		if (siteArray[arrayMember]["subcategories"]) {
			results += '<div style="border: 1px thin solid;"><b>window.' + siteArray[arrayMember]["submenuName"] + '</b>\n<ul>\n';
			for (attribute in self[siteArray[arrayMember]["submenuName"]]) {
				if ((attribute != "addMenuItem") && (attribute != "writeMenus") && (attribute != "MM_showMenu") && (attribute != "onMenuItemOver") && (attribute != "onMenuItemAction") && (attribute != "hideMenu") && (attribute != "hideChildMenu") && (attribute != "hideMenu") && (attribute != "actions")) {
					results += '<li>' + attribute + ': ' + self[siteArray[arrayMember]["submenuName"]][attribute] + '</li>\n';
				}
			}
			results += '</ul>\n</div>\n';
		}
	}
	return results;
}

/**
 * mm_menu 20MAR2002 Version 6.0
 * Andy Finnell, March 2002
 * Copyright (c) 2000-2002 Macromedia, Inc.
 *
 * based on menu.js
 * by gary smith, July 1997
 * Copyright (c) 1997-1999 Netscape Communications Corp.
 *
 * Netscape grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */

function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
	this.version = "020320 [Menu; mm_menu.js]";
	this.type = "Menu";
	this.menuWidth = mw;
	this.menuItemHeight = mh;
	this.fontSize = fs;
	this.fontWeight = "plain";
	this.fontFamily = fnt;
	this.fontColor = fclr;
	this.fontColorHilite = fhclr;
	this.menuBorder = 1;
	this.menuBgOpaque=opq;
	this.menuItemBorder = 1;
	this.menuItemIndent = idt;
	// this.bgColor = "#555555"; (Ignored)
	this.menuItemBgColor = bg;
	this.menuItemVAlign = valgn;
	this.menuItemHAlign = halgn;
	this.menuItemPadding = pad;
	this.menuItemSpacing = space;
	// this.menuLiteBgColor = "#ffffff"; (Ignored)
	// this.menuBorderBgColor = "#777777"; (Ignored)
	this.menuHiliteBgColor = bgh;
	// this.menuContainerBgColor = "#cccccc"; (Ignored)
	this.childMenuIcon = "arrows.gif";
	this.submenuXOffset = sx;
	this.submenuYOffset = sy;
	this.submenuRelativeToItem = srel;
	this.vertical = vert;
	this.items = new Array();
	this.actions = new Array();
	this.childMenus = new Array();
	this.hideOnMouseOut = true;
	this.hideTimeout = to;
	this.addMenuItem = addMenuItem;
	this.writeMenus = writeMenus;
	this.MM_showMenu = MM_showMenu;
	this.onMenuItemOver = onMenuItemOver;
	this.onMenuItemAction = onMenuItemAction;
	this.hideMenu = hideMenu;
	this.hideChildMenu = hideChildMenu;
	if (!window.menus) window.menus = new Array();
	this.label = " " + label;
	window.menus[this.label] = this;
	window.menus[window.menus.length] = this;
	if (!window.activeMenus) window.activeMenus = new Array();
}

function addMenuItem(label, action) {
	this.items[this.items.length] = label;
	this.actions[this.actions.length] = action;
}

function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function writeMenus(container) {
	if (window.triedToWriteMenus) return;
	var agt = navigator.userAgent.toLowerCase();
	window.mmIsOpera = agt.indexOf("opera") != -1;
	if (!container && document.layers) {
		window.delayWriteMenus = this.writeMenus;
		var timer = setTimeout('delayWriteMenus()', 500);
		container = new Layer(100);
		clearTimeout(timer);
	} else if (document.all || document.hasChildNodes || window.mmIsOpera) {
		document.writeln('<span id="menuContainer"></span>');
		container = FIND("menuContainer");
	}

	window.mmHideMenuTimer = null;
	if (!container) return;	
	window.triedToWriteMenus = true; 
	container.isContainer = true;
	container.menus = new Array();
	for (var i=0; i<window.menus.length; i++) 
		container.menus[i] = window.menus[i];
	window.menus.length = 0;
	var countMenus = 0;
	var countItems = 0;
	var top = 0;
	var content = '';
	var lrs = false;
	var theStat = "";
	var tsc = 0;
	if (document.layers) lrs = true;
	for (var i=0; i<container.menus.length; i++, countMenus++) {
		var menu = container.menus[i];
		if (menu.bgImageUp || !menu.menuBgOpaque) {
			menu.menuBorder = 0;
			menu.menuItemBorder = 0;
		}
		if (lrs) {
			var menuLayer = new Layer(100, container);
			var lite = new Layer(100, menuLayer);
			lite.top = menu.menuBorder;
			lite.left = menu.menuBorder;
			var body = new Layer(100, lite);
			body.top = menu.menuBorder;
			body.left = menu.menuBorder;
		} else {
			content += ''+
			'<div id="menuLayer'+ countMenus +'" style="position:absolute;z-index:1;left:10px;top:'+ (i * 100) +'px;visibility:hidden;color:' +  menu.menuBorderBgColor + ';">\n'+
			'  <div id="menuLite'+ countMenus +'" style="position:absolute;z-index:1;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;" onmouseout="mouseoutMenu();">\n'+
			'  <div id="menuFg'+ countMenus +'" style="position:absolute;left:'+ menu.menuBorder +'px;top:'+ menu.menuBorder +'px;visibility:hide;">\n'+
			'';
		}
		var x=i;
		for (var i=0; i<menu.items.length; i++) {
			var item = menu.items[i];
			var childMenu = false;
			var defaultHeight = menu.fontSize + (2 * menu.menuItemPadding) + 10;
			if (item.label) {
				item = item.label;
				childMenu = true;
			}
			menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
			var itemProps = '';
			if( menu.fontFamily != '' ) itemProps += 'font-family:' + menu.fontFamily +';';
			itemProps += 'font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + 'px;';
			if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
			if (document.all || window.mmIsOpera) 
				itemProps += 'font-size:' + menu.fontSize + 'px;" onmouseover="onMenuItemOver(null,this);" onclick="onMenuItemAction(null,this);';
			else if (!document.layers) {
				itemProps += 'font-size:' + menu.fontSize + 'px;';
			}
			var l;
			if (lrs) {
				var lw = menu.menuWidth;
				if( menu.menuItemHAlign == 'right' ) lw -= menu.menuItemPadding;
				l = new Layer(lw,body);
			}
			var itemLeft = 0;
			var itemTop = i * menu.menuItemHeight;
			if( !menu.vertical ) {
				itemLeft = i*menu.menuWidth;
				itemTop = 0;
			}
			var dTag = '<div id="menuItem'+ countItems +'" style="position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';
			var dClose = '</div>'
			if (menu.bgImageUp) dTag = '<div id="menuItem'+ countItems +'" style="background:url('+menu.bgImageUp+');position:absolute;left:' + itemLeft + 'px;top:'+ itemTop +'px;'+ itemProps +'">';

			var left = 0, top = 0, right = 0, bottom = 0;
			left = 1 + menu.menuItemPadding + menu.menuItemIndent;
			right = left + menu.menuWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
			if( menu.menuItemVAlign == 'top' ) top = menu.menuItemPadding;
			if( menu.menuItemVAlign == 'bottom' ) top = menu.menuItemHeight-menu.fontSize-1-menu.menuItemPadding;
			if( menu.menuItemVAlign == 'middle' ) top = ((menu.menuItemHeight/2)-(menu.fontSize/2)-1);
			bottom = menu.menuItemHeight - 2*menu.menuItemPadding;
			var textProps = 'position:absolute;left:' + left + 'px;top:' + top + 'px;';
			if (lrs) {
				textProps +=itemProps + 'right:' + right + ';bottom:' + bottom + ';';
				dTag = "";
				dClose = "";
			}
			
			if(document.all && !window.mmIsOpera) {
				item = '<div align="' + menu.menuItemHAlign + '">' + item + '</div>';
			} else if (lrs) {
				item = '<div style="text-align:' + menu.menuItemHAlign + ';">' + item + '</div>';
			} else {
				var hitem = null;
				if( menu.menuItemHAlign != 'left' ) {
					if(window.mmIsOpera) {
						var operaWidth = menu.menuItemHAlign == 'center' ? -(menu.menuWidth-2*menu.menuItemPadding) : (menu.menuWidth-6*menu.menuItemPadding);
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:' + menu.menuItemPadding + 'px;width:' + operaWidth + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					} else {
						hitem = '<div id="menuItemHilite' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
						item = '<div id="menuItemText' + countItems + 'Shim" style="position:absolute;top:1px;left:1px;right:-' + (left+menu.menuWidth-3*menu.menuItemPadding) + 'px;text-align:' 
							+ menu.menuItemHAlign + ';visibility:visible;">' + item + '</div>';
					}
				} else hitem = null;
			}
			if(document.all && !window.mmIsOpera) item = '<div id="menuItemShim' + countItems + '" style="position:absolute;left:0px;top:0px;">' + item + '</div>';
			var dText	= '<div id="menuItemText'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColor +';">'+ item +'&nbsp</div>\n'
						+ '<div id="menuItemHilite'+ countItems +'" style="' + textProps + 'color:'+ menu.fontColorHilite +';visibility:hidden;">' 
						+ (hitem||item) +'&nbsp</div>';
			if (childMenu) content += ( dTag + dText + '<div id="childMenu'+ countItems +'" style="position:absolute;left:0px;top:3px;"><img src="'+ menu.childMenuIcon +'"></div>\n' + dClose);
			else content += ( dTag + dText + dClose);
			if (lrs) {
				l.document.open("text/html");
				l.document.writeln(content);
				l.document.close();	
				content = '';
				theStat += "-";
				tsc++;
				if (tsc > 50) {
					tsc = 0;
					theStat = "";
				}
				status = theStat;
			}
			countItems++;  
		}
		if (lrs) {
			var focusItem = new Layer(100, body);
			focusItem.visiblity="hidden";
			focusItem.document.open("text/html");
			focusItem.document.writeln("&nbsp;");
			focusItem.document.close();	
		} else {
		  content += '  <div id="focusItem'+ countMenus +'" style="position:absolute;left:0px;top:0px;visibility:hide;font-size:1px;" onclick="onMenuItemAction(null,this);">&nbsp;</div>\n';
		  content += '   </div>\n  </div>\n</div>\n';
		}
		i=x;
	}
	if (document.layers) {		
		container.clip.width = window.innerWidth;
		container.clip.height = window.innerHeight;
		container.onmouseout = mouseoutMenu;
		container.menuContainerBgColor = this.menuContainerBgColor;
		for (var i=0; i<container.document.layers.length; i++) {
			proto = container.menus[i];
			var menu = container.document.layers[i];
			container.menus[i].menuLayer = menu;
			container.menus[i].menuLayer.Menu = container.menus[i];
			container.menus[i].menuLayer.Menu.container = container;
			var body = menu.document.layers[0].document.layers[0];
			body.clip.width = proto.menuWidth || body.clip.width;
			body.clip.height = proto.menuHeight || body.clip.height;
			for (var n=0; n<body.document.layers.length-1; n++) {
				var l = body.document.layers[n];
				l.Menu = container.menus[i];
				l.menuHiliteBgColor = proto.menuHiliteBgColor;
				l.document.bgColor = proto.menuItemBgColor;
				l.saveColor = proto.menuItemBgColor;
				l.onmouseover = proto.onMenuItemOver;
				l.onclick = proto.onMenuItemAction;
				l.mmaction = container.menus[i].actions[n];
				l.focusItem = body.document.layers[body.document.layers.length-1];
				l.clip.width = proto.menuWidth || body.clip.width;
				l.clip.height = proto.menuItemHeight || l.clip.height;
				if (n>0) {
					if( l.Menu.vertical ) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder + proto.menuItemSpacing;
					else l.left = body.document.layers[n-1].left + body.document.layers[n-1].clip.width + proto.menuItemBorder + proto.menuItemSpacing;
				}
				l.hilite = l.document.layers[1];
				if (proto.bgImageUp) l.background.src = proto.bgImageUp;
				l.document.layers[1].isHilite = true;
				if (l.document.layers.length > 2) {
					l.childMenu = container.menus[i].items[n].menuLayer;
					l.document.layers[2].left = l.clip.width -13;
					l.document.layers[2].top = (l.clip.height / 2) -4;
					l.document.layers[2].clip.left += 3;
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
			}
			if( proto.menuBgOpaque ) body.document.bgColor = proto.bgColor;
			if( proto.vertical ) {
				body.clip.width  = l.clip.width +proto.menuBorder;
				body.clip.height = l.top + l.clip.height +proto.menuBorder;
			} else {
				body.clip.height  = l.clip.height +proto.menuBorder;
				body.clip.width = l.left + l.clip.width  +proto.menuBorder;
				if( body.clip.width > window.innerWidth ) body.clip.width = window.innerWidth;
			}
			var focusItem = body.document.layers[n];
			focusItem.clip.width = body.clip.width;
			focusItem.Menu = l.Menu;
			focusItem.top = -30;
            focusItem.captureEvents(Event.MOUSEDOWN);
            focusItem.onmousedown = onMenuItemDown;
			if( proto.menuBgOpaque ) menu.document.bgColor = proto.menuBorderBgColor;
			var lite = menu.document.layers[0];
			if( proto.menuBgOpaque ) lite.document.bgColor = proto.menuLiteBgColor;
			lite.clip.width = body.clip.width +1;
			lite.clip.height = body.clip.height +1;
			menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
			menu.clip.height = body.clip.height + (proto.menuBorder * 3);
		}
	} else {
		if ((!document.all) && (container.hasChildNodes) && !window.mmIsOpera) {
			container.innerHTML=content;
		} else {
			container.document.open("text/html");
			container.document.writeln(content);
			container.document.close();	
		}
		if (!FIND("menuLayer0")) return;
		var menuCount = 0;
		for (var x=0; x<container.menus.length; x++) {
			var menuLayer = FIND("menuLayer" + x);
			container.menus[x].menuLayer = "menuLayer" + x;
			menuLayer.Menu = container.menus[x];
			menuLayer.Menu.container = "menuLayer" + x;
			menuLayer.style.zindex = 1;
		    var s = menuLayer.style;
			s.pixeltop = -300;
			s.pixelleft = -300;
			s.top = '-300px';
			s.left = '-300px';

			var menu = container.menus[x];
			menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
			if( menu.menuBgOpaque ) menuLayer.style.backgroundColor = menu.menuBorderBgColor;
			var top = 0;
			var left = 0;
			menu.menuItemLayers = new Array();
			for (var i=0; i<container.menus[x].items.length; i++) {
				var l = FIND("menuItem" + menuCount);
				l.Menu = container.menus[x];
				l.Menu.menuItemLayers[l.Menu.menuItemLayers.length] = l;
				if (l.addEventListener || window.mmIsOpera) {
					l.style.width = menu.menuItemWidth + 'px';
					l.style.height = menu.menuItemHeight + 'px';
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.top = top + 'px';
					l.style.left = left + 'px';
					if(l.addEventListener) {
						l.addEventListener("mouseover", onMenuItemOver, false);
						l.addEventListener("click", onMenuItemAction, false);
						l.addEventListener("mouseout", mouseoutMenu, false);
					}
					if( menu.menuItemHAlign != 'left' ) {
						l.hiliteShim = FIND("menuItemHilite" + menuCount + "Shim");
						l.hiliteShim.style.visibility = "inherit";
						l.textShim = FIND("menuItemText" + menuCount + "Shim");
						l.hiliteShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.hiliteShim.style.width = l.hiliteShim.style.pixelWidth;
						l.textShim.style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						l.textShim.style.width = l.textShim.style.pixelWidth;	
					}
				} else {
					l.style.pixelWidth = menu.menuItemWidth;
					l.style.pixelHeight = menu.menuItemHeight;
					l.style.pixelTop = top;
					l.style.pixelLeft = left;
					if( menu.menuItemHAlign != 'left' ) {
						var shim = FIND("menuItemShim" + menuCount);
						shim[0].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[1].style.pixelWidth = menu.menuItemWidth - 2*menu.menuItemPadding - menu.menuItemIndent;
						shim[0].style.width = shim[0].style.pixelWidth + 'px';
						shim[1].style.width = shim[1].style.pixelWidth + 'px';
					}
				}
				if( menu.vertical ) top = top + menu.menuItemHeight+menu.menuItemBorder+menu.menuItemSpacing;
				else left = left + menu.menuItemWidth+menu.menuItemBorder+menu.menuItemSpacing;
				l.style.fontSize = menu.fontSize + 'px';
				l.style.backgroundColor = menu.menuItemBgColor;
				l.style.visibility = "inherit";
				l.saveColor = menu.menuItemBgColor;
				l.menuHiliteBgColor = menu.menuHiliteBgColor;
				l.mmaction = container.menus[x].actions[i];
				l.hilite = FIND("menuItemHilite" + menuCount);
				l.focusItem = FIND("focusItem" + x);
				l.focusItem.style.pixelTop = -30;
				l.focusItem.style.top = '-30px';
				var childItem = FIND("childMenu" + menuCount);
				if (childItem) {
					l.childMenu = container.menus[x].items[i].menuLayer;
					childItem.style.pixelLeft = menu.menuItemWidth -11;
					childItem.style.left = childItem.style.pixelLeft + 'px';
					childItem.style.pixelTop = (menu.menuItemHeight /2) -4;
					childItem.style.top = childItem.style.pixelTop + 'px';
					l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
				}
				l.style.cursor = "hand";
				menuCount++;
			}
			if( menu.vertical ) {
				menu.menuHeight = top-1-menu.menuItemSpacing;
				menu.menuWidth = menu.menuItemWidth;
			} else {
				menu.menuHeight = menu.menuItemHeight;
				menu.menuWidth = left-1-menu.menuItemSpacing;
			}

			var lite = FIND("menuLite" + x);
			var s = lite.style;
			s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + (menu.menuBorder * 2);
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.menuLiteBgColor;

			var body = FIND("menuFg" + x);
			s = body.style;
			s.pixelHeight = menu.menuHeight + menu.menuBorder;
			s.height = s.pixelHeight + 'px';
			s.pixelWidth = menu.menuWidth + menu.menuBorder;
			s.width = s.pixelWidth + 'px';
			if( menu.menuBgOpaque ) s.backgroundColor = menu.bgColor;

			s = menuLayer.style;
			s.pixelWidth  = menu.menuWidth + (menu.menuBorder * 4);
			s.width = s.pixelWidth + 'px';
			s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
			s.height = s.pixelHeight + 'px';
		}
	}
	if (document.captureEvents) document.captureEvents(Event.MOUSEUP);
	if (document.addEventListener) document.addEventListener("mouseup", onMenuItemOver, false);
	if (document.layers && window.innerWidth) {
		window.onresize = NS4resize;
		window.NS4sIW = window.innerWidth;
		window.NS4sIH = window.innerHeight;
		setTimeout("NS4resize()",500);
	}
	document.onmouseup = mouseupMenu;
	window.mmWroteMenu = true;
	status = "";
}

function NS4resize() {
	if (NS4sIW != window.innerWidth || NS4sIH != window.innerHeight) window.location.reload();
}

function onMenuItemOver(e, l) {
	MM_clearTimeout();
	l = l || this;
	a = window.ActiveMenuItem;
	if (document.layers) {
		if (a) {
			a.document.bgColor = a.saveColor;
			if (a.hilite) a.hilite.visibility = "hidden";
			if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
			a.focusItem.top = -100;
			a.clicked = false;
		}
		if (l.hilite) {
			l.document.bgColor = l.menuHiliteBgColor;
			l.zIndex = 1;
			l.hilite.visibility = "inherit";
			l.hilite.zIndex = 2;
			l.document.layers[1].zIndex = 1;
			l.focusItem.zIndex = this.zIndex +2;
		}
		if (l.Menu.bgImageOver) l.background.src = l.Menu.bgImageOver;
		l.focusItem.top = this.top;
		l.focusItem.left = this.left;
		l.focusItem.clip.width = l.clip.width;
		l.focusItem.clip.height = l.clip.height;
		l.Menu.hideChildMenu(l);
	} else if (l.style && l.Menu) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";;
		} 
		l.style.backgroundColor = l.menuHiliteBgColor;
		l.zIndex = 1;
		if (l.Menu.bgImageOver) l.style.background = "url(" + l.Menu.bgImageOver +")";
		if (l.hilite) {
			l.hilite.style.visibility = "inherit";
			if( l.hiliteShim ) l.hiliteShim.style.visibility = "visible";
		}
		l.focusItem.style.pixelTop = l.style.pixelTop;
		l.focusItem.style.top = l.focusItem.style.pixelTop + 'px';
		l.focusItem.style.pixelLeft = l.style.pixelLeft;
		l.focusItem.style.left = l.focusItem.style.pixelLeft + 'px';
		l.focusItem.style.zIndex = l.zIndex +1;
		l.Menu.hideChildMenu(l);
	} else return;
	window.ActiveMenuItem = l;
}

function onMenuItemAction(e, l) {
	l = window.ActiveMenuItem;
	if (!l) return;
	hideActiveMenus();
	if (l.mmaction) eval("" + l.mmaction);
	window.ActiveMenuItem = 0;
}

function MM_clearTimeout() {
	if (mmHideMenuTimer) clearTimeout(mmHideMenuTimer);
	mmHideMenuTimer = null;
	mmDHFlag = false;
}

function MM_startTimeout() {
	if( window.ActiveMenu ) {
		mmStart = new Date();
		mmDHFlag = true;
		mmHideMenuTimer = setTimeout("mmDoHide()", window.ActiveMenu.Menu.hideTimeout);
	}
}

function mmDoHide() {
	if (!mmDHFlag || !window.ActiveMenu) return;
	var elapsed = new Date() - mmStart;
	var timeout = window.ActiveMenu.Menu.hideTimeout;
	if (elapsed < timeout) {
		mmHideMenuTimer = setTimeout("mmDoHide()", timeout+100-elapsed);
		return;
	}
	mmDHFlag = false;
	hideActiveMenus();
	window.ActiveMenuItem = 0;
}

function MM_showMenu(menu, x, y, child, imgname) {
	if (!window.mmWroteMenu) return;
	MM_clearTimeout();
	if (menu) {
		var obj = FIND(imgname) || document.images[imgname] || document.links[imgname] || document.anchors[imgname];
		x = moveXbySlicePos (x, obj);
		y = moveYbySlicePos (y, obj);
	}
	if (document.layers) {
		if (menu) {
			var l = menu.menuLayer || menu;
			l.top = l.left = 1;
			hideActiveMenus();
			if (this.visibility) l = this;
			window.ActiveMenu = l;
		} else {
			var l = child;
		}
		if (!l) return;
		for (var i=0; i<l.layers.length; i++) { 			   
			if (!l.layers[i].isHilite) l.layers[i].visibility = "inherit";
			if (l.layers[i].document.layers.length > 0) MM_showMenu(null, "relative", "relative", l.layers[i]);
		}
		if (l.parentLayer) {
			if (x != "relative") l.parentLayer.left = x || window.pageX || 0;
			if (l.parentLayer.left + l.clip.width > window.innerWidth) l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
			if (y != "relative") l.parentLayer.top = y || window.pageY || 0;
			if (l.parentLayer.isContainer) {
				l.Menu.xOffset = window.pageXOffset;
				l.Menu.yOffset = window.pageYOffset;
				l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
				l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
				if (l.parentLayer.menuContainerBgColor && l.Menu.menuBgOpaque ) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
			}
		}
		l.visibility = "inherit";
		if (l.Menu) l.Menu.container.visibility = "inherit";
	} else if (FIND("menuItem0")) {
		var l = menu.menuLayer || menu;	
		hideActiveMenus();
		if (typeof(l) == "string") l = FIND(l);
		window.ActiveMenu = l;
		var s = l.style;
		s.visibility = "inherit";
		if (x != "relative") {
			s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
			s.left = s.pixelLeft + 'px';
		}
		if (y != "relative") {
			s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
			s.top = s.pixelTop + 'px';
		}
		l.Menu.xOffset = document.body.scrollLeft;
		l.Menu.yOffset = document.body.scrollTop;
	}
	if (menu) window.activeMenus[window.activeMenus.length] = l;
	MM_clearTimeout();
}

function onMenuItemDown(e, l) {
	var a = window.ActiveMenuItem;
	if (document.layers && a) {
		a.eX = e.pageX;
		a.eY = e.pageY;
		a.clicked = true;
    }
}

function mouseupMenu(e) {
	hideMenu(true, e);
	hideActiveMenus();
	return true;
}

function getExplorerVersion() {
	var ieVers = parseFloat(navigator.appVersion);
	if( navigator.appName != 'Microsoft Internet Explorer' ) return ieVers;
	var tempVers = navigator.appVersion;
	var i = tempVers.indexOf( 'MSIE ' );
	if( i >= 0 ) {
		tempVers = tempVers.substring( i+5 );
		ieVers = parseFloat( tempVers ); 
	}
	return ieVers;
}

function mouseoutMenu() {
	if ((navigator.appName == "Microsoft Internet Explorer") && (getExplorerVersion() < 4.5))
		return true;
	hideMenu(false, false);
	return true;
}

function hideMenu(mouseup, e) {
	var a = window.ActiveMenuItem;
	if (a && document.layers) {
		a.document.bgColor = a.saveColor;
		a.focusItem.top = -30;
		if (a.hilite) a.hilite.visibility = "hidden";
		if (mouseup && a.mmaction && a.clicked && window.ActiveMenu) {
 			if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10) {
				setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 500);
			}
		}
		a.clicked = false;
		if (a.Menu.bgImageOver) a.background.src = a.Menu.bgImageUp;
	} else if (window.ActiveMenu && FIND("menuItem0")) {
		if (a) {
			a.style.backgroundColor = a.saveColor;
			if (a.hilite) a.hilite.style.visibility = "hidden";
			if (a.hiliteShim) a.hiliteShim.style.visibility = "inherit";
			if (a.Menu.bgImageUp) a.style.background = "url(" + a.Menu.bgImageUp +")";
		}
	}
	if (!mouseup && window.ActiveMenu) {
		if (window.ActiveMenu.Menu) {
			if (window.ActiveMenu.Menu.hideOnMouseOut) MM_startTimeout();
			return(true);
		}
	}
	return(true);
}

function hideChildMenu(hcmLayer) {
	MM_clearTimeout();
	var l = hcmLayer;
	for (var i=0; i < l.Menu.childMenus.length; i++) {
		var theLayer = l.Menu.childMenus[i];
		if (document.layers) theLayer.visibility = "hidden";
		else {
			theLayer = FIND(theLayer);
			theLayer.style.visibility = "hidden";
			if( theLayer.Menu.menuItemHAlign != 'left' ) {
				for(var j = 0; j < theLayer.Menu.menuItemLayers.length; j++) {
					var itemLayer = theLayer.Menu.menuItemLayers[j];
					if(itemLayer.textShim) itemLayer.textShim.style.visibility = "inherit";
				}
			}
		}
		theLayer.Menu.hideChildMenu(theLayer);
	}
	if (l.childMenu) {
		var childMenu = l.childMenu;
		if (document.layers) {
			l.Menu.MM_showMenu(null,null,null,childMenu.layers[0]);
			childMenu.zIndex = l.parentLayer.zIndex +1;
			childMenu.top = l.Menu.menuLayer.top + l.Menu.submenuYOffset;
			if( l.Menu.vertical ) {
				if( l.Menu.submenuRelativeToItem ) childMenu.top += l.top + l.parentLayer.top;
				childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			} else {
				childMenu.top += l.top + l.parentLayer.top;	
				if( l.Menu.submenuRelativeToItem ) childMenu.left = l.Menu.menuLayer.left + l.left + l.clip.width + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
				else childMenu.left = l.parentLayer.left + l.parentLayer.clip.width - (2*l.Menu.menuBorder) + l.Menu.menuLayer.left + l.Menu.submenuXOffset;
			}
			if( childMenu.left < l.Menu.container.clip.left ) l.Menu.container.clip.left = childMenu.left;
			var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
			if (w > l.Menu.container.clip.width)  l.Menu.container.clip.width = w;
			var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
			if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
			l.document.layers[1].zIndex = 0;
			childMenu.visibility = "inherit";
		} else if (FIND("menuItem0")) {
			childMenu = FIND(l.childMenu);
			var menuLayer = FIND(l.Menu.menuLayer);
			var s = childMenu.style;
			s.zIndex = menuLayer.style.zIndex+1;
			if (document.all || window.mmIsOpera) {
				s.pixelTop = menuLayer.style.pixelTop + l.Menu.submenuYOffset;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) s.pixelTop += l.style.pixelTop;
					s.pixelLeft = l.style.pixelWidth + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				} else {
					s.pixelTop += l.style.pixelTop;
					if( l.Menu.submenuRelativeToItem ) s.pixelLeft = menuLayer.style.pixelLeft + l.style.pixelLeft + l.style.pixelWidth + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else s.pixelLeft = (menuLayer.style.pixelWidth-4*l.Menu.menuBorder) + menuLayer.style.pixelLeft + l.Menu.submenuXOffset;
					s.left = s.pixelLeft + 'px';
				}
			} else {
				var top = parseInt(menuLayer.style.top) + l.Menu.submenuYOffset;
				var left = 0;
				if( l.Menu.vertical ) {
					if( l.Menu.submenuRelativeToItem ) top += parseInt(l.style.top);
					left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				} else {
					top += parseInt(l.style.top);
					if( l.Menu.submenuRelativeToItem ) left = parseInt(menuLayer.style.left) + parseInt(l.style.left) + parseInt(l.style.width) + (2*l.Menu.menuBorder) + l.Menu.submenuXOffset;
					else left = (parseInt(menuLayer.style.width)-4*l.Menu.menuBorder) + parseInt(menuLayer.style.left) + l.Menu.submenuXOffset;
				}
				s.top = top + 'px';
				s.left = left + 'px';
			}
			childMenu.style.visibility = "inherit";
		} else return;
		window.activeMenus[window.activeMenus.length] = childMenu;
	}
}

function hideActiveMenus() {
	if (!window.activeMenus) return;
	for (var i=0; i < window.activeMenus.length; i++) {
		if (!activeMenus[i]) continue;
		if (activeMenus[i].visibility && activeMenus[i].Menu && !window.mmIsOpera) {
			activeMenus[i].visibility = "hidden";
			activeMenus[i].Menu.container.visibility = "hidden";
			activeMenus[i].Menu.container.clip.left = 0;
		} else if (activeMenus[i].style) {
			var s = activeMenus[i].style;
			s.visibility = "hidden";
			s.left = '-200px';
			s.top = '-200px';
		}
	}
	if (window.ActiveMenuItem) hideMenu(false, false);
	window.activeMenus.length = 0;
}

function moveXbySlicePos (x, img) { 
	if (!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.leftMargin && ! onWindows ) x += parseInt(par.leftMargin);
			if( (par.offsetLeft != lastOffset) && par.offsetLeft ) x += parseInt(par.offsetLeft);
			if( par.offsetLeft != 0 ) lastOffset = par.offsetLeft;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}
	} else if (img.x) x += img.x;
	return x;
}

function moveYbySlicePos (y, img) {
	if(!document.layers) {
		var onWindows = navigator.platform ? navigator.platform == "Win32" : false;
		var macIE45 = document.all && !onWindows && getExplorerVersion() == 4.5;
		var par = img;
		var lastOffset = 0;
		while(par){
			if( par.topMargin && !onWindows ) y += parseInt(par.topMargin);
			if( (par.offsetTop != lastOffset) && par.offsetTop ) y += parseInt(par.offsetTop);
			if( par.offsetTop != 0 ) lastOffset = par.offsetTop;
			par = macIE45 ? par.parentElement : par.offsetParent;
		}		
	} else if (img.y >= 0) y += img.y;
	return y;
}

function MM_swapImgRestore() { 
	//v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { 
	//v3.0
	var d=document;
	if(d.images) {
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

