/**
 * Menu
 */
function lib_Menu()
{
	/**
	 * Class variables
	 */
	this.timeout = 125;
	this.closeTimer = null;




	/**
	 * Open submenu: make submenu element visible
	 *
	 * @param string id
	 */
	this.openSubmenu = function(id)
	{
		//cancel close timer
		this.cancelTimer();

		//close currently open submenu
		this.closeSubmenu();

		//set new current submenu and make the element visible
		if(document.getElementById(id))
		{
			lib_Menu_currentSubmenu = document.getElementById(id);
			lib_Menu_currentSubmenu.style.visibility = 'visible';
		}
	}




	/**
	 * Close submenu: make currently open submenu element invisible
	 */
	this.closeSubmenu = function()
	{
		if(lib_Menu_currentSubmenu)
		{
			lib_Menu_currentSubmenu.style.visibility = 'hidden';
		}
	}




	/**
	 * Start submenu closing timer
	 */
	this.startTimer = function()
	{
		this.closeTimer = window.setTimeout(this.closeSubmenu, this.timeout);
	}




	/**
	 * Cancel submenu closing timer
	 */
	this.cancelTimer = function()
	{
		if(this.closeTimer)
		{
			window.clearTimeout(this.closeTimer);
			this.closeTimer = null;
		}
	}
}

/**
 * Variable used by Page Menu
 *
 * Needs to be outside of object for "window.clearTimeout" to be able to access it
 */
var lib_Menu_currentSubmenu = null;
