var MainLink = '';
var MainBasic = '';
var NeedMouseOut = false;
var NeedMouseOver = false;
var ActiveMenu = '';
var MouseOver = '';

function DoMouseOut()
{
  if (NeedMouseOut) {
	NeedMouseOut = false;
    var target = document.getElementById(ActiveMenu);
	if (target) {
		var menu_main_normal = document.getElementById('tmp_menu_main_normal');
	    target.style.backgroundColor = xGetComputedStyle(menu_main_normal, 'backgroundColor', 0);
		target.style.color = xGetComputedStyle(menu_main_normal, 'color', 0);

		var subMenu = document.getElementById('sub'+ActiveMenu);
		var shadow = document.getElementById('menu_item_box_shadow');
		if (subMenu) {
			subMenu.style.visibility = 'hidden';
			shadow.style.visibility = 'hidden';
		}
	}
	ActiveMenu = '';
  }
}

function DoMouseOver()
{
	if (NeedMouseOver == false) {
		DoMouseOut();
	} else {
	DoMouseOut();
//    var target = e?e.target:window.event?window.event.srcElement:null;
	var target = document.getElementById(MouseOver);
//	alert(e);
	if (target) {
		ActiveMenu = target.id;

		var Container = document.getElementById('menu_area_body');
		var main_page = document.getElementById('main_page');
		
		var obj = document.getElementById('sub'+target.id);
		var shadow = document.getElementById('menu_item_box_shadow');
		
		var menu_main_over = document.getElementById('tmp_menu_main_over');
		
    	target.style.backgroundColor = xGetComputedStyle(menu_main_over, 'backgroundColor', 0);
		target.style.color = xGetComputedStyle(menu_main_over, 'color', 0);
		target.style.cursor = xGetComputedStyle(menu_main_over, 'cursor', 0);
		
		if (obj) {
			obj.style.visibility = 'visible';
			obj.style.left = main_page.offsetLeft + 90 + Container.offsetLeft + target.offsetLeft;

			shadow.style.visibility = 'visible';
			shadow.style.left = obj.offsetLeft+4;
			shadow.style.top = obj.offsetTop+4;
			shadow.style.width = obj.offsetWidth;
			shadow.style.height = obj.offsetHeight;

		}
	}
	}
	NeedMouseOut = false;
	NeedMouseOver = false;
}

function OnMouseOver(e)
{ 
	MouseOver = e.id;
	NeedMouseOver = true;
	setTimeout('DoMouseOver()', 250);
}

function isNeedMouseOut(e)
{
	if (NeedMouseOut == true && e) {
		setTimeout('DoMouseOut()', 250);
	}
}

function OnMouseOut(e)
{
	var target =  e;
	NeedMouseOut = true;
	NeedMouseOver = false;
	setTimeout('isNeedMouseOut('+target.id+')', 250);
}

function OnSubMouseOver(e)
{
	if (e) {
		NeedMouseOut = false;
		var objBase = document.getElementById('tmp_menu_item_over');
   		e.style.backgroundColor = xGetComputedStyle(objBase, 'backgroundColor', 0);
		e.style.color = xGetComputedStyle(objBase, 'color', 0);
		e.style.cursor = xGetComputedStyle(objBase, 'cursor', 0);
	}
}

function OnSubMouseOut(e)
{
	var objBase = document.getElementById('tmp_menu_item_normal');
	if (e && objBase) {
     	e.style.backgroundColor = xGetComputedStyle(objBase, 'backgroundColor', 0);
		e.style.color = xGetComputedStyle(objBase, 'color', 0);
		e.style.cursor = xGetComputedStyle(objBase, 'cursor', 0);
	}
	NeedMouseOut = true;
	setTimeout('isNeedMouseOut('+ActiveMenu+')', 500);
}

function OnClick(e, AExtra, AIdName)
{
	if (AExtra == '') {
		location.href=MainLink + AIdName;
	} else {
		location.href=MainBasic + AExtra + ':' + AIdName;
	}
}
