<!-- 个人邮件系统注册验证 start-->


function checkAccountName(theForm) {

	document.getElementById("yonghumingdiv").style.display="none";
	document.getElementById("yanzhengmadiv").style.display="none";
	document.getElementById("mimadiv").style.display="none";
	document.getElementById("agreediv").style.display="none";
	document.getElementById("yonghumingyicunzaidiv").style.display="none";
	document.getElementById("paycodediv").style.display="none";
	theForm.accountName.style.backgroundColor='';

	if (theForm.accountName.value.length < 5)
	{
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
	}

	if (theForm.accountName.value.length > 20)
	{
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
	}

	if (havenoChar1(theForm.accountName.value))
	{
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
	}

	if (havenoLetter(theForm.accountName.value.substring(0,1)))
	{
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
	}

	len = theForm.accountName.value.length;
	if (theForm.accountName.value.length >0 &&CheckLast(theForm.accountName.value.substring(len-1,len)))
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
	}
}

function checkOccupy(theForm,backid) {

	var num = 0; 
	document.getElementById("yonghumingdiv").style.display="none";
	document.getElementById("yanzhengmadiv").style.display="none";
	document.getElementById("mimadiv").style.display="none";
	document.getElementById("agreediv").style.display="none";
	document.getElementById("yonghumingyicunzaidiv").style.display="none";
	document.getElementById("paycodediv").style.display="none";

	if (theForm.accountName.value.length < 5)
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入位数有误，请输入5-20位字符。";
		num = num+1;
	}

	if (theForm.accountName.value.length > 20)
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入位数有误，请输入5-20位字符。";
		num = num+1;
	}

	if (havenoChar1(theForm.accountName.value))
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
		num = num+1;
	}

	if (havenoLetter(theForm.accountName.value.substring(0,1)))
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="用户名输入有误，请输入5-20位字符,邮箱名可以是5-20位字符，只能由英文小写字母(a-z)，阿拉伯数字(0-9)，下划线(_)，圆点(.)和横线(-)构成，不能有空格，并且必须以英文字母开头，不能以“_” “-” “.”结尾，不支持连续两个或两个以上的“_” “-” “.”。";
		num = num+1;
	}

	len = theForm.accountName.value.length;
	if (CheckLast(theForm.accountName.value.substring(len-1,len)))
	{
		theForm.accountName.focus();
		document.getElementById("yonghumingdiv").style.display="inline";
		document.getElementById("yonghumingdiv").innerHTML ="不能以“_”“-” “.”结尾";
		num = num+1;
	}

	if(num>0){
		return (false);
	}
	send_request('/frontuser/checkname.do?method=checkEmailAcc&accountName='+theForm.accountName.value+"@263.net",backid);
}

