String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

//Count string byte number, return integer
String.prototype.ByteCount = function()
{
	txt = this.replace(/(<.*?>)/ig,"");
	txt = txt.replace(/([\u0391-\uFFE5])/ig, "11");
	var count = txt.length;
	return count;
}

//mouse onclick the username box
function click_username_input(thisinput)
{
	regnameinfo.className = "show exactness";
	regnameinfo.innerHTML = "填写6?0位的用户?";
}

//mouse lost the username box
function check_username_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();

	if ( (thisinput.value.trim() == "") ) {
		regnameinfo.className="show null";
		regnameinfo.innerHTML="系统未检测到您的输入?";
	}
	else if ( count < 6 || count > 20 )
	{
		regnameinfo.className = "show err";
		regnameinfo.innerHTML = "输入不符合规范！";
	}
	else
	{
		regnameinfo.className = "show exactness";
		regnameinfo.innerHTML = "内容符合规范，可以使用！";
	}
}

//mouse onclick the email box
function click_email_input(thisinput)
{
	regemailinfo.className = "show exactness";
	regemailinfo.innerHTML = "填写常用邮箱名，用于登陆";
}

//mouse lost the email box
function check_email_input(thisinput)
{
	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	if ( (thisinput.value.trim() == "") ) {
		regemailinfo.className = "show null";
		regemailinfo.innerHTML = "系统未检测到您的输入?";
	}
	else if (!thisinput.value.match(re))
	{
		regemailinfo.className = "show err";
		regemailinfo.innerHTML = "输入不符合规范！";
	}
	else
	{
		regemailinfo.className = "show exactness";
		regemailinfo.innerHTML = "内容符合规范，可以使用！";
	}
}

//mouse onclick the password box
function click_password_input(thisinput)
{
	regpassinfo.className = "show exactness";
	regpassinfo.innerHTML = "填写6?0位的密码";
}

//mouse lost the password box
function check_password_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();

	if ( (thisinput.value.trim() == "") ) {
		regpassinfo.className="show null";
		regpassinfo.innerHTML="系统未检测到您的输入?";
	}
	else if ( count < 6 || count > 20 )
	{
		regpassinfo.className = "show err";
		regpassinfo.innerHTML = "输入不符合规范！";
	}
	else
	{
		regpassinfo.className = "show exactness";
		regpassinfo.innerHTML = "内容符合规范，可以使用！";
	}
}

//mouse onclick the chkpass box
function click_chkpass_input(thisinput)
{
		var oPass = Form1.password.value;
		if( oPass == "")
		{
			Form1.password.focus();
		}else{
			regpass2info.className="show exactness";
			regpass2info.innerHTML="请输入确认密?";
		}
}

//mouse lost the chkpass box
function check_chkpass_input(thisinput)
{
	var oPass = Form1.password.value;
	if( thisinput.value.length=="" )
	{
		regpass2info.className="show null";
		regpass2info.innerHTML = "系统未检测到您的输入?";
	}
	else if(thisinput.value != oPass)
	{
		regpass2info.className="show err";
		regpass2info.innerHTML = "确认密码与密码不一致！";
	}
	else
	{
		regpass2info.className = "show exactness";
		regpass2info.innerHTML = "密码确认通过?";
	}
}

//mouse onclick the nickname box
function click_nickname_input(thisinput)
{
	regnicknameinfo.className="show exactness";
	regnicknameinfo.innerHTML="姓名限制?个汉字以?";
}

//mouse lost the nickname box
function check_nickname_input(thisinput)
{
	var count = thisinput.value.trim().ByteCount();
	if( count == 0 )
	{
		regnicknameinfo.className="show null";
		regnicknameinfo.innerHTML="系统未检测到您的输入?";
	}
	else if ((thisinput.value.trim() != "") && (count < 2 || count > 8)) {
		regnicknameinfo.className="show err";
		regnicknameinfo.innerHTML="输入不符合规范！";
	}
	else
	{
		regnicknameinfo.className = "show exactness";
		regnicknameinfo.innerHTML = "内容符合规范，可以使用！";
	}
}

//mouse onclick the height box
function click_height_input(thisinput)
{
	regheightinfo.className="show exactness";
	regheightinfo.innerHTML="?30?60之间的数值！";
}

//mouse lost the height box
function check_height_input(thisinput)
{
    var count = thisinput.value.trim().ByteCount();
    var rs = /^[0-9]{3}$/;

    if( count == 0 )
    {
        regheightinfo.className="show null";
        regheightinfo.innerHTML="系统未检测到您的输入?";
    }
    else if((!thisinput.value.match(rs)) || (thisinput.value < 130 || thisinput.value > 260))
    {
        regheightinfo.className="show err";
        regheightinfo.innerHTML="输入不符合规范！";
    }
    else
    {
        regheightinfo.className = "show exactness";
        regheightinfo.innerHTML = "内容符合规范，可以使用！";
    }
}





//mouse onclick the workprovince box
function click_workprovince_input(thisinput)
{
	regworkareainfo.className="show exactness";
	regworkareainfo.innerHTML="请选择您所在的省份?";
}

