// NOTE: Any changes in this file require creation of a new version of the file,
//       and changes to any templates where it is used. In other words, if this
//       file is application_v1.js, changes go into new file application_v2.js.

//====================================================
//  Variables used for document tagging
//====================================================
var answerSetIds = new Array;
var stateArray = new Array;
var tagState = "";

//====================================================
//  Clear the tagging variables
//====================================================
function clearTagState() {
    answerSetIds = new Array;
    stateArray = new Array;
    tagState = "";
}
//====================================================
//  Locate the given answerset id, and clear the
//  corresponding tag state
//====================================================
function clearTagStateForAnsSet(anId) {
    tagState = "";
    for (var j=0;j<answerSetIds.length; j++) {
        if (answerSetIds[j] == anId) {
            tagState = "";
            break;
        }
    }
}
//====================================================
//  Locate the given answerset id, and get the
//  corresponding tag state
//====================================================
function getTagState(anId) {
    tagState = "";
    for (var j=0;j<answerSetIds.length; j++) {
        if (answerSetIds[j] == anId) {
            tagState = stateArray[j];
            break;
        }
    }
}
//====================================================
//  Locate the given answerset id, and set the
//  corresponding tag state
//====================================================
function setTagState(anId) {
    var stateUpdated = 0;
    for (var j=0;j<answerSetIds.length; j++) {
        if (answerSetIds[j] == anId) {
            stateArray[j] = tagState;
            stateUpdated = 1;
            break;
        }
    }
    //
    //  If the given id was not in the array, then this is a
    //  new answer set, so add it to the answerSetIds array
    //
    if (stateUpdated == 0) {
       answerSetIds[answerSetIds.length] = anId;
       stateArray[stateArray.length] = tagState;
    }
}
