 
 
 /*  用户登陆 */	

	function CheckForm()
	{
		if(document.UserLogin.username.value=="")
		{
			alert("请输入用户名");
			document.UserLogin.username.focus();
			return false;
		}
		if(document.UserLogin.password.value == "")
		{
			alert("请输入密码");
			document.UserLogin.password.focus();
			return false;
		}
	}
 /*  论坛发表主题 */		
	function Checkuserform()
	{
		if(document.userform.username.value=="")
		{
			alert("Please Enter Username");
			document.userform.username.focus();
			return false;
		}
		if(document.userform.password.value == "")
		{
			alert("Please Enter password");
			document.userform.password.focus();
			return false;
		}
	}


	  function Checksendpw()
{

	if (document.sendpw.name.value==""){
		alert("请输入你的用户ID！");
		document.sendpw.name.focus(); 
		return false
	}
	if (document.sendpw.quesion.value==""){
		alert("请填写你的密码问题");
		document.sendpw.quesion.focus(); 
		return false
	}	if(document.sendpw.answer.value==""){
		alert("请正确填写你的问题答应");
		document.sendpw.answer.focus(); 
		return false
	}
}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}




 /*  友情链接 */	

	function ChecklinkForm()
	{
		if(document.linkform.txtSiteName.value=="")
		{
			alert("请输入网站名称");
			document.linkform.txtSiteName.focus();
			return false;
		}
		if(document.linkform.txtSiteAddress.value == "")
		{
			alert("请输入要做链接的网址");
			document.linkform.txtSiteAddress.focus();
			return false;
		}
		if(document.linkform.txtDescription.value == "")
		{
			alert("请输入简短的网站描述");
			document.linkform.txtDescription.focus();
			return false;
		}
		if(document.linkform.txtContact.value == "")
		{
			alert("请输入联系人名称");
			document.linkform.txtContact.focus();
			return false;
		}
		if(document.linkform.txtEmail.value == "")
		{
			alert("请输入联系人EMAIL");
			document.linkform.txtEmail.focus();
			return false;
		}
		if(document.linkform.txtPhone.value == "")
		{
			alert("请输入联系人电话");
			document.linkform.txtPhone.focus();
			return false;
		}




	}

/*  用户注册脚本 */	

function CreateXMLHTTPObject()
{
	var xObject = null;

	try 
	{
		xObject = new ActiveXObject("Msxml2.xmlhttp.4.0");
	}
	catch (e)
	{
		try
		{
			xObject = new XMLHttpRequest(); 
			if (xObject.overrideMimeType) {//设置MiME类别
				xObject.overrideMimeType('text/xml');
			}
		}
		catch (e)
		{
			try 
			{
				xObject = new ActiveXObject("Msxml2.xmlhttp");
			} 
			catch (e) 
			{
				try 
				{
					xObject = new ActiveXObject("Microsoft.xmlhttp");
				} 
				catch (e) 
				{
					alert("Error: Unable to create XML HTTP object!");
				}
			}
		}
	}

	return xObject;
}

