var MenuObjects = new Object();
var isMSIE = false;

function status(blah)
{
	top.status = blah;
}

if (navigator.appName == "Microsoft Internet Explorer")
	isMSIE = true;

function AddMenuObject(obj)
{
	var x = 0;

	do
	{
		x = Math.floor((Math.random() * 100000));
	} while (MenuObjects[x] != null);

	MenuObjects[x] = obj;
	
	return x;
}

// MenuItem /////////////////////////////////////////
function MenuItem(name, url, target)
{
	if (arguments.length > 0)
	{
		this.init(name, url, target);
	}
}

MenuItem.prototype.init = function(name, url, target)
{
	this.Name = name;
	this.Parent = null;
	this.ID = AddMenuObject(this);
	this.Icon = null;
	this.URL = url;
	this.Target = target;
}

MenuItem.prototype.Paint = function()
{
	var style = "MenuItemStyle";
	var content = "<tr id=\"MenuItem_" + this.ID + "\""
		+ " onmouseover=\"parent.HighlightMenuItem(" + this.ID + ");\" "
		+ " onmouseout=\"parent.UnHighlightMenuItem(" + this.ID + ");\" "
		+ " onclick=\"parent.MenuItemClick(" + this.ID + ");\">";


	if (this.Parent.Icons == "on")
	{
		var icon = "<img src=\"trans.gif\"";

		if (this.Icon != null)
			icon = "<img src=\"" + this.Icon + "\"";

		icon += " height=\"" + this.Parent.MenuStyle.IconHeight + "\" width=\"" + this.Parent.MenuStyle.IconWidth + "\">";


		content += "<td class=\"MenuItemStyleIcon\">"
			+ icon
			+ "</td>"
			+ "<td class=\"MenuItemStyleMiddle\" style=\"width: 1px;\">"
			+ "<img src=\"trans.gif\" height=\"1\" width=\"1\">"
			+ "</td>";

		style = "MenuItemStyleRight";
	}

	content	+= "<td colspan=\"2\" class=\"" + style + "\">"
		+ this.Name
		+ "</td>";

	content += "</tr>";

	return content;
}

MenuItem.prototype.GetLocation = function()
{
	if (this.Parent instanceof MenuItem)
	{
		//var loc = this.Parent.GetLocation();
		var loc = new Object();
		loc.x = parseInt(this.Parent.IFrame.style.left);
		loc.y = parseInt(this.Parent.IFrame.style.top);

		if (this.Parent instanceof Menu)
		{
			var doc = this.Parent.IFrame.contentWindow.document;
			var element = doc.getElementById("MenuItem_" + this.ID);
			var eLoc = GetHtmlElementLocation(element);
			var sz = this.GetSize();
			loc.x += eLoc.x;
			loc.y += eLoc.y;

			if (this.AnchorDirection == "right")
			{
				loc.x += element.offsetWidth;
				loc.x += parseInt(this.Parent.MenuStyle.ItemMarginWidth);

				// Check window size
				var lastX = loc.x + sz.Width + (isMSIE ? 15 : 0);
				if (lastX > document.body.clientWidth)
				{
					this.AnchorDirection = "left";
					loc = this.GetLocation();
					this.AnchorDirection = "right";
				}
			}
			else if (this.AnchorDirection == "left")
			{
				loc.x -= sz.Width;
				loc.x -= (parseInt(this.Parent.MenuStyle.ItemMarginWidth));

				if (isMSIE) loc.x -= (parseInt(this.Parent.MenuStyle.ItemMarginWidth));
			}

			// Check window height
			var lastY = loc.y + sz.Height - document.body.scrollTop;

			status(lastY + " " + document.body.clientHeight + " " + document.body.scrollHeight + " " + document.body.offsetHeight + " " + document.body.scrollTop);
			if (lastY > document.body.clientHeight)
			{
				loc.y -= sz.Height;
				loc.y += element.offsetHeight;
				loc.y += (parseInt(this.Parent.MenuStyle.BorderWidth));

				if (!isMSIE) loc.y += (parseInt(this.Parent.MenuStyle.ItemMarginWidth));
			}
		}

		return loc;
	}
	else
	{
		var loc = GetHtmlElementLocation(this.Parent);
		if (this.AnchorDirection == "down")
		{
			loc.y += this.Parent.offsetHeight;
		}
		else if (this.AnchorDirection == "right")
		{
			loc.x += this.Parent.offsetWidth;
		}
		else if (this.AnchorDirection == "up")
		{
			var table = this.IFrame.contentWindow.document.getElementById("Menu_" + this.ID);
			loc.y -= table.scrollHeight;
			if (isMSIE)
				loc.y -= this.MenuStyle.ShadowWidth;
		}
		else if (this.AnchorDirection == "left")
		{
			var table = this.IFrame.contentWindow.document.getElementById("Menu_" + this.ID);
			loc.x -= table.scrollWidth;
			if (isMSIE)
				loc.x -= this.MenuStyle.ShadowWidth;
		}


		return loc;
	}
}


