/*document.write('<script type="text/javascript" src="js/jquery.accordion.js"></script>');*/

$(document).ready(function() {
    /*$('#rightmenu').accordion({ 
    header: '.expand', 
    event: 'click', 
    selectedClass: 'selected',
    active: '.selected',
    autoheight: false/,
    navigation: true,
    fillSpace: true, 
    animated: 'easeslide' /
    });*/
});

function changeImg(elm_id, img) {
    $("#" + elm_id).attr("src", img);
}

function showFaq(question, answer) {
    $("#SelectedQuestion").html(question);
    $("#SelectedAnswer").html(answer);
    $("#ShowFaq").show();
}

function filterFaqs(category) {
    $("#ShowFaq").hide();

    //Highlight the selected category
    $("a").each(function(i, el) {
        var aCategory = $(el).attr("category");
        if (aCategory != null) {
            $(el).attr("class", aCategory == category ? "selected" : "");
        }
    });

    //And show/hide the FAQs
    $("p").each(function(i, el) {
        var categories = $(el).attr("categories");
        if (categories != null) {
            var isfound = false;
            $.each(categories.split(","), function(i, item) {
                isfound |= $.trim(item) == $.trim(category);
            });
            isfound ? $(el).show() : $(el).hide();
        }
    });
}

function showCategories() {
    $("#divCategories").show();
    $("#showCategoriesLink").attr("class", "selected");
    $("#showFeaturedFaqsLink").attr("class", "");
    $("#ShowFaq").hide();

    //hardcoded!
    filterFaqs('Communication');
}

function showFeaturedFaqs() {
    $("#divCategories").hide();
    $("#showCategoriesLink").attr("class", "");
    $("#showFeaturedFaqsLink").attr("class", "selected");
    $("#ShowFaq").hide();

    $("p").each(function(i, el) {
        var isFeatured = $(el).attr("isFeatured");
        if (isFeatured != null) {
            (isFeatured == "true") ? $(el).show() : $(el).hide();
        }
    });
}
