/*
 * AJAX stuff for JQuery
 *
 * Version: $Revision: 1.6 $
 * Author: BeSite <info@besite.nl>
 * Copyright 2008 BeSite
 */

var BslAjax = {
    count: 0,
    waitMsg: "Een moment geduld a.u.b.",
    BlockUI: function()
    {
        if ( this.count == 0 )
        {
            // don't use the div itself calling multiple times will give error
            $.blockUI( { message: $('<div class="JQueryAjaxMessage"><h1><img src="/bsl/img/loading/big.gif" alt="[*]" style="vertical-align: middle; margin-right: 10px;" title="[*]" height="32" width="32">' + this.waitMsg + '</h1></div>') } );
        }
        this.count++;
    },
    
    UnblockUI: function()
    {
        this.count--;
        if ( this.count <= 0 )
        {    
            $.unblockUI();
            this.count = 0;
        }
    }
}

$(document).ajaxError
(
    function(request, settings)
    { 
        alert( msgAjaxInvalidReply );
        BslAjax.UnblockUI();
    }
);

$(document).ajaxStart
(
    function(request, settings)
    {
        BslAjax.BlockUI();
    }
);

$(document).ajaxStop
(
    function(request, settings)
    {
        BslAjax.UnblockUI();
    }
);

