/*
 * Javascipt menubar
 */
	// [#f 28]

var TICT_MID_counter = 0;
var TICT_MIID_counter = 0;
var TICT_SMAct = 0;
var TICT_MBAct = 0;
var TICT_MBIAct = 0;
var TICT_SubsNeeded = new Array();
var activate = false;
// var autoactivate = false;
var undroptimer = false;
var undroptime = 500;
var autoundrop = false;

var MenuItems = new Array();
var lastHover = false;
var useIframes = false;

var MenuBarItem = 0; // To enumerate all menuitems with images

var imgdir = "";

var issafari = false;
if (  (document.childNodes)&&(!document.all)&&
	(!navigator.taintEnabled)&&(!navigator.accentColorName) )
{
	issafari = true;
}

// create debug div

var dbdiv = new Object;
function initdbdiv()
{
	if ( issafari )
	{
		dbdiv = document.createElement("DIV");
		// dbdiv.innerHTML = "debugdiv:<BR><BR>";
		{
			var bodydiv = document.getElementsByTagName('BODY')[0];
			bodydiv.insertBefore(dbdiv, bodydiv.firstChild);
			// bodydiv.appendChild(dbdiv);
		}
		dbdiv.style.height = '100%';
		dbdiv.style.width = '100%';
		dbdiv.style.position = 'absolute';
		dbdiv.style.fontSize = '8px';
		dbdiv.style.zIndex = '-1';
		dbdiv.style.top = '0';
		dbdiv.style.visibility = 'hidden';
	}
	// dbdiv.style.display = 'none';
}

// menu management event functions

function unblockUnhover()
{
	dbdiv.innerHTML = "";
}

var clearsubtimer = 0;

function clearsubmenu()
{
	dbdiv.innerHTML += "Day Two clearsubmenu";
	if ( clearsubtimer == 0 )
	{
		return;
	}

	if ( lastHover )
	{
		if ( typeof lastHover.oldClassName == 'string' )
		{
			lastHover.className = lastHover.oldClassName;
		}
		lastHover = false;
	}

	if ( typeof TICT_SMAct.oldClassName == 'string' )
	{
		TICT_SMAct.className = TICT_SMAct.oldClassName;
		if ( useIframes )
		{
			document.getElementById('i' + TICT_SMAct.id).style.visibility = 'hidden';
		}
	}
	TICT_SMAct = TICT_SMAct.parentMenu;
	dbdiv.innerHTML = "";
}

function do_shover(object)
{
	if ( undroptimer )
	{
		window.clearInterval(undroptimer);
	}
	if ( clearsubtimer )
	{
		window.clearTimeout(clearsubtimer);
		clearsubtimer = 0;
	}
}

function do_sunhover(object)
{
	if ( autoundrop ) 
	{
		if ( undroptimer )
		{
			window.clearInterval(undroptimer);
		}
		undroptimer = window.setInterval("do_inactivate()", undroptime);
	}
	if ( TICT_SMAct.parentMenu == object )
	{
		dbdiv.innerHTML = "Day Two do_sunhover";
		clearsubtimer = window.setTimeout("clearsubmenu()", 10);
	}
}

var hoverArgs = new Array();

