<!--

/*
constant event.SUBMIT, event.CHANGE //Might be useful for event capturing in terms of identifying the event that called the data validation function.
*/

function verifyMetDeadline(deadlineStatus){
    today = new Date();
    deadline = new Date(2000, 8, 14);  //This was originally Sept. 10 (or Feb. 10)--I extended it to: Sept. 14, 1998 (or Feb. 14): The month seems to behave like an Array INDEX beginning at "0" for January.
    //NOTE: the "get..." method that must be used in the next statement to convert time to the # of msec since 1/1/1970.
    if (today.getTime() > deadline.getTime()) { //Student has gone past the deadline.
        alert("WHUPS!  You've messed up big time!  You not only missed the stated deadline for registering for the course but you're also well outside the generous additional grace period that I added--doesn't speak too well for your 'responsibility quotient'.  In order to become registered in the course you will now have to send your instructor an e-mail that contains the information that you would have/should have provided on the form as well as an explanation for why you didn't do this in a more timely way.  Sorry ... that you didn't follow directions.");
        return false  //Script should be terminated w/o making submission of data.
    }
    else    {   //  Student has NOT passed the deadline.
        return true   //Script may be continued.
    }
}

function verifyTextNotEmpty(textObject) {   //Verify that the text object is NOT empty.
    if (textObject.value == "")  {   //This text object is empty.
        alert("The box for your '" + textObject.name + "' is EMPTY.  Please FILL IN the required information before clicking the 'Add me ... NOW!' button again.");
        return false
    }
    else    {
        return true
    }
}

function verifyTextOnlyLetters(textObject)  {   //Verify that the text object contains only letters.
    for (i=0; i<textObject.value.length; i++) { //NOTE: It's the length of the .value; not of the textObject.
        if ((textObject.value.charAt(i)<"A")   ||
            (textObject.value.charAt(i)>"Z" && textObject.value.charAt(i)<"a")  ||
            (textObject.value.charAt(i)>"z"))  {   //The text object contains characters that are not letters.
                alert("The box for your '" + textObject.name + "' contains characters that are NOT LETTERS.  Please REPLACE these before clicking the 'Add me ... NOW!' button again.");
                return false    //  if any character is not a letter.
        }
    }
    return true //  when all characters have been tested and found to be letters.
}

function verifyPairedTextContent(eventStr, textObject, textObjectMate)    {
/*Rem'd Out:
    for (var eachProperty in inputObject){
        alert("." + eachProperty + " = " + inputObject[eachProperty]);
        alert(eachProperty + " = " + inputObject[eachProperty].value);
    }
*/

    if(eventStr != "submit")  {   //Initiating event was NOT "submit" (i.e., it was an "onChange"), exit from a text box.
        // DOES NOT WORK: alert(textObject[value]); //Similar to "for ... in ..." format.
        // DOES NOT WORK: alert(textObject[3]);
        // THIS WORKS: alert(textObject.value);
        if((textObject.value == "") ||
            (textObjectMate.value == ""))  {   //Only one, perhaps neither, text box has had anything added to it.
        }
        else    {   //Both boxes have had something added to them.
            if (textObject.value == textObjectMate.value)   {   //Their contents match--no problem.
            }
            else    {   //Their contents DON'T MATCH.
                //Clear contents of textObject & textObjectMate.
                textObject.value="";
                textObjectMate.value="";
                //Set focus to first box of pair.
                if(textObject.name.indexOf("_verif") >= 0)  {   //"_verif" currently has focus.
                    textObjectMate.focus()  //Focus given to the 1st of the two.
                }
                else    {
                    textObject.focus()  //Focus given to the 1st of the two.
                }
                alert("The contents of the pair of boxes, '"+textObject.name+"' and '"+textObjectMate.name+"', DO NOT MATCH--REENTER the appropriate data");
            }
        }
    }
    else    {   //Initiating event was a "Submit" action on the form.
        if((textObject.value == "") ||
        (textObjectMate.value == ""))  {   //Either text box empty is unacceptable.
            alert("ONE OR BOTH of the 'codename' boxes or the 'password' boxes is/are EMPTY.  PLEASE FILL IN the required omitted information before clicking the 'Add me ... NOW!' button again.")
            return false   // & terminate script.
        }
        else    {   //Both boxes have had something added to them.
            if (textObject.value == textObjectMate.value)   {   //Their contents match--no problem.
                return true// & continue script.
            }
            else    {   //Their contents DON'T MATCH.
                //Clear contents of textObject & textObjectMate.
                textObject.value="";
                textObjectMate.value="";
                //Set focus to first box of pair.
                if(textObject.name.indexOf("_verif") >= 0)  {   //"_verif" currently has focus.
                    textObjectMate.focus()  //Focus given to the 1st of the two.
                }
                else    {
                    textObject.focus()  //Focus given to the 1st of the two.
                }
                alert("The contents of the pair of boxes, '"+textObject.name+"' and '"+textObjectMate.name+"', DO NOT MATCH--REENTER the appropriate data");
                return false // to terminate script.
            }
        }
    }
}