//mouse lost the workprovince box
function check_workprovince_input(thisinput)
{
    if( thisinput.value.trim() == 0 )
    {
        regworkareainfo.className="show null";
        regworkareainfo.innerHTML="系统未检测到您的输入?";
    }
    else
    {
        regworkareainfo.className = "show null";
        regworkareainfo.innerHTML = "请选择您所在的城市?";
    }
}

//mouse onclick the workcity box
function click_workcity_input(thisinput)
{
	regworkareainfo.className="show exactness";
	regworkareainfo.innerHTML="请选择您所在的城市?";
}

//mouse lost the workcity box
function check_workcity_input(thisinput)
{
    if( thisinput.value.trim() == 0 )
    {
        regworkareainfo.className="show null";
        regworkareainfo.innerHTML="系统未检测到您的输入?";
    }
    else
    {
        regworkareainfo.className = "show exactness";
        regworkareainfo.innerHTML = "内容符合规范，可以使用！";
    }
}

/*
mouse onclick the checkcode box
function click_checkcode_input(thisinput)
{
	regcheckcodeinfo.className="show exactness";
	regcheckcodeinfo.innerHTML="请填写图片中的数字！";
}
*/

//mouse lost the checkcode box
function check_checkcode_input(thisinput)
{
    var count = thisinput.value.trim().ByteCount();
	var rc = /^[0-9]{5}$/;

    if (count == 0)
    {
        regcheckcodeinfo.className="show null";
        regcheckcodeinfo.innerHTML="系统未检测到您的输入?";
    }
    else if (!thisinput.value.match(rc))
    {
        regcheckcodeinfo.className="show err";
        regcheckcodeinfo.innerHTML="输入不符合规范！";
    }
    else
    {
        regcheckcodeinfo.className = "show exactness";
        regcheckcodeinfo.innerHTML = "内容符合规范，可以使用！";
    }
}

//mouse onclick the note textarea
function click_note_input(thisinput)
{
	regnoteinfo.className="show exactness";
	regnoteinfo.innerHTML="?0字到1000字之?";
}

//mouse lost the note textarea
function check_note_input(thisinput)
{
    if( thisinput.value.length == 0 )
    {
        regnoteinfo.className="show null";
        regnoteinfo.innerHTML="系统未检测到您的输入?";
    }
    else if((thisinput.value != "") && (thisinput.value.length < 20 || thisinput.value.length > 1000))
    {
        regnoteinfo.className="show err";
        regnoteinfo.innerHTML="输入不符合规范！";
    }
    else
    {
        regnoteinfo.className = "show exactness";
        regnoteinfo.innerHTML = "内容符合规范，可以使用！";
    }
}


//Check submit form error
function chkForm(objForm)
{
	var objForm;
	var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
	var rs = /^[0-9]{3}$/;
	var rc = /^[0-9]{5}$/;

	var email        = objForm.email.value;
	var password     = objForm.password.value;
	var nickname     = objForm.nickname.value;
    var year         = objForm.year.value;
    var month        = objForm.month.value;
    var day          = objForm.day.value;
	var height       = objForm.height.value;
    var marriage     = objForm.marriage.value;
    var degree       = objForm.degree.value;
    var income       = objForm.income.value;
    var province     = objForm.province.value;
    var city         = objForm.city.value;
    var checkcode    = objForm.checkcode.value;
    var note         = objForm.note.value;


	if (email == "" || (!email.match(re)))
	{
		objForm.email.focus();
		return false;
	}

	if (password == "" || (password.length < 6 || password.length > 20))
	{
		objForm.password.focus();
		return false;
	}

	if (objForm.password.value != objForm.chkpass.value)
	{
		objForm.chkpass.focus();
		return false;
	}

	if (nickname == "" || (nickname.trim().ByteCount()<2 || nickname.trim().ByteCount()>20))
	{
		objForm.nickname.focus();
		return false;
	}

    if(!(document.getElementById("sexf").checked || document.getElementById("sexm").checked))
    {
        regsexinfo.className="show err";
        regsexinfo.innerHTML="性别、生日、身高不能修改，请认真填写?";
        return false;
    }

    if (year == 0)
    {
        objForm.year.focus();
        return false;
    }

    if (month == 0)
    {
        objForm.month.focus();
        return false;
    }

    if (day == 0)
    {
        objForm.day.focus();
        return false;
    }

	if (height == "" || (!height.match(rs))  || (height < 130 || height > 260))
	{
		objForm.height.focus();
		return false;
	}

    if (marriage == 0)
    {
        objForm.marriage.focus();
        return false;
    }
    if (degree == 0)
    {
        objForm.degree.focus();
        return false;
    }

    if (income == 0)
    {
        objForm.income.focus();
        return false;
    }

    if (province == 0)
    {
        objForm.province.focus();
        return false;
    }

    if (city == 0)
    {
        objForm.city.focus();
        return false;
    }

    if (checkcode == "" || (!checkcode.match(rc)))
    {
        objForm.checkcode.focus();
        return false;
    }

    if (note == "" || (note.length < 20 || note.length >1000))
    {
        objForm.note.focus();
        return false;
    }

    if(!document.getElementById("readme").checked)
    {regreadmeinfo.innerHTML="必须同意本条款才能注册！";
        return false;
    }

	return true;
}

function default_focus(objName)
{
	eval("document.Form1."+objName+".focus();");
}