<!--
function trimSpace(x)
{
	var emptySpace = / /g;
	var trimAfter = x.replace(emptySpace,"");
	return(trimAfter);
}
function emailValidate(incomingString, defaultValue)
{
	if(trimSpace(incomingString).length == 0 || incomingString.search(/^\w+([\.-]?\w+)*@?\w*([\.-]?\w+)*(\.\w{1,})+$/g) == -1 || incomingString==defaultValue)
	{
		return false;
	}
	else
		return true;
}
function searchspecialcha(field) 
{
	var valid = "~'>%+;[]<{}"
	var ok = "no";
	var temp;
		for (var i=0; i<field.length; i++) 
			{
				temp = "" + field.substring(i, i+1);
				if (valid.indexOf(temp) >= 0) ok = "yes"; 
			}
		if (ok == "no") 
			{ return true; } 
		else
			{ return false; }
}

var n4 = (document.layers)?true:false;
var e4 = (document.all)?true:false;

function verify()	// Login
{
	validity = true;
		var missing_fields = new Array()
		  var total_missing = 0
		  // Loop through all the form elements
		  for (counter = 0; counter < document.theformlogin.length; counter++) 
		  {
		  
			// Is this a visible text field that's mandatory to check Tilde character?
			if (document.theformlogin[counter].type == "text" || document.theformlogin[counter].type == "password")
			{
			  // Is special character there?
			  if (searchspecialcha(document.theformlogin[counter].value)==false) 
			  {
				// If so, add the field to the array of find fields
				missing_fields[total_missing] = document.theformlogin[counter]
				total_missing++
			  }
			}
		  }

		  // Were there any fields get character?
		  if (total_missing > 0) {
			alert('抱歉，以下特殊字符不可用 \n\n ~  \' > % + ; [ ] < { }');
			
			// For emphasis, put the focus on the first field
			missing_fields[0].focus()
			validity = false;
		  }

	if (document.theformlogin.userid.value == "" )
	{
		alert("请输入用户名。");
		document.theformlogin.userid.focus();
		validity = false;
	}

	if (((document.theformlogin.userid.value.length < 3) || (document.theformlogin.userid.value.length > 40)) && validity == true )
	{
		alert("请输入最少由3个字元的登入名称。");
		document.theformlogin.userid.focus();
		validity = false;
	}


	if (((document.theformlogin.passwd.value.length < 1) || (document.theformlogin.passwd.value.length > 30)) && validity == true)
	{
		alert ("请输入密码。");
		document.theformlogin.passwd.focus();
		validity = false;
	}

	if (validity==true)
	{
		document.theformlogin.action="./login_end.asp";
		document.theformlogin.submit();
	}
}

function idfind()	//  forgot id
{
		var missing_fields = new Array()
		  var total_missing = 0
		  // Loop through all the form elements
		  for (counter = 0; counter < document.idfindform.length; counter++) 
		  {
		  
			// Is this a visible text field that's mandatory to check Tilde character?
			if (document.idfindform[counter].type == "text" || document.idfindform[counter].type == "password")
			{
			  // Is special character there?
			  if (searchspecialcha(document.idfindform[counter].value)==false) 
			  {
				// If so, add the field to the array of find fields
				missing_fields[total_missing] = document.idfindform[counter]
				total_missing++
			  }
			}
		  }

		  // Were there any fields get character?
		  if (total_missing > 0) {
			alert('抱歉，以下特殊字符不可用 \n\n ~  \' > % + ; [ ] < { }');
			
			// For emphasis, put the focus on the first field
			missing_fields[0].focus()
			return;
		  }
	with (document.idfindform)
	{
		if (lastname.value == "")
			{ alert("请输入您的姓氏。"); lastname.focus(); return false; }

		if (firstname.value == "")
			{ alert("请输入您的名字。"); firstname.focus(); return false; }

		if (email1.value == "")
			{ alert ("请输入您的电邮。"); email1.focus(); return false; }
		
		// Check valid email added by vinod on 21 june as per raj meeting to validate email.
		if(!emailValidate(email1.value, ''))
			{ alert("请输入有效的电子邮箱地址"); email1.focus(); return false;}

		type.value = "1";
	}
}

