function Form_Validator(theForm)
{
    if (theForm.FullName.value=="")
    {
        alert("Please enter a value for the \"Full Name\" field.");
        theForm.FullName.focus();
        return (false);
    }

    var checkOK = "0123456789-,";
    var checkStr = theForm.Year_of_Birth.value;
    var allValid = true;
    var validGroups = true;
    var decPoints = 0;
    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 only digit characters in the \"Year of Birth\" field.");
        theForm.Year_of_Birth.focus();
        return (false);
    }

    if ((theForm.Email.value == "") || !validate_email(theForm.Email.value))
    {
        alert("Please enter a valid \"Email\".");
        theForm.Email.focus();
        return (false);
    }

    if (theForm.Confirm.value == "")
    {
        alert("Please enter a value for the \"Confirm\" field.");
        theForm.Confirm.focus();
        return (false);
    }
    if (theForm.Email.value != theForm.Confirm.value)
    {
        alert("Please make sure that the email addresses match.");
        theForm.Email.focus();
        return (false);
    }
    var radioSelected = false;
    for (i = 0;  i < theForm.Course.length;  i++)
    {
        if (theForm.Course[i].checked)
            radioSelected = true;
    }
    if (!radioSelected)
    {
        alert("Please select a Course location option.");
        return (false);
    }
    if (theForm.Weeks.selectedIndex == 0)
    {
        alert("Please choose the \"Number of Weeks\".");
        theForm.Weeks.focus();
        return (false);
    }
    return (true);

    function validate_email(emailStr){
        apos=emailStr.indexOf("@");
        dotpos=emailStr.lastIndexOf(".");
        if (apos<1||dotpos-apos<2) {
            return false;
        }
        else {
            return true;
        }
    }
}
