var xue24User = null;
var XUsers = {
	isLogined : false,
	xUserID : "",
	xUserName : "",
	xUserRegname : "",
	xUserV : "",
	LoginHtml : function(user) {
		if (user != null) {
			return "<form name='loginform' method='post' action='/portal5.1/user/login.jsp'>E-mail: <inpout type='text' name='name' style='width:90px' style='font-size:12px; font-family:Arial' value='"
					+ user
					+ "'/>密码：<input type='password' name='pwd' style='width:90px' style='font-size:12px; font-family:Arial'/><input type='submit' value='登录' style='font-size:12px'/><input type='hidden' name='cook' value='1'/>&nbsp;&nbsp;&nbsp;</form>";
		} else {
			return "<form name='loginform' method='post' action='/portal5.1/user/login.jsp'>E-mail：<input type='text' name='name'  style='width:90px' style='font-size:12px; font-family:Arial'/>密码：<input type='password' name='pwd'  style='width:90px' style='font-size:12px; font-family:Arial'/><input type='submit' value=' 登 录 ' style='font-size:12px'/><input type='hidden' name='cook' value='1' />&nbsp;&nbsp;&nbsp;<a href='/www/login/forgotPassword.jsp'>忘记密码</a> | <a href='/www/reg/?step=a&mkt=yiyou2590008'>新用户注册</a></form>";
		}
	},
	LoginedHtml : function(user) {
		this.isLogined = true;
		this.xUserID = Cookies.Get("xue24UserID");
		this.xUserName = Cookies.Decode(Cookies.Get("xue24UserName"));
		this.xUserRegname = Cookies.Get("xue24UserRegName");
		this.xUserV = getXUserV();
		return "欢迎你，"
				+ "<span id='userFACE'> " + this.xUserName + "</span>&nbsp; | <a href='/portal5.1/user/modify_vote_info.jsp?userid="
				+ this.xUserID
				+ "'>修改我的投稿身份信息 </a> | <a href='/space/"
				+ this.xUserID
				+ "'>我的Xue24</a> | <a href='/www/profile/more.jsp?type=updatepwd&userid="
				+ this.xUserID
				+ "'>修改密码</a> | <a href='/www/login/logout.jsp' title='退出xue24的当前身份'>退出</a>";
	},
	Start : function() {
		if (//Cookies.Get("xue24UserID") != ""
				 Cookies.Get("xue24UserID") != null
				//&& Cookie.Get("xue24UserHash") != ""
				&& Cookies.Get("xue24UserHash") != null
				&& Cookies.Get("xue24UserRegName") != ""
				&& Cookies.Get("xue24UserRegName") != null
				&& Cookies.Get("xue24UserName") != ""
				&& Cookies.Get("xue24UserName") != null) {
			document.write(this.LoginedHtml(Cookies.Decode(Cookies.Get("xue24UserName"))));
		} else {
			document.write(this.LoginHtml(xue24User));
		}
	}
}
function getXUserV() {
	var rtn = Cookies.Get("xue24UserV");
	if (rtn == null || trn == "") {

	}
	return rtn;
}

var Cookies = {
	Decode : function(str) {
		var strArr;
		var strRtn = "";
		if (str != null && str.indexOf("a") > 1) {
			strArr = str.split("a");
			for (var i = strArr.length - 1; i >= 0; i--) {
				strRtn += String.fromCharCode(eval(strArr[i]));
			}
			return strRtn;
		}
		return null;
	},
	Code : function(str) {
		var strRtn = "";
		for (var i = str.length - 1; i >= 0; i--) {
			strRtn += str.charCodeAt(i);
			if (i) {
				strRtn += "a";
			}
		}
		return strRtn;
	},
	Get : function(name) {
		var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
		if (arr = document.cookie.match(reg)) {
			return unescape(arr[2]);
		} else {
			return null;
		}
	},
	Set : function(name, value) {
		var expdate = new Date();
		var argv = Cookies.Set.arguments;
		var argc = Cookies.Set.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
		var path = (argc > 3) ? argv[3] : null;
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;
		if (expires != null) {
			expdate
					.setTime(expdate.getTime()
							+ (expires * 24 * 60 * 60 * 1000));
		}
		document.cookie = name
				+ "="
				+ escape(value)
				+ ((expires == null) ? "" : ("; expires=" + expdate
						.toGMTString()))
				+ ((path == null) ? "" : ("; path=" + path))
				+ ((domain == null) ? "" : ("; domain=" + domain))
				+ ((secure == true) ? "; secure" : "");
	},
	Del : function(cookiesName) {
		var exp = new Date();
		exp.setTime(exp.getTime() - 1);
		var cval = this.Get(cookiesName);
		if (cval != null) {
			document.cookie = cookiesName + "=" + cval + ";expires="
					+ exp.toGMTString();
		}
	}
}

