// JavaScript Document
function ValidEmail(sEmail)	{
	var bValid;
	var iAt;
	bValid = true;

	iAt = sEmail.indexOf("@");

	if(iAt <= 0) {
		bValid = false;
	}
	else if(sEmail.indexOf(".", iAt + 2) == -1) {
		bValid = false;
	}
	else if(sEmail.length < 6) {
		bValid = false;
	}
	return bValid;
}
						
function ValidPhone(sPhone) {
	var bValid;

	bValid = true;

	if(sPhone.length < 10) {
		bValid = false;
	}
	else {
		for(i = 0; i < sPhone.length; i++) {
			if((sPhone.charAt(i) < "0" || sPhone.charAt(i) > "9") && (sPhone.charAt(i) != " " && sPhone.charAt(i) != "-")) {
				bValid = false;
				break;
			}
		}
	}

	return bValid;
}
function getURL (url) {
	document.location.href = url;
	}
	
function clearBox() {
	document.checkEligability.postcode.value = "";	
	document.checkEligability.postcode.focus();	
	}
function validatePostcodeCheck() {
	if (document.checkEligability.postcode.value == "" || document.checkEligability.postcode.value.length < 0) {
		alert("Please enter your postcode");
		document.checkEligability.postcode.focus();
		return false;
		}	
	}
function validateLogin() {
	if (document.lbForm.lbUsername.value == "") {
		alert("Please enter your username");
		document.lbForm.lbUsername.focus();
		return false;
		}
	if (document.lbForm.lbPassword.value == "") {
		alert("Please enter your password");
		document.lbForm.lbPassword.focus();
		return false;
		}
	}
function validateGetLogin() {
	if (document.forgotPass.forgotEmail.value == "") {
		alert("Please enter your email address");
		document.forgotPass.forgotEmail.focus();
		return false;
		}
	}
	
function validateRegister() {
	if (document.registerForm.reg_username.value == "") {
		alert("Please choose a username");
		document.registerForm.reg_username.focus();
		return false;
		}
	if (document.registerForm.reg_password.value == "") {
		alert("Please choose a password");
		document.registerForm.reg_password.focus();
		return false;
		}
	
	if (document.registerForm.reg_password.value != document.registerForm.reg_passwordConfirm.value) {
		alert("Your password and confirmation password do not match");
		document.registerForm.reg_passwordConfirm.value = "";
		document.registerForm.reg_passwordConfirm.focus();
		return false;		
		}		
	if (document.registerForm.reg_email.value == "" || ValidEmail(document.registerForm.reg_email.value) == false) {
		alert("Please provide your valid email address");
		document.registerForm.reg_email.focus();
		return false;				
		}
	if (document.registerForm.reg_emailConfirm.value != document.registerForm.reg_email.value) {
		alert("Your email address and confirmation email address do not match");				
		document.registerForm.reg_emailConfirm.focus();
		return false;			
	}
	if (ValidEmail(document.registerForm.reg_emailConfirm.value) == false) {
		alert("Your confirmation email address is not valid");				
		document.registerForm.reg_emailConfirm.focus();
		return false;		
	}
	if (document.registerForm.reg_fullname.value == "") {
		alert("Please provide your name");
		document.registerForm.reg_fullname.focus();
		return false;		
		}	
	if (document.registerForm.reg_jobTitle.value == "") {
		alert("Please provide your job title");
		document.registerForm.reg_jobTitle.focus();
		return false;		
		}	
	if (document.registerForm.reg_companyName.value == "") {
		alert("Please provide your company name");
		document.registerForm.reg_companyName.focus();
		return false;		
		}
	if (document.registerForm.reg_companyAddress.value == "") {
		alert("Please provide your company address");
		document.registerForm.reg_companyAddress.focus();
		return false;		
		}		
	if (document.registerForm.reg_companyPostcode.value == "") {
		alert("Please provide your company postcode");
		document.registerForm.reg_companyPostcode.focus();
		return false;		
		}	
	if (document.registerForm.reg_companyTel.value == "" || ValidPhone(document.registerForm.reg_companyTel.value) == false) {
		alert("Please provide your valid contact telephone number");
		document.registerForm.reg_companyTel.focus();
		return false;		
		}
	/*if (document.registerForm.verCode.value == "" || document.registerForm.verCode.value.length < 0) {
			alert("For security reasons, please verify the booking by entering the verification code shown in the box on the left");
			document.registerForm.verCode.value = "";
			document.registerForm.verCode.focus();
			return false;
		}
		checkcode(document.registerForm.verCode.value); 
		return false; */
}


function validateEventRegister() {		

	if (document.eventRegistration.reg_fullname.value == "") {
		alert("Please provide your name");
		document.eventRegistration.reg_fullname.focus();
		return false;		
		}	
	if (document.eventRegistration.reg_jobTitle.value == "") {
		alert("Please provide your job title");
		document.eventRegistration.reg_jobTitle.focus();
		return false;		
		}	
	if (document.eventRegistration.reg_companyName.value == "") {
		alert("Please provide your company name");
		document.eventRegistration.reg_companyName.focus();
		return false;		
		}
	if (document.eventRegistration.reg_companyAddress.value == "") {
		alert("Please provide your company address");
		document.eventRegistration.reg_companyAddress.focus();
		return false;		
		}		
	if (document.eventRegistration.reg_companyPostcode.value == "") {
		alert("Please provide your company postcode");
		document.eventRegistration.reg_companyPostcode.focus();
		return false;		
		}					
	if (document.eventRegistration.reg_email.value == "" || ValidEmail(document.eventRegistration.reg_email.value) == false) {
		alert("Please provide your valid email address");
		document.eventRegistration.reg_email.focus();
		return false;				
		}
	if (document.eventRegistration.reg_confEmail.value != document.eventRegistration.reg_email.value) {
		alert("Your email address and confirmation email address do not match");				
		document.eventRegistration.reg_confEmail.focus();
		return false;			
	}
	if (ValidEmail(document.eventRegistration.reg_confEmail.value) == false) {
		alert("Your confirmation email address is not valid");				
		document.eventRegistration.reg_confEmail.focus();
		return false;		
	}		
	if (document.eventRegistration.reg_companyTel.value == "" || ValidPhone(document.eventRegistration.reg_companyTel.value) == false) {
		alert("Please provide your valid contact telephone number");
		document.eventRegistration.reg_companyTel.focus();
		return false;		
	}	
}
	