function Check_Ally(theForm){
				var num = 0; 
				document.getElementById("yonghumingdiv").style.display="none";
				document.getElementById("yanzhengmadiv").style.display="none";
				document.getElementById("mimadiv").style.display="none";
				document.getElementById("agreediv").style.display="none";
				document.getElementById("yonghumingyicunzaidiv").style.display="none";
				document.getElementById("paycodediv").style.display="none";


				var isAccountNameFocus  = 0; 
				var isPassWordFocus     = 0; 
				var isPassWord2Focus    = 0; 
				var isVcodeFocus        = 0; 
				var isAgreeFocus        = 0; 
				var isPaycodeFocus        = 0; 

				if (theForm.agree.checked == false){
					//alert("您必须完全同意263收费邮箱服务条款中的内容才能申请263专递邮箱！");
					isAgreeFocus = 1;
					document.getElementById("agreediv").style.display="inline";
					num = num+1;
  				}


				if (theForm.accountName.value.length < 5){
					isAccountNameFocus = 1;	
					document.getElementById("yonghumingdiv").style.display="inline";
					document.getElementById("yonghumingdiv").innerHTML ="用户名输入位数有误，请输入5-20位字符。";
					num = num+1;
  				}

				if (theForm.accountName.value.length > 20)
				{
					theForm.accountName.focus();
					document.getElementById("yonghumingdiv").style.display="inline";
					document.getElementById("yonghumingdiv").innerHTML ="用户名输入位数有误，请输入5-20位字符。";
					num = num+1;
				}

				if (havenoChar(theForm.accountName.value)){
					isAccountNameFocus = 1;
					document.getElementById("yonghumingdiv").style.display="inline";
					document.getElementById("yonghumingdiv").innerHTML ="用户名输入格式有误，请勿使用特殊字符。";
					num = num+1;
  				}

				if (havenoLetter(theForm.accountName.value.substring(0,1))){
					isAccountNameFocus = 1;
					document.getElementById("yonghumingdiv").style.display="inline";
					num = num+1;
  				}

				len = theForm.accountName.value.length;
				if (CheckLast(theForm.accountName.value.substring(len-1,len))){
					isAccountNameFocus = 1;
					document.getElementById("yonghumingdiv").style.display="inline";
					num = num+1;
  				}

				if (theForm.vcode.value.length < 4) {
					isVcodeFocus = 1;
					document.getElementById("yanzhengmadiv").style.display="inline";
					num = num+1;
				}

				var pwd1 = document.form1.passwd.value;
				var pwd2 = document.form1.passwd2.value;

				if(JHshStrLen(pwd2)<6 ||JHshStrLen(pwd2)>8){
					document.getElementById("mimadiv").style.display="inline";
					document.getElementById("mimadiv").innerHTML ="密码应为6-8位，请重新输入。";
					num = num+1;
					isPassWord2Focus = 1;
				}
				if (havenoChar1(pwd2)){
					document.getElementById("mimadiv").style.display="inline";
					document.getElementById("mimadiv").innerHTML ="确认密码输入格式有误，请勿使用特殊字符";
					isPassWord2Focus = 1;
					num = num+1;
				}

				if(JHshStrLen(pwd1)<6 ||JHshStrLen(pwd1)>8){
					document.getElementById("mimadiv").style.display="inline";
					document.getElementById("mimadiv").innerHTML ="密码应为6-8位，请重新输入";
					num = num+1;
					isPassWordFocus = 1;
				}
				if (havenoChar1(pwd1)){
					document.getElementById("mimadiv").style.display="inline";
					document.getElementById("mimadiv").innerHTML ="密码输入格式有误，请勿使用特殊字符";
					num = num+1;
					isPassWordFocus = 1;
				}

				if(pwd1!=pwd2&&JHshStrLen(pwd2)>=6&&JHshStrLen(pwd2)<=8){
					document.getElementById("mimadiv").style.display="inline";
					document.getElementById("mimadiv").innerHTML ="密码输入不一致，请重新输入。";
					isPassWordFocus = 1;
					num = num+1;
				}
				
				if (theForm.paycode.value.length < 11
      				|| theForm.paycode.value.substring(0, 3) != "139"
     			 	&& theForm.paycode.value.substring(0, 3) != "138"
      				&& theForm.paycode.value.substring(0, 3) != "137"
      				&& theForm.paycode.value.substring(0, 3) != "136"
      				&& theForm.paycode.value.substring(0, 3) != "135"
      				&& theForm.paycode.value.substring(0, 3) != "159"
      				&& theForm.paycode.value.substring(0, 3) != "134"
      				&& theForm.paycode.value.substring(0, 3) != "133"
      				&& theForm.paycode.value.substring(0, 3) != "132"
      				&& theForm.paycode.value.substring(0, 3) != "131"
      				&& theForm.paycode.value.substring(0, 3) != "130"
      				&& theForm.paycode.value.substring(0, 3) != "153"
      				&& theForm.paycode.value.substring(0, 3) != "158"
      				&& theForm.paycode.value.substring(0, 3) != "159"
      				|| havenoNumber(theForm.paycode.value))
  				{
  					isPaycodeFocus = 1;
					theForm.paycode.focus();
					document.getElementById("paycodediv").style.display="inline";
					document.getElementById("paycodediv").innerHTML ="请填写正确的手机号码";
					num = num+1;
  				}

				if(num>0){
		
    				if(isAccountNameFocus==1){
						theForm.accountName.focus()			
						return (false);
					}else if(isPassWordFocus==1){
						theForm.passwd.focus()
						return (false);
					}else if(isPassWord2Focus==1){
						theForm.passwd2.focus()
						return (false);
					}else if(isVcodeFocus==1){
						theForm.vcode.focus();
						return (false);
					}else if(isAgreeFocus==1){
						theForm.agree.focus()			
						return (false);
					}else if(isPaycodeFocus==1){
						theForm.paycode.focus()			
						return (false);
					}
					return (false);		
				}else{
 					return (true)
				}
			}

function havenoNumber(theelement)
{
	//含有非数字字符 返回 true
	text="1234567890";
	for(i=0;i<=theelement.length-1;i++)
	{
		char1=theelement.charAt(i);
		index=text.indexOf(char1);
		if(index==-1)
		{
			return true;
		}
	}
	return false;
}
function isTrueNumber(theelement)
{
  text = "-1234567890";
  for (i = 0; i <= theelement.length - 1; i++)
  {
    char1 = theelement.charAt(i);
    index = text.indexOf(char1);
    if (index == -1)
    {
      return true;
    }
  }
  return false;
}
function havenoChar(theelement){//含有非法字符 返回 true
	text="abcdefghijklmnopqrstuvwxyz1234567890._-";
  for(i=0;i<=theelement.length-1;i++){
		char1=theelement.charAt(i);
    index=text.indexOf(char1);
    if(index==-1){
			return true;
    }
	}
  return false;
}
function havenoChar1(theelement){//含有非法字符 返回 true
	text="abcdefghijklmnopqrstuvwxyz1234567890._-";
  for(i=0;i<=theelement.length-1;i++){
		char1=theelement.charAt(i);
    index=text.indexOf(char1);
    if(index==-1){
			return true;
    }
	}
  return false;
}