// real on hover functionality
function do_rhover(object, mode, menuitemid, menuid, placeleft, staticmenu, drop)
{
	var submenu;
	var menuitem = MenuItems[menuitemid];
	var myParent = false;
	var pclass;

	if ( undroptimer )
	{
		window.clearInterval(undroptimer);
	}

	var alldiv = false;

	if ( typeof object.oldClassName != 'string' )
	{
		object.oldClassName = object.className;
	}

	if ( object.oldClassName.slice(object.oldClassName.length - 2) == "_D" )
	{
		return false;
	}

	if ( 1 )
	{
		// hide and reset  the previous submenu and reset the items of object
		if ( TICT_MBAct && (object.parentNode != TICT_SMAct) )
		{
			if ( object.focus )
			{
				object.focus();
			}
			if ( TICT_SMAct )
			{
				var lsubmenu;

				lsubmenu = TICT_SMAct;
				while ( lsubmenu ) // && (lsubmenu != object.parentNode) )
				{
					for (var i = 0; i < lsubmenu.childNodes.length; i++ )
					{
						if ( typeof lsubmenu.childNodes[i].oldClassName ==
							'string' )
						{
							lsubmenu.childNodes[i].className =
								lsubmenu.childNodes[i].oldClassName;
						}
					}
					if ( lsubmenu != object.parentNode )
					{
						if ( typeof lsubmenu.oldClassName == 'string' )
						{
							lsubmenu.className = lsubmenu.oldClassName;
							if ( useIframes )
							{
								document.getElementById('i' + lsubmenu.id).style.visibility = 'hidden';
							}
						}
						lsubmenu = lsubmenu.parentMenu;
					}
					else 
					{
						break;
					}
				}
				TICT_SMAct = lsubmenu
			}
		}
	}

	if ( mode == 0 )
	{
		if ( TICT_MBAct )
		{
			if ( TICT_MBAct && typeof TICT_MBAct.oldClassName == 'string' )
			{
				TICT_MBAct.className = TICT_MBAct.oldClassName;
				if ( !useIframes )
				{
					app = document.getElementById('cbApplet');
					if ( app != null )
					{
						app.style.visibility = 'visible';
					}
				}
			}
			// activate topmenu item
			if ( object.className != 'a' )
			{
				object.className = 'a';
			}
			if (object.parentNode.className != object.parentNode.oldClassName + 'A')
			{
				object.parentNode.oldClassName = object.parentNode.className;
				var temp = activate; // Hack to temporarily disable activate.
				activate = false;
				do_inactivate();
				activate = temp;
			}
			TICT_MBAct = object;
		}
		else 
		{
			if ( object.oldClassName.slice(object.oldClassName.length - 2) == "_H" )
			{
				if ( object.className != 'Hh' )
				{
					object.className = 'Hh';
				}
			}
			else
			{
				if ( object.className != 'h' )
				{
					object.className = 'h';
				}
			}
		}
	}
	else
	{
		// activate submenu item

		myParent = object.parentNode;
		var pclass = myParent.className;
		if ( typeof myParent.oldClassName == 'string' )
		{
			// myParent.className = myParent.oldClassName;
		}
		if ( object.oldClassName.slice(object.oldClassName.length - 2) == "_H" )
		{
			if ( object.className != 'Hh' )
			{
				object.className = 'Hh';
			}
		}
		else
		{
			if ( object.className != 'h' )
			{
				object.className = 'h';
			}
		}
	}

	// place and show submenu
	if ( menuid )
	{
		submenu = document.getElementById(menuid);
		if ( submenu )
		{
			submenu.parentMenu = 0;

			if ( !submenu.hasmoved )
			{
				// place
				if ( mode == 0 )
				{
					// don't move the first submenu for a staticmenu
					if ( ! staticmenu )
					{
						var menuoffset_x = 0;
						for ( var loopnode = object;
							loopnode && loopnode.nodeName != 'HTML';
							loopnode = loopnode.offsetParent )
						{
							menuoffset_x += loopnode.offsetLeft;
						}
						var smenuoffset_x = 0;
						for ( var loopnode = submenu;
							loopnode && loopnode.nodeName != 'HTML';
							loopnode = loopnode.offsetParent )
						{
							smenuoffset_x += loopnode.offsetLeft;
						}

						menuoffset_x -= smenuoffset_x;
						if ( placeleft )
						{
							submenu.style.marginLeft = ( - object.parentNode.offsetLeft -
									submenu.offsetWidth +
									menuoffset_x ) + 'px';
						}
						else
						{
							submenu.style.marginLeft = (  menuoffset_x ) + 'px';
						}
						//submenu.style.marginLeft = (menuoffset_x) + 'px';
						var b_offs = 3;
						if ( document.all )
						{
							b_offs = 2;
						}
						submenu.style.marginTop = -3 + 'px'; //(object.offsetTop - 6 - ) + 'px';
						submenu.hasmoved = true;
						submenu.firstsub = true;

						if ( useIframes )
						{
							var iframe = document.createElement("IFRAME");
							iframe.id = 'i' + submenu.id;
							iframe.setAttribute("src", "about:blank");
							iframe.setAttribute("frameborder", "0");
							iframe.setAttribute("scrolling", "no");
							iframe.setAttribute("marginwidth", "0");
							iframe.setAttribute("marginheight", "0");
							iframe.style.width = submenu.offsetWidth;
							iframe.style.height = submenu.offsetHeight;
							iframe.style.display = "block";
							iframe.style.position = "absolute";
							iframe.style.overflow = "hidden";
							iframe.style.margin = 0;
							iframe.style.padding = 0;
							iframe.style.marginLeft = submenu.style.marginLeft;
							iframe.style.marginTop = submenu.style.marginTop;
							iframe.style.zIndex = 3;
							iframe.style.visibility = 'hidden';

							submenu.parentNode.insertBefore(iframe, submenu);
						}

						// window.alert(submenu.id + ' ' + submenu.negofs);
					}
					else
					{
						// window.alert(staticmenu);
					}
					submenu.negofs = submenu.offsetTop;
				}
				else
				{
					var b_offs = -3;
					if ( (document.childNodes)&&(!document.all)&&
						(!navigator.taintEnabled)&&(!navigator.accentColorName) )
					{
						// safari
						b_offs = -4;
					}

					var menudiv;
					for ( menudiv = object;
						menudiv && menudiv.nodeName != 'DIV';
						menudiv = menudiv.parentNode );
					for ( ;
						menudiv &&
						menudiv.className != 'TICT_Menubar' && 
						menudiv.className != 'TICT_MenubarA';
						menudiv = menudiv.previousSibling );

					// window.alert(menudiv.offsetTop);
					// var menuoffset_y = menudiv.offsetTop;
					var menuoffset_x = 0;
					for ( ;menudiv && menudiv.nodeName != 'HTML'; menudiv = menudiv.offsetParent )
					{
						menuoffset_x += menudiv.offsetLeft;
					}
					if ( placeleft )
					{
						submenu.style.marginLeft = ( object.parentNode.offsetLeft -
								submenu.offsetWidth -
								menuoffset_x ) + 'px';
					}
					else
					{
						submenu.style.marginLeft = ( object.parentNode.offsetLeft +
							object.offsetWidth +
							2 - menuoffset_x ) + 'px';
					}
					var pmenuoffset_y = 0;
					if ( TICT_SMAct )
					{
						pmenuoffset_y = TICT_SMAct.offsetTop - TICT_SMAct.negofs;
						submenu.negofs = TICT_SMAct.negofs;
					}

					submenu.style.marginTop = (b_offs + pmenuoffset_y + object.offsetTop) + 'px';
					submenu.hasmoved = true;
					submenu.firstsub = false;

					if ( useIframes )
					{
						var iframe = document.createElement("IFRAME");
						iframe.id = 'i' + submenu.id;
						iframe.setAttribute("src", "about:blank");
						iframe.setAttribute("frameborder", "0");
						iframe.setAttribute("scrolling", "no");
						iframe.setAttribute("marginwidth", "0");
						iframe.setAttribute("marginheight", "0");
						iframe.style.width = submenu.offsetWidth;
						iframe.style.height = submenu.offsetHeight;
						iframe.style.display = "block";
						iframe.style.position = "absolute";
						iframe.style.overflow = "hidden";
						iframe.style.margin = 0;
						iframe.style.padding = 0;
						iframe.style.marginLeft = submenu.style.marginLeft;
						iframe.style.marginTop = submenu.style.marginTop;
						iframe.style.zIndex = 3;
						iframe.style.visibility = 'hidden';

						submenu.parentNode.insertBefore(iframe, submenu);
					}
				}
			}

			if ( 1 )
			{
				// show
				if ( TICT_MBAct )
				{
					if ( mode != 0 )
					{
						if ( submenu != TICT_SMAct )
						{
							submenu.parentMenu = TICT_SMAct;
							var slevel = 0;
							if ( TICT_SMAct && TICT_SMAct.level )
							{
								slevel = TICT_SMAct.level + 1;
							}
							submenu.level = slevel;
						}
					}

					if ( typeof submenu.oldClassName != 'string' )
					{
						submenu.oldClassName = submenu.className;
					}
					if ( submenu.className != submenu.oldClassName + 'A' )
					{
						submenu.className = submenu.oldClassName + 'A';
						if ( useIframes )
						{
							document.getElementById('i' + submenu.id).style.visibility = 'visible';
						}
						if ( !useIframes )
						{
							app = document.getElementById('cbApplet');
							if ( app != null )
							{
								app.style.visibility = 'hidden';
							}
						}
					}
					TICT_SMAct = submenu;
				}
			}
		}
	}
	else
	{
		if ( TICT_SMAct.parentMenu == object.parentNode )
		{
			TICT_SMAct = TICT_SMAct.parentMenu;
		}
	}

	if ( arguments.length > 6 && drop )
	{
		do_activate(object, mode, menuitemid, menuid, placeleft, staticmenu, drop);
		autoundrop = true;
	}

	dbdiv.innerHTML = "";
	lastHover = object;
}

