function bindNewsLinks(closeWindowText) {
    $(".show-news-link").each(function() {

        var href = this.href;
                   this.href = "javascript:;;";

        this.onclick = function() {
            showNewsContent(href, closeWindowText);
        }
    });

    $(".show-analytics-link").each(function() {

        var href = this.href;
                   this.href = "javascript:;;";

        this.onclick = function() {
            showAnalyticsContent(this, href, closeWindowText);
        }
    });
}


var newsContentStatus = 0;


function showAnalyticsContent(link, href, closeLinkText) {
    if (newsContentStatus == 1) // loading
        return;

    newsContentStatus = 1;
    closeNewsContent();

    $.post(href, {checkAccess: 1}, function(content) {
        if (content && content.length) {
            $("BODY").append(content);
            
            newsContentStatus = 2;
            $("#modal-box").modal();

            $("a").each(function() {
                this.onfocus = function() {
                    if (this.blur) this.blur()
                };
            });

        }
        else {
            newsContentStatus = 0;

            link.href = href;
            $(link).attr("target", "_blank");
            
            link.onclick = function() {};

            var formId = "analyticsDownloadForm" + $(link).attr("itemId");
            var form = $("#" + formId);
                form.submit();
        }
    });
}





function showNewsContent(href, closeLinkText) {
    if (newsContentStatus == 1) // loading
        return;
    
    newsContentStatus = 1;
    closeNewsContent();
    

    $.post(href, function(content) {
        $("BODY").append(content);
            
        newsContentStatus = 2;
        
        $("#modal-box").modal();

        $("a").each(function() {
            this.onfocus = function() {
                if (this.blur) this.blur()
            };
        });

    });
}


function closeNewsContent() {
    $.modal.close();
    $("#modal-box").remove();
}