// The functions to execute on DOM ready
        readyList = [],
 
+       // The ready event handler
+       DOMContentLoaded,
+
        // Save a reference to some core methods
        toString = Object.prototype.toString,
        hasOwnProperty = Object.prototype.hasOwnProperty,
        ready: function() {
                // Make sure that the DOM is not already loaded
                if ( !jQuery.isReady ) {
+                       // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
                        if ( !document.body ) {
                                return setTimeout( jQuery.ready, 13 );
                        }
                // Mozilla, Opera and webkit nightlies currently support this event
                if ( document.addEventListener ) {
                        // Use the handy event callback
-                       document.addEventListener( "DOMContentLoaded", function DOMContentLoaded() {
-                               document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
-                               jQuery.ready();
-                       }, false );
+                       document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
                        
                        // A fallback to window.onload, that will always work
                        window.addEventListener( "load", jQuery.ready, false );
                } else if ( document.attachEvent ) {
                        // ensure firing before onload,
                        // maybe late but safe also for iframes
-                       document.attachEvent("onreadystatechange", function onreadystatechange() {
-                               // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
-                               if ( document.readyState === "complete" ) {
-                                       document.detachEvent( "onreadystatechange", onreadystatechange );
-                                       jQuery.ready();
-                               }
-                       });
+                       document.attachEvent("onreadystatechange", DOMContentLoaded);
                        
                        // A fallback to window.onload, that will always work
                        window.attachEvent( "onload", jQuery.ready );
 
                        if ( document.documentElement.doScroll && toplevel ) {
                                doScrollCheck();
-
-                               function doScrollCheck() {
-                                       if ( jQuery.isReady ) {
-                                               return;
-                                       }
-
-                                       try {
-                                               // If IE is used, use the trick by Diego Perini
-                                               // http://javascript.nwbox.com/IEContentLoaded/
-                                               document.documentElement.doScroll("left");
-                                       } catch( error ) {
-                                               setTimeout( doScrollCheck, 1 );
-                                               return;
-                                       }
-
-                                       // and execute any waiting functions
-                                       jQuery.ready();
-                               }
                        }
                }
        },
 // All jQuery objects should point back to these
 rootjQuery = jQuery(document);
 
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+       DOMContentLoaded = function() {
+               document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+               jQuery.ready();
+       };
+
+} else if ( document.attachEvent ) {
+       DOMContentLoaded = function() {
+               // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+               if ( document.readyState === "complete" ) {
+                       document.detachEvent( "onreadystatechange", DOMContentLoaded );
+                       jQuery.ready();
+               }
+       };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+       if ( jQuery.isReady ) {
+               return;
+       }
+
+       try {
+               // If IE is used, use the trick by Diego Perini
+               // http://javascript.nwbox.com/IEContentLoaded/
+               document.documentElement.doScroll("left");
+       } catch( error ) {
+               setTimeout( doScrollCheck, 1 );
+               return;
+       }
+
+       // and execute any waiting functions
+       jQuery.ready();
+}
+
+if ( indexOf ) {
+       jQuery.inArray = function( elem, array ) {
+               return indexOf.call( array, elem );
+       };
+}
+
 function evalScript( i, elem ) {
        if ( elem.src ) {
                jQuery.ajax({
 
 
                // Init the element's event structure
                var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
-                       handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function eventHandle() {
+                       handle = jQuery.data( elem, "handle" ), eventHandle;
+
+               if ( !handle ) {
+                       eventHandle = function() {
                                // Handle the second event of a trigger and when
                                // an event is called after a page has unloaded
                                return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
                                        jQuery.event.handle.apply( eventHandle.elem, arguments ) :
                                        undefined;
-                       });
+                       };
+
+                       handle = jQuery.data( elem, "handle", eventHandle );
+               }
+
                // Add elem as a property of the handle function
                // This is to prevent a memory leak with non-native
                // event in IE.