MenuItem.prototype.GetSize = function()
{
	if (this instanceof Menu)
	{
		var table = this.IFrame.contentWindow.document.getElementById("Menu_" + this.ID);
		var sz = new Object();
		sz.Width = table.scrollWidth;
		sz.Height = table.scrollHeight;
		return sz;
	}
}

MenuItem.prototype.Highlight = function()
{
	var menuItemElement = this.Parent.IFrame.contentWindow.document.getElementById("MenuItem_" + this.ID);

	for (var i = 0; i < menuItemElement.childNodes.length; i++)
	{
		var td = menuItemElement.childNodes.item(i);
		if (td.nodeName == "TD")
		{
			if (td.className.search(/Highlight/) < 0)
				td.className += "Highlight";
		}
	}
	this.Parent.MousedOver = true;

	// Unhighlight everything else
	for (var j = 0; j < this.Parent.MenuItems.length; j++)
	{
		var item = this.Parent.MenuItems[j];
		if (item.ID != this.ID)
		{
			if (item instanceof Menu)
				item.Hide();

			item.UnHighlight();
		}
	}
}

MenuItem.prototype.UnHighlight = function()
{
	try
	{
		if (this instanceof Menu)
		{
			if (this.isVisible())
			{
				return false;
			}
		}
	
		var menuItemElement = this.Parent.IFrame.contentWindow.document.getElementById("MenuItem_" + this.ID);
	
		for (var i = 0; i < menuItemElement.childNodes.length; i++)
		{
			var td = menuItemElement.childNodes.item(i);
			if (td.nodeName == "TD")
			{
				td.className = td.className.replace(/Highlight/, ""); 
			}
		}
	}
	catch (e)
	{
	}
}

MenuItem.prototype.Click = function()
{
	if (this.Target)
		window.open(this.URL, '_blank');
	else
		document.location.href = this.URL;
}

function GetHtmlElementLocation(element)
{
	var loc = new Object();
	loc.x = 0;
	loc.y = 0;

	do
	{
		loc.x += element.offsetLeft;
		loc.y += element.offsetTop;
		element = element.offsetParent;
	} while (element != null);

	return loc;
}

// Menu /////////////////////////////////////////////

Menu.prototype = new MenuItem();
Menu.prototype.constructor = Menu;
Menu.superclass = MenuItem.prototype;

function Menu(name, anchorElement, menuStyle)
{
	if (arguments.length > 0)
	{
		this.init(name, anchorElement, menuStyle);
	}
}

function Menu_prototype_MouseOutHandler(e)
{
	var menu = MenuObjects[e];
	
	if (menu.MousedOver)
	{
		if (menu.OnMouseOut != null)
		{
			eval(menu.OnMouseOut);
		}
	}
}

