function splitName(formName)
{
    var nameField = document.getElementById("fullName");
    if (nameField && nameField.value)
    {
        var fullName = new String(nameField.value);

        // Name elements are separated by a space
        var firstSpace = fullName.indexOf(' ');
        var secondSpace = -1;
        var middleNameLength = -1;
        if (firstSpace > 0)
        {
            // See if there are actually three or more name elements specified
            secondSpace = fullName.indexOf(' ', firstSpace + 1);
            if (secondSpace > 0)
            {
                middleNameLength = secondSpace - (firstSpace + 1);
            }
        }

        // Check if there are initials in the middle (typically one or two, with or without periods)
        // Two initials with periods produces a middle name length of 4
        if (secondSpace > 0 && (middleNameLength <= 4 && (middleNameLength == 1 || fullName.charAt(secondSpace - 1) == '.')))
        {
            firstSpace = secondSpace; // We will split at firstSpace
        }

        // Okay, now we know where to split the name, if at all
        nameField = document.getElementById("LastName");
        if (nameField)
        {
            if (firstSpace > 0)
            {
                // Peel off the last name and stuff that into the field
                nameField.value = fullName.substring(firstSpace + 1);
                // Now handle the first name
                nameField = document.getElementById("FirstName");
                if (nameField)
                {
                    nameField.value = fullName.substring(0, firstSpace);
                }
            }
            else // No space; single name only, treat as last name
            {
                nameField.value = fullName;
            }
        }
        // alert("Split [" + fullName + "] into [" + document.getElementById("FirstName").value + "] and [" + document.getElementById("LastName").value + "]");
        document.getElementById(formName).submit();
    }
}

function emailThisPage()
{
    return window.open("EmailThisPage.htm", "emailelspage", "toolbar=no, location=no, directories=no, " +
                "status=no, menubar=no, scrollbars=no, resizable=yes, " +
                "copyhistory=no, width=550, height=500");
}
