// This File is used in all html pages In Right Frame to show menus.
/////////////////////////////////////////////////////////////////////////////
var SubMenuStyle = "font-family: Arial; font-Size: 9pt; background-color: #397AA8; color: white; font-Weight: Normal;";

var LeftFrame = window.parent.frames( 1 );
///////////////////////////////////////////////////////////////////////////
function ShowSubMenu( SMNo )
{
	var XPath = "//*/SubMenu[@no='"+ SMNo +"']";
	var SelMenu = LeftFrame.xmlDoc.selectSingleNode( XPath );

	var Rows = "";
	for(i = 0; i < SelMenu.childNodes.length; i++)
	{
		var SubMenu = SelMenu.childNodes[i];       
		var SMName = SubMenu.getAttribute( "name" );
		var SMLink = SubMenu.getAttribute( "link" );
		var SMNo   = SubMenu.getAttribute( "no" );

		Rows += "<TR onmouseout='HideSubMenu("+ SMNo.length +")' ";
		if( SMLink == null )
			Rows += " onmouseover='ShowSubMenu("+ SMNo +")' style='cursor: default'>";
		else
			Rows += " title='"+ SMLink +"' onclick='Row_OnClick()' style='cursor: hand'>";
		Rows += "<TD style='"+SubMenuStyle+"'><font size=1 color=Brown>&nbsp;►&nbsp;</font>" + SMName + "</TD></TR>";
	}			
	//var DivSrc = "<div id='SubMenu2"+ SMNo +"' style='visibility: visible; POSITION: Absolute; left:200; top:400;'><table cellspacing=1 bordercolor=black width=200>"+ Rows +"</table></div>"; 
	var SMNoLen = Number( SMNo.length ) - 1;
	var smo = document.all( "SubMenu" + SMNoLen ); 
	//smo.innerHTML = "<table cellspacing=0 cellpadding=0 bordercolor=white width=200 border=1>"+ Rows +"</table>";
	smo.innerHTML = "<table cellspacing=1 width=200 border=0>"+ Rows +"</table>";
	smo.style.visibility = "visible";

	// Set Position
	var SMNoLen2 = SMNoLen - 1;
	var SrcElem = event.srcElement;
	if( SrcElem.tagName == "FONT" )
		SrcElem = event.srcElement.parentElement;
	smo.style.top = document.all( "SubMenu" + SMNoLen2 ).offsetTop + SrcElem.offsetTop - 1;
	
	var smoStyleLeft = 0;
	while( SMNoLen2 > 0 )
	{
		smoStyleLeft += document.all( "SubMenu" + SMNoLen2 ).offsetWidth - 1;
		SMNoLen2 -= 1;
	}
	smo.style.left = smoStyleLeft - 2;
}
///////////////////////////////////////////////////////////////////////////
function HideSubMenu( SMNoLen )
{
	// Hide SubMenu(es)	
	var LastSMOIndex = 3;
	while( LastSMOIndex >= SMNoLen )
	{
		var smo2 = document.all( "SubMenu" + LastSMOIndex ); 
		var smo2Left = smo2.offsetLeft;
		var smo2Width = smo2.offsetWidth;
		if( event.clientX < smo2Left )
			smo2.style.visibility = "hidden";

		LastSMOIndex -= 1;
	}
	// Assess current Menu to hide or not
	SMNoLen -= 1;		
	smo = document.all( "SubMenu" + SMNoLen );
	var smoTop = smo.offsetTop;
	var smoHeight = smo.offsetHeight;
	if( event.clientY <= smoTop || event.clientY >= Number( smoTop + smoHeight ) )
		smo.style.visibility = "hidden";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//--------------------------------------
function Row_OnClick()
{
	var	MenuLink = event.srcElement.parentElement.title;
	if( MenuLink.indexOf( "http" ) > -1 || MenuLink.indexOf( ".pdf" ) > -1 )
		window.open( MenuLink, "", "width=750; height=550; resizable=1; top=30; left=30; " );//titlebar=yes; channelmode=yes; menubar=yes;
	else
		document.all.ShowFileFrame.src = MenuLink;
//		window.navigate( MenuLink );
	SubMenu1.style.visibility = "hidden";
	SubMenu2.style.visibility = "hidden";
	SubMenu3.style.visibility = "hidden";
}
///////////////////////////////////////////////////////////////////////////