function do_hoverArgs()
{
	dbdiv.innerHTML += 'do_hoverArgs<br>';
	while ( hoverArgs.length )
	{
		var hoverArg = hoverArgs.pop();
		do_rhover(hoverArg.object, hoverArg.mode, hoverArg.menuitemid,
				hoverArg.menuid, hoverArg.placeleft, hoverArg.staticmenu, hoverArg.drop);
	}
}

function do_hover(object, mode, menuitemid, menuid, placeleft, staticmenu, drop)
{
	var hoverArg = new Object;

	hoverArg.object = object;
	hoverArg.mode = mode;
	hoverArg.menuitemid = menuitemid;
	hoverArg.menuid = menuid;
	hoverArg.drop = drop;
	hoverArg.placeleft = placeleft;
	hoverArg.staticmenu = staticmenu;

	hoverArgs.push(hoverArg);
	//  window.setTimeout(do_hoverArgs, 0);
	do_hoverArgs();
}

function do_unhover(object, mode, menuitemid, menuid, placeleft, staticmenu, drop)
{
	var menuitem = MenuItems[menuitemid];

	dbdiv.innerHTML += "Day Two do_unhover<br>";

	if ( object != lastHover )
	{
		return;
	}

	if ( autoundrop ) 
	{
		if ( undroptimer )
		{
			window.clearInterval(undroptimer);
		}
		undroptimer = window.setInterval("do_inactivate()", undroptime);
	}
	if ( object == TICT_MBAct )
	{
		return;
	}

	var submenuParent = 0
	if ( menuid )
	{
		submenuParent = document.getElementById(menuid).parentMenu;
	}

	if ( object.parentNode == submenuParent )
	{
		return;
	}
	if ( object != TICT_SMAct && typeof object.oldClassName == 'string' )
	{
		object.className = object.oldClassName;
	}
	dbdiv.innerHTML = "";
}

