if (typeof(v6js_init_event_handler) == 'undefined') {
    var v6js_init_event_handler = true;

    // :NOTE: Entire content of event_handler.js is only loaded if not previously done



    // Methods currently Handled
    var ONLOAD      = 1;
    var ONRESIZE    = 2;
    var ONUNLOAD    = 3;
    var ONMOUSEUP   = 4;
    var ONMOUSEDOWN = 5;

    /*
     * Onload_Handler()
     */

    function Event_Handler ()
    {
        this.methods = new Array();

        /*
         * addMethod()
         */

        this.addMethod = function (event, method)
        {
            // Set the window events
            if ((event == ONLOAD) && (window.onload != runOnloadEvents)) {
                var orig_onload = window.onload;
                this.methods[this.methods.length] = new Event_Method(ONLOAD, orig_onload);
                window.onload = runOnloadEvents;
            }
            
            return this.methods[this.methods.length] = new Event_Method(event, method);
        }


        /*
         * runOnloadMethods()
         */

        this.runMethods = function (for_event)
        {
            if (this.methods.length) {
                for (i in this.methods) {
                    if (typeof(this.methods[i]) == 'function') continue;

                    if (this.methods[i].event == for_event) {
                        // Run and store the return value of each onload method
                        if (typeof(this.methods[i].method) == 'function') {
                            this.methods[i].return_val = this.methods[i].method();
                        } else if (typeof(this.methods[i].method) == 'string') {
                            this.methods[i].return_val = (eval(this.methods[i].method));
                        }
                    }
               }
            }
       }


    }



    /*
     * Event_Method()
     */

    function Event_Method (event, method)
    {
        this.event      = event;
        this.method     = method;
        this.return_val = null;

        this.getReturnVal = function ()
        {
            return this.return_val;
        }
    }



    // Create the event handler and onload event
    var event_handler  = new Event_Handler();



    // The only onload, onresize and onunload functions ever to be called via window.*
    function runOnloadEvents() {
        event_handler.runMethods(ONLOAD);
    }

    function runOnresizeEvents() {
        event_handler.runMethods(ONRESIZE);
    }

    function runOnunloadEvents() {
        event_handler.runMethods(ONUNLOAD);
    }

    function runOnmouseupEvents() {
        event_handler.runMethods(ONMOUSEUP);
    }

    function runOnmousedownEvents() {
        event_handler.runMethods(ONMOUSEDOWN);
    }

    // Set the window events
    if (window.onload) {
        event_handler.addMethod(ONLOAD, window.onload);
    }

    window.onload = runOnloadEvents;
    window.onresize = runOnresizeEvents;
    window.onunload = runOnunloadEvents;

    // Set the document events
    document.onmouseup    = runOnmouseupEvents;
    document.onmousedown  = runOnmousedownEvents;



    // :NOTE: Entire content of event_handler.js is now loaded, and won't be asked for again

}