function havenoLetter(theelement){//含有非法字符 返回 true
	text="abcdefghijklmnopqrstuvwxyz";
  index=text.indexOf(theelement);
  if(index==-1){
		return true;
	}
  return false;
}

function CheckLast(theelement){//含有非法字符 返回 true
	text="_-.";
  index=text.indexOf(theelement);
  if(index!=-1){
		return true;
	}
  return false;
}

function checkSex(){
	document.getElementById("xingbiediv").style.display="none";
}

function SetVcodeMsg(){
	var vcode = document.form1.vcode.value;
	
	if (vcode.length<4){
		document.getElementById("yanzhengmadiv").innerHTML ="请输入图片中的内容，不区分大小写。";
		document.getElementById("yanzhengmadiv").style.display="inline";
	}else{
		document.getElementById("yanzhengmadiv").innerHTML ="";
	}
	document.form1.vcode.style.backgroundColor='';
}

function SetQuestionMsg(){
	var question = document.form1.question.value;
	
	if (question.length>32){
		document.getElementById("mimawentidiv").innerHTML ="问题长度不大于32个字符";
		document.getElementById("mimawentidiv").style.display="inline";
	}
	if (question == null|| question.length<1){
		document.getElementById("mimawentidiv").innerHTML ="问题长度在1～32位之间";
		document.getElementById("mimawentidiv").style.display="inline";
	}else{
		document.getElementById("mimawentidiv").innerHTML ="";
	}
	document.form1.question.style.backgroundColor='';
}


function SetAnswerMsg(){
	var answer = document.form1.answer.value;
	
	if (JHshStrLen(answer)<6 ||JHshStrLen(answer)>32){
		document.getElementById("mimawentidiv").innerHTML ="答案长度在6～32位之间";
		document.getElementById("mimawentidiv").style.display="inline";
	}else{
		document.getElementById("mimawentidiv").innerHTML ="";
	}
	document.form1.answer.style.backgroundColor='';
}

function SetPwdMsg(){
	var pwd1 = document.form1.passwd.value;
	var pwd2 = document.form1.passwd2.value;
	document.form1.passwd.style.backgroundColor='';
	document.getElementById("mimadiv").style.display="inline";

	if(JHshStrLen(pwd1)<6 ||JHshStrLen(pwd1)>8){
		document.getElementById("mimadiv").innerHTML ="密码输入错误，请重新输入。";
	  return false;
	}else if (havenoChar1(pwd1)){
		document.getElementById("mimadiv").innerHTML ="密码输入格式有误，请勿使用特殊字符";
	  return false;
	}else if(pwd1!=pwd2&&JHshStrLen(pwd2)>0){
		document.getElementById("mimadiv").innerHTML ="密码输入不一致，请重新输入。";
	  return false;
	}
		document.getElementById("mimadiv").style.display="none";
}
function SetPwd2Msg(){
	var pwd1 = document.form1.passwd.value;
	var pwd2 = document.form1.passwd2.value;
	document.form1.passwd2.style.backgroundColor='';
	document.getElementById("mimadiv").style.display="inline";

	if(JHshStrLen(pwd2)<6 ||JHshStrLen(pwd2)>8){
		document.getElementById("mimadiv").innerHTML ="验证密码输入错误，请重新输入。";
	  return false;
	}else if (havenoChar1(pwd2)){
		document.getElementById("mimadiv").innerHTML ="验证密码输入格式有误，请勿使用特殊字符";
	  return false;
	}else if(pwd1!=pwd2){
		document.getElementById("mimadiv").innerHTML ="密码输入不一致，请重新输入。";
	  return false;
	}
		document.getElementById("mimadiv").style.display="none";
}

function initComponent() {

	if (form1.sexHidden.value == 0){
		form1.sex[0].checked=true;
		}else if (form1.sexHidden.value == 1){
		form1.sex[1].checked=true;
	}
	
	if (form1.MailTypeHidden.value == 45){
		form1.mailTypeRadio[0].checked=true;
		form1.prodId.value=45;
		}else if (form1.MailTypeHidden.value == 46){
		form1.mailTypeRadio[1].checked=true;
		form1.prodId.value=46;
	}

	for (i = 0; i < form1.yearInput.length; i++){
		if(form1.YearOfBirth.value==form1.yearInput.options[i].value)
		form1.yearInput.selectedIndex=i;
	}
	for (i = 0; i < form1.monthInput.length; i++){
		if(form1.MonthOfBirth.value==form1.monthInput.options[i].value)
		form1.monthInput.selectedIndex=i;
	}

	for (i = 0; i < form1.dayInput.length; i++){
		if(form1.DayOfBirth.value==form1.dayInput.options[i].value){
		form1.dayInput.selectedIndex=i;
		}
	}
}

