_menu = function()
{
	this.openmenu  = 0;
	this.subleft   = 150;
	this.submenu   = new Array();
	this.textcolor = '#000000';
	this.rollover  = '';
	this.font      = '';
	this.fontsize  = '';

	this.subdiv    = null;
	this.subtable  = null;

	/* -------------------------------------- */
	// Initiate menu object
	/* -------------------------------------- */
	this.init = function()
	{
		this.subtable = fetch_object('innersubmenu');
		this.subdiv   = fetch_object('submenu');
	}

	/* -------------------------------------- */
	// Add submenu item
	/* -------------------------------------- */
	this.add = function(parentid, title, link) 
	{
		if ( !this.submenu[parentid] )
		{
			this.submenu[parentid] = new Array();
		}

		this.submenu[parentid][this.submenu[parentid].length] = {'parent': parentid, 'title': title, 'link': link};
	}

	/* -------------------------------------- */
	// Show submenu
	/* -------------------------------------- */
	this.showSub = function(objParent, parentid)
	{
		var i;
		var row;
		var cell;
		var textNode;

		if ( !parentid && this.openmenu )
		{
			parentid = this.openmenu;
		}

		if ( !this.submenu[parentid] )
		{	
			return false;
		}
 
		if ( this.openmenu == parentid || !parentid )
		{
			this.subdiv.style.display = '';
			return false;
		}	

		this.subdiv.innerHTML = '';

		for ( i=0; i<this.submenu[parentid].length; i++ )
		{
			styleAttr = 'padding:4px; font-family:' + this.font + '; font-size:' + this.fontsize + '; color:' + this.textcolor;

			this.subdiv.innerHTML += '<div style="' + styleAttr + '" onclick="window.location=\'' + this.submenu[parentid][i].link + '\'" onmouseover="menu.rolloverColor(this)"  onmouseout="menu.rolloutColor(this)">' + this.submenu[parentid][i].title + '</div>';
		}

		if ( objParent )
		{
			this.subdiv.style.left = this.subleft + 'px';
			this.subdiv.style.top  = (objParent.offsetTop) + 'px';
		}

		this.openmenu = parentid;
		this.subdiv.style.display = '';
		return false;
	}

	/* -------------------------------------- */
	// Close submenu
	/* -------------------------------------- */
	this.closeSub = function()
	{
		this.subdiv.style.display = 'none';
	}

	/* -------------------------------------- */
	// Rollover color
	/* -------------------------------------- */
	this.rolloverColor = function(objLink)
	{
		objLink.style.backgroundColor = this.rollover;
	}

	/* -------------------------------------- */
	// Rollout color
	/* -------------------------------------- */
	this.rolloutColor = function(objLink)
	{
		objLink.style.backgroundColor = '';
	}

}