function verifyRadioButton(radioObject) {
    if((radioObject[0].checked==false)   &&
        (radioObject[1].checked==false)  &&
        (radioObject[2].checked==false)) {
        alert("You have not yet made a choice from the alternatives offered in the Academic Integrity section of this form.  Please do so before clicking the 'Add me ... NOW!' button again.");
        return false
    }
    else    {
        return true
    }
}

/*REM'd out--mSQL still viewed the resultant null values as too large.
function setCheckBox(checkBoxObject)    {
    if(!(checkBoxObject.checked))   {
        checkBoxObject.value = "";
    }
}
*/

function verifyText(eventStr, textObject, textObjectMate) {
    if((textObject.name=="codename")    ||
        (textObject.name=="crs_pswd"))  {
        if(!(verifyPairedTextContent(eventStr, textObject, textObjectMate)))  {
            return false    //The contents of the pair doesn't match.
        }
        else    {
            return true //The contents of the pair matches.
        }
    }
    if((textObject.name=="last_name")   ||
        (textObject.name=="first_name") ||
        (textObject.name=="vax_userid"))    {
        if(!(verifyTextNotEmpty(textObject)))   {
            return false    //It's empty.
        }
        else    {
            if (textObject.name != "vax_userid")    {   //Those objects that CANNOT contain Non-LETTER characters and cannot be empty.
                if(!(verifyTextOnlyLetters(textObject)))    {
                    return false    //Contains characters other than just letters.
                }
                else    {
                    return true //Contains only letters.
                }
            }
            else    {
                return true //It's the userID box.
            }
        }
    }
    if ((textObject.name = "mid_initial")   &&
        (textObject.value != ""))    {   //If mid_initial contains some non-null value.
        if (!(verifyTextOnlyLetters(textObject)))   {
            return false    //Mid_initial is NOT a letter.
        }
        else    {
            return true //  to the calling JScript.
        }
    }
    else    {
        return true //to the calling JScript; textObject is either not mid_initial or mid_initial is NULL.
    }
}


function verifyFormContent(eventStr, acad_integ, midterm_permit, acad_serv_permit, last_name, first_name, mid_initial, codename, codename_verif, crs_pswd, crs_pswd_verif, vax_userid)  {

    if (!(verifyMetDeadline())) {
        return false
    }

    if (!(verifyRadioButton(acad_integ)))   {
        return false
    }

    /*REM'd out--mSQL still viewed the resultant null values as too large.
    setCheckBox(midterm_permit) //Equate UNCHECKED to NULL.
    setCheckBox(acad_serv_permit)   //Equate UNCHECKED to NULL.
    */

    if (!(verifyText("", last_name, "")))   {   //1st "NULL" is the unneeded eventObject; Use the 2nd null, dummy value just to "hold" that parameter place.
        return false
    }

    if (!(verifyText("", first_name, "")))  {
        return false
    }

    if (!(verifyText("", mid_initial, ""))) {
        return false
    }

    if (!(verifyText(eventStr, codename, codename_verif)))  {    //Some way needed to pass "submit"/"onChange" event information.  There should be some way to capture the nature of the event rather than passing a string.
        return false
    }

    if (!(verifyText(eventStr, crs_pswd, crs_pswd_verif)))  {    //Some way needed to pass "submit"/"onChange".  There should be some way to capture the nature of the event rather than passing a string.
        return false
    }

    if (!(verifyText("", vax_userid, "")))  {
        return false
    }
    return true //All preceding function calls have returned "true", so proceed to actually submit the data.
}

// -->