/*************************************************
* Validate the registration form using JS		 *
* Created: 18.12.04 -> 01:03am					 *
* Modified: GS -> 18.12.04 @ 02:56am
		    GS -> 18.12.04 @ 09:33am
			GS -> 23.12.04 @ 22:50pm									 *
* Note:											 *
*************************************************/

function valRegister(which){
	if (which.js.value == "on"){
		// Make sure that the Colledge name is not empty
		if (which.CollegeName.value == ""){
			alert (registerARR[0]);
			which.CollegeName.focus();
			return false;
		}else
	
		// Make sure that the first name is not empty
		if (which.ContactFirstName.value == ""){
			alert (registerARR[1]);
			which.ContactFirstName.focus();
			return false;
		}else
		
		// Make sure that the last name is not empty
		if (which.ContactLastName.value == ""){
			alert (registerARR[2]);
			which.ContactLastName.focus();
			return false;
		}else
		
		// Make sure that the position is not empty
		if (which.CompanyPosition.value == ""){
			alert (registerARR[3]);
			which.CompanyPosition.focus();
			return false;
		}else
	
		// Make sure that the main telephone is not empty
		if (!isNumber(which.MainTel) || which.MainTel.value == ""){
			alert(registerARR[4]);
			which.MainTel.focus();
			return false;
		}else
		
		// Make sure that the enrolment telephone is not empty
		if (!isNumber(which.EnrolmentTel) || which.EnrolmentTel.value == ""){
			alert(registerARR[5]);
			which.EnrolmentTel.focus();
			return false;
		}else
	
		// Make sure that the Main email is not empty and is a valid email address
		if (!isEMailAddr(which.MainEmail)){
			alert(registerARR[6]);
			which.MainEmail.focus();
			which.MainEmail.select();
			return false;
		}else
		
		// Make sure that the Main email is not empty and is a valid email address
		if (!isEMailAddr(which.EnrolmentEmail)){
			alert(registerARR[7]);
			which.EnrolmentEmail.focus();
			which.EnrolmentEmail.select();
			return false;
		}else
		
		// Make sure Address line one is not empty
		if (which.AddressLine1.value == ""){
			alert(registerARR[8]);
			which.AddressLine1.focus();
			return false;
		}else
	
		// Make sure Town is not empty
		if (which.Town.value == ""){
			alert(registerARR[9]);
			which.Town.focus();
			return false;
		}else
	
		// Make sure that the postcode is not empty
		if (which.PostCode.value == ""){
			alert(registerARR[10]);
			which.PostCode.focus();
			return false;
		}else
		
		// Make sure that the postcode is not empty
		if (which.Country.value == ""){
			alert(registerARR[21]);
			which.Country.focus();
			return false;
		}else
		
		
		// Make sure that the country is not empty
		if (which.Country.value == ""){
			alert(registerARR[11]);
			which.Country.focus();
			return false;
		}else
		
		
		// Make sure that the at least one of the qualifications are selected 
		if (!is_multiple_checked('register', 'quali[]')){
			alert(registerARR[12]);
			return false;
		}else

		// Make sure that one course schedules are selected 
		if (!is_multiple_checked('register', 'sched[]')){
			alert(registerARR[13]);
			return false;
		}else
		
		// Make sure that the username is filled in and that its more than 4 chars and less than 15 chars
		if (which.UserName.value == "" || which.UserName.value.length < UsernameMinLength ||  which.UserName.value.length > UsernameMaxLength){
			alert(registerARR[14]);
			which.UserName.focus();
			which.UserName.select();
			return false;
		}else
	
		// Make sure that the first passowrd field is not blank
		if (which.Passwd1.value == "" || which.Passwd1.value.length < PasswdMinLength ||  which.Passwd1.value.length > PasswdMaxLength){
			alert(registerARR[15]);
			which.Passwd1.focus();
			return false;
		}else
	
		// Make sure that the second passowrd field is not blank
		if (which.Passwd2.value == "" || which.Passwd2.value.length < PasswdMinLength ||  which.Passwd2.value.length > PasswdMaxLength){
			alert(registerARR[16]);
			which.Passwd2.focus();
			return false;
		}else
	
		// Make sure that the second passowrd field is not blank
		if (which.Passwd1.value != which.Passwd2.value){
			alert(registerARR[17]);
			return false;
		}else
		
		// Make sure that a secret question is selected
		if (!isChosen(which.SecretQuestion)){
			alert(registerARR[18]);
			which.SecretQuestion.focus();
			return false;
		}else
	
		// Make sure that the secret answer is filled in
		if (which.SecretAnswer.value == ""){
			alert(registerARR[19]);
			which.SecretAnswer.focus();
			return false;
		}else
	
		// Make sure that the secret answer is filled in
		if (!document.getElementById('trm').checked){
			alert(registerARR[20]);
			return false;
		}
		else {
			document.register.sendit.disabled = true;
			return true;
		}
	}
	else {
		return true;
	}
}
