function ValidateRegForm() {

	EmptyFields = "";
		checkString = document.reg.username.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "A username is required.\n";
	}	
	regex = /[^A-Za-z0-9_]/
	if (regex.test(checkString) == true)	{
		EmptyFields = EmptyFields + "The username may consist of letters and numbers only.\n";
	}

	if (eval(document.reg.password)) {
		checkString = document.reg.password.value;
		if (checkString == "" ) {		
			EmptyFields = EmptyFields + "A password is required.\n";
		}	
		regex = /[^A-Za-z0-9_]/
		if (regex.test(checkString) == true)	{
			EmptyFields = EmptyFields + "The password may consist of letters and numbers only.\n";
		}
	}
	checkString = document.reg.first_name.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "A first name is required.\n";
	}	
	regex = /[^A-Za-z\.\-_ ]/
	if (regex.test(checkString) == true)	{
		EmptyFields = EmptyFields + "First Name may consist of letters, - and spaces only.\n";
	}
	
	checkString = document.reg.last_name.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "A last name is required.\n";
	}	
	regex = /[^A-Za-z\.\-\'_ ]/
	if (regex.test(checkString) == true)	{
		EmptyFields = EmptyFields + "Last Name may consist of letters, \',- and spaces only.\n";
	}	
	checkString = document.reg.company.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "A company name is required.\n";
	}	
	checkString = document.reg.title.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "A title is required.\n";
	}	
	checkString = document.reg.email.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "An email address is required.\n";
	} else if ((checkString.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) == false) {
		EmptyFields = EmptyFields + "The email address doesn't appear to be valid.\n";
	}	
	checkString = document.reg.state.value;
	if (checkString == "SELECT" ) {		
		EmptyFields = EmptyFields + "Please select a province.\n";
	}
	checkString = document.reg.phone.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "Please enter your telephone number.\n";
	}
	regex = /[^0-9]/
	if (regex.test(checkString) == true)	{
		EmptyFields = EmptyFields + "Your telephone number must only consist of numbers.\n";
	}	
	if (!document.reg.accept.checked) {		
		EmptyFields = EmptyFields + "You must agree to the rules and regulations.\n";
	}	
	
    if (EmptyFields != "") {
		alert(EmptyFields);
		return false;
	} else {
		return true;
	}
}

function ValidateLoginForm()	{
	EmptyFields = "";
	
	userString = document.login.username.value;
	if (userString == "" ) {		
		EmptyFields = EmptyFields + "A username is required.\n";
	}	
	regex = /[^A-Za-z0-9_\- .]/ // Matches any non-word character, spaces ok
	if (regex.test(userString) == true)	{
		EmptyFields = EmptyFields + "The username may consist of letters, numbers and spaces only.\n";
	}
	userString = document.login.password.value;
	if (userString == "" ) {		
		EmptyFields = EmptyFields + "The password is required.\n";
	}	
	regex = /[^A-Za-z0-9_~!@#$%^&*+=|?]/

	if (regex.test(userString) == true)	{
		EmptyFields = EmptyFields + "The password may consist of letters, numbers and spaces only.\n";
	}
		
	if (EmptyFields != "") {
		alert(EmptyFields);
		return false;
	} else {
		return true;
	}
}

function ValidateForgotForm(){
	EmptyFields = "";
	
		checkString = document.forgot.email.value;
	if (checkString == "" ) {		
		EmptyFields = EmptyFields + "An email address is required.\n";
	} else if ((checkString.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) == false) {
		EmptyFields = EmptyFields + "The email address doesn't appear to be valid.\n";
	}

	if (EmptyFields != "") {
		alert(EmptyFields);
		return false;
	} else {
		return true;
	}
}
