// JavaScript Document
<!--
// 展开隐藏选填信息
function expandInfo() {
	var d = document.getElementById('extraInfo');
	if(d.style.display == 'none') {
		d.style.display = '';
	} else {
		d.style.display = 'none';
	}
}
// 获取下级地区分类列表
function getSonArea(fid) {
	xmlhttp = initxmlhttp();
	var url = '../com.php?act=getsonarea&fid=' + fid;
	xmlhttp.open('POST', url, true);
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			document.getElementById('city').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}
//选择城市下的曲
function getArea(fid) {
    xmlhttp = initxmlhttp();
    var url = '../com.php?act=getarea&fid=' + fid;
    xmlhttp.open('POST', url, true);
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById('area').innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.send(null);
}
// 判断用户名是否被注册
function checkUsername() {
	var username = document.getElementById('username');
	xmlhttp = initxmlhttp();
	var url = '/plugins/user.php?act=user_exists&username=' + username.value;
	xmlhttp.open('GET', url, true);
	xmlhttp.onreadystatechange = function () {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var usernameDiv = document.getElementById('usernameDiv');
			// 去掉换行，回车，制表符，空格
			var rs = '' + xmlhttp.responseText.replace('\n','').replace('\r','').replace('\t','').replace(' ','') + '';
			switch (rs) {
				case '0':
					usernameDiv.innerHTML = '<font color=\"red\">请输入用户名</font>';
					username.focus();
					document.getElementById('usernameFlag').value = false;
					break;
				case '1':
					usernameDiv.innerHTML = '<font color=\"red\">用户名已被注册</font>';
					username.focus();
					document.getElementById('usernameFlag').value = false;
					break;
				case '2':
					usernameDiv.innerHTML = '<font color=\"green\">用户名可以使用</font>';
					document.getElementById('usernameFlag').value = true;
					break;
				default:
					break;
			}
		}
	}
	xmlhttp.send(null);
	return document.getElementById('usernameFlag').value;
}
// 判断密码长度
function checkPasswd() {
	var passwd = document.getElementById('passwd');
	var pl = passwd.value.length;
	var pwdDiv = document.getElementById('pwdDiv');
	if (pl == 0) {
		pwdDiv.innerHTML = '<font color="red">请输入密码</font>';
		return false;
	} else if (pl < 6) {
		pwdDiv.innerHTML = '<font color="red">密码长度不能低于6位</font>';
		return false;
	} else {
		pwdDiv.innerHTML = '';
		return true;
	}
}
// 验证确认密码
function checkRepasswd() {
	var repasswd = document.getElementById('repasswd');
	var passwd = document.getElementById('passwd');
	var repwdDiv = document.getElementById('repwdDiv');
	if (repasswd.value != passwd.value) {
		repwdDiv.innerHTML = '<font color="red">密码与确认密码不同</font>';
		return false;
	} else {
		repwdDiv.innerHTML = '';
		return true;
	}
}
// 验证email
function checkEmail() {
	var email = document.getElementById('email');
	var emailDiv = document.getElementById('emailDiv');
	if (!email.value) {
		emailDiv.innerHTML = '<font color="red">请输入您的e-mail</font>';
		return false;
	} else {
		var myreg = /^[a-zA-Z0-9\-_]+@[a-zA-z0-9\-]+\.[a-zA-z0-9\-]+(\.[a-zA-z0-9\-]+)?$/
		if (!myreg.test(email.value)) {
			emailDiv.innerHTML = '<font color="red">请输入正确的e-mail</font>'//;
			return false;
		} else {
			emailDiv.innerHTML = '';
			return true;
		}
	}
}
// 验证联系人姓名
function checkRealname() {
	realname = document.getElementById('realname');
	var realnameDiv = document.getElementById('realnameDiv');
	if (!realname.value) {
		realnameDiv.innerHTML = '<font color="red">请输入联系人姓名</font>';
		return false;
	} else {
		realnameDiv.innerHTML = '';
		return true;
	}
}
// 验证职位
function checkTitle() {
	var title = document.getElementById('title');
	var titleDiv = document.getElementById('titleDiv');
	if (!title.value) {
		titleDiv.innerHTML = '<font color="red">请输入您的职位</font>';
		return false;
	} else {
		titleDiv.innerHTML = '';
		return true;
	}
}
// 验证公司名
function checkCom_name() {
	var com_name = document.getElementById('com_name');
	var com_nameDiv = document.getElementById('com_nameDiv');
	if (!com_name.value) {
		com_nameDiv.innerHTML = '<font color="red">请输入公司名称</font>';
		return false;
	} else {
		com_nameDiv.innerHTML = '';
		return true;
	}
}
// 验证公司电话
function checkCom_phone() {
	var com_phone = document.getElementById('com_phone');
	var com_phoneDiv = document.getElementById('com_phoneDiv');
	if (!com_phone.value) {
		com_phoneDiv.innerHTML = '<font color="red">请输入公司电话</font>';
		return false;
	} else {
		com_phoneDiv.innerHTML = '';
		return true;
	}
}
// 验证公司地址
function checkCom_address() {
	var com_address = document.getElementById('com_address');
	var com_addressDiv = document.getElementById('com_addressDiv');
	if (!com_address.value) {
		com_addressDiv.innerHTML = '<font color="red">请输入公司地址</font>';
		return false;
	} else {
		com_addressDiv.innerHTML = '';
		return true;
	}
}
// 验证公司邮编
function checkPostzip() {
	var postzip = document.getElementById('postzip');
	var postzipDiv = document.getElementById('postzipDiv');
	if (!postzip.value) {
		postzipDiv.innerHTML = '<font color="red">请输入公司邮编</font>';
		return false;
	} else {
		postzipDiv.innerHTML = '';
		return true;
	}
}
// 验证行业分类
function checkIndust() {
	var indust = document.getElementById('indust_id');
	var industDiv = document.getElementById('industDiv');
	if (!indust.value) {
		industDiv.innerHTML = '<font color="red">请输选择行业分类</font>';
		return false;
	} else {
		industDiv.innerHTML = '';
		return true;
	}
}
// 验证码
function checkSafecode() {
	var safecode = document.getElementById('passcode');
	var safecodeDiv = document.getElementById('safecodeDiv');
	if (!safecode.value) {
		safecodeDiv.innerHTML = '<font color="red">请输入验证码</font>';
		return false;
	} else {
		return true;
	}
}

// 验证表单
function checkForm() {
	var usernameS = checkUsername();
	var passwdS = checkPasswd();
	var repasswdS = checkRepasswd();
	var emailS = checkEmail();
	var realnameS = checkRealname();
	var titleS = checkTitle();
/*	var com_nameS = checkCom_name();
	var com_phoneS = checkCom_phone();
	var com_addressS = checkCom_address();
	var postzipS = checkPostzip();
*/	var safecodeS = checkSafecode();
	if (!(
/*		usernameS && passwdS && repasswdS && emailS && realnameS && titleS && com_nameS && com_phoneS && com_addressS
		&& postzipS && safecodeS
*/
		usernameS && passwdS && repasswdS && emailS && realnameS && titleS && safecodeS
	)) {
		return false;
	} else
		return true;
}
// 验证企业注册表单
function checkComRegForm() {
	var com_nameS = checkCom_name();
	var com_phoneS = checkCom_phone();
	var com_addressS = checkCom_address();
	var postzipS = checkPostzip();
	var industS = checkIndust();
	if (!(com_nameS && com_phoneS && com_addressS && postzipS && industS)) {
		document.location = '#top';
		return false;
	} else {
		return true;
	}
}

//-->
