$j(document).ready(function() {
    setTimeout('keepAlive()', 180000);
    
    $j("#globalLoading").bind("ajaxSend", function(){
        $j(this).show();
//        $j('body').css('cursor', 'progress');
    }).bind("ajaxComplete", function(){
        $j(this).hide();
//        $j('body').css('cursor', 'auto');
    });
    
    
    $j("input[type=image]").bind("ajaxSend", function(){
        $j(this).addClass('ui-state-disabled');
        $j(this).attr('disabled', 'disabled');
        $j('body').css('cursor', 'progress');
    }).bind("ajaxComplete", function(){
        $j(this).removeClass('ui-state-disabled');
        $j(this).attr('disabled', '');
        $j('body').css('cursor', 'auto');
    });

    $j(window).bind("ajaxComplete", function(event, XMLHttpRequest, ajaxOptions) {
        if(XMLHttpRequest.responseText == 'loginRequired') {
            this.location.reload();
        }
    });
});


$j.fn.qtip.styles.heinekenError = {
    name: 'red', // Inherit from preset style
    color: 'white',
    background: '#9E0B0F',
    border: {
        width: 1,
        radius: 6,
        color: '#9E0B0F'
    },
    tip: 'bottomLeft'
};

function keepAlive()
{
    $j.ajax({
        type: 'get',
        url: '/default/index/keep-alive'
    });

    setTimeout('keepAlive()', 180000);
}
