function subfrm() {
	// check name
	var sRealname = trim(document.frm1.realname.value);
	if (sRealname == "") {
		alert("Please enter contact name");
		document.frm1.realname.select();
		document.frm1.realname.focus();
		return false;
	}
	
	// check phone no.
	var sDay_Phone = trim(document.frm1.Day_Phone.value);
	if (sDay_Phone.length > 0) {
		if (!validatePhone(sDay_Phone)) {
			alert("Phone number is invalid");
			document.frm1.Day_Phone.select();
			document.frm1.Day_Phone.focus();
			return false;
		}
	}
	
	// check email address
	var sEmail = document.frm1.Email_Address.value;	
	if (sEmail.length > 0) {
		if (!check_email(sEmail)) {
			alert("Email address is invalid");
			document.frm1.Email_Address.select();
			document.frm1.Email_Address.focus();
			return false;
		}
	}
	
	// must have at least one of: phone no/email address
	if ((sDay_Phone.length == 0) && (sEmail.length == 0)) {
		alert("Please enter phone number and/or email address");
		document.frm1.Day_Phone.select();
		document.frm1.Day_Phone.focus();
		return false;
	}
	
	// check relationship to child
	var sRelationship = trim(document.frm1.Relationship_to_Child.value);
	if (sRelationship == "") {
		alert("Please enter relationship to child");
		document.frm1.Relationship_to_Child.select();
		document.frm1.Relationship_to_Child.focus();
		return false;
	}
	
	// check child's name
	var sChild = trim(document.frm1.Child.value);
	if (sChild == "") {
		alert("Please enter name of child");
		document.frm1.Child.select();
		document.frm1.Child.focus();
		return false;
	}
	
	// check age
	var sAge = trim(document.frm1.Age.value);
	if (sAge == "") {
		alert("Please enter age of child");
		document.frm1.Age.select();
		document.frm1.Age.focus();
		return false;
	}
	
	// check date of birth
	var selectBox = document.frm1.DOB_M;
	var sDOB_M = selectBox.options[selectBox.selectedIndex].value;
	var selectBox = document.frm1.DOB_D;
	var sDOB_D = selectBox.options[selectBox.selectedIndex].value;
	var selectBox = document.frm1.DOB_Y;
	var sDOB_Y = selectBox.options[selectBox.selectedIndex].value;
	var dToday = new Date();
	var dDOB = new Date(sDOB_Y, sDOB_M, sDOB_D);
	if (dDOB >= dToday) {
		alert("Date of birth must be in the past");
		return false;
	}
	
	// check admission date
	var selectBox = document.frm1.For_Admission_Month;
	var sFor_Admission_Month = selectBox.options[selectBox.selectedIndex].value;
	var selectBox = document.frm1.For_Admission_Year;
	var sFor_Admission_Year = selectBox.options[selectBox.selectedIndex].value;
	var dToday = new Date();
	var dAdmission_date = new Date(sFor_Admission_Year, sFor_Admission_Month, dToday.getDay());
	if (dAdmission_date <= dToday) {
		alert("Please choose a future admission date");
		return false;
	}
	
	document.frm1.Parent.value = document.frm1.realname.value;
	if (sEmail == "") {
		document.frm1.email.value = "noreply@icms.edu.hk";
		document.frm1.Note.value = "Please do not reply to this email. The sender did not leave an email address.";
	}
	else {
		document.frm1.email.value = sEmail;
		document.frm1.Note.value = "";
	}
	document.frm1.subject.value = "From Website - Request an Appointment";
	document.frm1.redirect.value = "http://icms.edu.hk/admissions/procAdmDone_e.php";
	document.frm1.submit();
}
function initFrm() {
	document.frm1.realname.focus();
}
