//
// Mootools orgiginal compat
//

//(function(){
//    var natives = [Array, Function, String, RegExp, Number];
//    for (var i = 0, l = natives.length; i < l; i++) natives[i].extend = natives[i].implement;
//})();
//
//window.extend = document.extend = function(properties){
//    for (var property in properties) this[property] = properties[property];
//};

// Required by the assignments below
window[Browser.Engine.name] = window[Browser.Engine.name + Browser.Engine.version] = true;

// Used by Dashboard certificate alert (not implemented)
//window.ie = window.trident;

// Used by fx.js, EduPro data entry
window.ie6 = window.trident4;

// Used by EduPro data entry
window.ie7 = window.trident5;

// Used in fx.js, history_manager.js
Class.empty = function(){};

// Used by history_manager.js
Array.implement({
    copy: function(start, length){
        return $A(this, start, length);
    }
});

// Used all over Sentral - our main obstacle to upgrading from 1.11!
Element.implement({

    getText: function(){
        return this.get('text');
    },

    setText: function(text){
        return this.set('text', text);
    },

    setHTML: function(){
        return this.set('html', arguments);
    },

    getHTML: function(){
        return this.get('html');
    },

    getTag: function(){
        return this.get('tag');
    },

    getValue: function() {
        return this.getProperty('value');
    }
});


// Used all over Sentral - our main obstacle to upgrading from 1.11!
var Ajax = new Class({

    Extends: Request,

    options: {
        update: false
    },

    initialize: function(url, options){
        this.parent(options);
        this.url = url;
    },

    request: function(data){
        return this.send(this.url, data || this.options.data);
    },

    send: function(url, data){
        if (!this.check(arguments.callee, url, data)) return this;
        return this.parent({url: url, data: data});
    },

    success: function(text, xml){
        if (this.options.update) $(this.options.update).empty().set('html', text);
        text = this.processScripts(text);
        this.onSuccess(text, xml);
    },

    failure: function(){
        this.fireEvent('failure', this.xhr);
    }

});

// Still used in EduPro (expanders)
Fx.implement({
    stop: function(){
        return this.cancel();
    }
});

// Still used in ResourceMan, WebPxP
Fx.Style = function(element, property, options){
    return new Fx.Tween(element, $extend({property: property}, options));
};

// Still used in EduPro
Element.implement({
    effect: function(property, options){
        return new Fx.Tween(this, $extend({property: property}, options));
    }
});

// Still used in Messaging, TimePlan, WebAttend, WebPxP
var $ES = function(selector, filter){
    return ($(filter) || document).getElements(selector);
};




//
// Sentral change
// Added for backward compatibility
//
// Used in fx.js for dialogs
//
Request.implement({
    getAllResponseHeaders: function(){
        try {return this.xhr.getAllResponseHeaders();} catch(e){};
        return null;
    }
})