function passwdfind()	//  forgot password
{
		var missing_fields = new Array()
		  var total_missing = 0
		  // Loop through all the form elements
		  for (counter = 0; counter < document.pwdfindform.length; counter++) 
		  {
		  
			// Is this a visible text field that's mandatory to check Tilde character?
			if (document.pwdfindform[counter].type == "text" || document.pwdfindform[counter].type == "password")
			{
			  // Is special character there?
			  if (searchspecialcha(document.pwdfindform[counter].value)==false) 
			  {
				// If so, add the field to the array of find fields
				missing_fields[total_missing] = document.pwdfindform[counter]
				total_missing++
			  }
			}
		  }

		  // Were there any fields get character?
		  if (total_missing > 0) {
			alert('抱歉，以下特殊字符不可用 \n\n ~  \' > % + ; [ ] < { }');
			
			// For emphasis, put the focus on the first field
			missing_fields[0].focus()
			return;
		  }
	with (document.pwdfindform)
	{
		if (userid.value == "")
			{ alert("请输入用户名。"); userid.focus(); return false; }

		if (email2.value == "")
			{ alert ("请输入您的电邮。"); email2.focus(); return false; }
		// Check valid email added by vinod on 21 june as per raj meeting to validate email.
		if(!emailValidate(email2.value, ''))
			{ alert("请输入有效的电子邮箱地址"); email2.focus(); return false;}
		type.value = "2";
	}
}

function passwdchange()	// change password
{
		validity = true;
		var missing_fields = new Array()
		  var total_missing = 0
		  // Loop through all the form elements
		  for (counter = 0; counter < document.theform.length; counter++) 
		  {
		  
			// Is this a visible text field that's mandatory to check Tilde character?
			if (document.theform[counter].type == "text" || document.theform[counter].type == "password")
			{
			  // Is special character there?
			  if (searchspecialcha(document.theform[counter].value)==false) 
			  {
				// If so, add the field to the array of find fields
				missing_fields[total_missing] = document.theform[counter]
				total_missing++
			  }
			}
		  }

		  // Were there any fields get character?
		  if (total_missing > 0) {
			alert('抱歉，以下特殊字符不可用 \n\n ~  \' > % + ; [ ] < { }');
			
			// For emphasis, put the focus on the first field
			missing_fields[0].focus()
			validity = false;
			return;
		  }
	if (document.theform.passwd.value == "" )
	{
		alert("请输入现用密码。");
		document.theform.passwd.focus();
		validity = false;
		return;
	}
	if (document.theform.newpasswd.value.length < 6 || document.theform.newpasswd.value.length > 32)
	{
		alert ("新密码必须要有6至32个字元。");
		document.theform.newpasswd.focus();
		validity = false;
		return;
	}

	if (document.theform.newpasswd.value == "")
	{
		alert ("请输入新密码。");
		document.theform.newpasswd.focus();
		validity = false;
		return;
	}
	else
		{
			var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_";
			var ok = "yes";
			var temp;
			for (var cntuserid=0; cntuserid<document.theform.newpasswd.value.length; cntuserid++)
			{
			temp = "" + document.theform.newpasswd.value.substring(cntuserid, cntuserid+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
			}
			if (ok == "no") {
			alert("新密码包含非法字符");
			document.theform.newpasswd.focus();
			document.theform.newpasswd.select();
			return;
			}
		}


	if (document.theform.newpasswd.value != document.theform.newpasswdcheck.value)
	{
		alert ("新密码和确认密码必须相符。");
		document.theform.newpasswdcheck.focus();
		validity = false;
		return;
	}

	if (validity==true)
	{
		document.theform.action="./updatepassword_end.asp";
		document.theform.submit();
	}
}

function keyCheck(e) {
	if (n4) var keyValue = e.which;
	else if (e4) var keyValue = event.keyCode;

	if (keyValue == 13) {
		verify();
		return false;
	} else return true;
}

function gotoPass() {
	if (n4) var keyValue = e.which;
	else if (e4) var keyValue = event.keyCode;

	if (keyValue == 13) {
		document.theform.passwd.focus();
		return false;
	} else return true;
}

function moveFocus() {
	document.theform.userid.focus();
	return;
}

//-->