function EnhancedMenu (props)
{
	this.menu	= document.getElementById(props.menuId);
	if (typeof(props.hoverClass) != 'undefined')
	{
		this.hoverClass	= props.hoverClass;
	}
	else
	{
		this.hoverClass	= null;
	}
}

EnhancedMenu.prototype.enhance = function()
{
	for (var i = 0; i < this.menu.childNodes.length; i++)
	{
		var node = this.menu.childNodes[i];
		if (node.nodeName == "UL")
		{
			this.enhance(node);
		}
		else if (node.nodeName == "LI")
		{
			for (var j = 0; j < node.childNodes.length; j++)
			{
				var node2 = node.childNodes[j];
				if (node2.nodeName == "A")
				{
					node.onclick = this.enhancheLi(node2.href);
					if (this.hoverClass != null)
					{
						var hoverClass = this.hoverClass;
						node.onmouseover = function () {
							this.className += ' '+hoverClass;
						}
						node.onmouseout = function () {
							this.className = this.className.substr(0, (hoverClass.length-1));
						}
					}
				}
			}
		}
	}
}

EnhancedMenu.prototype.enhancheLi = function(url)
{
	return function () { window.location.href = url; }
}
EnhancedMenu.prototype.init = function(elArr)
{
	for (var i in elArr)
	{
		var menu = new EnhancedMenu (elArr[i]);
		menu.enhance();
	}
}
