function makeMenu(e) {
	var children = e.getElements('li');
	
	for (var i = 0; i < children.length; i++) {
		var child = children[i];
		var parent = child.getParent();
		var grandParent = parent.getParent();
				
		// For headers and footers (for rounded corners, etc.)
		if (grandParent.tagName != 'LI') {
			// This is a top-level link.
			child.grab(new Element('span', {'class':'header'}), 'top');
		} else if (!parent.visited) {
			// This is one of the submenu items. 
			parent.grab(new Element('li', {'class':'header'}), 'top');
			parent.grab(new Element('li', {'class':'footer'}), 'bottom');
			parent.visited = true;
		}
		
		child.addEvent('mouseenter', highlightMenuItem.bindWithEvent(child));
		child.addEvent('mouseleave', dimMenuItem.bindWithEvent(child));
		
		var sub = child.getElement('ul');
		if (sub) {
			child.subMenu = sub;
			
			child.getElement('a').addClass('subMenuIndicator');

//			sub.slider = new Fx.Styles(sub, {duration: 250, transition: Fx.Transitions.Quad.easeOut});
//			sub.setOpacity(0);
//			sub.style.display = 'block';
			sub.setStyle('display', 'none');

			child.addEvent('mouseenter', openSubMenu.bindWithEvent(child));
			child.addEvent('mouseleave', closeSubMenu.bindWithEvent(child));
		};

		var link = child.getFirst();
		if (link.tagName == 'SPAN') {
			link = link.getFirst();
		}

		if (link != null || link != undefined) {
			child.href = link;
		}
		
		var tip = child.getElement('.menu_tip');
		if (tip) {
			var tipParent = tip.getParent();
			if (!tipParent.hasTip) { // Prevent adding of multiple events.
				tipParent.hasTip = true;

				// Frames for PNG
				
				tip.grab(new Element('div', {'class':'header'}), 'top');
				tip.grab(new Element('div', {'class':'footer'}), 'bottom');
			
				// Mouse events
				tipParent.addEvent('mouseenter', displayMenuTip.bindWithEvent(tip));
				tipParent.addEvent('mouseleave', hideMenuTip.bindWithEvent(tip));
				tip.addEvent('click', openLinkFromEvent.bindWithEvent(child));
			};
		}
		
	};
	
}

function openLinkFromEvent() {
	if (this.href) {
		document.location = this.href;
	};
}

function openSubMenu() {
	this.addClass('highlighted');
	this.subMenu.setStyle('display', 'block');
//	this.subMenu.slider.stop();
//	this.subMenu.slider.start({'opacity': [0, 1]});
}

function closeSubMenu() {
	this.removeClass('highlighted');
	this.subMenu.setStyle('display', 'none');
//	this.subMenu.slider.stop();
//	this.subMenu.slider.start({'opacity': [1, 0]});
}

function displayMenuTip() {
	this.style.display = 'block';
}

function hideMenuTip() {
	this.style.display = 'none';
}

function highlightMenuItem() {
	this.addClass('highlighted');
}

function dimMenuItem() {
	this.removeClass('highlighted');
}

