// sets values to asp menu; values are written in mainbtn.jsp
// negative ids below (-3, -2 and -1) are defined in com.valuatum.util.SystemConstants

// the menu index of the company that is currently viewed
var activeAspIndex = 0;

// count the rows
var k = 0;

// personal default option
if(showPersonalSelectionOption && asp.length > 1) {
    // new list option to be added
    id = -3;
    opt = new Option(personalSelectionStr, id);
    // add option using eval (notice that we use j instead of i)
    eval("document.menuForm.asps.options[k] = opt");
    if(id == acAspId) {
        activeAspIndex = k;
    }
    k++;
}

// asp default option
if(showAspDefaultOption && asp.length > 1) {
    // new list option to be added
    id = -2;
    opt = new Option(aspDefaultStr, id);
    // add option using eval (notice that we use j instead of i)
    eval("document.menuForm.asps.options[k] = opt");
    if(id == acAspId) {
        activeAspIndex = k;
    }
    k++;
}

// all option
if(showAllOption && asp.length > 1) {
    // new list option to be added
    id = -1;
    opt = new Option(allDataProvidersStr, id);
    // add option using eval (notice that we use j instead of i)
    eval("document.menuForm.asps.options[k] = opt");
    if(id == acAspId) {
        activeAspIndex = k;
    }
    k++;
}

// single asps in menu (if menu exists)
if(document.menuForm.asps.options != null) {
    for(i = 0; i < asp.length; i++) {
        // new list option to be added
        opt = new Option(asp[i][1], asp[i][0]);
        // add option using eval (notice that we use j instead of i)
        eval("document.menuForm.asps.options[k] = opt");
        // get selected aspId; the first test is used in SV and the second in AC pages
        if(asp[i][0] == document.menuForm.hiddenAspId.value || asp[i][0] == acAspId) {
            activeAspIndex = k;
        }
        k++;
    }
}

// modify option
if(showModifyOption && asp.length > 1) {
    // new list option to be added
    id = -4;
    opt = new Option(modifyPersonalStr, id);
    // add option using eval (notice that we use j instead of i)
    eval("document.menuForm.asps.options[k] = opt");
    k++;
}

// this needs to be here, because otherwise <IE6 will make an empty option to the beginning
if (asp.length == 1) {
    document.menuForm.asps.selectedIndex = 0;
}

// select asp if wanted and match was found
if(setAspId) {
    document.menuForm.asps.selectedIndex = activeAspIndex;
}
