
/**
 * 登录
 */
function login(formId,msgId){
	var username = $("username");
	var password = $("password");
	
	if(username.value == '' || password.value == ''){
		Element.update(msgId, "用户名或者密码不为空");
		return false;
	}
	if(username.value.indexOf("@") > 0 && !validEmail(password)){
		Element.update(msgId, '邮箱格式不对');
		return false;
	}
	//$(formId).submit();
	return true;
}
/**
 * 验证email
 */
function validEmail(password,msgId){
	//if(password.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){
		return true;
	//}
	//return false;
}

Event.observe(window,'load',function(){
	var autoLoginObj = GetCookie("autoLogin");
	$("autoLogin").checked = autoLoginObj=="true"?true:false;
});

// 自动登陆选项改变
function autoLoginChanged(checkLoginObj){
	if (checkLoginObj.checked) { // 用户选中了自动登陆
		SetCookie("autoLogin", "true", 36000000, "/");
	} else { // 用户没有选中自动登陆
		SetCookie("autoLogin", "false", 36000000, "/");
	}
}