﻿Ext.namespace('Hardcore', 'Hardcore.AjaxAPI');

if(typeof Hardcore == 'undefined')
{
    Hardcore = Ext.Hardcore;
}

Ext.namespace('C4', 'C4.Util');

if(typeof C4 == 'undefined')
{
    C4 = Ext.C4;
}

Ext.namespace('Utility');

if(typeof Utility == 'undefined')
{
    Utility = Ext.Utility;
}



Utility.AjaxProConfig = function()
{
    Ext.onReady(this.Initialize.createDelegate(this));
}

Ext.extend(Utility.AjaxProConfig, Ext.util.Observable,
{
    Initialize : function()
    {
        this.addEvents({"onData": true});
        
        
        AjaxPro.onError = this.onError.createDelegate(this);
        
        AjaxPro.onTimeout = this.onTimeout.createDelegate(this);
        
        AjaxPro.timeoutPeriod = 30 * 1000; //15000;
        
        AjaxPro.onLoading = this.onLoading.createDelegate(this);
        
    },
    
    onLoading : function(b)
    {
        if (b)
        {
            Functions.ShowLoader(true);
        }
        else
        {
            Functions.ShowLoader(false);
        }
    },
    
    onError : function(response)
    {
        alert('(From Utility.AjaxProConfig.onError) There was an error message from the AJAX call:\n\n' + response.error.Message);
    },
    
    onTimeout : function(ms, request)
    {
        //request.method C# method name
        AjaxPro.abort;
        alert('AjaxPro timeout on: ' + request.method);
        return true;
    }
});

var apc = new Utility.AjaxProConfig();