Menu.prototype.init = function(name, anchorElement, menuStyle)
{
	Menu.superclass.init.call(this, name);

	if (anchorElement != null)
	{
		this.Parent = anchorElement;
	}

	this.ID = AddMenuObject(this);
	this.IFrame = document.createElement("IFRAME");
	this.IFrame.style.position = "absolute";
	this.IFrame.style.display = "none";
	this.IFrame.style.top = "0";
	this.IFrame.style.left = "0";
	this.IFrame.style.zIndex = 99;
	//this.IFrame.allowTransparency = true;
	this.IFrame.frameBorder = 0;
	this.IFrame.scrolling = "no";
	if (isMSIE)
		this.IFrame.src = "about:blank";
	else
		this.IFrame.src = "blank.html";
		
	this.IFrame.onmouseout = new Function("Menu_prototype_MouseOutHandler(" + this.ID + ");");
	document.body.appendChild(this.IFrame);

	if (isMSIE)
	{
		var IFrameDoc = this.IFrame.contentWindow.document;
		IFrameDoc.open();
		IFrameDoc.writeln("<html><body></body></html>");
		IFrameDoc.close();
	}

	this.MenuItems = new Array();

	this.ContentBuilt = false;
	this.MousedOver = false;
	this.ShowOn = "over";
	this.Icons = "off";
	this.AnchorDirection = "down";

	// Style Stuff
	if (menuStyle == null)
		this.MenuStyle = new MenuStyle();
	else
		this.MenuStyle = menuStyle;
		
	this.OnMouseOut = null;
}

Menu.prototype.Highlight = function()
{
	Menu.superclass.Highlight.call(this);
	if (this.ShowOn == "over")
	{
		this.Show();
	}
}

Menu.prototype.Click = function()
{
	Menu.superclass.Click.call(this);
	if (this.ShowOn == "click")
	{
		this.Show();
	}
}

Menu.prototype.isVisible = function()
{
	return (this.IFrame.style.display != "none");
}

Menu.prototype.AddItem = function(item)
{
	if (item instanceof MenuItem)
	{
		item.Parent = this;
		this.MenuItems[this.MenuItems.length] = item;

		// Propagate various properties.
		if (item instanceof Menu)
		{
			item.ShowOn = this.ShowOn;
			item.Icons = this.Icons;
			item.AnchorDirection = "right";
		}
	}
	else
	{
		throw "Only MenuItems can be added to a Menu.";
	}
}

Menu.prototype.Refresh = function()
{
	var body = this.IFrame.contentWindow.document.body;

	body.style.backgroundColor = "transparent";
	body.style.margin = "0px 0px 0px 0px";

	var style = this.MenuStyle;

	var content = "";

	if (isMSIE)
	{
		var ss = this.IFrame.contentWindow.document.createStyleSheet();
		ss.cssText = style.GetItemStyleSheet();
	}
	else
	{
		// Write the style tag...
		content += "<style type=\"text/css\">";
		content += style.GetItemStyleSheet();
		content += "</style>";
	}

	content += "<table id=\"Menu_" + this.ID + "\" cellspacing=\"0\" cellpadding=\"0\""
			+ " width=\"" + style.Width 
			+ "\" style=\"border: " + style.BorderWidth + " "
			+ style.BorderStyle + " " + style.BorderColor;

	if (style.Shadow)
	{
		content += "; filter:progid:DXImageTransform.Microsoft.DropShadow(color = #30000000 offX = "
				+ style.ShadowWidth + " offY = " + style.ShadowWidth
				+ ")";
	}
	
	content += ";\"><tr><td width=\"" + style.Width + "\">";

	content += "<table cellspacing=\"0\" cellpadding=\"0\""
			+ " width=\"" + style.Width 
			+ "\" style=\"" + style.GetMenuStyle()
			+ "\">";

	for (var i = 0; i < this.MenuItems.length; i++)
	{
		content += this.MenuItems[i].Paint();
	}

	content += "</table></td></tr></table>";

	body.innerHTML = content;

	this.ContentBuilt = true;
}

Menu.prototype.Initialize = function()
{
	if (isMSIE)
	{
		this.Refresh();

		for (var i = 0; i < this.MenuItems.length; i++)
		{
			if (this.MenuItems[i] instanceof Menu)
			{
				this.MenuItems[i].Initialize();
			}
		}
	}
}