function do_activate(object, mode, menuitemid, menuid, placeleft, staticmenu, drop)
{
	var objParent = object.parentNode;


	if ( ! menuid )
	{
		return false;
	}

	if ( typeof objParent.oldClassName != 'string' )
	{
		objParent.oldClassName = objParent.className;
	}

	if ( object.className.slice(object.className.length - 2) == "_D" )
	{
		return false;
	}

	if ( mode == 0 )
	{
		if ( objParent.className != objParent.oldClassName + 'A' )
		{
			objParent.className = objParent.oldClassName + 'A';
			if ( !useIframes )
			{
				app = document.getElementById('cbApplet');
				if ( app != null )
				{
					app.style.visibility = 'hidden';
				}
			}
		}
	}

	if ( object == TICT_MBAct )
	{
		return false;
	}

	activate = true;
	if ( TICT_MBAct != 0 )
	{
		return false;
	}

	TICT_MBAct = object;

	menu = document.getElementById(menuid);
	if ( ! menu )
	{
		return false;
	}

	if ( typeof menu.oldClassName != 'string' )
	{
		menu.oldClassName = menu.className;
	}
	if ( menu.className != menu.oldClassName + 'A' )
	{
		menu.className = menu.oldClassName + 'A';
		if ( useIframes )
		{
			document.getElementById('i' + menu.id).style.visibility = 'visible';
		}
	}
	menu.parentMenu = 0;
	menu.level = 1;
	TICT_SMAct = menu;
}

