function chknumber(num) {

	num=num
	var checkOK = "0123456789- "; // the valid characters
	var checkStr = num;
	var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
	if (j == checkOK.length)
	{
	allValid = false;
	break;
	}
	if (ch != ",")
	allNum += ch;
	}
	if (!allValid)
	{
		//alert("Please enter a valid number.");
		return false;
	}
	else 
	{
		return true;
	}
} // END OF CHKNUMBER FUNCTION

//ensure the e-mail field is valid
function chkmail(email) {

	email=email

		// test if valid company email address, must have @ and .
		var checkEmail = "@.";
		var checkStr = email;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
		{
		if (ch == checkEmail.charAt(j) && ch == "@")
		EmailAt = true;
		if (ch == checkEmail.charAt(j) && ch == ".")
		EmailPeriod = true;
			  if (EmailAt && EmailPeriod)
				break;
			  if (j == checkEmail.length)
				break;
			}
			// if both the @ and . were in the string
		if (EmailAt && EmailPeriod)
		{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid)
		{
		
		return false;
		}
		else 
		{
		return true;
		}

} // END OF CHKMAIL FUNCTION


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function validatecareer() {
	if (trim(frmteaching.Name.value)==""){
		alert("Please enter your name.");
		frmteaching.Name.focus();
		return false;
	}

	if (trim(frmteaching.Address.value)==""){
		alert("Please enter your address.");
		frmteaching.Address.focus();
		return false;
	}

	if (trim(frmteaching.Tel.value)==""){
		alert("Please enter your contact number.");
		frmteaching.Tel.focus();
		return false;
	}

	if (trim(frmteaching.Tel.value) != "") {
		if (!chknumber(frmteaching.Tel.value)) {
			alert("Please enter a valid contact number.");
			frmteaching.Tel.focus();
			return false;
		}
	}

	if (trim(frmteaching.Email.value)==""){
		alert("Please enter your e-mail address.");
		frmteaching.Email.focus();
		return false;
	}

	if (trim(frmteaching.Email.value) != "") {
		if (!chkmail(frmteaching.Email.value)) {
			alert("Please enter a valid e-mail address.");
			frmteaching.Email.focus();
			return false;
		}
	}

	input = trim(frmteaching.Qualifications.value);
	if(input.length == 0){
		alert("Please briefly state your qualifications.");
		frmteaching.Qualifications.focus();
		return false;
	}

	//return true;
} // function validatecareer

function validatecareerFT() {
	if (trim(frmteaching.Name.value)==""){
		alert("Please enter your name.");
		frmteaching.Name.focus();
		return false;
	}

	if (trim(frmteaching.Address.value)==""){
		alert("Please enter your address.");
		frmteaching.Address.focus();
		return false;
	}

	if (trim(frmteaching.Tel.value)==""){
		alert("Please enter your contact number.");
		frmteaching.Tel.focus();
		return false;
	}

	if (trim(frmteaching.Tel.value) != "") {
		if (!chknumber(frmteaching.Tel.value)) {
			alert("Please enter a valid contact number.");
			frmteaching.Tel.focus();
			return false;
		}
	}

	if (trim(frmteaching.Email.value)==""){
		alert("Please enter your e-mail address.");
		frmteaching.Email.focus();
		return false;
	}

	if (trim(frmteaching.Email.value) != "") {
		if (!chkmail(frmteaching.Email.value)) {
			alert("Please enter a valid e-mail address.");
			frmteaching.Email.focus();
			return false;
		}
	}

	input = trim(frmteaching.Qualifications.value);
	if(input.length == 0){
		alert("Please briefly state your qualifications.");
		frmteaching.Qualifications.focus();
		return false;
	}

	//return true;
} // function validatecareerFT

function validatefeedbackFT() {
	if (trim(frmfeedback.name.value)==""){
		alert("Please enter your name.");
		frmfeedback.name.focus();
		return false;
	}

	if (trim(frmfeedback.email.value)==""){
		alert("Please enter your e-mail address.");
		frmfeedback.email.focus();
		return false;
	}

	if (trim(frmfeedback.email.value) != "") {
		if (!chkmail(frmfeedback.email.value)) {
			alert("Please enter a valid e-mail address.");
			frmfeedback.email.focus();
			return false;
		}
	}

	input = trim(frmfeedback.feedback.value);
	if(input.length == 0){
		alert("Please share your feedback.");
		frmfeedback.feedback.focus();
		return false;
	}

	//return true;
} // function validatefeedbackFT

function validatefeedback() {
	if (trim(frmfeedback.name.value)==""){
		alert("Please enter your name.");
		frmfeedback.name.focus();
		return false;
	}

	if (trim(frmfeedback.email.value)==""){
		alert("Please enter your e-mail address.");
		frmfeedback.email.focus();
		return false;
	}

	if (trim(frmfeedback.email.value) != "") {
		if (!chkmail(frmfeedback.email.value)) {
			alert("Please enter a valid e-mail address.");
			frmfeedback.email.focus();
			return false;
		}
	}

	input = trim(frmfeedback.feedback.value);
	if(input.length == 0){
		alert("Please share your feedback.");
		frmfeedback.feedback.focus();
		return false;
	}

	//return true;
} // function validatefeedback