//-----
// File: umu.js
//
// Version: 1.0
// Date: January 30, 2005
//
// Author: Ron Stewart (ron.stewart@gmail.com)
//
// Copyright Notice: Copyright 2005 (c) Ron Stewart. All Rights Reserved.
// This file, its contents, and the JavaScript functions present herein are
// copyrighted material, owned solely by Ron Stewart. Special permission has
// been granted to Rob Crose for incorporation of this file into the Internet
// Web site developed for Baseball Chapel at http://www.baseballchapel.org/.
// This file may not be copied, modified, re-used, or re-purposed without the
// express written permission of the author. 
// 
// Removal of this copyright statement is expressly prohibited.
//-----
function umu(sArg)
{
	// Split the argument into the tokens and their values...
	aArgs = sArg.split(",");
	
	// Iterate over the token/value pairs, processing each one...
	for (var a = 0; a < aArgs.length; a++)
	{
		// Attempt to split this pair into the token that we will look for
		// within the URL, and the value that we will squeeze into its place...
		aToken = aArgs[a].split("=");
		if (aToken.length == 2)
		{
			// Create a regular expression to find all crunched versions of the token
			// and replace them with the supplied value...
			var oExp = new RegExp("#" + aToken[0] + "#", "ig");
			
			// Now rip through the menu structure, updating all of the occurrences of 
			// the token in any URL with the specified value...
			for (var i = 0; i < awmm.length; i++) 
			{
				for (var j = 0; j < awmm[i].cn.length; j++)
				{
					for (var k = 0; k < awmm[i].cn[j].it.length; k++)
					{
						if (awmm[i].cn[j].it[k].url != null)
						{
							awmm[i].cn[j].it[k].url = awmm[i].cn[j].it[k].url.replace(oExp, aToken[1]);
						}
					}
				}
			}
		}
	}
}
function ddms()
{
	document.write("<p class=\"menudebug\">");
	document.write("awmm.length: " + awmm.length + "<br />");
	for (var i = 0; i < awmm.length; i++) 
	{
		document.write("awmm[" + i + "].nm: " + awmm[i].nm + "<br />");
		document.write("awmm[" + i + "].cn.length: " + awmm[i].cn.length + "<br />");
		for (var j = 0; j < awmm[i].cn.length; j++)
		{
			// These are the sub-menus...
			document.write("awmm[" + i + "].cn[" + j + "].tn: " + awmm[i].cn[j].tn + "<br />");
			document.write("awmm[" + i + "].cn[" + j + "].it.length: " + awmm[i].cn[j].it.length + "<br />");
			for (var k = 0; k < awmm[i].cn[j].it.length; k++)
			{
				document.write("awmm[" + i + "].cn[" + j + "].it[" + k + "].inm: " + awmm[i].cn[j].it[k].inm + "<br />");
				document.write("awmm[" + i + "].cn[" + j + "].it[" + k + "].url: " + awmm[i].cn[j].it[k].url + "<br />");
			}
		}
	}
	document.write("</p>");
}