function do_inactivate()
{
	var objParent;
	if ( activate )
	{
		activate = false;
		return true;
	}

	if ( TICT_MBAct )
	{
		objParent = TICT_MBAct.parentNode;
		objParent.className = objParent.oldClassName;
		if ( !useIframes )
		{
			app = document.getElementById('cbApplet');
			if ( app != null )
			{
				app.style.visibility = 'visible';
			}
		}
		TICT_MBAct.className = TICT_MBAct.oldClassName;

		var submenu = TICT_SMAct;
		while ( submenu )
		{
			submenu.className = submenu.oldClassName;
			if ( useIframes )
			{
				document.getElementById('i' + submenu.id).style.visibility = 'hidden';
			}
			for (var i = 0; i < submenu.childNodes.length; i++ )
			{
				var childNode = submenu.childNodes[i];
				if ( typeof childNode.oldClassName == 'string' )
				{
					childNode.className = childNode.oldClassName;
				}
			}
			submenu = submenu.parentMenu;
		}
		TICT_SMAct = 0;
		TICT_MBAct = 0;
	}
	lastHover = false;
	hoverArgs.length = 0;
	return true;
}

function ItemImage(type, url)
{
	this.imageType = type;
	this.imageUrl = url;
}

// MenuItem object

function mi_printImages(position)
{
	var n = this.menuItemImages.length;

	if ( n == 0 )
	{
		// bail out, no images
		return;
	}

	for ( i = 0; i < n; i++ )
	{ 
		switch ( this.menuItemImages[i].imageType )
		{
			case "r":
			case "r1":
			case "r2":
				if ( position == "right" )
				{
					var imgClassName  = 'MenuImage_' + i;
					var strStyle = "";
					if ( this.menuItemImages[i].imageType != "r" )
					{
						// strStyle = ' style="display: none;"';
					}
					document.write('<IMG src="' + this.menuItemImages[i].imageUrl +
						'" class="' + imgClassName + '"' + strStyle + '>');
				}
				break;
		}
	}
}

// MenuItem object

function mi_addImage(imageType, imageUrl)
{
	var newImage = new ItemImage(imageType, imageUrl);
	this.menuItemImages.push(newImage);
}

// MenuItem object

