var sCurrentMenu="";

function FindNamedObject(name)
{
	if(window.navigator.appname == "Microsoft Internet Explorer")
	{
		return document.all[name];
	}
	else
	{
		return document.getElementById(name);
	}

}

// This is the OnMouseOver handler
function MoveMenuDown(name)
{
	// First, find the object by this name
	var menu = FindNamedObject(name);

	// Now, move the menuto down to a coordinate of TODO
	MoveToY(menu, 0);
}

// This is the OnMouseOut handler
function MoveMenuUp(name)
{
	// First, find the object by this name
	var menu = FindNamedObject(name);

	// Now, move the menu back up to a coordinate of zero, shamelessly copied from
	// the CSS file.
	MoveToY(menu, -70);
}

// This is called to toggle the text color for the menu headings
function ChangeTextColor(name, color)
{
	// First, find the object by the name
	// Then, set the color.


	if ( (name == 'menuabout') || (name == 'menuteachers') || (name == 'menutraining') )
	{
		var text = FindNamedObject(name);
		text.style.color = color;
	}
	else
	{
		var atext = FindNamedObject('link'+name);
		atext.style.color = color;
	}
}



//Shows and Golds the text of the main menu
function ShowMenu(name)
{
	var obj;

	HideMenu(sCurrentMenu);
	sCurrentMenu=name;

	var sMenu = 'menu' + name;
	var sSub = 'sub' + sMenu;

	obj=FindNamedObject(sMenu);
	//obj.style.color = '#F5E3B7';
	ChangeTextColor(sMenu,'#F5E3B7');

	if ( (name != 'home') && (name != 'host') && (name != 'online') )
	{
		obj=FindNamedObject(sSub);
		obj.style.display = 'inline';
	}


}
//Hides the text of the main menu
function HideMenu(name)
{
	if(name=="")
		return;
	var obj;
	var sMenu = 'menu' + name;
	var sSub = 'sub' + sMenu;

	obj=FindNamedObject(sMenu);
	//obj.style.color = '#FFFFFF';
	ChangeTextColor(sMenu, '#FFFFFF');


	if ( (name != 'home') && (name != 'host') && (name != 'online') )
	{
		obj=FindNamedObject(sSub);
		obj.style.display = 'none';
	}


}
//Hides all submenus
function HideAllMenus()
{
	HideMenu(sCurrentMenu);
	sCurrentMenu="";

}

//shows menu
function DoMenuSetup(name)
{
	var obj;

	if((name=='synthesis')||(name=='aboutaadil')||(name=='links'))
	{
		ShowMenu('about');
	}
	else if((name=='unitedstates')||(name=='international'))
	{
		ShowMenu('teachers');
	}
	else if((name=='introduction')||(name=='200')||(name=='500')||(name=='certificate'))
	{
		ShowMenu('training');
	}
	else
	{
		HideAllMenus();
		return;
	}

	obj=FindNamedObject('linksubmenu' + name);	
	obj.style.fontWeight = 'bold';

			
}


function MouseOut(name, evt) // to run onmouseout of header div tag?
{
	// First, we get the name of the element that fired the mouseout event.  If
	// that is not 'mainmenu', we don't care about the event.
	var e = evt || window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.id != 'mainmenu') 
		return;

	// If the mainmenu element fired the event, then we are either leaving the menu, or
	// we are going to a child element.  If the latter, we don't want to do anything
	// either.  Only if the mouse is actually leaving the outer boundary of the mainmenu
	// element do we want to respond to the event.
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg && reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode;
	if (reltg == tg) 
		return;

	// If we get here, then the mouse was leaving the menu altogether.
	HideAllMenus();
	ShowMenu(name);
}