Menu.prototype.Show = function()
{
	if (!this.ContentBuilt)
	{
		this.Refresh();
	}

	this.IFrame.style.visibility = "hidden";
	this.IFrame.style.display = "";
	var loc;
	if (this.Parent != null)
	{
		loc = this.GetLocation();
	}
	else
	{
		loc = GetHtmlElementLocation(window.event.srcElement);
		loc.x += window.event.offsetX;
		loc.y += window.event.offsetY;
	}
	this.IFrame.style.top = loc.y;
	this.IFrame.style.left = loc.x;
	this.IFrame.style.visibility = "";

	var table = this.IFrame.contentWindow.document.getElementById("Menu_" + this.ID);
	var style = this.MenuStyle;
	var borderWidth = parseInt(style.BorderWidth) * 2;
	if (style.Shadow)
	{
		this.IFrame.style.width = table.scrollWidth + borderWidth + style.ShadowWidth;
		this.IFrame.style.height = table.scrollHeight + borderWidth + style.ShadowWidth;
	}
	else
	{
		this.IFrame.style.width = table.scrollWidth + borderWidth;
		this.IFrame.style.height = table.scrollHeight + borderWidth;
	}
}

Menu.prototype.Hide = function()
{
	for (var i = 0; i < this.MenuItems.length; i++)
	{
		if (this.MenuItems[i] instanceof Menu)
		{
			// The order here is very important.  Hide() before UnHighlight()
			this.MenuItems[i].Hide();
			this.MenuItems[i].UnHighlight();
		}
	}

	this.IFrame.style.display = "none";
}

Menu.prototype.Paint = function()
{
	var style = "MenuItemStyleLeft";
	var content = "<tr id=\"MenuItem_" + this.ID + "\""
			+ " onmouseover=\"parent.HighlightMenuItem(" + this.ID + ");\" "
			+ " onmouseout=\"parent.UnHighlightMenuItem(" + this.ID + ");\" "
			+ " onclick=\"parent.MenuItemClick(" + this.ID + ");\">";


	if (this.Parent.Icons == "on")
	{
		var icon = "<img src=\"trans.gif\"";

		if (this.Icon != null)
			icon = "<img src=\"" + this.Icon + "\"";

		icon += " height=\"" + this.Parent.MenuStyle.IconHeight + "\" width=\"" + this.Parent.MenuStyle.IconWidth + "\">";

		content += "<td class=\"MenuItemStyleIcon\">"
			+ icon
			+ "</td>"
			+ "<td class=\"MenuItemStyleMiddle\" style=\"width: 1px;\">"
			+ "<img src=\"trans.gif\" height=\"1\" width=\"1\">"
			+ "</td>";

		style = "MenuItemStyleMiddle";
	}

	content += "<td class=\"" + style + "\">"
			+ this.Name
			+ "</td>"
			+ "<td align=\"right\" valign=\"middle\" class=\"MenuItemStyleRight\">"
			+ "<img src=\"arrow.gif\" height=\"7\" width=\"4\" align=\"absmiddle\">"
			+ "</td>"
			+ "</tr>";

	return content;
}

// MenuSeparator ////////////////////////////////////

MenuSeparator.prototype = new MenuItem();
MenuSeparator.prototype.constructor = MenuSeparator;
MenuSeparator.superclass = MenuItem.prototype;

function MenuSeparator()
{
	this.init();
}

MenuSeparator.prototype.init = function()
{
	MenuSeparator.superclass.init("");
}

MenuSeparator.prototype.Paint = function()
{
	var content = "<tr id=\"MenuItem_" + this.ID + "\">";

	if (this.Parent.Icons == "on")
	{
		content += "<td class=\"MenuItemStyleSeparatorIcon\">"
			+"<img style=\"height: " + this.Parent.MenuStyle.SeparatorHeight 
			+ ";\" src=\"trans.gif\" height=\"1\" width=\"1\">"
			+ "</td>"
			+ "<td class=\"MenuItemStyleSeparatorIconRight\" style=\"width: 1px;\">"
			+ "</td>";
	}

	content += "<td colspan=\"2\" class=\"MenuItemSeparatorStyle\">"
			+"<img style=\"height: " + this.Parent.MenuStyle.SeparatorHeight 
			+ ";\" src=\"trans.gif\" height=\"1\" width=\"1\">"
			+ "</td>"
			+ "</tr>";

	return content;
}