function mi_printItem(menumode, autodrop, showarrows, placeleft, staticmenu)
{
	var mi_class;
	var retval = -1;

	if ( arguments.length < 2 )
	{
		autodrop = false;
	}
	if ( arguments.length < 3 )
	{
		showarrows = false;
	}

	switch ( menumode )
	{
		case 0:	// menubar
			this.mi_class = 'TICT_MBItem';
			break;
		default:
			this.mi_class = 'TICT_DDItem';
			break;
	}

	var strItemmode = "";
	switch ( this.mode )
	{
		case 0: 	// disabled
			this.mi_class += '_D';
			break;
		case 1:		// normal;
			this.mi_class += '_N';
			break;
		case 2:		// highlite
			this.mi_class += '_H';
			break;
	}

	var strOnClick;
	var strHArgs = 'this, ' + menumode + ', ' + this.menuItemID + ', ' +
		(this.menuID?'\'' + this.menuID + '\'':'false') + ', ' + placeleft +
		', ' + staticmenu;

	if ( autodrop )
	{
		strHArgs += ', true';
	}

	switch ( this.type )
	{
		case 0:		// url
			strOnClick = '';
			break;

		case 1:		// submenu
			if ( autodrop && this.action != '#' )
			{
				strOnClick = '';
			}
			else
			{
				strOnClick = 'do_activate(' + strHArgs + '); return false;';
			}
			break;
	}

	var href = this.action.replace(/"/g, '&quot;');
	var aonclick = '';
	if ( href == '' )
	{
		aonclick = ' style="cursor: pointer;"  onclick="return false;"';
	}
	if ( href == '#' )
	{
		href = ' href';
		href = '';
		aonclick = ' style="cursor: pointer;"  onclick="return false;"';
	}
	else
	{
		href = ' href="' + href + '"';
	}
	
	document.write(
		'<SPAN class="' + this.mi_class + '"' +
		' onclick="' + strOnClick + '"' +
		' onmouseover="do_hover(' + strHArgs + ');event.cancelbubble=true;"' +
		' onmouseout="do_unhover(' + strHArgs + ');event.cancelbubble=true;">');
	
	if ( this.menuItemImages.length > 0 )
	{
		document.write('<SPAN class="MenuItem_' + MenuBarItem + '">');
	}
		
	document.write('<A' + href + this.targ + aonclick + '>' + this.name + '</A>');

	if ( this.menuItemImages.length > 0 )
	{
		this.printImages("right");
		MenuBarItem++;
		document.write('</SPAN>');
	}

	/** 
	  * Show little arrow to the right if there are sub menu's
	  */
	  
	if ( menumode != 0 && showarrows )
	{
		/**
		  * only applies to menu items,  not to top bar
		  */
		if ( this.menuID != false )
		{
			document.write('<SPAN class="little_menu_arrow">' +
					'<IMG src="sysimg/little_menu_arrow.gif">' +
					'</SPAN>');
		}
	}


	document.write('</SPAN>');

	if ( this.type == 1 )
	{
		retval = TICT_SubsNeeded.length;
		TICT_SubsNeeded[TICT_SubsNeeded.length] = this.menu;
	}
	return retval;
}

function MenuItem(parent, name, type, arg, mode, targ, selected)
{
	if ( arguments.length < 6 )
	{
		selected = false;
	}
	this.parent = parent;	// parent menu id
	this.name = name;
	this.type = type;
	this.action = '#';
	this.targ = '';
	this.menuID = false;	// id of the submenu
	this.selected = selected;

	this.menuItemID = TICT_MIID_counter++;
	MenuItems[this.menuItemID] = this;

	this.mode = 1;		// default normal active
	if ( typeof mode == 'number' )
	{
		this.mode = mode;
	}
	switch ( type )
	{
		case 0:		// url
			this.action = arg;
			if ( typeof targ == 'string' )
			{
				this.targ = ' target="' + targ + '"';
			}
			break;

		case 1:		// submenu
			this.menu = arg;
			this.menuID = arg.menuID;
			if ( typeof targ == 'string' )
			{
				// user targ for action; later split when targ is implemented
				this.action = targ;
			}
			break;
	}
	this.addImage = mi_addImage;
	this.menuItemImages = new Array();
	this.printImages = mi_printImages;

	this.printItem = mi_printItem;
}

// Submenu object

function sm_addMenuItem(name, type, arg, mode, targ, selected)
{
	if ( arguments.length < 6 )
	{
		selected = false;
	}

	var menuitem = new MenuItem(this, name, type, arg, mode, targ, selected);
	this.menuItems[this.numMenuItems++] = menuitem;
	return menuitem;
}

// Submenu object

function sm_printMenu(mainmenu, numprinted, showarrows, placeleft, staticmenu)
{
	var i;
	var myprinted = 0;
	var strMenu;
	maxprint = 0;
	inlineitems = false;
	if ( arguments.length > 1 )
	{
		if ( mainmenu.maxitems )
		{
			maxprint = mainmenu.maxitems - numprinted;
		}
		inlineitems = mainmenu.inlinesubs;
	}

	if ( arguments.length < 3 )
	{
		showarrows = false;
	}


	if ( this.numMenuItems )
	{
		this.m_class = 'TICT_Submenu';
		document.write('<DIV ID="' + this.menuID + '" class="' + this.m_class + '"' +
			' onmouseover="do_shover(this);" onmouseout="do_sunhover(this)" style="z-index: 4;">');

		for ( i = 0; i < this.numMenuItems && ( maxprint == 0 || myprinted < maxprint ); i++ )
		{
			var subnum = this.menuItems[i].printItem(1, true, showarrows, placeleft, staticmenu);
			myprinted++;
			// window.alert ("sn: " + subnum + "\r\nili: " + inlineitems);
			if ( inlineitems && subnum >= 0 )
			{
				var subsprinted = TICT_SubsNeeded[subnum].printMenu(mainmenu, myprinted, showarrows, placeleft, staticmenu);
				if ( this.allwaysopen )
				{
					myprinted += subsprinted;
				}
				// myprinted += sm_printMenu(mainmenu, myprinted + numprinted, showarrows);
			}
		}
		document.write('</DIV>');
	}

	return myprinted; // return the number of items printed
}

function Submenu()
{
	this.menuItems = new Array();
	this.numMenuItems = 0
	this.menuID = 'TICT_MID_' + TICT_MID_counter++;
	this.addMenuItem = sm_addMenuItem;
	this.printMenu = sm_printMenu;
}

// Menubar object

function mb_addMenuItem(name, type, arg, mode, targ, selected)
{
	if ( arguments.length < 6 )
	{
		selected = false;
	}
	var menuitem = new MenuItem(this, name, type, arg, mode, targ, selected)
	this.menuItems[this.numMenuItems++] = menuitem;
	return menuitem;
}

function mb_printMenu(showarrows, doiframes)
{
	if (arguments.length < 1)
	{
		showarrows = false;
	}
	if ( arguments.length < 2 )
	{
		doiframes = false;
	}
	useIframes = doiframes;

	var i;
	this.m_class = 'TICT_Menubar';
	document.write('<DIV id="xxxtempxxx" class="' + this.m_class + '">');
	
	var numprinted = 0;

	for ( i = 0; i < this.numMenuItems && (this.maxitems == 0 || numprinted < this.maxitems); i++ )
	{
		var subnum = this.menuItems[i].printItem(0, this.autoactivate, showarrows, this.displayleft, this.inlinesubs);
		numprinted++;

		if ( this.inlinesubs && subnum >= 0 )
		{
			var subsprinted = TICT_SubsNeeded[subnum].printMenu(this, numprinted, showarrows, this.displayleft, this.inlinesubs);
			if ( this.allwaysopen )
			{
				numprinted += subsprinted;
			}
		}
	}
	document.write('</DIV>');

	if ( ! this.inlinesubs )
	{
		var n = TICT_SubsNeeded.length;
		for ( i = 0; i < TICT_SubsNeeded.length; i++ )
		{
			TICT_SubsNeeded[i].printMenu(0,0,showarrows,this.displayleft, this.inlinesubs);
		}
	}

	var mbdiv = document.getElementById('xxxtempxxx');
	mbdiv.id = '_xxxtempxxx';
}

function mb_setInlineSubMenus()
{
	this.inlinesubs = true;
	if ( arguments.length > 0 )
	{
		this.inlinesubs = arguments[0];
	}
}

function mb_setMaxMenuItems(numitems)
{
	this.maxitems = numitems;
}

function mb_setAlwaysOpen()
{
	this.allwaysopen = true;
	if ( arguments.length > 0 )
	{
		this.allwaysopen = arguments[0];
	}
}

function mb_setAutoActivate()
{
	this.autoactivate = true;
	if ( arguments.length > 0 )
	{
		this.autoactivate = arguments[0];
	}
}

function mb_setDisplayLeft()
{
	if ( arguments.length > 0 )
	{
		this.displayleft = arguments[0];
	}
	
}

function Menubar()
{
	this.menuItems = new Array();
	this.numMenuItems = 0
	this.autoactivate = false;
	this.allwaysopen = false;
	this.maxitems = 0;
	this.inlinesubs = false;
	this.displayleft = false;

	this.addMenuItem = mb_addMenuItem;
	this.printMenu = mb_printMenu;
	this.setInlineSubMenus = mb_setInlineSubMenus;
	this.setMaxMenuItems = mb_setMaxMenuItems;
	this.setAlwaysOpen = mb_setAlwaysOpen;
	this.setAutoActivate = mb_setAutoActivate;
	this.setDisplayLeft = mb_setDisplayLeft;
}

initdbdiv();
