//////////////////////////////////
// getNumbers(strInput)
// function accepts a string and 
// returns a string stripped of all
// but numerical digits.
//
function getNumbers(strInput){
	var ValidChars = "0123456789";
	var Char;
	var strNumbers = "";
	for (i = 0; i < strInput.length; i++){ 
		Char = strInput.charAt(i); 
		if (ValidChars.indexOf(Char) != -1){
			strNumbers += Char;
		}
	}
	return strNumbers;
}//End function getNumbers()
function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
function checkForm(){
	var txtName = document.getElementById("txtName");
	var txtEmail = document.getElementById("txtEmail");
	var txtPhone = document.getElementById("txtPhone");
	if (txtName.value == ""){
		alert("Please provide your Name.");
		txtName.focus();
		return false;
	}
	if (txtEmail.value == ""){
		alert("Please provide your Email Address.");
		txtEmail.focus();
		return false;
	}
	else if (!isValidEmail(txtEmail.value) ){
		alert("Email Address appears to be invalid.");
		txtEmail.focus();
		return false;		
	}
	if (txtPhone.value == ""){
		// not required
	}
	else {
		txtPhone.value = getNumbers(txtPhone.value);
		if (txtPhone.value.length != 10){
			alert("Phone Number must be 10 digits including area code.");
			txtPhone.select();
			return false;
		}
	}
	// all good
	return true;
}
