var http_request;
function ajax_send_request(url) {
	http_request=false;
	if(window.XMLHttpRequest) {
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/xml");
		}
	}
	else if(window.ActiveXObject) {
		try {
			http_request = new ActiveXObject("Msxml2.XMLHttp");
		} catch (e) {
			try {
				http_request = new ActiveXobject("Microsoft.XMLHttp");
			} catch (e) {
				return false;
			}
		}
	}
	if (!http_request) {
		return false;
	}
	http_request.onreadystatechange = ajax_processrequest;
	http_request.open("GET", url, true);
	http_request.send(null);
}

function ajax_processrequest() {
	if(http_request.readyState==4) {
		if(http_request.status==200) {
			if (http_request.responseText=="register_email_duplicate") {
				document.getElementById('msg_Email').innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 邮箱已被他人使用！</font>";
			} else if (http_request.responseText=="register_email_ok") {
				document.getElementById('msg_Email').innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
			} else if (http_request.responseText=="authn_error") {
				document.getElementById('msg_Authn').innerHTML = "<font color=red>&nbsp;&nbsp;×</font>";
			} else if (http_request.responseText=="authn_ok") {
				document.getElementById('msg_Authn').innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
			}else if (http_request.responseText=="register_payaccount_duplicate") {
				document.getElementById('msg_Payacc').innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 结算帐号使用次数过多！</font>";
			} else if (http_request.responseText=="register_payaccount_ok") {
				document.getElementById('msg_Payacc').innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
			}
		}
	}
}

function useremail_check(obj) {
	var username = document.pflform.email.value;
	if (!username) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 注册邮箱不能为空！</font>";
	} else if (!username.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/)) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 邮箱地址格式错误！</font>";
	} else {
		document.getElementById(obj).innerHTML = "&nbsp;&nbsp;<img src=\"images/wait.gif\" width=\"10\" height=\"10\" border=\"0\">";
		ajax_send_request("http://www.gtecn.com.cn/interface/ajax.php?ajax_type=register_email&eml="+username);
	}
}
function userpwd_check(obj) {
	var userpwd = document.pflform.password.value;
	if (!userpwd) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 用户密码不能为空！</font>";
	} else if (userpwd.length<6) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 密码不可少于六位！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function userpwd_check2(obj) {
	var userpwd = document.pflform.password.value;
	var userpwd2 = document.pflform.password2.value;
	if (userpwd2!=userpwd) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 重复密码不一致！</font>";
	} else if (userpwd2=="" && userpwd=="") {
		document.getElementById(obj).innerHTML = "";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function userqq_check(obj) {
	var userqq = document.pflform.qq.value;
	if (userqq=="") {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* QQ号码不可为空！</font>";
	} else if (isNaN(userqq) || userqq.indexOf("-")!=-1 || userqq.indexOf(".")!=-1) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* QQ号码必须数字！</font>";
	} else if (userqq.length<5) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* QQ号码大于四位！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function userphone_check(obj) {
	var userphone = document.pflform.phone.value;
	if (userphone=="") {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 电话号码不可为空！</font>";
	} else if (isNaN(userphone) || userphone.indexOf("-")!=-1 || userphone.indexOf(".")!=-1) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 电话号码必须数字！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function username_check(obj) {
	var username = document.pflform.name.value;
	if (username=="") {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 注册姓名不可为空！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function userpayacc_check(obj) {
	var userpaymtd = document.pflform.paymethod.value;
	var userpayacc = document.pflform.payaccount.value;
	if (userpayacc=="") {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 结算帐号不可为空！</font>";
	} else if (userpaymtd=="支付宝" && !userpayacc.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/)) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 支付宝帐号为邮箱！</font>";
	} else if (userpaymtd!="支付宝" && (isNaN(userpayacc) || userpayacc.indexOf("-")!=-1)) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 银行帐号必须数字！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function userpayname_check(obj) {
	var payname = document.pflform.payname.value;
	if (payname=="") {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 结算姓名不可为空！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function authn_check(obj) {
	var authnum = document.pflform.authn.value;
	if (authnum.length<4) {
		document.getElementById(obj).innerHTML = "<font color=#FF0000>&nbsp;&nbsp;×</font>";
	} else {
		document.getElementById(obj).innerHTML = "&nbsp;&nbsp;<img src=\"images/wait.gif\" width=\"10\" height=\"10\" border=\"0\">";
		ajax_send_request("http://www.gtecn.com.cn/interface/ajax.php?ajax_type=authnum&authn="+authnum);
	}
}

function email_checks(obj) {
	var msn = document.pflform.msn.value;
	if (!msn) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* MSN地址不能为空！</font>";
	} else if (!msn.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/)) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* MSN地址格式错误！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function province_checks(obj) {
	var province = document.pflform.province.value;
	return false;
	if (!province) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 省份不能为空！</font>";
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function city_checks(obj) {
	var city = document.pflform.city.value;
	if (!city) {
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 城市不能为空！</font>";
		alert("KK");
	} else {
		document.getElementById(obj).innerHTML = "<font color=#3333BB>&nbsp;&nbsp;√</font>";
	}
}
function payaccount_check(obj){
	var payaccount = document.pflform.payaccount.value;
	if(!payaccount){
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 结算帐号不能为空！</font>";
	}
	else if(!payaccount.match(/^[0-9]{19}$/)){
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 结算帐号格式错误！</font>";
	}
	else if(payaccount.substring(0,4) != 6222){
		document.getElementById(obj).innerHTML = "<font color=red>&nbsp;&nbsp;×<br>&nbsp;* 该帐号不存在！</font>";
	}
	else{
		document.getElementById(obj).innerHTML = "&nbsp;&nbsp;<img src=\"images/wait.gif\" width=\"10\" height=\"10\" border=\"0\">";
		ajax_send_request("http://www.gtecn.com.cn/interface/ajax.php?ajax_type=register_payaccount&payaccount="+payaccount);
	}
}
