// JavaScript Document
	var MenuVisible = false;
	var SelectedMenuID = 0;
	var ClickCount = 0;

  function OverMenu(MenuID)
  {
  /*
  	MenuVisible = !MenuVisible;
	ClickCount = 0;*/
	if(MenuVisible && MenuID>0)
	{ //показываем меню
		//прячем старое
		if(SelectedMenuID > 0 && SelectedMenuID != MenuID)
		{
			oldMenu = document.getElementById("SubMenu_" + SelectedMenuID);
			if(oldMenu != null)
			{
				oldMenu.style.visibility = 'hidden';
				MenuHeadOut(SelectedMenuID);
			}
		}
		SelectedMenuID = MenuID;
		//показываем новое
		newMenu = document.getElementById("SubMenu_"+MenuID);
		if(newMenu != null)
		{
			newMenu.style.visibility = 'visible';
			MenuHeadOn(MenuID);
		}
	}
  }
  function SelectMenu(MenuID)
  {
	if(MenuID == SelectedMenuID && MenuVisible)
	{
		MenuVisible = false;
	}
	else
	{
		MenuVisible = true;
	}
	ClickCount = 0;
	if(MenuVisible && MenuID>0)
	{ //показываем меню
		//прячем старое
		if(SelectedMenuID > 0)
		{
			oldMenu = document.getElementById("SubMenu_" + SelectedMenuID);
			if(oldMenu != null)
			{
				oldMenu.style.visibility = 'hidden';
				MenuHeadOut(SelectedMenuID);
			}
		}
		SelectedMenuID = MenuID;
		//показываем новое
		newMenu = document.getElementById("SubMenu_"+MenuID);
		if(newMenu != null)
		{
			newMenu.style.visibility = 'visible';
			MenuHeadOn(MenuID);
		}
	}
	else
	{
		//прячем себяже
		newMenu = document.getElementById("SubMenu_"+MenuID);
		if(newMenu != null)
		{
			newMenu.style.visibility = 'hidden';
			MenuVisible = false;
			ClickCount = 0;
			MenuHeadOut(SelectedMenuID);
		}
	}
  }
  function MenuHeadOn(MenuID)
  {
  	obj = document.getElementById("MenuScos_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "RightMenuScos")
		{
			obj.setAttribute('className','RightMenuScosCl');
			obj.setAttribute('class','RightMenuScosCl');
		}
	}
	obj = document.getElementById("MenuHead_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "OutItem")
		{
			obj.setAttribute('className','OnItem');
			obj.setAttribute('class','OnItem');
		}
	}
	obj = document.getElementById("SelectedLeft_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "LeftSelectedScosCl")
		{
			obj.setAttribute('className','LeftSelectedScos');
			obj.setAttribute('class','LeftSelectedScos');
		}
	}
  }
  function MenuHeadOut(MenuID)
  {
  	obj = document.getElementById("MenuScos_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "RightMenuScosCl")
		{
			obj.setAttribute('className','RightMenuScos');
			obj.setAttribute('class','RightMenuScos');
		}
	}
	obj = document.getElementById("MenuHead_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "OnItem")
		{
			obj.setAttribute('className','OutItem');
			obj.setAttribute('class','OutItem');
		}
	}
	obj = document.getElementById("SelectedLeft_"+MenuID);
	if(obj!=null)
	{
		if(obj.className == "LeftSelectedScos")
		{
			obj.setAttribute('className','LeftSelectedScosCl');
			obj.setAttribute('class','LeftSelectedScosCl');
		}
	}
  }
  function CloseMenu()
  {
  	ClickCount++;
	if(ClickCount >=2 )
	{ //прячем меню
		if(SelectedMenuID>0)
		{
			menuObj = document.getElementById("SubMenu_"+SelectedMenuID);
			if(menuObj!=null)
			{
				menuObj.style.visibility = 'hidden';
				MenuHeadOut(SelectedMenuID);
				MenuVisible = false;
			}
		}
	}
  }
  function SubMenuOn(Obj)
  {
	var thisDiv = Obj.getElementsByTagName("div")[0];

	if(thisDiv.className == "SelectZone")
	{
		thisDiv.setAttribute('className','SelectedZone');
		thisDiv.setAttribute('class','SelectedZone');
	}
  }
  
  function SubMenuOut(Obj)
  {
	var thisDiv = Obj.getElementsByTagName("div")[0];

	if(thisDiv.className == "SelectedZone")
	{
		thisDiv.setAttribute('className','SelectZone');
		thisDiv.setAttribute('class','SelectZone');
	}
  }
