function num_notificaciones() {
    // hack para que no salga el loader ajax
    $('#ajax-loader-body').hide();
    $('#ajax-loader-body').off(".mine");
    
    send = {'referer' : 'common', 'action': 'get_numero_notificaciones', 'data' : {}}                
    $.getJSON(ajax_dispatcher, send, function(data) {
        if(data.sucess == 'ok') {
            notificaciones_switch = $("#notificaciones-switch");
            notificaciones_switch.text(data.data.numero_notificaciones);
            if(data.data.numero_notificaciones > 0) {
                notificaciones_switch.addClass("success");
            }
            else {
                notificaciones_switch.removeClass("success");
            }
        }
    });
    
    // hack (2da parte)
    $('#ajax-loader-body').on("ajaxStart.mine", function() { $(this).show(); });
    $('#ajax-loader-body').on("ajaxStop.mine", function() { $(this).hide(); });    
}
    
$(document).ready(function() {
    ajax_dispatcher = "/ajax/dispatcher.php";
      
    $("#notificaciones-switch").click(function(e) {
        e.preventDefault();
        
        if($("ul#notificaciones").css('display') == 'none') {
            send = {'referer' : 'common', 'action': 'get_notificaciones_dropdown', 'data' : {}}
            $.get(ajax_dispatcher, send, function(data) {
                $("ul#notificaciones").html(data);
                num_notificaciones();
            });
        }
    });    
    
    intervalo_notificaciones = setInterval("num_notificaciones()", 20000);
});
