function JsMenu(name)
{
	this.Direction = 0;		//主菜单排列方向：0代表横向，1代表竖向
	this.MainWidth = 160;	//主菜单各项宽度
	this.MainHeight = 20;	//主菜单各项高度
	
	this.ItemWidth = null;
	this.ItemHeight = null;
	
	this.MainIcon = null;
	this.MainAlign = null;
	
	this.ItemIcon = null;
	this.ItemAlign = null;
	
	this.MainAnchor = null;
	this.ItemAnchor = null;
	
	this.Spacing = 0;
	this.Padding = 0;
	
	this.OutBgColor = '';
	this.OverBgColor = '';
	
	this.OutBorder = '0px solid #BBBBBB';
	this.OverBorder = '0px solid #999999';
	
	
	this.Name = 'JM';		//注：不用更改
	this.Icon = '·';		//注：不用更改
	var HasItems = false;
	var MenuItems = new Array();
	this.Add = function(Id,Parent,Text,Href,Target,Title)
	{
		HasItems = true;
		MenuItems[MenuItems.length] = new Array(Id,Parent,Text,Href,Target,Title);
	};
	
	this.Load = function()
	{
		if(name == null)
			this.Name += Math.random().toString().replace('.','0');
		else
			this.Name = this.Name + name;
		if(this.MainHeight != null) this.MainHeight = 'height="'+this.MainHeight+'"';
		if(this.ItemHeight != null) this.ItemHeight = 'height="'+this.ItemHeight+'"';
		if(this.MainAlign != null) this.MainAlign = 'align="'+this.MainAlign+'"';
		if(this.ItemAlign != null) this.ItemAlign = 'align="'+this.ItemAlign+'"';
		if(this.MainAnchor != null) this.MainAnchor = 'class="'+this.MainAnchor+'"';
		if(this.ItemAnchor != null) this.ItemAnchor = 'class="'+this.ItemAnchor+'"';
		if(this.MainIcon == null)
			this.MainIcon = this.Icon;
		else
			this.MainIcon = '<img border="0" src="'+this.MainIcon+'" align="absmiddle"/>';
		if(this.ItemIcon == null)
			this.ItemIcon = this.Icon;
		else
			this.ItemIcon = '<img border="0" src="'+this.ItemIcon+'" align="absmiddle"/>';
	};
	
	this.getMain = function(NO)
	{
		if(this.Direction == 1) document.write('<tr>');
		document.write('<td width="'+this.MainWidth+'" '+this.MainAlign+' '+this.MainHeight+' bgcolor="'+this.OutBgColor+'" style="border:'+this.OutBorder+';padding:'+this.Padding+';white-space:nowrap;" title="'+MenuItems[NO][5]+'"');
		document.write(' onmouseover="this.bgColor=\''+this.OverBgColor+'\';this.style.border=\''+this.OverBorder+'\';'+this.Name+'_'+MenuItems[NO][0]+'.style.display=\'inline\';" onmouseout="this.bgColor=\''+this.OutBgColor+'\';this.style.border=\''+this.OutBorder+'\';'+this.Name+'_'+MenuItems[NO][0]+'.style.display=\'none\';">');
		document.write('<div style="display:inline;width:'+(this.MainWidth-20)+'px;">&nbsp;'+this.MainIcon+' <a href="'+MenuItems[NO][3]+'" target="'+MenuItems[NO][4]+'" '+this.MainAnchor+' >'+MenuItems[NO][2]+'</a>&nbsp;</div>');
		document.write('<div id="'+this.Name+'_'+MenuItems[NO][0]+'_HI" align="right" style="display:none;width:20px;"><span style="font-family:Webdings">4</span></div>');
		if(this.Direction == 1)
		{
			document.write('<td width="0" align="left" valign="top" onmouseover="'+this.Name+'_'+MenuItems[NO][0]+'.style.display=\'inline\';" onmouseout="'+this.Name+'_'+MenuItems[NO][0]+'.style.display=\'none\';">');
			document.write('<div id="'+this.Name+'_'+MenuItems[NO][0]+'" style="position:absolute;display:none;">');
			document.write(this.getItems(MenuItems[NO][0]));
			document.write('</div>');
			document.write('</td>');
		}
		else
		{
			document.write('<br/>');
			document.write('<div id="'+this.Name+'_'+MenuItems[NO][0]+'" style="position:absolute;display:none;">');
			document.write(this.getItems(MenuItems[NO][0]));
			document.write('</div>');
		}
		document.write('</td>');
		if(this.Direction == 1) document.write('</tr>');
	};
	
	this.getItems = function(PID)
	{
		var HasItems = false;
		var ItemString = null;
		ItemString = '<table style="border-collapse:collapse;" border="0" cellpadding="0" cellspacing="0">';
		for(var i=1; i<MenuItems.length; i++)
		{
			if(MenuItems[i][1] == PID)
			{
				HasItems = true;
				ItemString += '<tr>';
				ItemString += '<td width="'+this.ItemWidth+'" '+this.ItemAlign+' '+this.ItemHeight+' bgcolor="'+this.OutBgColor+'" style="border:'+this.OutBorder+';padding:'+this.Padding+';white-space:nowrap;" title="'+MenuItems[i][5]+'"';
				ItemString += ' onmouseover="this.bgColor=\''+this.OverBgColor+'\';this.style.border=\''+this.OverBorder+'\';'+this.Name+'_'+MenuItems[i][0]+'.style.display=\'inline\';" onmouseout="this.bgColor=\''+this.OutBgColor+'\';this.style.border=\''+this.OutBorder+'\';'+this.Name+'_'+MenuItems[i][0]+'.style.display=\'none\';">';
				ItemString += '<div style="display:inline;width:'+(this.ItemWidth-20)+'px;">&nbsp;'+this.ItemIcon+' <a href="'+MenuItems[i][3]+'" target="'+MenuItems[i][4]+'" '+this.ItemAnchor+'>'+MenuItems[i][2]+'</a>&nbsp;</div>';
				ItemString += '<div id="'+this.Name+'_'+MenuItems[i][0]+'_HI" align="right" style="display:none;width:20px;"><span style="font-family:Webdings">4</span></div>';
				ItemString += '<td width="0" align="left" valign="top" onmouseover="'+this.Name+'_'+MenuItems[i][0]+'.style.display=\'inline\';" onmouseout="'+this.Name+'_'+MenuItems[i][0]+'.style.display=\'none\';">';
				ItemString += '<div id="'+this.Name+'_'+MenuItems[i][0]+'" style="position:absolute;display:none;">';
				ItemString += this.getItems(MenuItems[i][0]);
				ItemString += '</div>';
				ItemString += '</td>';
				ItemString += '</td>';
				ItemString += '</tr>';
				ItemString += '<tr>';
				ItemString += '<td bgcolor="" style="line-height:'+this.Spacing+'px;">&nbsp;</td>';
				ItemString += '</tr>';
			}
		}
		ItemString += '</table>';
		if(HasItems)
		{
			ItemString += '<script language="javascript" type="text/javascript">';
			ItemString += 'document.getElementById("'+this.Name+'_'+PID+'_HI").style.display = "inline";';
			ItemString += '</script>';
			return ItemString;
		}
		else
			return '&nbsp;';
	};
	
	this.Show = function()
	{
		if(HasItems)
		{
			this.Load();
			document.write('<table style="border-collapse:collapse;" border="0" cellpadding="0" cellspacing="0">');
			this.getMain(0);
			for(var i=1; i<MenuItems.length; i++)
			{
				if(MenuItems[i][1] == 0)
				{
					if(this.Direction == 1)
					{
						document.write('<tr>');
						document.write('<td bgcolor="" style="line-height:'+this.Spacing+'px;">&nbsp;</td>');
						document.write('</tr>');
					}
					else
					{
						document.write('<td bgcolor="" width="'+this.Spacing+'"><spacer/></td>');
					}
					this.getMain(i);
				}
			}
			document.write('</table>');
		}
	};
	
	this.toString = function()
	{
		return '[class JsMenu]';
	};
}
