﻿//菜单的节点
function Node(object)
{
	if(object!=null)
		this.object=object;	
	this.evaluate();
}
//菜单的类型，item为菜单项，link为超链接，line为分隔符
Node.prototype.Type="item";
//菜单项的Id（唯一标识），一般为读取自数据库的id
Node.prototype.OnlyId="0";
//菜单项的图标
Node.prototype.Ico="";
//取菜单项的名称，如果为空，则为null
Node.prototype.Name="null";
//菜单项是否显示，默认为true
Node.prototype.Visible=true;
//该菜单是否启用，默认为true
Node.prototype.Enable=true;
//导航地址
Node.prototype.Url="#";
//菜单的目标，如果type为item，则为事件；如type为line，则为超链的target
Node.prototype.Target="_blank";
//
//该节点，是否有子级
Node.prototype.IsChilds=false;
//该节点，是否是第一个节点
Node.prototype.IsFirst=false;
//该节点，是否是最后一个节点
Node.prototype.IsLast=false;

//给各个属性赋值
Node.prototype.evaluate=function()
{
	//菜单的类型，item为菜单项，link为超链接，line为分隔符
	var type=this.object.getAttribute("type");
	this.Type= type==null||type=="" ? "item" : type.toLowerCase();
	//
	var onlyId=this.object.getAttribute("onlyId");
	this.OnlyId= onlyId==null||onlyId=="" ? "0" : onlyId;
	//菜单项目的图标
	var ico=this.object.getAttribute("ico");
	this.Ico= ico==null ? "" : ico.toLowerCase();
	//取菜单项的名称
	var name=this.object.getAttribute("name");
	this.Name= name==null||type=="" ? "null" : name;
	
	//菜单项是否显示，默认为true
	var visible=this.object.getAttribute("visible");	
	visible= visible==null ? "true" : visible.toLowerCase();	
	visible= visible!="true"&&visible!="false" ? "true" : visible;
	this.Visible=Boolean(visible=="true" ? 1 : 0);	
	//该菜单是否启用,默认为true
	var enable=this.object.getAttribute("enable");
	enable= enable==null ?  "true" : enable.toLowerCase();
	enable= enable!="true"&&enable!="false" ? "true" : enable;
	this.Enable=Boolean(enable=="true" ? 1 : 0);
	//导航地址
	var url=this.object.getAttribute("navigation");
	url= url==null||url=="" ? "#" : url.toLowerCase();
	this.Url=url;
	//菜单的目标，如果type为item，则为事件；如type为line，则为超链的target
	var target=this.object.getAttribute("target");
	this.Target= target==null||target=="" ? "_blank" : target;
	//该节点，是否有子级
	this.IsChilds=this.object.childNodes.length>0 ? true : false;
	//该节点，是否是第一个节点
	this.IsFirst=this.object.prevSibling==null ? true : false;
	//该节点，是否是最后一个节点级
	this.IsLast=this.object.nextSibling==null ? true : false;
};