



		/* ----------------------------------------------------------------------------------------
		 * constants to use
		 */
		var MENU_VERTICAL_TOP		= 0;
		var MENU_VERTICAL_BOTTOM	= 1;
		var MENU_HORIZONTAL_LEFT	= 2;
		var MENU_HORIZONTAL_RIGHT	= 3;

		var EXPAND_RIGHT			= 0;
		var EXPAND_BOTTOM			= 1;
		var EXPAND_LEFT				= 2;
		var EXPAND_TOP				= 3;

		var CLASS_INACTIVE			= 'inactive';	// classname for inactive menu
		var CLASS_ACTIVE			= 'active';		// classname for active menu
		var CLASS_HOVER				= 'hover';		// classname for entries hovered by the mouse
		var CLASS_PARENT			= 'parent';		// classname for entries that are parents of the one hovered by the mouse

		/* TODO: introduce effect delay (for fading eg.) */
		var EFFECT_NONE				=     0;		// don't do anything special
//		var EFFECT_PARENTOPAQUE		=     1;		// set parents to parameter-value transparency
//		var EFFECT_HOVEROPAQUE		=     2;		// set hover to parameter-value transparency
//		var EFFECT_HOVERBORDER		=     3;		// set border to parameter-value color
//		var EFFECT_SETCLASS			=     4;		// set class to parameter-value class
		var EFFECT_HIDE_ALL			= 0 + 0;		// hide out, param is hide-time
		var EFFECT_HIDE_BLOCK		= 0 + 1;		// hide out, param is hide-time
		var EFFECT_HIDE_ENTRY		= 0 + 2;		// hide out, param is hide-time
		var EFFECT_FADE_ALL			= 4 + 0;		// fade out, param is fade-time
		var EFFECT_FADE_BLOCK		= 4 + 1;		// fade out, param is fade-time
		var EFFECT_FADE_ENTRY		= 4 + 2;		// fade out, param is fade-time
		var EFFECT_SHRINK_ALL		= 8 + 0;		// shrink out, param is shrink-time
		var EFFECT_SHRINK_BLOCK		= 8 + 1;		// shrink out, param is shrink-time
		var EFFECT_SHRINK_ENTRY		= 8 + 2;		// shrink out, param is shrink-time
		var EFFECT_HOOK				= 65536;		// apply a special hook to it, hook is parameter hook(obj, type)
		// undock
		// undock with movement (untill out of window ...)

		var MODE_STAY				=  0;			// let the menu stay open
		var MODE_COLLAPSE			=  1;			// collapse the menu

		/* break process control for hooks */
		var BREAK_CONTINUE			=  0;			// skip all breaks
		var BREAK_ONBLOCK			=  1;			// break after deconstructed block
		var BREAK_ONENTRY			=  2;			// break after deconstructed entry
		var BREAK_REPEAT			=  2;			// something's wrong repeat deconstruction
		var BREAK_ABORT				=  3;			// something's wrong repeat deconstruction

		/* the hook-types */
		var HOOK_CLICKED			= 1;
		var HOOK_HOVERED			= 2;
		var HOOK_HOVERBROTHER		= 3;
		var HOOK_HOVERCHILD			= 4;
		var HOOK_HOVERPARENT		= 5;
		var HOOK_HOVERPARENTBROTHER	= 6;

		var emptyCell				= (MSIE ? '<img src="" width="0" height="0" />' : '');

		/* ----------------------------------------------------------------------------------------
		 * standard class representing a menu-entry
		 */
		function menuEntryConfiguration(
				classname, align,
				hovereffect, hoverparams,
				leavemode,
				leaveeffect, leaveparams) {
			/* TODO: undock, hooks, dynamic stuff */

			/* configuration */
			this.classname	 = classname;					// the text of the entry
			this.align		 = align;						// how to align the menu

			this.hovereffect = hovereffect;					// do this effect on hover ...
			this.hoverparams = hoverparams;					// ... with these parameters

			this.leavemode   = leavemode;					// collapse menu on mouseout, or not
			this.leaveeffect = leaveeffect;					// do this effect on leave ...
			this.leaveparams = leaveparams;					// ... with these parameters
		}

		function menuEntryModification(
				correctEntX, correctEntY,
				correctExpX, correctExpY,
				activator) {
			/* modification */
			this.correctEntX	= correctEntX;				// correct the entry horizontal
			this.correctEntY	= correctEntY;				// correct the entry vertical

			this.correctExpX	= correctExpX;				// correct the expander horizontal
			this.correctExpY	= correctExpY;				// correct the expander vertical

			this.activator		= activator;				// instead of use the whole entry use this activator
		}

		function menuEntry(
				active, name,
				configuration, modification,
				subexpand, subentries,
				extras) {
			/* TODO: icons, shortcuts */
			if (!configuration)
				configuration = mcTerminate;
			if (!modification)
				modification = mmNone;

			/* configuration */
			this.active = active;							// active menu-entry or inactive

			this.name		 = name;						// the text of the entry
			this.classname	 = configuration.classname;		// the text of the entry
			this.scut		 = null;						// the shortcut to trigger the entry, and character underlined
			this.icon		 = null;						// the icon of the entry after the text
			this.extras		 = extras;						// your own stuff

			this.align		 = configuration.align;			// how to align the menu

			this.expand      = subexpand;					// an array of subentries
			this.entries     = subentries;					// how the subentries should expand

			this.hovereffect = configuration.hovereffect;	// do this effect on hover ...
			this.hoverparams = configuration.hoverparams;	// ... with these parameters

			this.leavemode   = configuration.leavemode;		// collapse menu on mouseout, or not
			this.leaveeffect = configuration.leaveeffect;	// do this effect on leave ...
			this.leaveparams = configuration.leaveparams;	// ... with these parameters

			this.entOffsX	 = modification.correctEntX;	// positioning
			this.entOffsY	 = modification.correctEntY;	// positioning
			this.expOffsX	 = modification.correctExpX;	// positioning
			this.expOffsY	 = modification.correctExpY;	// positioning

			/* dynamic data */
			this.id      = null;							// identification
			this.parent  = null;							// parent-pointer
			this.root	 = null;							// root-pointer
			this.level   = 0;								// level, and z-index

			this.visible = false;							// visibility
			this.posX    = 0;								// positioning
			this.posY	 = 0;								// positioning

			this.obj       = null;							// identification
			this.expander  = null;							// the expander containing the code
			this.container = null;							// the container of this entry
			this.html      = null;							// the constructed html-code
		}

		function menuBlock(
				active, name, align,
				expand, entries) {
			/* configuration */
			this.active = active;							// active menu-entry or inactive

			this.name = name;								// the text of the entry

			this.align = align;								// how to align the menu

			this.expand  = expand;							// an array of subentries
			this.entries = entries;							// how the subentries should expand

			/* dynamic data */
			this.id      = null;							// identification
			this.parent  = null;							// parent-pointer
			this.root	 = null;							// root-pointer

			this.clicked = null;							// the last clicked element
			this.last    = null;							// the last hovered element
			this.left    = null;							// the last left element
			this.kill    = null;							// the element to kill

			this.obj     = null;							// identification
			this.html    = null;							// the constructed html-code
		}

		/* ----------------------------------------------------------------------------------------
		 */
		var mcTerminate = new menuEntryConfiguration(null, null, EFFECT_NONE, null, MODE_COLLAPSE, EFFECT_NONE, null);
		var mmNone = new menuEntryModification(0, 0, 0, 0, null);
