//功能：去掉字符串前后空格
//返回值：去掉空格后的字符串
function fnRemoveBrank(strSource)
{
 return strSource.replace(/^\s*/,'').replace(/\s*$/,'');
}
function String.prototype.lenB()
{
return this.replace(/[^\x00-\xff]/g,"**").length;
}
//
function checkUserExist(){
	if (fnRemoveBrank(regsiter.username.value)== "") {
		alert ('请输入会员帐号 ！');
		regsiter.username.focus();
		return false;
	}else{
		window.open("checkUser.php?login="+regsiter.username.value,"","width=340,height=200,scrollbars=no");
	}
	return false;
}

//检查邮箱
function checkmailbox(username)
{
  var re, r;

  re = /\S/;
  r = username.match(re);
  if (!r)
  {
	alert("请填写邮箱地址！");
	return false;
  }
  else
  {
	window.open("CheckMail.php?action=cmailbox&value="+username,"")
  }
}

function Juge(theForm)
{
var objv = theForm.username.value;
  var pattern = /^[A-Za-z0-9]{4,20}$/;
  flag = pattern.test(objv);
  if(!flag) 
 {
  alert("用户名：要求为4-20个字母或数字！请重新输入。");
  theForm.username.focus();
  return(false);
  }
  
  var objv = theForm.password.value;
  var pattern = /^[A-Za-z0-9]{4,20}$/;
  flag = pattern.test(objv);
  if(!flag) 
 {
  alert("密码：要求为4-20个字母或数字！请重新输入。");
  theForm.password.focus();
  return(false);
  }
  if (theForm.password2.value !=theForm.password.value)
  {
    alert("两次密码输入不一致，请重新确认密码!");
    theForm.password2.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.schoolname.value) == "")
  {
    alert("请输入院校名称!");
    theForm.schoolname.focus();
    return (false);
  }
    if (fnRemoveBrank(theForm.suozdi.value) == "")
  {
    alert("请选择所在地!");
    theForm.suozdi.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.property.value) == "")
  {
    alert("请选择院校性质!");
    theForm.property.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.type.value) == "")
  {
    alert("请选择院校类型!");
    theForm.type.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.schoolcount.value) == "")
  {
    alert("请输入院校简介!");
    theForm.schoolcount.focus();
    return (false);
  }
  if ((theForm.schoolcount.value).lenB()>=2000)
  {
	 alert("院校简介太长了，要求不多于8000个字符!");
	 theForm.schoolcount.focus();
	 return (false);
  } 
  if (fnRemoveBrank(theForm.recruitintr.value) == "")
  {
    alert("请输入招生简章!");
    theForm.recruitintr.focus();
    return (false);
  }
  if ((theForm.recruitintr.value).lenB()>=2000)
  {
	 alert("招生简章太长了，要求不多于8000个字符!");
	 theForm.recruitintr.focus();
	 return (false);
  } 
  if (fnRemoveBrank(theForm.address.value) == "")
  {
    alert("请输入通信地址!");
    theForm.address.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.zipcode.value) == "")
  {
    alert("请输入通信地址!");
    theForm.zipcode.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.manseg.value) == "")
  {
    alert("请输入联系人!");
    theForm.manseg.focus();
    return (false);
  }
  if (fnRemoveBrank(theForm.tel.value) == "")
  {
    alert("请输入联系电话!");
    theForm.tel.focus();
    return (false);
  }
  var objv = theForm.mailbox.value;
  var pattern = /^([a-zA-Z0-9_-])+(\.([a-zA-Z0-9_-])+)*@([a-zA-Z0-9_-])+(\.([a-zA-Z0-9_-])+)+$/;
  flag = pattern.test(objv);
  if(!flag)
  {
    alert("电子邮件：格式不正确！请重新输入。");
	theForm.mailbox.focus();
	return (false); 
  } 
 }
