var ShowingMenu = false;
var ShowingMenuID = '';
var MenuTimeout = null;
var delay = 300;
var opera = (navigator.userAgent.indexOf('Opera') != -1);

function MenuButtonOver(id){
	if(MenuTimeout != null)
		clearTimeout(MenuTimeout);
	ShowMenu(id);
}
function MenuButtonOut(id){
	MenuTimeout = setTimeout(HideMenu,delay);
}

function SubMenuOver(id){
	if(MenuTimeout != null)
		clearTimeout(MenuTimeout);
}
function SubMenuOut(id){
	MenuTimeout = setTimeout(HideMenu,delay);
}

function ShowMenu(id){
	if(ShowingMenu && id != ShowingMenuID)
		HideMenu(ShowingMenuID);
		
	ShowingMenu = true;
	ShowingMenuID = id;
	var menu = GetObject('sm_'+id);
	var button = GetObject('mb_'+id);
	var corner = GetObject('sc_'+id);
	var iframe = GetObject('m_ifd');
	if(menu != null && button != null){
		var buttonLeft = GetX(button);
		var buttonTop = GetY(button);
		var buttonHeight = GetHeight(button);
		var buttonWidth = GetWidth(button);
		menu.style.left = (buttonLeft-1)+'px';
		menu.style.top = (buttonTop+buttonHeight)+'px';
		menu.style.display = 'block';
		ie = document.all;
		
		if(iframe != null && ie && !opera){		
			iframe.style.left = (buttonLeft-1)+'px';
			iframe.style.top = (buttonTop+buttonHeight)+'px';
			iframe.style.width = GetWidth(menu)+'px';
			iframe.style.height = GetHeight(menu)+'px';
			iframe.style.display = 'block';
			iframe.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		}
		
		if(corner != null){
			corner.style.left = (buttonLeft-1)+'px';
			corner.style.top = (buttonTop+buttonHeight)+'px';
			corner.style.display = 'block';
		}
	}
}
function HideMenu(){

	ShowingMenu = false;
	id = ShowingMenuID;
	ShowingMenuID = null;
	var menu = GetObject('sm_'+id);
	var corner = GetObject('sc_'+id);
	var iframe = GetObject('m_ifd');
	if(menu != null)
		menu.style.display = 'none';
	if(iframe != null)
		iframe.style.display = 'none';
	if(corner != null)
		corner.style.display = 'none';
}