﻿// Get an array of the items from the item array which do not exist in the exclusion array
// The comparison is done on the fields itemArrCompElemStr and exclusionArrCompElemStr
//  itemArr : the array with the items to keep, only items not in the exclusionArr will be returned
//  exclusionArr : the array with the item to not include
//  itemArrElemStr : the element within each item in the itemArr to compare
//  exclusionArrElemStr : the element within each item in the exclusionArr to compare
function GetDiffArray(itemArr, exclusionArr, itemArrCompElemStr, exclusionArrCompElemStr)
{
    var itemCount = itemArr.length;
    var exclusionCount = exclusionArr.length;
    
    var diffArr = new Array();
    
    for(var i = 0; i < itemCount; ++i)
    {
        var isDiff = true;
        
        for(var j = 0; j < exclusionCount; ++j)
        {
            if (itemArr[i][itemArrCompElemStr] == exclusionArr[j][exclusionArrCompElemStr])
            {
                isDiff = false;
                break;
            }
        }
        
        // differnt, add to diff array
        if (isDiff == true)
        {
            diffArr.push(itemArr[i]);
        }
    }
    
    return diffArr;
}

// implement Array.map function
if (!Array.prototype.map)
{
    Array.prototype.map = function(fun /*, thisp*/)
    {
        var len = this.length;
        if (typeof fun != "function")
            throw new TypeError();

        var res = new Array(len);
        var thisp = arguments[1];
        for (var i = 0; i < len; i++)
        {
            if (i in this)
                res[i] = fun.call(thisp, this[i], i, this);
        }

        return res;
    };
}
// implement Array.indexOf
if (!Array.prototype.indexOf)
{
    Array.prototype.indexOf = function(elt /*, from*/)
    {
        var len = this.length;

        var from = Number(arguments[1]) || 0;
        from = (from < 0)
            ? Math.ceil(from)
            : Math.floor(from);
        if (from < 0)
            from += len;

    for (; from < len; from++)
    {
        if (from in this &&
            this[from] === elt)
        return from;
    }
        return -1;
    };
}

