﻿function ApplyImageToElement(imageString, e)
{
    if (e === null || e === undefined)
    { return; }
    
    var element = $get(e);
    
    if (element === null || e === undefined)
    { return; }
    
    element.innerHTML = imageString;
}


function getDisplayNamesForItems(items, callback)
{
    var userNames = new Array();
    for(var i = 0; i < items.Result.length; i++)
        userNames[i] = items.Result[i].UserID;

    SharpLogic.Boost.Forums.SiteService.GetUserDisplayNames(userNames, onDisplayNames, null, items);
    
    function onDisplayNames(userDisplayNames, context, sender)
    {
        var customTemplateDictionary = new Array();
        for(var i = 0; i < userDisplayNames.length; i++)
        {
            var dictionaryElement = {};
            dictionaryElement['#DisplayName#'] = userDisplayNames[i];
            customTemplateDictionary[i] = dictionaryElement;
        }
        callback(context, customTemplateDictionary);
    }
}

function LimitText(textField, msg, maxLength)
{
    if (textField.value.length > maxLength)
    {
        if (confirm(msg))
        {
            textField.value = textField.value.substring(0, maxLength);    
            return true;
        }
        
        return false;
    }
}