if (typeof Event._onloadInit == 'undefined') {
    Object.extend(Event, {
        _observe: Event.observe,
        observe: function(element, name, observer, useCapture) {
            if (name == 'load') {
                this._observeLoad(observer);
            } else {
                this._observe(element, name, observer, useCapture);
            }
        },
        _observeLoad: function(observer) {
            if (typeof this._load_observers == 'undefined') {
                this._load_observers = [];
            }
            this._load_observers.push(observer);
        },
        _runOnload: function() {
            if (typeof this._load_observers == 'undefined') return;
            var func;
            while (func = this._load_observers.shift()) {
                if (typeof func == 'function') {
                    func();
                } else {
                    // rely on this and ill kill you - love, greg
                    eval(func);
                }
            }
        },
        _onloadInit: function() {
            if (/WebKit/i.test(navigator.userAgent)) {
                this._onload_timer = setInterval((function() {
                    if (/loaded|complete/.test(document.readyState)) {
                        clearInterval(this._onload_timer);
                        this._runOnload();
                    }
                }).bind(this), 10);
            } else if (window.addEventListener) {
                if (document.addEventListener) {
                    document.addEventListener("DOMContentLoaded", this._runOnload.bind(this), false);
                } else {
                    window.addEventListener("load", this._runOnload.bind(this), false);
                }
            } else if (document.addEventListener) {
                document.addEventListener("load", this._runOnload.bind(this), false);
            } else if (window.attachEvent) {
                /*@cc_on @*/
                /*@if (@_win32)
                    document.write('<script id="__ie_onload" defer src="javascript:void(0)"></script>');
                    var script = document.getElementById("__ie_onload");
                    script.onreadystatechange = function() {
                        if (this.readyState == "complete") {
                           Event._runOnload();
                        }
                    };
                /*@end @*/
            } else {
                if (window.onload) this._observeLoad(window.onload);
                window.onload = this._runOnload.bind(this);
            }
        }
    });
    Event._onloadInit();
}
