function check_reg_account(iForm)
{
  var val = iForm.email.value;
  var re = new RegExp(".+?\@.+?\..+", "i");
  var ok = re.test(val);
  if(!ok) return(alert('提供的帐号不合法!'));
  iForm.submit();
}

function check_user_login(iForm)
{
  var val = iForm.email.value;
  var re = new RegExp(".+?\@.+?\..+", "i");
  var ok = re.test(val);
  if(!ok) return(alert('输入的email不合法!'));
  
  var pswd = iForm.pswd.value;
  pswd = pswd.replace(/^\s*/gi, '');
  pswd = pswd.replace(/\s*$/gi, '');
  if(0 == pswd.length) return(alert('请输入密码!'));
  iForm.submit();
}


function check_user_chg_pswd(iForm)
{
  var pswdold  = iForm.pswdold.value;
  var pswdnew1 = iForm.pswdnew1.value;
  var pswdnew2 = iForm.pswdnew2.value;
  pswdold  = pswdold.replace(/(?:^\s*|\s*$)/gi, '');
  pswdnew1 = pswdnew1.replace(/(?:^\s*|\s*$)/gi, '');
  pswdnew2 = pswdnew2.replace(/(?:^\s*|\s*$)/gi, '');
  if(0 == pswdold.length) return(alert('请输入原始密码!'));
  if(0 == pswdnew1.length) return(alert('请输入新密码!'));
  if(pswdnew1 != pswdnew2) return(alert('两次输入的密码不一致!'));
  iForm.submit();
}



function check_view_reqnum(iForm)
{
  var date1 = iForm.date1.value;
  var date2 = iForm.date2.value;
  if(0==date1.length || 0==date2.length) return(alert('请输入日期'));
  iForm.submit();
}

function check_user_add_ip(iForm)
{
  var ip = iForm.ip.value;
  ip = ip.replace(/(?:^\s*|\s*$)/gi, '');
  ip = ip.replace(/^0*/gi, '');
  var patt = new RegExp("^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+");
  var ok = patt.test(ip);
  if(!ok) return(alert("IP不合法!"));
  iForm.submit(); 
}


//开发者注册时用ajax检查mail是否被用过
function check_reg_email(iForm)
{
  return;
  var email = iForm.email.value;
  var r=Math.random();
  //alert(email+","+r);
  AjaxSend("ajax/jx_check_email.php?r="+r, "", "email="+email, check_reg_email_rs);
}

function check_reg_email_rs(rText)
{
  //alert(rText);
  var r = parseInt(rText);
  if(1==r) {
    document.getElementById('tipmail').innerHTML = "<font color='red'>mail已被注册!</font>";
    document.getElementById('submitreg').disabled = true;
  }else {
    document.getElementById('tipmail').innerHTML = "<font color='blue'>mail可用!</font>";
    document.getElementById('submitreg').disabled = false;
  }
}
//开发者注册时用ajax检查ip是否被用过
function check_reg_serverip(iForm)
{
  return;
  var serverip = iForm.serverip.value;
  var r=Math.random();
  AjaxSend("ajax/jx_check_serverip.php?r="+r, "", "serverip="+serverip, check_reg_serverip_rs);
}
function check_reg_serverip_rs(rText)
{
  var r = parseInt(rText);
  if(1==r) {
    document.getElementById('tipip').innerHTML = "<font color='red'>IP已被使用!</font>";
    document.getElementById('submitreg').disabled = true;
  }else {
    document.getElementById('tipip').innerHTML = "<font color='blue'>IP可用!</font>";
    document.getElementById('submitreg').disabled = false;
  }
}


//apireg.php注册页面
function checkInput(iform)
{
  
  var applicant = trim(iform.applicant.value);
  if(0 == applicant.length) return(alert('请填写申请人姓名.'));
  var email = trim(iform.email.value);
  if(0 == email.length) return(alert('请填写有效的 Email.'));
  var serverip = trim(iform.serverip.value);
  if(!iform.ctype.checked && 0 == serverip.length) return(alert('请填写有效的服务器IP地址，或者选择“直连模式”.'));
  var phone = trim(iform.phone.value);
  if(iform.ctype.checked && 0 == phone.length) return(alert('直连模式需要填写电话'));
  var appname = trim(iform.appname.value);
  if(0 == appname.length) return(alert('请填写应用程序的名称'));
  if(!iform.law.checked) {
    return(alert('您未接受驴博士使用协议.'));
  }
  iform.submit();
  //return true;
}
function trim(str)//删除左右两端的空格
{ 
  return str.replace(/(^\s*)|(\s*$)/g, "");
}

//变换注册类型
function changeCType(iform, chk)
{
  if(chk) {
    document.getElementById('serverip').disabled = true;
    document.getElementById('serverip').style.backgroundColor = '#CCC';
  }else {
    document.getElementById('serverip').disabled = false;
    document.getElementById('serverip').style.backgroundColor = '';
  }
}
//end apireg.php注册页面


//user_login.php 用户登录页面
function findPswd()
{
  var iform = document.forms['lform'];
  if(0 == iform.email.value.length) return(alert('请输入你的email地址!'));
  iform.action.value = 3;
  iform.submit();
} 

//end user_login.php 用户登录页面

