subsection_timer = 0;
suspicious_over_timer = 0;
collapse_all_timer = 0;

// When someone mouseovers a subsection we start a timer to open the
// subsection so that there is a bit of a delay.
function OverSubsection(num)
{
	// Check if 
	if (suspicious_over_timer)
		return;
	if (collapse_all_timer)
	{
		window.clearTimeout(collapse_all_timer);
		collapse_all_timer = 0;
	}
	subsection_timer = window.setTimeout("choose_subsection("+num+")", 400);
}
// When someone leaves a subsection
function OutOfSubsection(num)
{
	if (subsection_timer) {
		// Clear the subsection timer so that we don't open this
		// subsection, since it's not meant to be opened.
		window.clearTimeout(subsection_timer);
		subsection_timer = 0;
	}
	if (!collapse_all_timer)
		collapse_all_timer = window.setTimeout("collapse_subsections()", 5000);
}

// Selects one subsection to show and hides the rest.
function choose_subsection(num)
{
	for (var i = 0; menu_entries[i]; i++)
	{
		if (i != num)
			menu_entries[i].style.display = "none";
		else
			menu_entries[i].style.display = "block";
	}

	// Set a timer so we can cancel a mouseover on another section for
	// 100ms to avoid accidentally triggering the opening of another
	// section when the last section collapsed.
	suspicious_over_timer = window.setTimeout("suspicious_over_timer = 0", 100);
}
function collapse_subsections()
{
	for (var i = 0; menu_entries[i]; i++)
		menu_entries[i].style.display = "none";
	collapse_all_timer = 0;
}