// MenuStyle ////////////////////////////////////////
function MenuStyle()
{
	this.Width = "auto";
	this.BackgroundColor = "#6685a3";
	this.BorderColor = "#D1DAE3";
	this.BorderWidth = "2px";
	this.BorderStyle = "solid";
	this.Shadow = false;
	this.ShadowWidth = 4;
	this.FontFamily = "Arial, Helvetica, sans-serif";
	this.FontSize = "x-small";
	this.FontColor = "#ffffff";
	this.FontWeight = "normal";
	this.FontDecoration = "none";
	this.FontStyle = "normal";
	this.PaddingWidth = "0px";

	// MenuItem Stuff
	this.ItemBackgroundColor = "#6685a3";
	this.ItemHighlightColor = "#B6BDD2";
	this.ItemHighlightBorderColor = "#D1DAE3";
	this.ItemHighlightBorderWidth = "0px";
	this.ItemHighlightBorderStyle = "solid";
	this.ItemPaddingWidth = "4px";
	this.ItemMarginWidth = "0px";

	// Separator Stuff
	this.SeparatorColor = "D1DAE3";
	this.SeparatorHeight = "2px"

	// Icon Stuff
	this.IconBackgroundColor = "#E0E0E0";
	this.IconWidth = 20;
	this.IconHeight = 20;

	// Style Methods
	this.GetSeparatorStyle = MenuStyle_SeparatorStyle;
	this.GetItemStyle = MenuStyle_ItemStyle;
	this.GetHighlightStyle = MenuStyle_HighlightStyle;
	this.GetMenuStyle = MenuStyle_MenuStyle;
	this.GetItemStyleSheet = MenuStyle_ItemStyleSheet;
}

function MenuStyle_SeparatorStyle()
{
	var styleText = "";
	
	styleText += "background-color: " + this.SeparatorColor + ";";
	styleText += " cursor: pointer; padding: 0px 0px 0px 0px;";
	styleText += " height: " + this.SeparatorHeight + ";";

	return styleText;
}

function MenuStyle_ItemStyleSheet()
{
	var commonText = "";
	var styleText = "";

	commonText += "font-family: " + this.FontFamily + ";";
	commonText += " font-size: " + this.FontSize + ";";
	commonText += " font-weight: " + this.FontWeight + ";";
	commonText += " font-style: " + this.FontStyle + ";";
	commonText += " text-decoration: " + this.FontDecoration + ";";
	commonText += " padding: " + this.ItemPaddingWidth + ";";
	commonText += " margin: " + this.ItemMarginWidth + ";";
	commonText += " color: " + this.FontColor + ";";

	// Icon Styles
	styleText += ".MenuItemStyleIcon { " + commonText
			+ " background-color: " + this.IconBackgroundColor + ";"
			+ " border-left: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " width: " + this.IconWidth + "px;"
			+ " }\n";

	styleText += ".MenuItemStyleIconHighlight { " + commonText
			+ " background-color: " + this.ItemHighlightColor + ";"
			+ " border-left: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " width: " + this.IconWidth + "px;"
			+ " }\n";

	// Single Column Styles

	styleText += ".MenuItemStyle { " + commonText
			+ " background-color: " + this.ItemBackgroundColor + ";"
			+ " border: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " }\n";

	styleText += ".MenuItemStyleHighlight { " + commonText
			+ " background-color: " + this.ItemHighlightColor + ";"
			+ " border: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " }\n";

	// Left Column Styles
	styleText += ".MenuItemStyleLeft { " + commonText
			+ " background-color: " + this.ItemBackgroundColor + ";"
			+ " border-left: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " }\n";

	styleText += ".MenuItemStyleLeftHighlight { " + commonText
			+ " background-color: " + this.ItemHighlightColor + ";"
			+ " border-left: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " }\n";

	// Middle Column Styles
	styleText += ".MenuItemStyleMiddle { " + commonText
			+ " background-color: " + this.ItemBackgroundColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " }\n";

	styleText += ".MenuItemStyleMiddleHighlight { " + commonText
			+ " background-color: " + this.ItemHighlightColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " }\n";

	// Right Column Styles
	styleText += ".MenuItemStyleRight { " + commonText
			+ " background-color: " + this.ItemBackgroundColor + ";"
			+ " border-right: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " }\n";

	styleText += ".MenuItemStyleRightHighlight { " + commonText
			+ " background-color: " + this.ItemHighlightColor + ";"
			+ " border-right: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " " + this.ItemHighlightBorderStyle + " " + this.ItemHighlightBorderColor + ";"
			+ " }\n";


	styleText += ".MenuItemSeparatorStyle { "
			+ "background-color: " + this.SeparatorColor + ";"
			+ " cursor: pointer; padding: 0px;"
			+ " border: " + this.ItemMarginWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " height: " + this.SeparatorHeight + ";"
			+ " }\n";

	styleText += ".MenuItemStyleSeparatorIcon { " + commonText
			+ " background-color: " + this.IconBackgroundColor + ";"
			+ " border-left: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " border-top: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " border-bottom: " + this.ItemHighlightBorderWidth + " solid " + this.IconBackgroundColor + ";"
			+ " width: " + this.IconWidth + "px;"
			+ " cursor: pointer; padding: 0px;"
			+ " height: " + this.SeparatorHeight + ";"
			+ " }\n";

	styleText += ".MenuItemStyleSeparatorIconRight { " + commonText
			+ " background-color: " + this.ItemBackgroundColor + ";"
			+ " border: " + this.ItemHighlightBorderWidth + " solid " + this.ItemBackgroundColor + ";"
			+ " cursor: pointer; padding: 0px;"
			+ " height: " + this.SeparatorHeight + ";"
			+ " }\n";

	return styleText;
}

