  var currentSubMenu = null; 
  var currentSubMenuNum = 0; 
  var closeTimer = null; 
  var closedMenu = null;
  
  function ShowNewWin(id, width, height)
  {
    window.open("http://www.n-studio.ru/image.aspx?" + id, "image_" + id, "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + width + ",height=" + height, true);
  }
  
  function OpenMenuAndChangeClass(num, itemId, className)
  {
    openSubMenu(num);
    document.getElementById(itemId).className = className;
  }
  
  function CloseMenuAndChangeClass(num, itemId, className)
  {
    closeSubMenu(num);
    document.getElementById(itemId).className = className;
  }
  
  function openSubMenu(num) 
  { 
	
	close();
	closedMenu = null;  
	///очмщаем старые открытые меню
	if (closeTimer != null)
	{
		window.clearTimeout(closeTimer); 
	}
  
    var subMenu = document.getElementById("subMenu" + num); 
    if (subMenu != null) 
    { 
      cancelCloseTime(); 
      subMenu.style.display=''; 
      
      if ((currentSubMenu != null) && (currentSubMenuNum != num)) 
      { 
        //currentSubMenu.style.display='none'; 
      } 
      currentSubMenu = subMenu; 
      currentSubMenuNum = num; 
      
    } 
  } 
  
  
  function closeTime() 
  { 
	return;
    closeTimer = window.setTimeout(closeMenu, 1000); 
  } 
  
  function cancelCloseTime() 
  { return;
    if (closeTimer != null) 
    { 
      window.clearTimeout(closeTimer); 
      closeTimer = null; 
      
    } 
  } 
  
  function closeMenu() 
  { 
	 return;
    if (currentSubMenu != null) 
    { 
      currentSubMenu.style.display='none'; 
      currentSubMenu = null; 
      currentSubMenuNum = 0; 
    } 
  } 
  
  function close()
  {
	if (closedMenu != null)
	{
		closedMenu.style.display='none'; 
		closedMenu = null;
	}
  }
  
  function closeSubMenu(ID)
  {
  
	///очмщаем старые открытые меню
	 window.clearTimeout(closeTimer); 
	 close(closedMenu);
	 closedMenu = null;
  
	closedMenu = document.getElementById("subMenu" + ID); 
	/*msgbox("closing subMenu" + ID);*/
	closeTimer = window.setTimeout("close()", 4000); 
    /*if (subMenu != null) 
    { 
      subMenu.style.display='none'; 
      
      currentSubMenu = null; 
      currentSubMenuNum = 0; 
    }*/
  }
  
  document.onclick = closeMenu;
