////////////////////////////////////////////////////////////////////////////////
//
//    ATTENTION NETSCAPE NAVIGATOR 3.0 USERS!!!
//
//    If you see this text while using the site and you did NOT click on
//    View -> Source, you're using a buggy browser.
//
//    FOLLOW THESE STEPS
//
//    Read through these two steps before doing them.
//    1. Press your BACK BUTTON.
//    2. Click on REFRESH or RELOAD.
//
//    You should now be able to use the site without seeing this message.
//    This problem can however return if your browser does not cache this
//    document correctly.
//
//    UPGRADE YOUR BROWSER
//
//    Upgrade your browser to Netscape's latest and you will not have this
//    problem any more.
//
//    Netscape browsers can be found at http://home.netscape.com/
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//  checker 1.00  --  Please leave this notice.
//
//  By Juan Rubio (jrubio@ece.utexas.edu)  Last modified 2001-09-26
////////////////////////////////////////////////////////////////////////////////

//===================================================================
function checkString(theInput,minLength,maxLength)
{
    // only allow letters to be entered
    var checkPattern = "abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVWXYZ.-";
    var checkStr = theInput.value;
    var checkLength = checkStr.length;
    var allValid = true;
    var allCorrect = "";
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkPattern.length;  j++)
            if (ch == checkPattern.charAt(j))
                break;
        if (j == checkPattern.length)
        {
            allValid = false;
            break;
        }
        if (ch != ",")
            allCorrect += ch;
    }
    if (!allValid)
    {
        alert("Please enter only letters in this field.");
        theInput.focus();
        return (false);
    }

    if ( minLength == maxLength && checkLength != minLength )
    {
        alert("The string you entered has to be " + minLength + " characters long.");
        theInput.focus();
        return (false);
    } else {
    if ( checkLength<minLength || checkLength>maxLength )
    {
        alert("The string you entered has to be between " + minLength + " and " + maxLength + " characters long.");
        theInput.focus();
        return (false);
    }
    }
}

//===================================================================
function checkNumber(theInput,minNumber,maxNumber)
{
    // only allow numbers to be entered
    var checkPattern = "0123456789";
    var checkStr = theInput.value;
    var allValid = true;
    var allCorrect = "";
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkPattern.length;  j++)
            if (ch == checkPattern.charAt(j))
                break;
        if (j == checkPattern.length)
        {
            allValid = false;
            break;
        }
        if (ch != ",")
            allCorrect += ch;
    }
    if (!allValid)
    {
        alert("Please enter only digit characters in this field.");
        theInput.focus();
        return (false);
    }

    var RealNumber = parseInt(theInput.value,10);
    if ( RealNumber<minNumber || RealNumber>maxNumber )
    {
        alert("The number has to be between " + minNumber + " and " + maxNumber + ".");
        theInput.focus();
        return (false);
    }
    return (true);
}
//===================================================================
function checkEmail(theInput)
{
    // test if valid email address, must have @ and .
    var checkPattern = "@.";
    var checkStr = theInput.value;
    var EmailValid = false;
    var EmailAt = false;
    var EmailPeriod = false;
    for (i = 0;  i < checkStr.length;  i++)
    {
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkPattern.length;  j++)
        {
            if (ch == checkPattern.charAt(j) && ch == "@")
                EmailAt = true;
            if (ch == checkPattern.charAt(j) && ch == ".")
                EmailPeriod = true;
            if (EmailAt && EmailPeriod)
                break;
            if (j == checkPattern.length)
                break;
        }
        // if both the @ and . were in the string
        if (EmailAt && EmailPeriod)
        {
            EmailValid = true
                break;
        }
    }
    if (!EmailValid)
    {
        alert("The \"email\" field must contain an \"@\" and a \".\".");
        if ( theInput.value.length > 0 )
            theInput.focus();
        return (false);
    }
}
//===================================================================

