$(document).ready(function() {
    $(".programms a").click(function() {
        var programms_str = '';
        var count = 0;
        var selected_id = $(this).attr('id');
        var table = $(this).parent().parent().parent().parent();

        var id = 0;
        table.find('a').each(function(i) {
            id = $(this).attr('id');
            if (selected_id != id) {            
                programms_str += id + ',';
                ++count;
            }
        });
        if (!count) return true;
        
        $.get(
            '/ajax_index.php?module=Link&action=saveProgrammsList',
            {
                top_link:  table.prev().find('a').html(),
                programms: programms_str
            }, function(data) {}
        );
        
        return true;
    });
});

