var selected_item = "";

function toggle_menu(id)
{
	// see if the id passed in is the one that is already selected
	if (id == selected_item)
	{
		// if it is, close the selection and clear the selected_item variable
		do_toggle(id);
		selected_item = "";
	}
	else
	{
		// otherwise, close the current selection, then open the new selection
		do_toggle(selected_item);
		do_toggle(id);
		selected_item = id;
	}
}

function do_toggle(id)
{
	i = 1;
	
	// loop through all the sub-elements for the id passed in.
	// eg if id was "onsite", this would look for "onsite1", "onsite2" etc
	do
	{
		// get the next possible element
		h = document.getElementById(id + i);
		if (h == null)
		{
			// element doesn't exist - assume we have reached the end
			break;
		}
		else
		{
			// switch the display - fromoff to on and vice versa
			if (h.className == "sub_menu")
			{
				h.className = "sub_menu_display";
			}
			else
			{
				h.className = "sub_menu";
			}
		}
		
		// increment the count
		i++;
	} while(1);
}