//Common functions to build Menu for navigation
function showMenu(menu,submenu)
{
	var elementid = document.getElementById(submenu);
	
	var xCoord = getXCoord(menu);
	var yCoord = getYCoord(menu);

	xCoord += 125;
		
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var	totalHeight = yCoord + getHeight(submenu) + 10
		var availHeight = parseInt(document.body.offsetHeight)*1 + parseInt(document.body.scrollTop)*1
		
		if (totalHeight > availHeight)
		{
			yCoord = yCoord - getHeight(submenu) + 16;
		}
	}
	else
	{
	}
	
	xCoord += 'px';
	yCoord += 'px';
	
	elementid.style.visibility = 'visible';
	elementid.style.left = xCoord;
	elementid.style.top = yCoord;
}
//_____________________________________________________________________________________________________________________

function hideMenu(submenu)
{
	var elementid = document.getElementById(submenu);
	
	if (elementid.style.visibility == 'visible') elementid.style.visibility = 'hidden';
}
//_____________________________________________________________________________________________________________________

function getXCoord(id)
{
	var elementid = document.getElementById(id);
	var xCoord = elementid.offsetLeft;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		xCoord += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	return xCoord;
}
//_____________________________________________________________________________________________________________________

function getYCoord(id)
{
	var elementid = document.getElementById(id);
	var yCoord = elementid.offsetTop;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		yCoord += parent.offsetTop;
		parent = parent.offsetParent;
	}
	return yCoord;
}
//_____________________________________________________________________________________________________________________

//Function to get the height of the submenu
function getHeight(id)
{
	var elementid = document.getElementById(id);
	var height = elementid.offsetHeight;
	return height;
}
//_____________________________________________________________________________________________________________________

//Function for page navigation
function fnLink(pPageNam)
{
	location.href = pPageNam;
}
//_____________________________________________________________________________________________________________________

function BuildMenu(pStrMenuNam, pStrSubMenuNam, pArrLnkNam, pArrPgNam)
{
strHtml = strHtml + "<table width=" + fIntTblWid + " border=" + fStrTblBdrSiz + " bordercolor=" + fStrTblBdrClr + " cellspacing=" + fIntTblCellSpc + " cellpadding=" + fIntTblCellPad + " id=" + pStrSubMenuNam + " style='position:absolute; z-index:1; visibility:hidden;' onMouseOver=showMenu('" + pStrMenuNam + "','" + pStrSubMenuNam + "');" + pStrMenuNam + ".style.backgroundColor='" + fStrTdMOverClr + "' onMouseOut=hideMenu('" + pStrSubMenuNam + "');" + pStrMenuNam + ".style.backgroundColor=''>"
for (i=0; i<pArrLnkNam.length; i++)
	strHtml = strHtml + "<tr><td style='CURSOR: hand' bgcolor=#E5EAEE onmouseout=this.style.backgroundColor='" + fStrTdBgClr + "' onmouseover=this.style.backgroundColor='" + fStrTdMOverClr + "' onClick=fnLink('" + pArrPgNam[i] + "')><a href=" + pArrPgNam[i] + ">" + pArrLnkNam[i] + "</a></td></tr>"
strHtml = strHtml + "</table>"
}
//_____________________________________________________________________________________________________________________
