Native.implement([Element, Document], {
    getElementsByClassName: function(a) {
        return this.getElements('.' + a)
    },
    getElementsBySelector: function(a) {
        return this.getElements(a)
    }
});
Elements.implement({
    filterByTag: function(a) {
        return this.filter(a)
    },
    filterByClass: function(a) {
        return this.filter('.' + a)
    },
    filterById: function(a) {
        return this.filter('#' + a)
    },
    filterByAttribute: function(a, b, c) {
        return this.filter('[' + a + (b || '') + (c || '') + ']')
    }
});
var $E = function(a, b) {
    return ($(b) || document).getElement(a)
};
var $ES = function(a, b) {
    return ($(b) || document).getElements(a)
};
Class.empty = $empty;
Class.prototype.extend = function(a) {
    a.Extends = this;
    return new Class(a)
};
window.extend = document.extend = function(a) {
    for (var b in a) this[b] = a[b]
};
window[Browser.Engine.name] = window[Browser.Engine.name + Browser.Engine.version] = true;
window.ie = window.trident;
window.ie6 = window.trident4;
window.ie7 = window.trident5;
$A = function(a, b, c) {
    if (Browser.Engine.trident && $type(a) == 'collection') {
        b = b || 0;
        if (b < 0) b = a.length + b;
        c = c || (a.length - b);
        var d = [];
        for (var i = 0; i < c; i++) d[i] = a[b++];
        return d
    }
    b = (b || 0) + ((b < 0) ? a.length: 0);
    var e = ((!$chk(c)) ? a.length: c) + b;
    return Array.prototype.slice.call(a, b, e)
};
(function() {
    var a = [Array, Function, String, RegExp, Number];
    for (var i = 0, l = a.length; i < l; i++) a[i].extend = a[i].implement
})();
Event.keys = Event.Keys;
Element.extend = Element.implement;
Elements.extend = Elements.implement;
Element.implement({
    getFormElements: function() {
        return this.getElements('input, textarea, select')
    },
    replaceWith: function(a) {
        a = $(a);
        this.parentNode.replaceChild(a, this);
        return a
    },
    removeElements: function() {
        return this.dispose()
    }
});
Element.alias({
    'dispose': 'remove',
    'getLast': 'getLastChild'
});
Element.implement({
    getText: function() {
        return this.get('text')
    },
    setText: function(a) {
        return this.set('text', a)
    },
    setHTML: function() {
        return this.set('html', arguments)
    },
    getHTML: function() {
        return this.get('html')
    },
    getTag: function() {
        return this.get('tag')
    }
});
Element.implement({
    setOpacity: function(a) {
        return this.set('opacity', a)
    }
});
Fx.implement({
    custom: function(a, b) {
        return this.start(a, b)
    },
    clearTimer: function() {
        return this.cancel()
    },
    stop: function() {
        return this.cancel()
    }
});
Fx.Base = Fx;
Fx.Styles = Fx.Morph;
Element.implement({
    effects: function(a) {
        return new Fx.Morph(this, a)
    }
});
Fx.Scroll.implement({
    scrollTo: function(y, x) {
        return this.start(y, x)
    }
});
Fx.Style = function(a, b, c) {
    return new Fx.Tween(a, $extend({
        property: b
    },
    c))
};
Element.implement({
    effect: function(a, b) {
        return new Fx.Tween(this, $extend({
            property: a
        },
        b))
    }
});
Array.implement({
    copy: function(a, b) {
        return $A(this, a, b)
    }
});
Array.alias({
    erase: 'remove',
    combine: 'merge'
});
Function.extend({
    bindAsEventListener: function(a, b) {
        return this.create({
            'bind': a,
            'event': true,
            'arguments': b
        })
    }
});
Function.empty = $empty;
Hash.alias({
    getKeys: 'keys',
    getValues: 'values',
    has: 'hasKey',
    combine: 'merge'
});
var Abstract = Hash;
Object.toQueryString = Hash.toQueryString;
var XHR = new Class({
    Extends: Request,
    options: {
        update: false
    },
    initialize: function(a, b) {
        this.parent(b);
        this.url = a
    },
    request: function(a) {
        return this.send(this.url, a || this.options.data)
    },
    send: function(a, b) {
        if (!this.check(arguments.callee, a, b)) return this;
        return this.parent({
            url: a,
            data: b
        })
    },
    success: function(a, b) {
        a = this.processScripts(a);
        if (this.options.update) $(this.options.update).empty().set('html', a);
        this.onSuccess(a, b)
    },
    failure: function() {
        this.fireEvent('failure', this.xhr)
    }
});
var Ajax = XHR;
JSON.Remote = new Class({
    options: {
        key: 'json'
    },
    Extends: Request.JSON,
    initialize: function(a, b) {
        this.parent(b);
        this.onComplete = $empty;
        this.url = a
    },
    send: function(a) {
        if (!this.check(arguments.callee, a)) return this;
        return this.parent({
            url: this.url,
            data: {
                json: Json.encode(a)
            }
        })
    },
    failure: function() {
        this.fireEvent('failure', this.xhr)
    }
});
Cookie.set = function(a, b, c) {
    return new Cookie(a, c).write(b)
};
Cookie.get = function(a) {
    return new Cookie(a).read()
};
Cookie.remove = function(a, b) {
    return new Cookie(a, b).dispose()
};
Element.implement({
    getValue: function() {
        return this.get('value')
    },
    getSelected: function() {
        return new Elements($(this).getElements('option').filter(function(a) {
            return a.selected
        }))
    }
});
Json = new Hash({
    evaluate: function(a, b) {
        return JSON.decode(a, (b || false))
    },
    toString: function(a) {
        return JSON.encode(a)
    }
});
window.onDomReady = function(a) {
    return this.addEvent('domready', a)
};
