//This javascript is for the AI Org List To check all the boxes. 
function ChangeCheckBoxState(id, checkState)
{
    var cb = document.getElementById(id);
    if (cb != null)
    {
        cb.checked = checkState;
    }
}

// Toggles through all of the checkboxes defined in the CheckBoxIDs array
// and updates their value to the checkState input parameter
function ChangeAllCheckBoxStates(checkState, checkbox)
{
    if (CheckBoxIDs != null)
    {
        for (var i = 0; i < CheckBoxIDs.length; i++)
        {
            ChangeCheckBoxState(CheckBoxIDs[i], checkState);
        }
    }
      
}

// Whenever a checkbox is toggled, we need to
// check the checkbox if ALL of the checkboxes are
// checked, and uncheck it otherwise
function ChangeHeaderAsNeeded()
{
    if (CheckBoxIDs != null)
    {
        // check to see if all other checkboxes are checked
        for (var i = 1; i < CheckBoxIDs.length; i++)
        {
            var cb = document.getElementById(CheckBoxIDs[i]);
            if (!cb.checked)
            {
                // Whoops, there is an unchecked checkbox, make sure
                // that the header checkbox is unchecked
                ChangeCheckBoxState(CheckBoxIDs[0], false);
                return;
            }
        }
        // If we reach here, ALL GridView checkboxes are checked
        ChangeCheckBoxState(CheckBoxIDs[0], true);
    }
}