	/**
		创建者：Josh.Li 
		创建时间： 2005-4-2
		描述：
		   用于管理用户的登陆信息
	
	*/
	
	/*
	<User password="8888" username="xxzx" action="UserLogon" userid="14" englishname="xxzx" chinesename="信息中心" email="" groupid="2" description="" useful="1" rolelist="_root,Go2Home,S12,S13,S72,S73,S74,S75,S76,S118,S119,S120,S121,S77,S78,S87,S88,S89,S90,S92,S93,S79,S94,S95,S96,S97,S98,S99,S100,S80,S101,S102,S103,S104,S105,S106,S81,S107,S108,S82,S83,S84,S109,S110,S111,S112,S85,S113,S114,S115,S86,S151,S116,Go2Subject,C12,C13,C72,C73,C74,C75,C76,C118,C119,C120,C121,C77,C78,C87,C88,C89,C90,C92,C93,C79,C94,C95,C96,C97,C98,C99,C100,C80,C101,C102,C103,C104,C105,C106,C81,C107,C108,C82,C83,C84,C109,C110,C111,C112,C85,C113,C114,C115,C86,C151,C116,Go2Content,AF00002,AF00003,Go2Application,SM0002,SM0003,SM0006,SM0008,SM0009,SM0010,Go2Admin,F001,F002,F003,F004,Go2Logout" sessionid="223DA07F48737DE5152EC05398EBEAF4">
		<Result/>
	</User>
	*/	
	function UserBean(){
		this.userid = ""
		this.ChineseName = ""
		this.EnglishName = ""
		this.Email = ""
		this.Description = "" 
		this.Useful = ""
		this.RoleList = ""
		this.SessionId = ""
		this.Gzdw = ""

		var oRole = new Array()

		var errDescription = ""
		var xmldoc = new ActiveXObject("microsoft.xmldom")
		xmldoc.async = false


		//载入数据 
		this.load = function(sXML){
			xmldoc.loadXML(sXML)
			if(xmldoc.parseError.errorCode != 0){
				errDescription = xmldoc.parseError.reason
				return ;
			}
			var oRoot = xmldoc.documentElement
			this.userid = oRoot.getAttribute("userid");
			this.ChineseName = oRoot.getAttribute("chinesename")
			this.EnglishName = oRoot.getAttribute("englishname")
			this.Email = oRoot.getAttribute("email")
			this.Description = oRoot.getAttribute("description")
			this.RoleList = oRoot.getAttribute("rolelist")
			this.SessionId = oRoot.getAttribute("sessionid")
			this.Useful = oRoot.getAttribute("useful")
			this.Gzdw = oRoot.getAttribute("gzdw");

			oRole = this.RoleList.split(",");
			
		}
		
		//===判断sRoleItem 是否在角色字符中
		this.isInRole = function (sRoleItem){
			
			var i,bResult
			bResult = false
			for(i=0;i<oRole.length;i++){
				if(oRole[i] == sRoleItem){
					bResult = true
					break;
				}
			}

			return bResult;
		}


		//=== 
		//_root,Go2Subject,S_,Go2Content,C_,Go2Application,AF_,Go2Admin,SM_,Go2Function,F_,Go2Logout
		//类型： Subject ,Content,Application,Admin,Function,Logout
		this.GetRoleByType = function(sType){
			var i
			var sRoleList = ""

			for(i=0;i<oRole.length;i++){
				var sRole = oRole[i]
				var firstChar 
				switch(sType){
					case "Subject":
						firstChar = sRole.substring(0,1)
						secondChar = sRole.substring(0,2)
						if(sRole == "Go2Subject" || (firstChar == "S" && secondChar != "SM")){
							if(sRole == "Go2Subject")
								sRoleList += sRole + ",";
							else
								sRoleList += sRole.substring(1,sRole.length) + ","
						}
						break;
					case "Content":
						firstChar = sRole.substring(0,1)
						if(sRole == "Go2Content" || firstChar == "C"){
							if(sRole == "Go2Content")
								sRoleList += sRole + ","
							else
								sRoleList += sRole.substring(1,sRole.length) + ","	
						}
						break;
					case "Application":
						firstChar = sRole.substring(0,2)
						if(sRole == "Go2Application" || firstChar == "AF"){
							sRoleList += sRole + ","; 
						}
						break;
					case "Admin":
						firstChar = sRole.substring(0,2)
						if(sRole == "Go2Admin" || firstChar == "SM"){
							sRoleList += sRole + ","
						}
						break;
					case "Function":
						firstChar = sRole.substring(0,1)
						if(sRole == "Go2Function"  || firstChar == "F"){
							sRoleList += sRole + ","
						}
						break
					case "Logout":
						if(sRole == "Go2Logout")
							sRoleList += sRole + ","
						break;
					default:
				}
			}

			if(sRoleList != ""){
				sRoleList = sRoleList.substring(0,sRoleList.length-1)
			}
			return sRoleList;
		}
		
		//返回总角色名称
		this.GetMainRole = function(){
			
			var params = new Array("Subject","Content","Application","Function","Admin","Logout")
			var i
			var sMainRoleList = ""
			for(i=0;i<params.length;i++){
				var param = params[i]
				var sRoles = this.GetRoleByType(param)
				if(sRoles != "")
					sMainRoleList += sRoles + ","
			}

			if(sMainRoleList != "")
				sMainRoleList = sMainRoleList.substring(0,sMainRoleList.length-1);
			return sMainRoleList;
		}


		
	
	}