function check_form(){
	if (document.getElementById("UserName").value=="")
	{
		document.getElementById("UserName_box").className="errorbox";
		document.getElementById("UserName_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
		document.getElementById("UserName_true").style.visibility = "hidden";
	}
	if (document.getElementById("Password").value=="")
	{
		document.getElementById("Password_box").className="errorbox";
		document.getElementById("Password_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />密码由6-15个英文字母(区分大小写)或数字组成，建议采用易记、难猜的英文、数字组合。";
		document.getElementById("Password_true").style.visibility = "hidden";
	}
	if (document.getElementById("PwdConfirm").value=="")
	{
		document.getElementById("PwdConfirm_box").className="errorbox";
		document.getElementById("PwdConfirm_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />请再输入一遍您上面填写的密码。";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
	}
	if (document.getElementById("Email").value=="")
	{
		document.getElementById("Email_box").className="errorbox";
		document.getElementById("Email_box").innerHTML = "<font color='RED'>此项必须填写。</font><br />请再输入一遍您上面填写的密码。";
		document.getElementById("Email_true").style.visibility = "hidden";
	}

	if (document.getElementById("UserName").value=="")
	{
		document.getElementById("UserName").focus();
		return false;
	}
	else if (document.getElementById("Password").value=="")
	{
		document.getElementById("Password").focus();
		return false;
	}
	else if (document.getElementById("PwdConfirm").value=="")
	{
		document.getElementById("PwdConfirm").focus();
		return false;
	}else if (document.getElementById("Email").value=="")
	{
		document.getElementById("Email").focus();
		return false;
	}else{
	
		var finished = true;
	
if(document.UserReg.agreement.value!=checked){
			finished = false;
			alert("请同意注册协议");
			document.UserReg.agreement.focus(); 
			return false;
		}
		allElements = document.getElementsByTagName('*');

		for (var i=0; i<allElements.length; i++)
		{
			var obj = allElements[i];
			if (obj.className=="errorbox")
			{
				finished = finished && false;
			}
			else
			{
				finished = finished && true;
			}
		}

		if (finished)
		{
			return true;
		}
		else
		{
			return false;
		}
	}





}


function input_onfocus(input)
{



	if (document.getElementById(input.name+"_box"))
	{
		if (document.getElementById(input.name+"_box").innerHTML!="")
		{
			if ((document.getElementById(input.name+"_box").className!="errorbox") && 
				(input.name!='jobtitle') &&
				(input.name!='mobileno'))
			{
				document.getElementById(input.name+"_box").className="nowbox";
			}
		}
	}
	switch (input.name)
	{
		case "memberid":
			if (document.getElementById("UserName_box").className!="errorbox")
			{
				document.getElementById("UserName_box").innerHTML = "会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
			}
			break;

		case "Password":
			if (document.getElementById("Password_box").className!="errorbox")
			{
				document.getElementById("Password_box").innerHTML = "密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合。";
			}
			break;
		case "PwdConfirm":
			if (document.getElementById("PwdConfirm_box").className!="errorbox")
			{
				document.getElementById("PwdConfirm_box").innerHTML = "请再输入一遍您上面填写的密码。";
			}
			break;	
		case "Email":
			if (document.getElementById("Email_box").className!="errorbox")
			{/*非常重要！这是客户与您联系的首选方式，请务必填写真实，并确认是您最常用的电子邮件。*/
				document.getElementById("Email_box").innerHTML = "请确保使用了您常用的邮箱。";
			}
			break;	
			
			
	}

}



function input_onblur(input)
{
	if (document.getElementById(input.name+"_box"))
	{
		if (document.getElementById(input.name+"_box").innerHTML!="")
		{
			if (document.getElementById(input.name+"_box").className!="errorbox")
			{
				document.getElementById(input.name+"_box").className="px12";
			}	
		}		
	}
	switch (input.name)
	{
		case "UserName":
			change_memberid();
			break;	
		case "Password":
			change_password();
			break;
		case "PwdConfirm":
			change_repassword();
			break;
		case "Email":
			change_email();
			break;


	}
}


function change_memberid()
{
	var obj = document.getElementById("UserName");
	
	if ((obj.className!="errorbox") && (obj.value!=''))
	{
		action = 1;

		xmlhttp = CreateXMLHTTPObject();
		xmlhttp.onreadystatechange = getReady;
		xmlhttp.open("POST", "member_check.php?action=memberid", true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send("memberid="+obj.value);
		document.getElementById("UserName_box").className="nowbox";
		document.getElementById("UserName_box").innerHTML="正在与数据库服务器通讯中...";
	}
}


function change_password() {
	var obj = document.getElementById("Password");
	if (obj.value.length==0)
	{
		if (document.getElementById("Password_box").className!="errorbox")
		{
			document.getElementById("Password_box").className="px12";
			document.getElementById("Password_box").innerHTML = "密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合";
			document.getElementById("Password_true").style.visibility = "hidden";
		}
	}
	else if (obj.value.length<6 || obj.value.length>15)
	{
		document.getElementById("Password_box").className="errorbox";
		document.getElementById("Password_box").innerHTML = "<font color='RED'>您填写的有误。<br /></font>密码由6-15个英文字母或数字组成，建议采用易记、难猜的英文、数字组合。";
		document.getElementById("Password_true").style.visibility = "hidden";
	}
	else
	{
		document.getElementById("Password_box").innerHTML = "填写正确。";
		document.getElementById("Password_box").className="px12";
		document.getElementById("Password_true").style.visibility = "visible";
	}
	if (document.getElementById("PwdConfirm").value!="")
	{
		change_repassword();
	}
}


function change_repassword() {
	var repassword_obj = document.getElementById("PwdConfirm");
	var password_obj = document.getElementById("Password");
	if (repassword_obj.value.length==0)
	{
		document.getElementById("PwdConfirm_box").className="px12";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
		document.getElementById("PwdConfirm_box").innerHTML = "请再输入一遍您上面填写的密码。";
	}
	else if (repassword_obj.value==password_obj.value)
	{
		document.getElementById("PwdConfirm_box").className="px12";
		document.getElementById("PwdConfirm_box").innerHTML = "填写正确。";
		document.getElementById("PwdConfirm_true").style.visibility = "visible";
	}
	else
	{
		document.getElementById("PwdConfirm_box").className="errorbox";
		document.getElementById("PwdConfirm_box").innerHTML = "<font color='RED'>您再次填写的密码不一致。</font><br />请按照上方填写的密码再填一次。";
		document.getElementById("PwdConfirm_true").style.visibility = "hidden";
	}
}

function change_email()
{


	var obj = document.getElementById("Email");

	if(obj.value==""){

		document.getElementById("Email_box").className="errorbox";
		document.getElementById("Email_true").style.visibility = "hidden";
		document.getElementById("Email_box").innerHTML = "<font color='RED'>请填写邮箱地址。</font><br />请确保使用了您常用的邮箱。<br />";

	}else{
		var i = 1;
		var len = obj.value.length;
		if (len > 100){
			document.getElementById("Email_box").className="errorbox";
			document.getElementById("Email_true").style.visibility = "hidden";
			document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写邮箱地址长度超过100个字符。</font><br />请确保使用了您常用的邮箱。<br />";
		}else{

			pos1 = obj.value.indexOf("@");
			pos2 = obj.value.indexOf(".");
			pos3 = obj.value.lastIndexOf("@");
			pos4 = obj.value.lastIndexOf(".");
			//check '@' and '.' is not first or last character
			if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len)) {
				document.getElementById("Email_box").className="errorbox";
				document.getElementById("Email_true").style.visibility = "hidden";
				document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写的有误。</font><br />请确保使用了您常用的邮箱。<br />";
			}else{
				//check @. or .@
				if( (pos1 == pos2 - 2) || (pos1 == pos2 + 2) 
				|| ( pos1 != pos3 )  //find two @
				|| ( pos4 < pos3 ) ) //. should behind the '@'  		
				{
					document.getElementById("Email_box").className="errorbox";
					document.getElementById("Email_true").style.visibility = "hidden";
					document.getElementById("Email_box").innerHTML = "<font color='RED'>您填写的有误。</font><br />请确保使用了您常用的邮箱。<br />";
				}else{

					document.getElementById("Email_box").className="px12";
					document.getElementById("Email_box").innerHTML = "填写正确。";
					document.getElementById("Email_true").style.visibility = "visible";

				}
			}
		}
	}

}



function getReady()
{

	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			if (action==1)
			{
				switch (xmlhttp.responseText){
					case "OK":
						document.getElementById("UserName_box").innerHTML = "该会员名可以注册。";
						document.getElementById("UserName_box").className="px12";
						document.getElementById("UserName_true").style.visibility = "visible";
						break;
					case "ERR_1":
						document.getElementById("UserName_box").innerHTML = "<font color='RED'>该用户名已经被注册。</font><br />会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
						document.getElementById("UserName_box").className="errorbox";
						document.getElementById("UserName_true").style.visibility = "hidden";
						break;

					case "ERR_2":
						document.getElementById("UserName_box").innerHTML = "<font color='RED'>您填写的有误。<br /></font>会员登录名只能由6-15个英文字母或数字组成(不支持中文)";
						document.getElementById("UserName_box").className="errorbox";
						document.getElementById("UserName_true").style.visibility = "hidden";
						break;
					default:

				}

			}
			xmlhttp = null;
		}
	}
	
}


 /*  会员注册详细表单控制 */		

	function CheckUserReg()
	{
		if(document.UserReg.user_lc.value=="")
		{
			alert("请输入真实姓名");
			document.UserReg.user_lc.focus();
			return false;
		}
		if(document.UserReg.nian.value == "")
		{
			alert("请选择出生年月");
			document.UserReg.nian.focus();
			return false;
		}
		if(document.UserReg.yue.value == "")
		{
			alert("请选择出生年月");
			document.UserReg.yue.focus();
			return false;
		}
		if(document.UserReg.Province.value == "")
		{
			alert("请选择来自省份");
			document.UserReg.Province.focus();
			return false;
		}

		if(document.UserReg.xueli.value == "")
		{
			alert("请选择最高学历");
			document.UserReg.xueli.focus();
			return false;
		}
		if(document.UserReg.txtCollege.value == "")
		{
			alert("请输入毕业学校");
			document.UserReg.txtCollege.focus();
			return false;
		}


		if(document.UserReg.txtMajor.value == "")
		{
			alert("请输入所学专业");
			document.UserReg.txtMajor.focus();
			return false;
		}
		if(document.UserReg.phone.value == "")
		{
			alert("请输入联系电话");
			document.UserReg.phone.focus();
			return false;
		}
		if(document.UserReg.mobile.value == "")
		{
			alert("请输入手机号");
			document.UserReg.mobile.focus();
			return false;
		}

		if(document.UserReg.lstBigArea.value == "")
		{
			alert("请输入任职区域或者学校住所");
			document.UserReg.lstBigArea.focus();
			return false;
		}
		if(document.UserReg.lstBigArea2.value == "")
		{
			alert("请输入家庭住所");
			document.UserReg.lstBigArea2.focus();
			return false;
		}

		if(document.UserReg.chkList.value == ""||document.UserReg.chkList1.value == ""||document.UserReg.chkList3.value == ""||document.UserReg.chkList4.value == ""  )
		{
			alert("请选择辅导方式");
			document.UserReg.chkList.focus();
			return false;
		}



	}



 /*  用户修改密码 */	

	function checkinput()
	{
		if(document.userpass.password.value=="")
		{
			alert("请输入旧密码");
			document.userpass.password.focus();
			return false;
		}
		if(document.userpass.new_pass.value == "")
		{
			alert("请输入新密码");
			document.userpass.new_pass.focus();
			return false;
		}
		if(document.userpass.new_pass2.value == "")
		{
			alert("请输入确认密码");
			document.userpass.new_pass2.focus();
			return false;
		}
	}

	function checkorderform()
	{
		if(document.orderform.txtName.value=="")
		{
			alert("请输入您的姓名");
			document.orderform.txtName.focus();
			return false;
		}
		if(document.orderform.txtPhone.value == "")
		{
			alert("请输入联系电话");
			document.orderform.txtPhone.focus();
			return false;
		}
		if(document.orderform.txtMobile.value == "")
		{
			alert("请输入手机号码");
			document.orderform.txtMobile.focus();
			return false;
		}
	}
