function Validate(){
	if (document.RegistrationForm.FirstName.value.length<1){
		alert("Please enter your firstname.");
		document.RegistrationForm.FirstName.focus();
		return false;
	}
	if (document.RegistrationForm.SurName.value.length<1){
		alert("Please enter your surname.");
		document.RegistrationForm.SurName.focus();
		return false;
	}
	if (!CheckEmailAddress(document.RegistrationForm.email.value)){
		alert("Please enter a valid email address.");
		document.RegistrationForm.email.focus();
		return false;
	}
	if (document.RegistrationForm.Company.value.length<1){
		alert("Please enter your company name.");
		document.RegistrationForm.Company.focus();
		return false;
	}
	if (document.RegistrationForm.address.value.length<10){
		alert("Please enter a valid company address.");
		document.RegistrationForm.address.focus();
		return false;
	}
	if (document.RegistrationForm.PostCode.value.length<3){
		alert("Please enter a valid postcode.");
		document.RegistrationForm.PostCode.focus();
		return false;
	}
	
	if (document.RegistrationForm.AreaCode.value.length<1){
		alert("Please enter the correct dialling code for your region");
		document.RegistrationForm.AreaCode.focus();
		return false;
	}
	if (document.RegistrationForm.PhoneNumber.value.length<6){
		alert("Please enter a valid telephone number for your organisation");
		document.RegistrationForm.PhoneNumber.focus();
		return false;
	}
	return true;
}

function CheckEmailAddress(pEmailAddress){
	DotLoc=pEmailAddress.indexOf(".");
	ampLoc=pEmailAddress.indexOf("@");
	EndChar=pEmailAddress.charAt(pEmailAddress.length-1)
	if (DotLoc<1 || ampLoc<1 || EndChar=="." || EndChar=="@") return false;
	return true;
}

function NumericOnly(pEvent){
	var ValidChars="1234567890";
	keycode = (pEvent.keyCode) ? pEvent.keyCode: pEvent.which;
	char=String.fromCharCode(keycode);
	if (ValidChars.indexOf(char)==-1) return false;
	return true;
}

function ChangeForm(pSelect){
	if (pSelect=="Academia"){
		document.getElementById("CompanyName").firstChild.nodeValue="Institution: ";
		document.getElementById("CompanyType").style.display="none";
	}
	else{
		document.getElementById("CompanyName").firstChild.nodeValue="Company: ";
		document.getElementById("CompanyType").style.display="block";
	}
}

function CheckCancel(){
	if (window.confirm("Are you sure want to clear the form and start over?")) return true;
	return false;
}
