﻿function btn_click(){

var isValid=   CheckForm(document.forms[0]);
if(is_userName_ok==null && isValid)
{
    CheckExist(document.getElementById("userName"));
    }
    if(is_email_ok==null && isValid)
    {
    CheckExistEmail(document.getElementById("email"));
    }

   if(isValid && is_userName_ok && is_email_ok)
   {
//       //用户名与密码不能重复
//       if(document.getElementById("userName").value==document.getElementById("password").value)
//       {
//            alert("帐号名与密码不能相同！");
//            document.getElementById("password").focus();
//            return;
//       }
       document.forms[0].submit();  
       document.getElementById("ok").value = "提交中，请稍后...";
       document.getElementById("ok").disabled = true;	
   }
}

var is_userName_ok=null;
var is_email_ok=null;
function CheckExist(obj)
{
   var userName=obj.value;
   var remoteParm=new Array();
   remoteParm.push(userName);
   zhAjax.stateID="userName_prompt";
   zhAjax.isTimeout=false;
   zhAjax.ajaxStateText.wait="正在检测……";
   zhAjax.ajaxStateText.succeed="";
   zhAjax.simple("CheckExistsUserName",function (_return){
    if(_return!=null)
    {
        if(_return=="True")
        {
         is_userName_ok=true;
            zhAjax.SetText("帐号未被使用，可以注册！","right");
        }
        else
        {
             is_userName_ok=false;
            zhAjax.SetText("帐号已被使用，不能注册，请重新设置帐号！","wrong");
        }
    }
   },remoteParm);
}

//检测email
function CheckExistEmail(obj)
{
   var email=obj.value;
   var remoteParm=new Array();
   remoteParm.push(email);
   zhAjax.stateID="email_prompt";
   zhAjax.isTimeout=false;
   zhAjax.ajaxStateText.wait="正在检测……";
   zhAjax.ajaxStateText.succeed="";
   zhAjax.simple("CheckExistsEmail",function (_return){
    if(_return!=null)
    {
        if(_return=="True")
        {
        is_email_ok=true;
            zhAjax.SetText("恭喜您，可以注册！","right");
        }
        else
        {
        is_email_ok=false;
            zhAjax.SetText("email已被注册，请点击找回密码或重新申请email后再注册","wrong");
        }
    }
   },remoteParm);
}
