﻿function $(o)
{
	return document.getElementById(o);
}
function uc(c)
{
	if(c.indexOf("-")==-1)return c;
	cArr = c.split("-");c = "";
	for(var i=1;i<cArr.length;i++)c += String.fromCharCode(cArr[i]);
	return c;
}

function checkLogin()
{
	var theForm = $("lf");
	var err_msg ="";
	if(theForm.username.value=="")
		err_msg += "请输入用户名!<br/>"
	if(theForm.password.value=="")
		err_msg += "请输入密码!<br/>"
	if(err_msg=="")
	{
		theForm.vc.value =uc(theForm.vc.value);
		return true;
	}
	else
	{
		$("result").innerHTML = err_msg;
		$("result").style.color = "red";
		return false;
	}
}

function checkReg()
{
	var theForm = $("regForm");
	var err_msg ="";
         
	if(theForm.agree.checked==false)
		err_msg += "必须同意并尊受方便面三国用户注册协议才能注册!<br/>";

        if(theForm.username.value.length > 12)
                err_msg += "用户名不能超过12个字符(6个汉字)..<br/>";
	if(theForm.username.value=="")
		err_msg += "用户名不能为空..<br/>";
	if(theForm.password.value=="")
		err_msg += "登陆密码不能为空..<br/>";
	else
	{
		if(theForm.password.value!=theForm.cpassword.value)
			err_msg += "两次输入的密码不一样，请重新输入..<br/>";
	}
	if(theForm.mail.value=="")
		err_msg += "电子邮件不能为空..<br/>";

	if(err_msg=="")
	{
		theForm.vc.value =uc(theForm.vc.value);
		return true;
	}
	else
	{
		$("result").innerHTML = err_msg;
		$("result").style.color = "red";
		return false;
	}
}