// Functions to deal with "wiki edit sets"

var wikiSets = new Array();

function AddWikiSet(setId, setNumber, setName, type) {
        //alert("AddWikiSet");
        var newSet = new Object();
        newSet.setId = setId;
        newSet.setNumber = setNumber;
        newSet.setName = setName;
        // New classification constants for types are given above.
        // for legacy reasons, USER_OWNED sets might come in as type 0 or 1; set either to USER_OWNED.
        if (type == 0 || type == 1) {
                newSet.type = USER_OWNED;
        } else {
                newSet.type = type;
        }
        wikiSets[wikiSets.length] = newSet;
}

function RemoveWikiSet(setId) {

        var tbr;

//        alert("removing setId = " + setId);

        // Find the index of the to-be-removed setId
        for (var i = 0; i < wikiSets.length; ++i) {
                if (wikiSets[i].setId == setId) {
                        tbr = i;
                        break;
                }
        }

        // Now get rid of the set itself.  We can't actually remove it from the noteSets array,
        // because that would screw up the ordering of the notes from the other sets.  Instead
        // we just set that array value to an object with a single field: a type of GHOST_SET.
        // This makes the variable into a kind of "ghost noteSet" that won't disturb the others.
        // We have to be careful, though, to deal with ghost noteSets in places like prefs.html.
        wikiSets[tbr] = new Object();
        wikiSets[tbr].type = GHOST_SET;

        // Update (9/12/2005): Actually, we could just remove it now, but don't worry about changing that.

        // Reload the main text window, in case there was a note from this set on the current page
        LoadSection('reload');
}