function checkbirthday(year, month, day) {
  if (month == 2) {
    if ((year % 400) == 0 || ((year % 4) == 0 && (year % 100) != 0)) {
      if (day > 29) {
        return false;
      }
    } else if (day > 28) {
      return false;
    }
  }

  if (month == 4 || month == 6 || month == 9 || month == 11) {
    if (day > 30) {
      return false;
    }
  }
  return true;
}


function JHshStrLen(sString){
	var sStr,iCount,i,strTemp ; 
	iCount = 0 ;
	sStr = sString.split("");
	for (i = 0 ; i < sStr.length ; i ++){
		strTemp = escape(sStr[i]); 
		if (strTemp.indexOf("%u",0) == -1){ // 表示是汉字
			iCount = iCount + 1 ;
		}else{
		iCount = iCount + 2 ;
		}
	}
	return iCount ;
}

function CharMode(iN){ 
	if (iN>=48 && iN <=57) //数字 
	return 1; 
	if (iN>=65 && iN <=90) //大写字母 
	return 2; 
	if (iN>=97 && iN <=122) //小写 
	return 4; 
	else 
	return 8; //特殊字符 
} 
//发送调用其他页面请求
var http_request = false;
function send_request(url,type) {//初始化、指定处理函数、发送请求的函数
	http_request = false;
	//开始初始化XMLHttpRequest 对象
	if(window.XMLHttpRequest) {            //Mozilla 浏览器
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) { //设置MiME 类别
			http_request.overrideMimeType("text/xml");
		}
	}else if (window.ActiveXObject) {     // IE 浏览器
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}
	if (!http_request) { // 异常，创建对象实例失败
		window.alert("不能创建XMLHttpRequest 对象实例.");
		return false;
	}
	if(type==1){
		//检查邮箱名是否存在
		http_request.onreadystatechange = processRequest;
	}
	http_request.open("GET", url, true);// 确定发送请求的方式和URL 以及是否同步执行下段代码
	http_request.send(null);
}
//获得邮箱名检查结果
function processRequest() {					// 处理检测用户名返回信息的函数
	if (http_request.readyState == 4) { 	// 判断对象状态
		if (http_request.status == 200) {   // 信息已经成功返回，开始处理信息
			var msg=http_request.responseText;
			document.getElementById("yonghumingyicunzaidiv").style.display="inline";
			if(msg==0){
				document.getElementById("yonghumingyicunzaidiv").innerHTML ="<font color=\"#0000FF\">此用户可以使用，请继续完成注册。</font>";
			}else if(msg==-1){
				document.getElementById("yonghumingyicunzaidiv").innerHTML ="判断账号(email=" + msg + ")是否存在时出错！";
			}else{
				document.getElementById("yonghumingyicunzaidiv").innerHTML ="用户名"+msg+"已经存在，请重新输入。<br><div style='cursor:hand' onclick=\"showcommend()\">或者点击此处由系统根据您的需要推荐给您合适的邮箱名</div>";
			}

		} else { //页面不正常
			alert("请求有异常。");
		}
	}
}

function checkcnnic(){
	window.location.href="http://showme.263.net/domain/reg.jsp";
}

function SetPaycodeMsg(){
	var paycode = document.form1.paycode;
	
  if (paycode.value.length < 11
      || paycode.value.substring(0, 3) != "139"
      && paycode.value.substring(0, 3) != "138"
      && paycode.value.substring(0, 3) != "137"
      && paycode.value.substring(0, 3) != "136"
      && paycode.value.substring(0, 3) != "135"
      && paycode.value.substring(0, 3) != "159"
      && paycode.value.substring(0, 3) != "134"
      && paycode.value.substring(0, 3) != "133"
      && paycode.value.substring(0, 3) != "132"
      && paycode.value.substring(0, 3) != "131"
      && paycode.value.substring(0, 3) != "130"
      && paycode.value.substring(0, 3) != "153"
      && paycode.value.substring(0, 3) != "158"
      && paycode.value.substring(0, 3) != "159"
      || havenoNumber(paycode.value))
  {
		document.getElementById("paycodediv").style.display="inline";
		document.getElementById("paycodediv").innerHTML ="请填写正确的手机号码";
  } else {
  	document.getElementById("paycodediv").style.display="none";
  	document.getElementById("paycodediv").innerHTML ="";
  }
	document.form1.paycode.style.backgroundColor='';
}
