current_menu = "";
current_global_menu = "";
menu_on = 0;
global_menu_on = 0;
//-----------------------------------------------------------------------------
// buildMenu(array, menu name, class name)
function buildMenu(menu_array, menu_name, class_name)
{
	// [0] - URL
	// [1] - Text
	// [2] - Target

	out_string = "";
	
	out_string += "<span id=\"" + menu_name + "\" style=\"display: none; position: absolute;\" onMouseOver=\"stopTimer();\" onMouseOut=\"startTimer();\">";
	
	if (menu_array.length > 0)
	{
		out_string += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"" + class_name + "\">";
		
		for (i = 0; i < menu_array.length; i+= 3)
		{
			out_string += "<tr>";
			out_string += "<td "
			out_string += "class=\"menu_off\" onClick=\"goUrl('" + menu_array[i] + "', '" + menu_array[i+2] + "');\" "
			out_string += "onMouseOver=\"this.className = 'menu_on';\" onMouseOut=\"this.className = 'menu_off';\" "
			out_string += ">" + menu_array[i+1] + "</td>";
			out_string += "</tr>";
		}
		
		out_string += "</table>";
	}

	out_string += "</span>";
	
//	alert(out_string);
//	document.write("<textarea cols=80 rows=10>" + out_string + "</textarea>");
	document.write(out_string);
}

//-----------------------------------------------------------------------------
// showMenu(menu name, direction)
function showMenu(menu_name, direction)
{
	hideMenu();
	current_menu = menu_name;

	// highlight parent menu
	document.getElementById("parent_" + menu_name).className = "button_on";
	
	// get position to show menu at
	x_pos = getAbsPos("parent_" + menu_name)[0];
	y_pos = getAbsPos("parent_" + menu_name)[1];
	x_offset = 0;
	y_offset = 0;
	
	if (direction == "right")
	{
		x_offset = document.getElementById("parent_" + menu_name).offsetWidth;
	}
	else if (direction = "below")
	{
		y_offset = document.getElementById("parent_" + menu_name).offsetHeight;
		y_offset += 3;
	}
	
	x_pos += x_offset;
	y_pos += y_offset;
	
	// show menu
	document.getElementById(menu_name).style.left = x_pos;
	document.getElementById(menu_name).style.top = y_pos;
	document.getElementById(menu_name).style.display = "block";
}

//-----------------------------------------------------------------------------
// hideMenu()
function hideMenu()
{
	if (current_menu != "")
	{
		document.getElementById("parent_" + current_menu).className = "button_off";
		document.getElementById(current_menu).style.display = "none";
	}
	
	current_menu = "";
}


//-----------------------------------------------------------------------------
function startTimer()
{
	menu_on = setTimeout("hideMenu()", 500);
}

function stopTimer()
{
	if (menu_on != 0)
	{
		clearTimeout(menu_on);
	}
}

function goUrl(go_url, go_target)
{
	if (go_url != "")
	{
		if (go_target != "")
		{
			window.open(go_url);
		}
		else
		{
			location.href = go_url;
		}
	}
}

function getX(el) 
{ 
	xPos = el.offsetLeft; 
	tempEl = el.offsetParent; 
	while (tempEl != null) 
	{ 
		xPos += tempEl.offsetLeft; 
		tempEl = tempEl.offsetParent; 
	} 
	return xPos; 
} 

function getY(el) 
{ 
	yPos = el.offsetTop; 
	tempEl = el.offsetParent; 
	
	while (tempEl != null) 
	{ 
		yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; 
	} 
	
	return yPos; 
} 

function getAbsPos(id) 
{ 
	var el = document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : null; 
	
	if (el) 
	{ 
		var trueX = getX(el); 
		var trueY = getY(el); 
	} 
	
	return new Array(trueX, trueY);
} 

function showMenuSide(menu_name, side)
{
	if (current_menu != "")
	{
		hideMenu();
	}
	
	current_menu = menu_name;
	
	parentWidth = eval("document.getElementById(\"parent_" + menu_name + "\").offsetWidth");
	parentHeight =  eval("document.getElementById(\"parent_" + menu_name + "\").offsetHeight");


	if (side == "left")
	{
		xPos = getAbsPos("parent_" + menu_name)[0];
		yPos = getAbsPos("parent_" + menu_name)[1];
		
//		xPos -= (eval("document.getElementById(\"" + menu_name + "\").offsetWidth"));
		xPos -= 152;
//		alert(menu_name);
//		yPos -= parentHeight;
	}
	
	if (side == "bottom")
	{
		xPos = getAbsPos("parent_" + menu_name)[0];
		yPos = getAbsPos("parent_" + menu_name)[1];
		yPos += parentHeight + 2;
	}
	
	// show menu
	eval("document.getElementById(\"" + menu_name + "\").style.left='" + xPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.top='" + yPos + "'");
	eval("document.getElementById(\"" + menu_name + "\").style.display='block'");
	
}