﻿function continuteRegister()
{
    if (confirm("注册成功!,但需要进一步填写信息,它将会使你更被多人访问,是否马上填写信息?"))
    {
       window.location = "Register.aspx?step=2";
    }
}


function selectAreaChange(top,subtop)
{
		var selectTop=document.getElementById(top);
		var selectSubTop=document.getElementById(subtop);
		for(n = selectSubTop.length - 1; n >=0; n--)		//清空下一级
		{
			selectSubTop.options[n] = null;
		}	
		topValue = selectTop.value;			//获取上一级值			
		selectSubTop.options[selectSubTop.length] = new Option("请选择","");		
		for (n=0; n<areaGroup.length; n++)
		{
			if(areaGroup[n][0] == topValue)
			{
				selectSubTop.options[selectSubTop.length] = new Option(areaGroup[n][3], areaGroup[n][2]);
			}
		}
	   selectSubTop.options[0].selected=true;
}


function selectAreaChange(top,subtop,noteText)
{
		var selectTop=document.getElementById(top);
		var selectSubTop=document.getElementById(subtop);
		for(n = selectSubTop.length - 1; n >=0; n--)		//清空下一级
		{
			selectSubTop.options[n] = null;
		}	
		topValue = selectTop.value;			//获取上一级值			
		selectSubTop.options[selectSubTop.length] = new Option(noteText,"");		
		for (n=0; n<areaGroup.length; n++)
		{
			if(areaGroup[n][0] == topValue)
			{
				selectSubTop.options[selectSubTop.length] = new Option(areaGroup[n][3], areaGroup[n][2]);
			}
		}
	   selectSubTop.options[0].selected=true;
}

function selectCollegeChange(top,subtop)
{
		var selectTop=document.getElementById(top);
		var selectSubTop=document.getElementById(subtop);
		for(n = selectSubTop.length - 1; n >=0; n--)		//清空下一级
		{
			selectSubTop.options[n] = null;
		}	
		topValue = selectTop.value;			//获取上一级值			
		selectSubTop.options[selectSubTop.length] = new Option("请选择","");		
		for (n=0; n<collegeGroup.length; n++)
		{
			if(collegeGroup[n][0] == topValue)
			{
				selectSubTop.options[selectSubTop.length] = new Option(collegeGroup[n][2], collegeGroup[n][1]);
			}
		}
	   selectSubTop.options[0].selected=true;
}


function selectCollegeChange(top,subtop,noteText)
{
		var selectTop=document.getElementById(top);
		var selectSubTop=document.getElementById(subtop);
		for(n = selectSubTop.length - 1; n >=0; n--)		//清空下一级
		{
			selectSubTop.options[n] = null;
		}	
		topValue = selectTop.value;			//获取上一级值			
		selectSubTop.options[selectSubTop.length] = new Option(noteText,"");		
		for (n=0; n<collegeGroup.length; n++)
		{
			if(collegeGroup[n][0] == topValue)
			{
				selectSubTop.options[selectSubTop.length] = new Option(collegeGroup[n][2], collegeGroup[n][1]);
			}
		}
	   selectSubTop.options[0].selected=true;
}


function fGetCode()
{   
    document.getElementById('getcode').src = "Validations.aspx";  
}

function sumit_register()
{
   
    var userName=document.getElementById("txtUserName");
    if(userName.value=="")
    {   
        userName.focus();    
        alert("用户名不能为空");
        
        return;
    }
    if(!hasNoSpace(userName.value))
    {
       userName.focus(); 
       alert("用户名输入的格式不正确");
       return;
    }
    
    var password=document.getElementById("txtPassword");
    if(password.value=="")
    {
          password.focus(); 
          alert("密码不能为空");
          return;
    } 
    var email=document.getElementById("txtEmail");
    if(!isEmail(email.value))
    {
        email.focus();
        alert("邮箱格式不正确");
        return;
    }
         
    var ddlFriendGoal = document.getElementById("ddlFriendGoal");
    var ddlFriendGoalSelectValue= ddlFriendGoal.options[ddlFriendGoal.selectedIndex].value;
    if(ddlFriendGoalSelectValue=="")
    {
      alert("请选择交友目的");
      return;
    }
         
    var ddlYear= document.getElementById("ddlYear");
    var ddlMonth= document.getElementById("ddlMonth");
    var ddlDay= document.getElementById("ddlDay");
    

    if(!IsDate(ddlYear.options[ddlYear.selectedIndex].value+"-"+ddlMonth.options[ddlMonth.selectedIndex].value+"-"+ddlDay.options[ddlDay.selectedIndex].value))
    {
        alert("请选择正确的日期");
        return;
    }
   
    if(!checkRadio("Gender"))
    {
         alert("请选择性别");
         return;
    }
    
  
    var tall=document.getElementById("txtTall");
    if(!hasNoSpace(tall.value)||!IsInteger(tall.value)||(parseInt(tall.value)>210||parseInt(tall.value)<150))
    { 
        tall.focus();
        alert("请正确输入身高");
        return;
    }  
    var weight=document.getElementById("txtWeight");
    if(!hasNoSpace(weight.value)||!IsInteger(weight.value)||(parseInt(weight.value)>150||parseInt(weight.value)<40))
    { 
        weight.focus();
        alert("请正确输入体重");
        return;
    }
   
    var ddlNCountry= document.getElementById("ddlNCountry");
    var ddlNProvince= document.getElementById("ddlNProvince");
    var ddlNCity= document.getElementById("ddlNCity");
    if(ddlNCountry.value=="")
    {
        alert("请选择出生地的国家");
        return;
    }
    if(ddlNProvince.value=="")
    {
        alert("请选择出生地的省份");
        return;
    }
      if(ddlNCity.value=="")
    {
        alert("请选择出生地的城市");
        return;
    }
    
    var ddlCountry= document.getElementById("ddlCountry");
    var ddlProvince= document.getElementById("ddlProvince");
    var ddlCollege= document.getElementById("ddlCollege");
    if(ddlCountry.value=="")
    {
        alert("请选择大学的国家");
        return;
    }
    if(ddlProvince.value=="")
    {
        alert("请选择大学的省份");
        return;
    }
    if(ddlCollege.value=="")
    {
        alert("请选择大学");
        return;
    }
    var ddlMajor= document.getElementById("ddlMajor");
    if(ddlMajor.value=="")
    {
        alert("请选择专业");
        return;
    }
    var ddlGrade= document.getElementById("ddlGrade");
    if(ddlGrade.value=="")
    {
        alert("请选择年级");
        return;
    } 
    var ddlEducation=document.getElementById("ddlEducation");
    if(ddlEducation.value=="")
    {
        alert("请选择学历");
        return;
    }   
       
    var descr=document.getElementById("txtDesciption");
    descr.value=descr.value.replace(/(^\s*)|(\s*$)/g, "");
    if(descr.value.length<20||descr.value.length>300)
    {
        alert("字数在20到300字之间");
        return;
    }
     
    var chkAgree=document.getElementById("chkAgree");
    if(!chkAgree.checked) 
    {
       alert("请已经阅读并同意《高校情缘会员条款》");
        return;
    }
     
   
    var myForm =  document.forms['form1'];
    if (!myForm) {
            myForm = document.form1;
    }
    myForm.action="../Register/Register.aspx?act=reg";
    myForm.submit();  
    
}


function checkLegalCollegeNum(name)
{
    var ddlCollege=document.getElementById(name);
    var count = 0;
    for(var i=0; i<ddlCollege.options.length; i++)
     if(ddlCollege.options[i].selected) count++;
    if(count>4)
       return false;
    return true;
} 
