Itransition.setDocumentTitle({project: 'LSBF InterActive'})

Ext.BLANK_IMAGE_URL = document.baseURI + 'includes/ext/resources/images/default/s.gif'
Ext.AJAX_LOADING_URL = document.baseURI + 'includes/interactive/images/ajax-loader.gif'

Ext.Ajax.defaultHeaders = {
    'Accept': 'application/json'
};

Ext.Ajax.on('requestcomplete', function(connection, response, options) {
    if (options.isUpload) {
        return; // response are bogus if connection used to upload file
    }
    
    // trim Content-Type because IE7 adds newline to the end
if (typeof response.getResponseHeader['Content-Type'] !== 'undefined') {

    if (response.getResponseHeader['Content-Type'].trim() == 'application/json') {
        response.responseObject = Ext.util.JSON.decode(response.responseText);
    }

}

});

(function(){
    Ext.Ajax.on('requestexception', function(conn, response) {
       if (response.status === 403) {
           if (typeof response.getResponseHeader['X-Location'].trim() !== 'undefined') {
               document.location = response.getResponseHeader['X-Location']
           }
       }
    })
})()

Ext.form.Field.prototype.msgTarget = 'side'; // turn on validation errors beside the field globally

Ext.QuickTips.init()

// Looks like ColumnLayout doesn't count width of target element properly in IE, so we add explicit scrollOffset
Ext.layout.ColumnLayout.override({
    //scrollOffset: Ext.isIE ? 17 : 0
});

if (!Array.prototype.each) {
    /**
     * Executes the specified function once for every item in the array, passing each
     * item as the first, index as second and array length as third parameter.
     * Returning false from the function will stop the iteration.
     * @param {Function} fn The function to execute for each item.
     * @param {Object} scope (optional) The scope in which to execute the function.
     */
    Array.prototype.each = function(fn, scope) {
        var items = [].concat(this); // each safe for removal
        for(var i = 0, len = items.length; i < len; i++){
            if(fn.call(scope || items[i], items[i], i, len) === false){
                break
            }
        }
    }
}