// jq_menu.js
//

//---------------------------------
$.fn.menu = function(o)
	{
	$(this).html();
	var s = "";
	var i;
	for (i=0; i<o.items.length; ++i)
		{
		var itm = o.items[i];
		
		if (o.horiz) 
			{
			if (!itm.type) itm.type = "dflt";
			switch(itm.type)
				{
				case "choice":
					s += "<a class='dis'>"+itm.label+"</a>";
					var itms = itm.info.itms;
					for (j=0; j<itms.length; ++j)
						{
						var oItm = itms[j];
						s += nbsp(1)+"<a>"+oItm.label+"</a>";
						}
					s += nbsp(5);
					break;
					
				case "dflt":
					s += "<a";
					if (itm.onClick) 
						{
						s += " onClick='" + itm.onClick + "(this)';";
						}
					if (itm.onmousedown) 
						{
						s += " onmousedown='" + itm.onmousedown + "(this)';";
						}
					if (itm.klass)
						{
						s += " class='"+itm.klass+"'";
						}
					s += ">" + itm.label+"</a>" + nbsp(5);
					break;
				}
			}
		else s += "<BR>";
		}
	$(s).appendTo($(this));
	if (itm.klass) $(this).children("a."+itm.klass).attr(itm.klass,true);
	$(this).children("a.dis").attr("dis",true);
	$(this).children("a")
	.hover(function(){
		if ($(this).attr("dis"))$(this).css({color: "#ccccff"});
		else $(this).css({color: "yellow"});
	}, function(){
		if (!$(this).attr("dis"))
		$(this).css({
			color: "#ccccff"
		});
	})
	.addClass("menuitem");
	return $(this);
	}