var selectedTopic = null



$(document).ready(function () {
    targetsIds.forEach(function (value) {
        addListener("A_TARGET_" + value)
    })
    addListener("common-topic")
    adjustLeftBarSize()
})

 function addListener(id) {
    try {
        $("#" + id).click(function () {

            if (selectedTopic == id) {
                return
            }
            if (selectedTopic != null) {
                $("#" + selectedTopic + "-items").hide()
            }
            selectedTopic = id
            $("#" + selectedTopic + "-items").show()
        })
    } catch (e) {
        console.error(e)
    }
}

function updateContent(url) {
    $.get( url, function( data ) {
        $( "#content-pane" ).html( data );
        $(window).scrollTop(0);
    });
}

function showPopup(url){
    $.get( url, function( data ) {
        var dialogDiv = $( "#dialog" )
        if(dialogDiv.length ==0 ){
            $("body").append($("<div id='dialog'>"))
            dialogDiv = $( "#dialog" )
        }
        $("#dialog").html(data)
        dialogDiv.dialog({})
    });
}

function adjustLeftBarSize() {
    $("#left-bar").height($(window).height()-80)
}