function MenuStyle_ItemStyle()
{
	var styleText = "";
	var menuStyle = this;

	styleText += "font-family: " + menuStyle.FontFamily + ";";
	styleText += " font-size: " + menuStyle.FontSize + ";";
	styleText += " font-weight: " + menuStyle.FontWeight + ";";
	styleText += " font-style: " + menuStyle.FontStyle + ";";
	styleText += " text-decoration: " + menuStyle.FontDecoration + ";";
	styleText += " background-color: " + menuStyle.ItemBackgroundColor + ";";
	styleText += " border: " + menuStyle.ItemHighlightBorderWidth + " solid " 
			+ menuStyle.ItemBackgroundColor + ";";
	styleText += " padding: " + menuStyle.ItemPaddingWidth + ";";
	styleText += " margin: " + menuStyle.ItemMarginWidth + ";";

	return styleText;
}

function MenuStyle_HighlightStyle()
{
	var styleText = "";
	var menuStyle = this;

	styleText += "font-family: " + menuStyle.FontFamily + ";";
	styleText += " font-size: " + menuStyle.FontSize + ";";
	styleText += " font-weight: " + menuStyle.FontWeight + ";";
	styleText += " font-style: " + menuStyle.FontStyle + ";";
	styleText += " text-decoration: " + menuStyle.FontDecoration + ";";
	styleText += " background-color: " + menuStyle.ItemHighlightColor + ";";
	styleText += " border: " + menuStyle.ItemHighlightBorderWidth + " " + menuStyle.ItemHighlightBorderStyle 
			+ " " + menuStyle.ItemHighlightBorderColor + ";";
	styleText += " padding: " + menuStyle.ItemPaddingWidth + ";";
	styleText += " margin: " + menuStyle.ItemMarginWidth + ";";

	return styleText;
}

function MenuStyle_MenuStyle()
{
	var styleText = "";

	styleText += "background-color: " + this.BackgroundColor + ";";
	styleText += " border: " + this.ItemMarginWidth + " solid " + this.ItemBackgroundColor + ";";
	styleText += " cursor: pointer;";

	return styleText;
}

/////////////////////////////////////////////////////

function HighlightMenuItem(itemNum)
{
	var menuItem = MenuObjects[itemNum];
	menuItem.Highlight();
}

function UnHighlightMenuItem(itemNum)
{
	var menuItem = MenuObjects[itemNum];
	menuItem.UnHighlight();
}

function MenuItemClick(itemNum)
{
	var menuItem = MenuObjects[itemNum];
	menuItem.Click();
}
