// Internal Variables  		
var OverButton = false;  	
var OverMenu = false;   	
var CurrentMenu = "";   
var RootMenu = null;

//distance from links to Menu
var leftGap = 140;

function MenuNav(URL)
{
  if (URL) window.location.href = URL;
} 

function HideSingleMenu(Menu)
{   
		Menu.style.display = "none";  
		if( ! OverButton && ! OverMenu) KillTree(CurrentMenu);  
		if(RootMenu==Menu.id)RootMenu=null;  
}

function KillTree(Menu)
{   
		var Counter;      	
		var MenuArray;   	
		var MenuName;    
		if (! Menu) return;  	
		MenuArray = Menu.id.split("_");   
		MenuName = "";  
		for (Counter = 0; Counter < (MenuArray.length); Counter++){ 
			if (Counter != 0){ MenuName = MenuName + "_";}   
			MenuName = MenuName + MenuArray[Counter];  
			eval(MenuName).style.display = "none";}    
		RootMenu = null;  	
}

function MouseOverButton(Menu)
{   
		OverButton = true;		
		if (Menu.HideTimer) clearTimeout(Menu.HideTimer);  
		if (RootMenu != Menu.id)
    {   	
			if (RootMenu) HideSingleMenu(eval(RootMenu));  	
			RootMenu = Menu.id;  	
			
			//window.event.y - window.event.offsetY + 3 - 3 + document.body.scrollTop;
			Menu.style.left = (window.event.x + (leftGap - window.event.offsetX)) - 3; 
			
			//Original Code
			Menu.style.top = window.event.y - window.event.offsetY - 1 + document.body.scrollTop + 2;

			Menu.style.display="inline";
    }  
} 

function MouseOutButton(Menu)
{ 
		Menu.HideTimer = setTimeout("HideSingleMenu(" + Menu.id + ");", 1);  
		OverButton = false; 
}

function MouseOverMenu(Menu)
{   	
		if (Menu.HideTimer) clearTimeout(Menu.HideTimer);   	 
		if (Menu.ParentMenu) clearTimeout(Menu.ParentMenu.HideTimer);  
		CurrentMenu = Menu;   
		OverMenu = true;   	
}

function MouseOutMenu(Menu)
{ 
		if (! OverButton) Menu.HideTimer = setTimeout("HideSingleMenu(" + Menu.id + ");",1); 
		CurrentMenu = Menu;   
		OverMenu = false;   	
}

function MouseOverMenu1(Menu)
{   	
		Menu.style.backgroundColor="#FFFFFF"; 
		Menu.style.color="#003366"; 
}

function MouseOutMenu1(Menu, Menu3)
{  
		if (Menu3 == 0) Menu.style.backgroundColor="#003366"; //dark blue
		if (Menu3 == 1) Menu.style.backgroundColor="#6699CC"; //light blue
		//Menu.style.backgroundColor="#003366"; 
		Menu.style.color="#FFFFFF"; 

}

function MouseOverTop(Menu)
{   	
		Menu.style.backgroundColor="#FFFFFF"; 
		Menu.style.color="#003366"; 
}

function MouseOutTop(Menu)
{  
		Menu.style.backgroundColor="#C2DAF6";
		Menu.style.color="#36669F"; 
}

function MouseOverItem(Item,SubMenu,yPos,topRows,LangType)
{ 
		Item.style.backgroundColor="FFFFFF"; 
		Item.style.color="#003366"; 
		if (SubMenu){ 
			Child = eval(Item.id.replace(/I/, "M"));
			//alert (Child.id);
			if (Child.HideTimer) {
				clearTimeout(Child.HideTimer);
				//alert ("Childid = " + Child.id + "   ChilTimer = " + Child.HideTimer);
				}
			Child.style.left = 140;//(window.event.x + (140 - window.event.offsetX)) - 160;\
			/* 
				LangType value of 1, means that it is an English menu,
			    yPosition is set for position of second flyout, language needs to
			    be determined due to different height of menu items,
				yPos value is the order of menu position with the first menu being set at 2,
				currently set up for 11 first level menu items
			*/
			if (LangType == 1)
			{
				// Position for english flyout menu
				if(yPos == 2) yPosition = 205;
				if(yPos == 3) yPosition = 238;
				if(yPos == 4) yPosition = 261;
				if(yPos == 5) yPosition = 315;
				if(yPos == 6) yPosition = 350;
				if(yPos == 7) yPosition = 378;
				if(yPos == 8) yPosition = 411;
				if(yPos == 9) yPosition = 444;
				if(yPos == 10) yPosition = 477;
				if(yPos == 11) yPosition = 510;
				if(yPos == 12) yPosition = 543;
				if(yPos == 13) yPosition = 585;
				if(yPos == 14) yPosition = 636;
				if(yPos == 15) yPosition = 569;
				if(yPos == 16) yPosition = 702;
				if(yPos == 16) yPosition = 735;
			}
			else {
				// Position for french flyout menu
				if(yPos == 2) yPosition = 205; 
				if(yPos == 3) yPosition = 238;
				if(yPos == 4) yPosition = 280;
				if(yPos == 5) yPosition = 325;
				if(yPos == 6) yPosition = 380;
				if(yPos == 7) yPosition = 380;
				if(yPos == 8) yPosition = 408;
				if(yPos == 9) yPosition = 487;
				if(yPos == 10) yPosition = 505;
				if(yPos == 11) yPosition = 545;
				if(yPos == 12) yPosition = 610;
				if(yPos == 13) yPosition = 610;
				if(yPos == 14) yPosition = 610;
				if(yPos == 15) yPosition = 610;
				if(yPos == 16) yPosition = 610;
				if(yPos == 17) yPosition = 610;
			}
			Child.style.top = window.event.y - window.event.offsetY + document.body.scrollTop + 5 - yPosition - (20 * topRows);
			//Child.style.top = yPosition;//window.event.y;// - window.event.offsetY;// - yPosition;// - (yPos * 32);
			Child.style.display = "inline";
			//yPosition = 0;
    } 
}

function MouseOutItem(Item, SubMenu)
{ 
		Item.style.backgroundColor = "#6699CC"; 
		Item.style.color = "#FFFFFF"; 
		if (SubMenu)
    {
			Child = eval(Item.id.replace(/I/, "M")); 
			Child.ParentMenu = Item.parentElement;
			Child.HideTimer = setTimeout("HideSingleMenu(" + Child.id + ")",1);
    }
}

// Browser detection
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;

function init()
{
document.onmouseup=mouseUp;
if (ns4)
{document.captureEvents(Event.MOUSEUP);}
}