// fill left box of ezDoubleSelectObj from a http service call
function FillDoubleSelectFromHTTP(url, ezDoubleSelectObj)
{
    var req;
    
    if (typeof XMLHttpRequest != "undefined") 
    {
        req = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    req.ezDoubleSelectObj = ezDoubleSelectObj;
    req.open("GET", url, true);

    // NOTE: browser may cache requests - make url unique to prevent this
    var uniqueStr = 'ticks=' + (new Date()).getTime();
    if (url.indexOf('?') == -1) {
    	url += '?' + uniqueStr;
    }
    else {
    	url += '&' + uniqueStr;
    }
    
    req.onreadystatechange = 
        function()
        {
            if (req.readyState == 4) 
            {
                if (req.status == 200) 
                {
                    // filter item array to remove the current item if there is one
                    var availItemArr = eval(req.responseText);
                    var filteredAvailItemArr = new Array();
                    var count = availItemArr.length;
                    
                    for (var i = 0; i < count; i++)
                    {
                        if (availItemArr[i].id != this.currentItemId)
                        {
                            filteredAvailItemArr.push(availItemArr[i]);
                        }
                    }
                    
                    req.ezDoubleSelectObj.SetLeftItems(filteredAvailItemArr, 'title', 'id');
                }
            }
        };
    req.send(null);
}      

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
// EZSelect - wrapper for select element
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------

function EZSelect(selObj)
{
    this.selObj = selObj;
}
    
EZSelect.prototype =
{
    // Add a single item to the existing list
    AddItem : function(text, val)
    {
        var optn = document.createElement("OPTION");    
        optn.text = text;
        optn.value = val;
        this.selObj.options.add(optn);
    },

    // add a range of items to the existing list
    //  textStr : the name of the text element in the itemArr
    //  valueStr : the name of the value element in the itemArr
    AddRange : function(itemArr, textStr, valueStr)
    {
        if (itemArr)
        {
            var count = itemArr.length;
            for (var i = 0; i < count; i++)
            {
                this.AddItem(itemArr[i][textStr], itemArr[i][valueStr]);
            }
        }
    },

    RemoveAll : function()
    {
        var count = this.selObj.options.length;
        for(var i = 0; i < count; ++i)
        {
            this.selObj.remove(0); // keep removing first element
        }
    },

    // Remove the items in the array
    //  valueStr : the name of the value element in the itemArr
    RemoveRange : function(itemArr, valueStr)
    {
        var leaveItems = GetDiffArray(this.selObj.options, itemArr, 'value', valueStr);
        
        this.RemoveAll();
        this.AddRange(leaveItems, 'text', 'value');
    },

    // set the list to these items
    //  textStr : the name of the text element in the itemArr
    //  valueStr : the name of the value element in the itemArr
    SetItems : function(itemArr, textStr, valueStr)
    {
        this.RemoveAll();
        this.AddRange(itemArr, textStr, valueStr);
    },

    // Set the selected state of all items in the list
    //  true for selected, false for not selected
    SetSelectedState : function(isSelected)
    {
        var count = this.selObj.options.length;
        for(var i = 0; i < count; ++i)
        {
            this.selObj[i].selected = isSelected;
        } 
        
        // IE needs this
        this.selObj.selectedIndex = -1;
    },

    // Get an array of selected options.  An empty array means no items are selected
    //  textStr : the name of the element to hold the text values
    //  valueStr : the name of the element to hold the value values
    GetSelectedArray : function(textStr, valueStr)
    {
        var selArr = new Array();
        
        var count = this.selObj.options.length;
        for(var i = 0; i < count; ++i)
        {
            var currOption = this.selObj.options[i];
            
            if (this.selObj[i].selected == true)
            {
                var item = new Object();
                item[textStr] = currOption.text;
                item[valueStr] = currOption.value;
                selArr.push(item);
            }
        }
        
        return selArr;
    },

    // Get a copy of all the options with the specified text and value element names
    //  textStr : the name of the element to hold the text values
    //  valueStr : the name of the element to hold the value values
    GetAllArray : function(textStr, valueStr)
    {
        var arr = new Array();
    
        var count = this.selObj.options.length;
        for(var i = 0; i < count; ++i)
        {
            var currOption = this.selObj.options[i];
            
            var item = new Object();
            item[textStr] = currOption.text;
            item[valueStr] = currOption.value;
            arr.push(item);
        }
        
        return arr;
    },
    
    // Move the first selected item up one place
    MoveFirstSelectedUp : function ()
    {
        var index = this.selObj.selectedIndex;
        // only perform move up if an option is selected and is not already at top
        if (index > 0)
        {
            var selArr = this.GetAllArray('t', 'v');
            var selectedObj = selArr.splice(index, 1)[0];
            selArr.splice(index-1, 0, selectedObj);
            this.SetItems(selArr, 't', 'v');
            this.selObj.options[index-1].selected = true;
        }
    },
    
    // Move the first selected item down one place
    MoveFirstSelectedDown : function()
    {
        var index = this.selObj.selectedIndex;
        if (index != -1 && index < this.selObj.length-1)
        {
            var selArr = this.GetAllArray('t', 'v');
            var selectedObj = selArr.splice(index, 1)[0];
            selArr.splice(index+1, 0, selectedObj);
            this.SetItems(selArr, 't', 'v');
            this.selObj.options[index+1].selected = true;
        }
    }
};

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
// EZDoubleSelect - left and right select lists with control buttons
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------

function EZDoubleSelect(selLeftObj, selRightObj, btnAllToRightObj, btnSelToRightObj, btnSelToLeftObj, btnAllToLeftObj, hiddenValueObj, hiddenValueDelimStr)
{
    this.selLeftObj = selLeftObj;
    this.selRightObj = selRightObj;
    
    this.btnAllToRightObj = btnAllToRightObj;
    this.btnSelToRightObj = btnSelToRightObj;
    this.btnSelToLeftObj = btnSelToLeftObj;
    this.btnAllToLeftObj = btnAllToLeftObj;
    this.hiddenValueObj = hiddenValueObj;
    this.hiddenValueDelimStr = hiddenValueDelimStr;
    
    this.ezSelLeft = new EZSelect(this.selLeftObj);
    this.ezSelRight = new EZSelect(this.selRightObj);
    
    // NOTE : needed within button functions to get reference to this object
    var that = this;
    
    this.btnAllToRightObj.onclick = function(ev)
    {
        that.MoveAllToRight();
        return false;
    }
    
    this.btnSelToRightObj.onclick = function()
    {
        that.MoveSelectedToRight();
        return false;
    }
    
    this.btnSelToLeftObj.onclick = function()
    {
        that.MoveSelectedToLeft();
        return false;
    }
    
    this.btnAllToLeftObj.onclick = function()
    {
        that.MoveAllToLeft();
        return false;
    }
}
    
EZDoubleSelect.prototype =
{
    // Set new items for left select.
    // Only the items that are not currently on the right will actually be set to the left select.
    //  textStr : the name of the element holding the text values
    //  valueStr : the name of the element holding the value values
    SetLeftItems : function(itemArr, textStr, valueStr)
    {
        var rightItems = this.ezSelRight.GetAllArray('text', 'value');
        var diffItems = GetDiffArray(itemArr, rightItems, valueStr, 'value');
        
        this.ezSelLeft.SetItems(diffItems, textStr, valueStr);
    },
    
    // Set new items for right select.
    // Left items are cleared
    //  textStr : the name of the element holding the text values
    //  valueStr : the name of the element holding the value values
    SetRightItems : function(itemArr, textStr, valueStr)
    {
        this.ezSelRight.SetItems(itemArr, textStr, valueStr);
        this.ezSelLeft.RemoveAll();
        this.onEZDoubleSelectChanged();
    },
    
    // Get a copy arry of the options on the right with the specified text and value element names
    //  textStr : the name of the element to hold the text values
    //  valueStr : the name of the element to hold the value values
    GetSelectedItems : function(textStr, valueStr)
    {
        return this.ezSelRight.GetAllArray(textStr, valueStr);
    },
    
    // Get a copy arry of the options on the left with the specified text and value element names
    //  textStr : the name of the element to hold the text values
    //  valueStr : the name of the element to hold the value values
    GetAvailableItems : function(textStr, valueStr)
    {
        return this.ezSelRight.GetAllArray(textStr, valueStr);
    },
    
    MoveAllToRight : function()
    {
        var leftItems = this.ezSelLeft.GetAllArray('text', 'value');
        this.ezSelRight.AddRange(leftItems, 'text', 'value');
        this.ezSelLeft.RemoveAll();
        this.onEZDoubleSelectChanged();
    },
    
    MoveSelectedToRight : function()
    {
        var leftItems = this.ezSelLeft.GetSelectedArray('text', 'value');
        this.ezSelRight.AddRange(leftItems, 'text', 'value');
        this.ezSelLeft.RemoveRange(leftItems, 'value');
        this.onEZDoubleSelectChanged();
    },
    
    MoveSelectedToLeft : function()
    {
        var rightItems = this.ezSelRight.GetSelectedArray('text', 'value');
        this.ezSelLeft.AddRange(rightItems, 'text', 'value');
        this.ezSelRight.RemoveRange(rightItems, 'value');
        this.onEZDoubleSelectChanged();
    },
    
    MoveAllToLeft : function()
    {
        var rightItems = this.ezSelRight.GetAllArray('text', 'value');
        this.ezSelLeft.AddRange(rightItems, 'text', 'value');
        this.ezSelRight.RemoveAll();
        this.onEZDoubleSelectChanged();
    },
    
    // Event is raised when selected items on right side changes
    //  the hidden list is updated
    onEZDoubleSelectChanged : function()
    {
        var selectedArr = this.ezSelRight.GetAllArray('t', 'v');
        var text = '';
        
        var count = selectedArr.length;
        for (var i = 0; i < count; i++)
        {
            text += selectedArr[i].v;
            if (i < count - 1)
            {
                text += this.hiddenValueDelimStr;
            }
        }
        
        this.hiddenValueObj.value = text;
    }
};

var EZDisplayThumbnail = function(imageUrl)
{
    if (document.images)
    {
        document.getElementById('ezThumbnailImage').src = imageUrl;        
        showFlyout('ezDisplayThumbnailImage');
    }
}


//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
// EZSortParentChildSelect - parent select and child select, allow sorting on both
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------

function EZSortParentChildSelect(catIdMap, selParentObj, selChildObj, btnMoveUp, btnMoveDown, hiddenChildValueObj)
{
    this.catIdMap = catIdMap;
    this.selParentObj = selParentObj;
    this.selChildObj = selChildObj;
    this.btnMoveUp = btnMoveUp;
    this.btnMoveDown = btnMoveDown;
    this.hiddenChildValueObj = hiddenChildValueObj;
    
    this.ezSelParent = new EZSelect(this.selParentObj);
    this.ezSelChild = new EZSelect(this.selChildObj);
    
    // NOTE : needed within button functions to get reference to this object
    var that = this;
    
    this.selParentObj.onchange = function(ev)
    {
        that.ParentSelectChanged();
    }
    
    this.selChildObj.onchange = function(ev)
    {
        that.ChildSelectChanged();
    }
    
    this.btnMoveUp.onclick = function(ev)
    {
        that.MoveSelectedUp();
        return false;
    }
    
    this.btnMoveDown.onclick = function(ev)
    {
        that.MoveSelectedDown();
        return false;
    }
}

EZSortParentChildSelect.prototype =
{
    // parent select changed, refresh child select, disable up/down button
    ParentSelectChanged: function() {
        var catId = this.selParentObj.value;
        var subCats = this.catIdMap['cat_' + catId];

        this.ezSelChild.SetItems(subCats, 'title', 'id');

        this.btnMoveUp.disabled = 'disabled';
        this.btnMoveDown.disabled = 'disabled';
        this.btnMoveUp.className = "disabled";
        this.btnMoveDown.className = "disabled";
    },

    // child select changed, enable/disable up/down button
    ChildSelectChanged: function() {
        this.btnMoveUp.disabled = 'disabled';
        this.btnMoveDown.disabled = 'disabled';
        this.btnMoveUp.className = "disabled";
        this.btnMoveDown.className = "disabled";
        if (this.selChildObj.selectedIndex > 0) {
            this.btnMoveUp.disabled = '';
            this.btnMoveUp.removeAttribute("className");
            this.btnMoveUp.removeAttribute("class");
        }
        if (this.selChildObj.selectedIndex < this.selChildObj.options.length - 1) {
            this.btnMoveDown.disabled = '';
            this.btnMoveDown.removeAttribute("className");
            this.btnMoveDown.removeAttribute("class");
        }
    },

    // move child selected item up
    MoveSelectedUp: function() {
        this.ezSelChild.MoveFirstSelectedUp();
        this.ChildSelectChanged();
        this.onEZSortParentChildSelectChanged();
    },

    // move child selected item down
    MoveSelectedDown: function() {
        this.ezSelChild.MoveFirstSelectedDown();
        this.ChildSelectChanged();
        this.onEZSortParentChildSelectChanged();
    },

    // refresh sort order data stored in hiddenChildValueObj
    // format is "id,order;id,order;id,order;..."
    onEZSortParentChildSelectChanged: function() {
        var kvarr = this.hiddenChildValueObj.value.split(';');
        var karr = kvarr.map(function(el, index, arr) { return el.split(',')[0]; });
        for (var i = 0; i < this.selChildObj.options.length; i++) {
            var optval = this.selChildObj.options[i].value;
            var newkv = optval + ',' + (i + 1);
            var index = karr.indexOf(optval);
            if (index != -1) {
                kvarr[index] = newkv;
            }
            else {
                kvarr[kvarr.length] = newkv;
            }
        }
        this.hiddenChildValueObj.value = kvarr.join(";");
    }
}

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
// EZCategorySelect
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------

function EZCategorySelect(catIdMap, selCategoryObj, selSubCategoryObj, hiddenCat, onSubCatChanged)
{
    this.catIdMap = catIdMap;
    this.selCategoryObj = selCategoryObj;
    this.selSubCategoryObj = selSubCategoryObj;
    this.hiddenCat = hiddenCat;
    this.onSubCatChanged = onSubCatChanged;
    
    this.ezSelCat = new EZSelect(this.selCategoryObj);
    this.ezSelSubCat = new EZSelect(this.selSubCategoryObj);
    
    // NOTE : needed within button functions to get reference to this object
    var that = this;
    
    this.selCategoryObj.onchange = function(ev)
    {
        that.CategorySelectChanged();
    }
    
    this.selSubCategoryObj.onchange = function(ev)
    {
        that.SubCategorySelectChanged();
    }
}

EZCategorySelect.prototype =
{
    // parent select changed, refresh child select
    CategorySelectChanged : function()
    {
        var catId = this.selCategoryObj.value;
        var subCats = this.catIdMap['cat_' + catId];
        this.ezSelSubCat.SetItems(subCats, 'title', 'id');
    },
    
    SubCategorySelectChanged : function()
    {
        this.hiddenCat.value = this.selSubCategoryObj.value;
        if (this.onSubCatChanged)
        {
            this.onSubCatChanged(this.hiddenCat.value);
        }
    },
    
    Reset : function()
    {
        this.hiddenCat.value = '';
        this.ezSelCat.SetSelectedState(false);
        this.ezSelSubCat.RemoveAll();
    }
}

//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------
// EZItemSelectFull
//--------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------

function EZItemSelectFull(ezCatSelectObj, ezDoubleSelectObj, btnCancel, btnDone, serviceUrl, currentItemId, displayElementId)
{
    this.ezCatSelectObj = ezCatSelectObj;
    this.ezDoubleSelectObj = ezDoubleSelectObj;
    this.btnCancel = btnCancel;
    this.btnDone = btnDone;
    this.serviceUrl = serviceUrl;
    this.currentItemId = currentItemId;
    this.displayElementId = displayElementId;
    this.rollBackSelectArr = new Array();

    // NOTE : needed within button functions to get reference to this object
    var that = this;

    this.btnCancel.onclick = function(ev)
    {
        that.Cancel();
        return false;
    }
    
    this.btnDone.onclick = function(ev)
    {
        that.Done();
        return false;
    }

    this.ezCatSelectObj.onSubCatChanged = function(catId)
    {
        that.SubCatChanged(catId);
        return false;
    }
}

EZItemSelectFull.prototype =
{
    Cancel: function() {
        this.ezDoubleSelectObj.SetRightItems(this.rollBackSelectArr, 't', 'v');
        this.ezCatSelectObj.Reset();
        hideFlyout();
    },

    Done: function() {
        this.DisplaySelection(this.displayElementId);
        hideFlyout();
    },

    GetSelectedItems: function(textStr, valueStr) {
        return this.ezDoubleSelectObj.GetSelectedItems(textStr, valueStr);
    },

    Show: function(flyoutDivId) {
        this.rollBackSelectArr = this.ezDoubleSelectObj.GetSelectedItems('t', 'v');
        showFlyout(flyoutDivId);
    },

    SubCatChanged: function(catId) {
        FillDoubleSelectFromHTTP(this.serviceUrl + catId, this.ezDoubleSelectObj);
    },

    DisplaySelection: function() {
        var displayElem = document.getElementById(this.displayElementId);

        if (displayElem != null) {
            var selArr = this.ezDoubleSelectObj.GetSelectedItems('text', 'val');

            if (selArr.length > 0) {
                displayElem.innerText = "";
                displayElem.textContent = "";

                for (var i = 0; i < selArr.length; i++) {
                    if (selArr.length > i && i > 0) {
                        displayElem.innerText += ', ';
                        displayElem.textContent += ', ';
                    }
                    displayElem.innerText += selArr[i].text;
                    displayElem.textContent += selArr[i].text;
                }
                displayElem.style.display = "block";
            }
            else {
                //displayElem.style.display = "none";
                displayElem.innerText = "None selected";
                displayElem.textContent = "None selected";
            }
        }
    }
}

function EZRewardSelectFull(lstRewardCategory, ezDoubleSelectObj, btnCancel, btnDone, serviceUrl)
{
    this.lstRewardCategory = lstRewardCategory;
    this.ezDoubleSelectObj = ezDoubleSelectObj;
    this.btnCancel = btnCancel;
    this.btnDone = btnDone;
    this.serviceUrl = serviceUrl;
    this.rollBackSelectArr = new Array();

    // NOTE : needed within button functions to get reference to this object
    var that = this;

    this.btnCancel.onclick = function(ev)
    {
        that.Cancel();
        return false;
    }
    
    this.btnDone.onclick = function(ev)
    {
        that.Done();
        return false;
    }

    this.lstRewardCategory.onchange = function(ev)
    {
        that.RewardCatChanged();
        return false;
    }
}

EZRewardSelectFull.prototype =
{
    Cancel : function()
    {
        this.ezDoubleSelectObj.SetRightItems(this.rollBackSelectArr,'t','v');
        hideFlyout();
    },
    
    Done : function()
    {
        DisplaySelectedRewards();
        hideFlyout();
    },

    GetSelectedItems : function(textStr, valueStr)
    {
        return this.ezDoubleSelectObj.GetSelectedItems(textStr, valueStr);
    },
    
    Show : function(flyoutDivId)
    {
        this.rollBackSelectArr = this.ezDoubleSelectObj.GetSelectedItems('t', 'v');
        showFlyout(flyoutDivId);
    },

    RewardCatChanged : function()
    {
        var catId = this.lstRewardCategory.value;
        FillDoubleSelectFromHTTP(this.serviceUrl + catId, this.ezDoubleSelectObj);
    }
}

///////////EZ Availabilty Companies select
function EZAvailabilityCompanySelect_DoneClicked(ezDblSelInstance)
{
    var lblAvailableToCompanies = document.getElementById(ezAvailability_lblAvailableToCompanies_ClientID);
    var spanCompanySelectListing = document.getElementById(ezAvailability_spanCompanySelectListing_ClientID);    
    var selectedArr = ezDblSelInstance.GetSelectedItems('t', 'v');
    var selectedArrLength = selectedArr.length;
    
    // set title to "Restricted" or "All Companies"
    if(selectedArrLength > 0)
    {
        lblAvailableToCompanies.setAttribute("innerText", "Restricted");
        lblAvailableToCompanies.setAttribute("textContent", "Restricted");
    }
    else
    {
        lblAvailableToCompanies.setAttribute("innerText", "All Companies");
        lblAvailableToCompanies.setAttribute("textContent", "All Companies");
    }
    
    // clear, then set list of companies
    spanCompanySelectListing.innerHTML = '';
    for(var i = 0; i < selectedArrLength; i++)
    {
        if (i > 0)
        {
            spanCompanySelectListing.innerHTML += ', ';
        }
        spanCompanySelectListing.innerHTML += selectedArr[i].t;
    }
    
    hideFlyout();
    
    return false;
}

function DisplaySelectedItems(listContainerElemId, selectId) {
    var listContainer = document.getElementById(listContainerElemId);
    var select = document.getElementById(selectId);
    if (select != null && listContainer != null) {
        if (select.options.length > 0) {
            listContainer.innerText = '';
            listContainer.textContent = '';
            for (var i = 0; i < select.options.length; i++) {
                if (select.options.length > i && i > 0) {
                    listContainer.innerText += ", ";
                    listContainer.textContent += ", ";
                }
                listContainer.innerText += select.options[i].text;
                listContainer.textContent += select.options[i].text;
            }
            listContainer.style.display = "block";
        }
        else {
            //listContainer.style.display = "none";
            listContainer.innerText = "";
            listContainer.textContent = "";
        }
    }
}

function DisplayPrimaryProducts()
{
    DisplaySelectedItems("primaryProductList", "ctl00_ContentPlaceHolderShowForm_ezPrimaryProductSelect_selRight");
}

function DisplaySelectedJobFunctions()
{
    DisplaySelectedItems("jobFunctionList", "ctl00_ContentPlaceHolderShowForm_ezJobFunctionSelect_selRight");
}

function DisplaySelectedUserTypes()
{
    DisplaySelectedItems("lblUserTypeList", "ctl00_ContentPlaceHolderShowForm_ezUserStatusTypesSelect_selRight");
}

function DisplayLearningPlans()
{
    DisplaySelectedItems("learningPlansList", "ctl00_ContentPlaceHolderShowForm_cntrLearningPlanSelect_selRight");
}

function DisplaySelectedRewards()
{
    DisplaySelectedItems("rewardTitles", "ctl00_ContentPlaceHolderShowForm_cntrRewardSelect_ctrlEZDoubleSelect_selRight");
}

function DisplaySelectedContests()
{
    DisplaySelectedItems("contestTitles", "ctl00_ContentPlaceHolderShowForm_cntrContestSelect_selRight");
}