RESULT_ERROR = 'error'
RESULT_OK = 'ok'

function blockWait() {
    //$.blockUI( '<div class="block_wait"> Just a moment...</div>' );

    if (!document.getElementById('jquery_loading')) {
        var obj = document.createElement('span');
        obj.id = 'jquery_loading';

        var txt = document.createTextNode('Loading...');
        obj.appendChild(txt);

        document.body.appendChild(obj);
    }
    
    $('#jquery_loading').slideDown('fast');
}

function unblock() {
    $('#jquery_loading').slideUp('fast');
}

function loadPartialList(url, pattern, page) {
    var url = url + '?p=' + page;

    $(pattern).load(url);
}

// Triggers setup

$(document).ready(function() {
  $(document).ajaxStart(function() {
//    $(this).show();
    blockWait()
  }).ajaxStop(function() {
    //$(this).hide();
    unblock()
  }).ajaxError(function(){
    if (window.console && window.console.error) {
        console.error(arguments);
    }

    unblock()
  });
});

/*
$(document).ajaxError(function(){
    if (window.console && window.console.error) {
        console.error(arguments);
    }

    unblock()
});

$(document).ajaxSuccess(function(){
    unblock()
});

$(document).beforeSend(function(){
    blockWait()
});

$(document).ajaxStart(function(){
    blockWait()
});
*/
