//dependencies:
// /dwr/util.js

/* Defaults for dropdown */
var DEFAULT_SELECT_OPTION_USE_NONE          = 0;
var DEFAULT_SELECT_OPTION_USE_ANY           = 1;
var DEFAULT_SELECT_OPTION_USE_ALL           = 2;
var DEFAULT_SELECT_OPTION_USE_SELECT_ONE    = 3;

/* Utility method for populating a select item. */
/* This method is called after a call to a DWR call. */
function populateSelectCallback(list, theField, selectedValue) {
    /*Defect 29386 - DWR and Webkit don't play nice or get along well together.
        dwr.util.removeAllOptions(theField); */
    theField.innerHTML = "";
    dwr.util.addOptions(theField, list, "optionValue", "optionLabel");
    if (selectedValue != null && selectedValue != '') {
        setDropdown(theField, selectedValue);
    }
}

function setDropdown(ele,val) {
    for (var j=0, loopCounter=ele.length; j<loopCounter; j++) {
        if (ele.options[j].value == val) {
            ele.options[j].selected = true;
        }
    }
}


