//字母和数字和下划线组合
function notchinese(str){ 
var reg=/[^A-Za-z0-9_]/g 
    if (reg.test(str)){ 
    return (false); 
    }else{ 
return(true);    } 
} 

function fucCheckNUM(NUM) 
{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length== 0)
		return 0
	for (i=0;i<NUM.length;i++)
	{
		j=strTemp.indexOf(NUM.charAt(i));	
		if (j==-1)
		{
		//说明有字符不是数字
			return 0;
		}
	}
	//说明是数字
	return 1;
}

var uid=0;
var paymode1=2;

function isEmpty(obj){
	if(obj==null || obj.value.length<1){
		return false;
	}
	return true;
}
function logincheck(form) {
	if(!isEmpty(form.username)){
		alert("用户名不能为空");	
		form.username.focus();
		return false;
	}
	var str;
	str=form.username.value;
	if (str =="")
	 {
		window.alert ("合作ID不能为空！");
		form.username.focus();
		return false;
	 }
	 
	 if (fucCheckNUM(str)==0 )
	 {
		//window.alert ("合作ID只能含有数字字符！");
		//form.username.focus();
		//return false;
	 }
	 
	if(!isEmpty(form.password)){
		alert("密码不能为空");	
		form.password.focus();
		return false;
	}

}

function setpaymode(num) {
	var paymode1;
	paymode1=num;
	if(paymode1==2){
		document.myform.bankAccount.value="";
		document.all.cunzhe.innerHTML="存折帐号";	
	}else if(paymode1==3){
		document.myform.bankAccount.value="95588";
		document.all.cunzhe.innerHTML="工行卡号";
	}else if(paymode1==4){
		document.myform.bankAccount.value="";
		document.all.cunzhe.innerHTML="招行卡号";
	}
}

function regcheck(form) {
	
	if(!(form.archk.checked)){
	alert("请先接收服务条款才可以继续注册!!");
	form.archk.focus();
	return false;
	}

	if(!isEmpty(form.username)){
		alert("用户名不能为空");	
		form.username.focus();
		return false;
	}
	//if(notchinese(form.username)){
	//	alert("用户名只能是字母和数字和下划线组合");	
	//	form.username.focus();
	//	return false;
	//}
	
	if(!isEmpty(form.userPassword)){
		alert("密码不能为空");	
		form.userPassword.focus();
		return false;
	}
	if(!isEmpty(form.userPassword2)){
		alert("密码确认不能为空");	
		form.userPassword2.focus();
		return false;
	}
  if(form.userPassword.value != form.userPassword2.value){
		alert("密码不一致");	
		form.userPassword2.focus();
		return false;
	}
	if(!isEmpty(form.nickname)){
		alert("用户真实姓名不能为空");	
		form.nickname.focus();
		return false;
	}
	if(!isEmpty(form.idCardNum)){
		alert("身份证号不能为空");	
		form.idCardNum.focus();
		return false;
	}
	if(!isEmpty(form.telephone)){
		alert("电话号码不能为空");	
		form.telephone.focus();
		return false;
	}
	if(!isEmpty(form.mobile)){
		alert("手机号码不能为空");	
		form.mobile.focus();
		return false;
	}
	if(!isEmpty(form.postcode)){
		alert("邮编不能为空");	
		form.postcode.focus();
		return false;
	}
	if(!isEmpty(form.address)){
		alert("地址不能为空");	
		form.address.focus();
		return false;
	}
	if(!isEmpty(form.email)){
		alert("email不能为空");	
		form.email.focus();
		return false;
	}
	if(!isEmpty(form.webAddress)){
		alert("网址不能为空");	
		form.webAddress.focus();
		return false;
	}
	
	if(!isEmpty(form.webtype)){
		alert("请选择网站类型！");	
		form.webtype.focus();
		return false;
	}	
	if(!isEmpty(form.webName)){
		alert("网站名称不能为空");	
		form.webName.focus();
		return false;
	}	
		str=form.classid.value;	
		if (str=="请选择"){
			alert("没有选择开户银行所在地区!请重新选择");
			form.classid.focus();
			return false;
		}
	if(!isEmpty(form.bankUsername)){
		alert("开户名不能为空！");	
		form.bankUsername.focus();
		return false;
	}
	if(!isEmpty(form.bankDesc)){
		alert("开户行全称不能为空！");	
		form.bankDesc.focus();
		return false;
	}
    var strpay;
	if(form.paymode[0].checked==true){
	strpay=2;
	}
	if(form.paymode[1].checked==true){
	strpay=3;
	}
	if(form.paymode[2].checked==true){
	strpay=4;
	}

	//alert("paymode="+strpay+"!" ); 
	if(strpay==2){
		str1=form.Nclassid.value;
		str2=form.bankAccount.value;
			if (!(str1.substring(0,4)==str2.substring(0,4))){
				alert("所选择的开户地区和帐号不符!\n此地区帐号必须以"+str1.substring(0,4)+"开头,请再次检查存折!!");
				form.bankAccount.focus();
				return false;
			}
	}
	if(strpay==3){
		str3=form.bankAccount.value;
			if (str3.length!=19 && str3.length!=16){
				alert("您填写的工商银行卡号位数不正确!");
				form.bankAccount.focus();
				return false;
			}
	}	
	if(strpay==4){
		/*
		str3=form.bankAccount.value;
			if (str3.length>=16){
				alert("您填写的招商银行卡号位数不正确!");
				form.bankAccount.focus();
				return false;
			}
		*/
	}	
	if(!isEmpty(form.bankAccount)){
		alert("帐号不能为空");	
		form.bankAccount.focus();
		return false;
	}
		
return true;

}

//用户注册检测
var xmlHttp;

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

//返回信息提示框
function showActionMessage(){
var msg ;
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            msg= xmlHttp.responseText;
            alert(msg);
        }
    }
}

function sendcheckuser(myc){
   var ccontent ;
   ccontent=myc.value;
   if (ccontent!=""){
      var url;
      url="checkuser.php?ccontent=" + ccontent ;
      createXMLHttpRequest();
      xmlHttp.onreadystatechange = showActionMessage;
      xmlHttp.open("get",url);
      xmlHttp.send(null);
   }
   else
   	{
   		alert('用户名不能为空！');
   	}
}