$j(document).ready(function() {
    setTimeout('keepAlive()', 120000);
    
    $j("#globalLoading").bind("ajaxSend", function(){
        $j(this).show();
//        $j('body').css('cursor', 'progress');
    }).bind("ajaxComplete ajaxError", 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 ajaxError ", 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('.closeCustomDialog').live('click', function() {
        $j('.customDialog').fadeOut('normal', function() {
            $j(this).children('.popUpContainer').remove();
            $j(this).dialog('close').remove();
        });
        
        return false;
    });
    
    
    $j('.halfDisabled').css('opacity', 0.5);
    $j('.disabled').live('click', function() {
        return false;
    });
});



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

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