var bInitialized=false;
var LocationArray=new Array();
LocationArray[0]='';
LocationArray[1]='';
function document.onreadystatechange()
{
	if (document.readyState!="complete") return;
	if (bInitialized) return;
	bInitialized = true;
	//MenuWindow.document.onclick=HiddenMainMenu;
	OpreateWindow.document.onclick=HiddenMainMenu;
}

function MouseOverMainMenu()
{
	var el=event.srcElement;
	if (el.HaveChild!=null)
	{
		if (event.type=='mouseover')
		{
			for (var i=0;i<document.body.all.length;i++)
			{
				if (document.body.all(i).className=='highlightitem') document.body.all(i).className='menuItem';
				if (document.body.all(i).style.backgroundColor=='highlight') document.body.all(i).style.backgroundColor='menu';
			}
			el.className='highlightitem';
			LocationArray[0]=el.OperateText;
			document.all(el.offsetParent.sourceIndex-1).style.backgroundColor='highlight';
			var TempObj=ChildMenu;
			TempObj.innerHTML=el.children(0).innerHTML;
			TempObj.style.posTop=MainMenu.style.posTop+el.parentElement.parentElement.offsetTop;//MainMenu.style.posTop;//el.offsetHeight;
			TempObj.style.posLeft=MainMenu.clientWidth+3;//el.offsetWidth;
			TempObj.className='childMenuShow';
			//alert(el.parentElement.parentElement.offsetTop);
		}
		else
		{
			if (event.toElement.id.substr(0,5)=='Child')
			{
				document.all(el.offsetParent.sourceIndex-1).style.backgroundColor='highlight';
				el.className='highlightitem';
				LocationArray[0]=el.OperateText;
				ChildMenu.className='childMenuShow';
			}
			else
			{
				document.all(el.offsetParent.sourceIndex-1).style.backgroundColor='menu';
				el.className='menuItem';
				ChildMenu.className='childMenu';
			}
		}
	}
	else
	{
		ChildMenu.className='childMenu';
		for (var i=0;i<document.body.all.length;i++)
		{
			if (document.body.all(i).className=='highlightitem') document.body.all(i).className='menuItem';
			if (document.body.all(i).style.backgroundColor=='highlight') document.body.all(i).style.backgroundColor='menu';
		}
		if (el.className.toLowerCase()=="menuitem")
		{
			el.className="highlightItem";
			LocationArray[0]=el.OperateText;
			el.parentElement.parentElement.children(0).style.backgroundColor='highlight';
		}
		else if (el.className.toLowerCase()=="highlightitem") el.className="menuItem";
	}
}

function MouseOverChildMenu() 
{   
	var el=event.srcElement;
	switch (el.tagName.toLowerCase())
	{
		case 'img':
			el=event.srcElement.parentElement.parentElement;
			break;
		case 'td':
			el=event.srcElement.parentElement;
			break;
		case 'tr':
			break;
		default:
			return;
	}
	if (el.className.toLowerCase()=="menuitem")
	{
		el.className="highlightItem";
		for (var i=0;i<el.children.length;i++) el.children(i).style.color='#FFFFFF';
		LocationArray[1]=el.OperateText;
	}
	else if (el.className.toLowerCase()=="highlightitem")
	{
		el.className="menuItem";
		for (var i=0;i<el.children.length;i++) el.children(i).style.color='#000000';
		LocationArray[1]='';
	}
	if (el.className.toLowerCase()=="menuitemdisable") 
	{
		if (el.style.backgroundColor=="highlight") el.style.backgroundColor="";
		else el.style.backgroundColor="highlight";
	}
}

function ClickMainMenu(MenuObj)
{
   var el=event.srcElement;
   if (el.ExeFunction != null)
   {
	   if (el.className.toLowerCase()!='menuitemdisable')
	   {
		  for (var i=0;i<MenuObj.all.length-1;i++)
		  {
			   if (MenuObj.all(i).className=='highlightitem')
			   {
				    MenuObj.all(i).className='MenuItem';
				}
		   }
		   MenuObj.releaseCapture();
		   MenuObj.className = "mainmenu";
		   ShowLocation();
		   eval(el.ExeFunction);
	   }
	   MenuWindow.MainMenuButton.className='BtnMouseOver';
	   ChildMenu.className='menu';
   }
}

function CMClickMenu(Obj)
{
	var el=event.srcElement;
	switch (el.tagName.toLowerCase())
	{
		case 'img':
			el=event.srcElement.parentElement.parentElement;
			break;
		case 'td':
			el=event.srcElement.parentElement;
			break;
		case 'tr':
			break;
		default:
			return;
	}
	if (el.ExeFunction!=null)
	{
		for (var i=0;i<MainMenu.all.length-1;i++)
		{
			if (MainMenu.all(i).className=='highlightitem')
			{
				MainMenu.all(i).className='MenuItem';
			}
			else
			{
				//if (MainMenu.all(i).background.toLowerCase()!='') MainMenu.all(i).backgroundColor='menu';
			}
			//alert(MainMenu.all(i).backgroundColor);
			if (MainMenu.all(i).style.backgroundColor=='highlight') MainMenu.all(i).style.backgroundColor='';
		}
		MainMenu.className='mainmenu';
		MenuWindow.MainMenuButton.className='BtnMouseOver';
		Obj.releaseCapture();
		Obj.className='menu';
		ShowLocation();
		eval(el.ExeFunction);
	}
}

function HiddenMainMenu()
{
	MainMenu.className='mainmenu';
	ChildMenu.className='childmenu';
	MenuWindow.MainMenuButton.className='BtnMouseOver';
}

function ShowLocation()
{
	if (LocationArray[1]!='')
		MenuWindow.LocationArea.innerHTML='<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前位置:</strong>'+LocationArray[0]+'/'+LocationArray[1];
	else
		MenuWindow.LocationArea.innerHTML='<strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前位置:</strong>'+LocationArray[0];
}