// searchPopList.js
// Populate the drop down boxes for the Civil War search page.

function selectEvent() {

    // initialize dropdown box
    if (document.searchForm.rName.value == "BLANK") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        with (document.searchForm.regiment) {
            options[0] = new Option("--NONE--", "0", false, false);
        }
    }

    // populate dropdown box with Artillery
    if (document.searchForm.rName.value == "ARTI") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        for (k = 0; k < regName1.length; k++) {
            with (document.searchForm.regiment) {
                options[k] = new Option(regName1[k], regValue1[k], false, false);
            }
        }
    }

    // populate dropdown box with Infantry
    if (document.searchForm.rName.value == "INFA") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        for (k = 0; k < regName2.length; k++) {
            with (document.searchForm.regiment) {
                options[k] = new Option(regName2[k], regValue2[k], false, false);
            }
        }
    }

    // populate dropdown box with Cavalry
    if (document.searchForm.rName.value == "CAVA") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        for (k = 0; k < regName3.length; k++) {
            with (document.searchForm.regiment) {
                options[k] = new Option(regName3[k], regValue3[k], false, false);
            }
        }
    }

    // populate dropdown box with US Colored Troops
    if (document.searchForm.rName.value == "USCT") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        for (k = 0; k < regName4.length; k++) {
            with (document.searchForm.regiment) {
                options[k] = new Option(regName4[k], regValue4[k], false, false);
            }
        }
    }

    // populate dropdown box with Engineers
    if (document.searchForm.rName.value == "ENGI") {
        document.searchForm.regiment.options.length = 0;
        // clear box options

        for (k = 0; k < regName5.length; k++) {
            with (document.searchForm.regiment) {
                options[k] = new Option(regName5[k], regValue5[k], false, false);
            }
        }
    }
}

function initializeRegiment() {
    document.searchForm.regiment.selectedIndex = document.searchForm.regCode.value;
}
