/*
Copyright (C) 2000-2010 Beyond SQL.com, Inc.
$LastChangedRevision: 2 $
*/

    /*
     *  Updates a form field and submits the form
     */
    function updateFieldAndSubmit(lField, lValue, lForm) {
        // update form field and submit
        $(lField).value = lValue;
        lForm.method = "POST";
        lForm.submit();
    }

    /*
     *  Moves selected items from the source list to the target list
     */
    function updateLists(sourceList, targetList) {
        var i = sourceList.selectedIndex;

        // check if anything is selected
        if(i != -1) {
            for(i = sourceList.selectedIndex; i < sourceList.length; i++) {
                if(sourceList.options[i].selected) {

                    // create a new option and add it to the target list
                    var newOption = new Option(sourceList.options[i].text, sourceList.options[i].value);
                    targetList.options[targetList.length] = newOption;

                    // delete the option from the source list
                    sourceList.options[i] = null;
                    i--;    // decrement the counter since an option deleted
                }
            }
        }
    }

    /*
     *  Concatenates all option values in a given select list
     *  into a single string and updates the given form field
     *  with the string.
     */

    function saveListVals(lListObj, lField) {
        var i = 0;
        var listItems = "";

        // loop through items in select list, mark as selected
        for(i = 0; i < lListObj.length; i++) {
            listItems += lListObj.options[i].value + ',';
        }
        // remove final comma & update form field
        listItems = listItems.slice(0,-1);
        lField.value = listItems;

        return true;
    }
