
/*
windowLoader = function () 
{
	authcode();
	//var ajax = new Ajax.Request('relay.php', {onSuccess: userLogin_handler_check, method: 'post', parameters: 'relay=checkLogin'});
}

function authcode()
{
	var today = new Date();
	var today_ms = ""
		+ today.getFullYear() + (today.getMonth() + 1) + today.getDate()
		+ today.getMinutes() + today.getSeconds() + today.getMilliseconds();
	$("#authcode").attr({ src: "?type=user&model=authcode&t="+today_ms, alt: "刷新验证码" });
	$("#authcode").click(authcode);
}
*/
function checkLogin()
{
	//alert($("#username").attr("value"));
/*	if ($("#checkcode")[0].value == '')
	{
		alert("验证码不能为空！");
		return false;
	}
	if ($("#checkcode")[0].value.length != 4)
	{
		alert("验证码格式不正确！");
		return false;
	}*/
	if ($("#username")[0].value== '')
	{
		alert("用户名不能为空！");
		return false;
	}
	if ($("#password")[0].value== '')
	{
		alert("密码不能为空！");
		return false;
	}
	if ($("#username")[0].value.length<3)
	{
		alert("用户名少于三位！");
		return false;
	}
	if ($("#password")[0].value.length<6)
	{
		alert("密码少于六位！");
		return false;
	}
	
	login();
}

function login()
{
	var rflag = "0";
	if($("#rembflag").attr('checked')==true)
	{
		rflag = "1";
	}
	$.ajax({
		type: "POST",
		url:  "/user/login/action/checklogin",
		data: "username="+$("#username").val()+"&password="+$("#password").val()+"&rembflag="+rflag,
		success: function(msg){ 
		 if (msg=='error_auth')
		 {
			 alert("验证码错误");
		 }
		 else if (msg=='error_nu')
		 {
			 alert("非法用户");
		 }
		 else if (msg=='error_pw')
		 {
			 alert("密码错误");
		 }
		 else if (msg=='error_pw_lt')
		 {
			 alert("密码错误超3次，用户被锁定");
		 }
		  else if (msg=='error_lt')
		 {
			 alert("用户被锁定，请联系管理员");
		 }
		 else if (msg=='succeed')
		 {
			getUserInfo();
		 }
		 else
		{
			 alert("未知错误");
		}
		} 
	}); 	
}

function getUserInfo()
{
	$.ajax({
					type: "POST",
					url:  "/user/login/action/getuserinfo",
					data:"type="+$("#flag").val(),
					success: function(msg){ 
						$("#logined").html(msg);
						
					} 
				});
}

function userLogout()
{
	$.ajax({
		type: "POST",
		url:  "/user/logout/",
		data: "",
		success: function(){ 
		 getUserInfo();
		} 
	}); 	
}



//window.onload = windowLoader;
