/*************************************************
* 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									 *
			JI -> 30.05.05 @ 13:00pm
* Note:											 *
*************************************************/

function valRegister(which){
	if (which.js.value == "on"){
		// Make sure that the Colledge name is not empty
		if (which.CompanyName.value == ""){
			alert (registerARR[0]);
			which.CompanyName.focus();
			return false;
		}else
	
		// Make sure Address line one is not empty
		if (which.AddressLine1.value == ""){
			alert(registerARR[1]);
			which.AddressLine1.focus();
			return false;
		}else
	
		// Make sure Town is not empty
		if (which.Town.value == ""){
			alert(registerARR[2]);
			which.Town.focus();
			return false;
		}else
	
		// Make sure that the postcode is not empty
		if (which.PostCode.value == ""){
			alert(registerARR[3]);
			which.PostCode.focus();
			return false;
		}else
		
		// Make sure that the postcode is not empty
		if (which.Country.value == ""){
			alert(registerARR[17]);
			which.Country.focus();
			return false;
		}else
		
		// Make sure that the Company telephone is not empty
		if (!isNumber(which.CompanyTel) || which.CompanyTel.value == ""){
			alert(registerARR[4]);
			which.CompanyTel.focus();
			return false;
		}else
		
		// Make sure that the Mail email is not empty and is a valid email address
		if (!isEMailAddr(which.Email1)){
			alert(registerARR[5]);
			which.Email1.focus();
			which.Email1.select();
			return false;
		}else
		
		// Make sure that the Mail email is not empty and is a valid email address
		if (which.CompanyRep.value == ""){
			alert(registerARR[13]);
			which.CompanyRep.focus();
			return false;
		}else
		
		// Make sure that the psoition in the comapny is filled in 
		if (which.CompanyPosition.value == ""){
			alert(registerARR[16]);
			which.CompanyPosition.focus();
			return false;
		}else
		
		// Make sure that the Company Type is selected atleast one
		if (!is_multiple_checked('register', 'type[]')){
			alert(registerARR[14]);
			return false;
		}else

		// Make sure that one product is selected
		if (!is_multiple_checked('register', 'product[]')){
			alert(registerARR[15]);
			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[6]);
			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[7]);
			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[8]);
			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[9]);
			return false;
		}else
		
		// Make sure that a secret question is selected
		if (!isChosen(which.SecretQuestion)){
			alert(registerARR[10]);
			which.SecretQuestion.focus();
			return false;
		}else
	
		// Make sure that the secret answer is filled in
		if (which.SecretAnswer.value == ""){
			alert(registerARR[11]);
			which.SecretAnswer.focus();
			return false;
		}else
	
		// Make sure that the secret answer is filled in
		if (!document.getElementById('trm').checked){
			alert(registerARR[12]);
			return false;
		}
		else {
			document.register.sendit.disabled = true;
			return true;
		}
	}
	else {
		return true;
	}
}
