function Form_Validator(theForm)
{
    if (theForm.Name.value == "")
    {
        alert("Please enter a value for the \"Name\" field.");
        theForm.Name.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);
    }

    if (theForm.AreaCode.value == "")
    {
        alert("Please enter a value for the \"Area Code\" field.");
        theForm.AreaCode.focus();
        return (false);
    }

    var checkOK = "0123456789-";
    var checkStr = theForm.AreaCode.value;
    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;
        }
        allNum += ch;
    }
    if (!allValid)
    {
        alert("Please enter only digit characters in the \"Area Code\" field.");
        theForm.AreaCode.focus();
        return (false);
    }

    if (theForm.PhonePrefix.value == "")
    {
        alert("Please enter a value for the \"Phone Prefix\" field.");
        theForm.PhonePrefix.focus();
        return (false);
    }

    checkOK = "0123456789-";
    checkStr = theForm.PhonePrefix.value;
    allValid = true;
    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;
        }
        allNum += ch;
    }
    if (!allValid)
    {
        alert("Please enter only digit characters in the \"Phone Prefix\" field.");
        theForm.PhonePrefix.focus();
        return (false);
    }

    if (theForm.PhoneSuffix.value == "")
    {
        alert("Please enter a value for the \"Phone Suffix\" field.");
        theForm.PhoneSuffix.focus();
        return (false);
    }

    checkOK = "0123456789-";
    checkStr = theForm.PhoneSuffix.value;
    allValid = true;
    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;
        }
        allNum += ch;
    }
    if (!allValid)
    {
        alert("Please enter only digit characters in the \"Phone Suffix\" field.");
        theForm.PhoneSuffix.focus();
        return (false);
    }

    checkOK = "0123456789-";
    checkStr = theForm.Extension.value;
    allValid = true;
    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;
        }
        allNum += ch;
    }
    if (!allValid)
    {
        alert("Please enter only digit characters in the \"Extension\" field.");
        theForm.Extension.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;
        }
    }
}