function Menu()
{
	var _this = this;
	var menuItems = [];

	DEFAULT_MENU_CLASS = 'userNickMenuContainer';
	DEFAULT_MENU_LINK_CLASS = 'newMenuLink';
	MENU_ITEM_SIZE = 15;

	var rowStyle = 'newMenuRow';
	var rowMouseOverStyle = 'newMenuRowOver';
	var disabledRowStyle = '';
	var defaultHandler = false;
	var height = 0;
	var width = 0;
	var panel = new Panel({headerClass:'', bodyClass:'', footerClass:'', containerClass:DEFAULT_MENU_CLASS,
						  clickOutClose:true });
	this.getPanel = function MGetPanel(){return panel}
	// fake frame off add if needed iframe:true, iframeClass:DEFAULT_MENU_CLASS
	var container = panel.getBodyReferense();
	this.setDefaultHandler = function MSetDefaultHandler(func)
	{
		defaultHandler = func;
	}
	this.setStyle = function MSetStyle(containerStyle,_rowStyle, mouseOver, disabled)
	{
		container.className = containerStyle;
		if (_rowStyle) rowStyle = _rowStyle;
		if (mouseOver) rowMouseOverStyle = mouseOver;
		if (disabled) disabledRowStyle = disabled; 
	}
	this.addItem = function MAddItem(menuItem,id)
	{
		function hrefHandler(){
			window.location = this.myHref;
		}
		//caption, handler, number, disabled
		if (!menuItem.number) menuItem.number = menuItems.length;
		//captionSpan = CEAC('span',{className:rowStyle});
		rowDiv = CDiv(container);//,{className:rowStyle}
		// for compatibility to old code TODO remove
		var id_text ="";
		if (id) id_text = 'id="'+id+'"';
		if (menuItem.href) 
		{
			menuItem.handler = hrefHandler;
			rowDiv.myHref = menuItem.href;
			//rowDiv.innerHTML = "<a "+id_text+" class='"+ DEFAULT_MENU_LINK_CLASS +"' href='"+menuItem.href+"'>"+menuItem.caption+"</a>";
		}
		rowDiv.innerHTML = "<span "+id_text+" class='"+ DEFAULT_MENU_LINK_CLASS +"'"+(menuItem.fontSize?" style='font-size: "+menuItem.fontSize+"'":'')+">"+menuItem.caption+"</span>";
		if (menuItem.handler) rowDiv.handler = menuItem.handler;
		if (menuItem.disabled) rowDiv.itemEnebled = false;
		else rowDiv.itemEnebled = true;
		if (rowDiv.itemEnebled)
		{
			if (menuItem.onclick) rowDiv.onclick = function (){eval(menuItem.onclick);};
			else if (rowDiv.handler) rowDiv.onclick = rowDiv.handler;
			else if (defaultHandler && !menuItem.href) rowDiv.onclick = defaultHandler;
			MOCC(rowDiv,rowStyle,rowMouseOverStyle);
		}
		else rowDiv.className = disabledRowStyle;

		if (menuItem.paddingLeft)
			rowDiv.style.paddingLeft = menuItem.paddingLeft;

		if (menuItem.marginTop)
			rowDiv.style.marginTop = menuItem.marginTop;

		if (menuItem.fontStyle)
			rowDiv.style.fontStyle = menuItem.fontStyle;

		if (menuItem.fontWeight)
			rowDiv.style.fontWeight = menuItem.fontWeight;

		menuItems[menuItem.number] = rowDiv;
	}
	this.addText = function MAddText(_obj){
		var rowDiv = CDiv(container);
		rowDiv.className = _obj.className;
		rowDiv.innerHTML = _obj.caption;
	}
	// auto formating by content
	this.showFor = function MShowFor(owner){
		//panel.updateByContent();
		panel.showRelative(owner,'auto');
	}
	this.showContextMenu = function MShowContextMenu(owner, ownerWidth){
		if (ownerWidth)
			panel.setWidth(ownerWidth);

		panel.showRelative(owner,'auto');
	}
	// required, _left, _top
	// optional, _width, _height
	this.show = function MShow(_left, _top, _width, _height){
		panel.showXY(_left, _top);
		if (_width) 
		{
			panel.setWidth(_width);
			width = _width;
		}
		else 
		{
			width = container.clientWidth;
			container.style.width = null;
		}
		if (_height) 
		{
			panel.setHeight(_height);
			height = _height;
		}
		else 
		{
			height = container.clientHeight;
			container.style.height = null;
		}
	}
	this.clear = function MClear()
	{
		while (container.firstChild) removeNodeXB(container.firstChild);
		//container.firstChild.removeNode(true);//.nextSibling 
		menuItems = [];
	}
	this.hide = function MHide(){
		panel.hide();
	}
	function cancelEvent(){return false;}
	function hideClick(_event){
		_this.hide();
	}
	this.disableCloseOnClickOut = function (){
		panel.disableCloseOnClickOut();
	}
}