var CurrentPageId;							// WSMId of the selected WSM Object.
var CurrentLevel;								// Level of the selected WSM Object.
var iTimeout = new Array();				// tbv timeout voor weer inklappen van menu's
var iTimeoutMs = 800; 					// timeout in ms voor weer inklappen van menu's
var currentMenuGroupId = null; 	// Het huidige, opgeklapte menu

iTimeout.length = 0;

//---------------------------
function MenuCollapseTimeout(MenuId, WSMId)
{
// Deze functie klapt het opgegeven menu na een timeout van iTimeoutMs (ms) in:
  iTimeout[MenuId, WSMId] = setTimeout("MenuCollapse('" + MenuId + "', " + WSMId + ");", iTimeoutMs);
}

function MenuCollapse(MenuId, WSMId)
{
  clearTimeout(iTimeout[MenuId, WSMId]);
  var theMenu = document.getElementById(MenuId + "Page" + WSMId + "Sub");
  if (theMenu != null)
		theMenu.style.display="none";
}

function MenuExpand(MenuId, WSMId, Level)
{
// Eerst een evt. eerder opengeklapt menu sluiten
  clearTimeout(iTimeout[MenuId, WSMId]);

// Evt. vorig menu weer inklappen
  if (currentMenuGroupId != null && currentMenuGroupId != WSMId && CurrentLevel >= Level)
  {
		var theMenu = document.getElementById(MenuId + "Page" + currentMenuGroupId + "Sub");
		if (theMenu != null)
			theMenu.style.display = "none";
  }

// Stel het nieuwe WSMId in als currentMenuGroupId
  currentMenuGroupId = WSMId;
	CurrentLevel = Level;

  var divMenu = document.getElementById(MenuId + "Page" + WSMId + "Sub");

	if (divMenu != null)
  {
		divMenu.style.display = "";
	}
  MenuCollapseTimeout(MenuId, WSMId);
  MenuKeepExpanded(MenuId, WSMId);
}

function MenuKeepExpanded(MenuId, WSMId)
{
  clearTimeout(iTimeout[MenuId, WSMId]);
}

// Get the page corresponding with a WSM Object
function GetPage(PageId)
{
	if(PageId!=0)
		document.location="getpage.aspx?PageId="+PageId;

	CurrentPageId = PageId;
}

