// THIS CONTROLS THE BULK OF PASSWORD HANDLING FOR USER/PROFILE/LOGIN/RESET MANAGEMENT


///////////////////////////////////////////////////////////////////////////////////////////////
// PASSWORD COMPLEXITY CHECK FUNCTION
// AUTHOUR: WBQ
// UPDATED: 2006-07-07
// DESCRIPTION: USE THIS FUNCTION TO CONTROL MINIMUM DIGI/ALPHA/SPEC REQUIREMENTS. CURRENTLY, ANY 3 OF THE FOUR ABOVE WILL LET THE PASSWORD PASS - THIS MATCHES THE WINDOWS COMPLEX PASSWORD STYLES WE HAVE IN EFFECT - 2006-07-07 WBQ
function passwdCheck(pwd){
	x1 = /[a-z]/;  //a miniscule letter must be present
	x2 = /[A-Z]/;  //a majiscule letter must be present
	x3 = /\d/;  //a numeric digit must be present
	x4 = /[~!@#$%^&*()_+{}|]/;  //special chars that must be present
	OK = (x1.test(pwd) && x2.test(pwd) && x3.test(pwd)) || (x1.test(pwd) && x2.test(pwd) && x4.test(pwd)) || (x1.test(pwd) && x3.test(pwd) && x4.test(pwd)) || (x2.test(pwd) && x3.test(pwd) && x4.test(pwd))  ;
	if (!OK){return true;} return false;
	}
///////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////////////////
// CHECK PASSWORD FIELDS
// AUTHOUR: WBQ
// UPDATED: 2006-07-07
// DESCRIPTION: THIS FUNCTION CAN TAKE ANY FORM, BUT IS EXPECTING <PWD> AND <REPEATPWD> AS THE FIELDS TO CHECK AGAINST EACH OTHER AS MATCHING VALUES. IT ALSO CHECKS COMPLEXITY USING passwdCheck().
function checkPwdFields(form) {
	var form = document.getElementById(form);
	var PWD = document.getElementById('PWD');
	var REPEATPASSWORD = document.getElementById('REPEATPASSWORD');
	var invalid = pwdInvalid; // Invalid character is a space set in _scripts/_general.js
	var minLength = pwdMinLength; // Minimum length set in _scripts/_general.js

if (PWD.value.length < minLength) 	
	{
	//	CB('PWD');
	CC('PWD');
	PWD.select();
	PWD.focus();
	alert('The Password Must Be At Least ' + minLength + ' Characters Long.');
	return false;
	}	
	
if (PWD.value.indexOf(invalid) > -1) 	
	{
//	CB('PWD');
	CC('PWD');
	PWD.select();
	PWD.focus();
	alert('Spaces Are Not Allowed In A Password');
	return false;
	}	
	
if (REPEATPASSWORD.value.length == 0)
	{
	CB('PWD');
	CC('REPEATPASSWORD');
	REPEATPASSWORD.select();
	REPEATPASSWORD.focus();
	alert('Please Re-Enter the Password Exactly As Typed Before.');
	return false;
	}
	
if (REPEATPASSWORD.value != PWD.value)
	{
	CC('PWD');
	CC('REPEATPASSWORD');
	REPEATPASSWORD.select();
	REPEATPASSWORD.focus();
	alert('Your Password And Your Re-entered Password Do Not Match. \n Please Try Again.');
	return false;
	}
	
if (passwdCheck(PWD.value) == true)
	{
		CC('PWD');
		CC('REPEATPASSWORD');
//		test1 = chr(149);
//		test1 = String.fromCharCode(303,304,305,306,405,501,502,205,999);
		themsg = "The Password Needs To Contain Any Three Of The Four Following Character Sets: \n\t Upper Alpha (ABC,etc.)\n\t Lower Alpha (abc,etc.)\n\t Special (!#$,etc.)\n\t Numeric (123,etc.)" ;
		//+		test1 + 'and finally';
		alert(themsg);
		PWD.select();
		PWD.focus();
		return false;
	}
else {
	CB('PWD');
	CB('REPEATPASSWORD');
	return true;}
}
///////////////////////////////////////////////////////////////////////////////////////////////
