﻿// Blogs module functions that can be used in any blogs module pages but not elsewhere in the site

function DisplayCategories(strBlogId,strCategories) {
    strCategoriesLinks = "";
    arrCategories = strCategories.split(",");
    for (var i = 0; i < arrCategories.length; i++) {
        arrCategories[i] = Trim(arrCategories[i]);
        if (strCategoriesLinks != "") {
            strCategoriesLinks += ", ";
        }
        strCategory = arrCategories[i].replace(" ", "-"); // Only replaces the first space. Needs a regex?
        strCategoriesLinks += '<a href="/blogs/' + strBlogId + '/category/' + strCategory + '.aspx">' + arrCategories[i] + '</a>';
    }
    return strCategoriesLinks;
}

function DisplayCategoriesElement(strBlogId, strCategories, strElementId) {
    if (document.getElementById(strElementId) && document.getElementById(strElementId).innerHTML) {
        document.getElementById(strElementId).innerHTML = DisplayCategories(strBlogId, strCategories);
    }
}
