Ext.menu.Menubar = function(config){
	Ext.menu.Menubar.superclass.constructor.call(this, config);
	this.cls += " x-menubar";
	if (this.orientation == "vertical") {
		this.subMenuAlign = "tl-tr?";
		this.cls += " x-vertical-menubar";
	} else {
		this.subMenuAlign = "tl-bl?";
		this.cls += " x-horizontal-menubar";
	}
};

Ext.extend(Ext.menu.Menubar, Ext.menu.Menu, {
	plain: true,
	cls: "",
	minWidth: 120,
	shadow: false,
	orientation: "horizontal",

	// private
	render : function(container){
		if(this.el){
			return;
		}
		if(container){
			var el = this.el = Ext.get(container);
			el.addClass("x-menu");
		} else {
			var el = this.el = new Ext.Layer({
				cls: "x-menu",
				shadow:this.shadow,
				constrain: false,
				parentEl: this.parentEl || document.body,
				zindex:15000
			});
		}

		this.keyNav = new Ext.menu.MenuNav(this);

		if(this.plain){
				el.addClass("x-menu-plain");
		}
		if(this.cls){
				el.addClass(this.cls);
		}
		// generic focus element
		this.focusEl = el.createChild({
				tag: "a", cls: "x-menu-focus", href: "javascript:void(0)", onclick: "return false;", tabIndex:"-1"
		});
		var ul = el.createChild({tag: "ul", cls: "x-menu-list"});
		ul.on("mouseover", this.onMouseOver, this);
		this.items.each(function(item){
			var li = document.createElement("li");
			li.className = "x-menu-list-item";
			ul.dom.appendChild(li);
			item.render(li, this);
		}, this);
		this.ul = ul;
	},

	show: function(container) {
		if(!this.el){
			this.render(container);
		}
		this.fireEvent("beforeshow", this);
		this.fireEvent("show", this);
	},

	hide: function(){
		if(this.activeItem){
			this.activeItem.deactivate();
		 delete this.activeItem;
		}
	},

	onClick: function(e){
		if(this.activeItem){
			this.hide();
		}else{
			var t=this.findTargetItem(e);
			if(t){
				if(t.canActivate && !t.disabled){this.setActiveItem(t,true)}
			}
			if(t.href!=''){
				document.location.href=t.href;
			}
			//this.fireEvent("click", this, e, t);
		}
		e.stopEvent();
	},
	onMouseOver: function(e){
		var t=this.findTargetItem(e);
		if(t){
			if(t.canActivate && !t.disabled){
				this.setActiveItem(t,true);
			}
		}
		e.stopEvent();
	},
	onMouseOut: function(e){
    this.hide()
	}
});
