+
+(function(){
+ /*
+ * Bind a number of event-handling functions, dynamically
+ */
+ var e = ("blur,focus,contextmenu,load,resize,scroll,unload,click,dblclick," +
+ "mousedown,mouseup,mouseenter,mouseleave,mousemove,mouseover,mouseout," +
+ "change,reset,select,submit,keydown,keypress,keyup").split(",");
+
+ // Go through all the event names, but make sure that
+ // it is enclosed properly
+ for ( var i = 0; i < e.length; i++ ) {(function(){
+
+ var o = e[i];
+
+ // Handle event binding
+ jQuery.prototype[o] = function(f){ return this.bind(o, f); };
+
+ // Handle event unbinding
+ jQuery.prototype["un"+o] = function(f){ return this.unbind(o, f); };
+
+ // Handle event triggering
+ jQuery.prototype["do"+o] = function(){ return this.trigger(o); };
+
+ // Finally, handle events that only fire once
+ jQuery.prototype["one"+o] = function(f){
+ // Attach the event listener
+ return this.bind(o, function(e){
+ // TODO: Remove the event listener, instead of this hack
+
+ // If this function has already been executed, stop
+ if ( this[o+f] !== null )
+ return true;
+
+ // Otherwise, mark as having been executed
+ this[o+f]++;
+
+ // And execute the bound function
+ return f.apply(this, [e]);
+ });
+ };
+
+ })();}
+
+ /*
+ * All the code that makes DOM Ready work nicely.
+ */
+
+ jQuery.isReady = false;
+ jQuery.readyList = [];
+
+ // Handle when the DOM is ready
+ jQuery.ready = function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( jQuery.readyList ) {
+ // Execute all of them
+ for ( var i = 0; i < jQuery.readyList.length; i++ )
+ jQuery.readyList[i].apply( document );
+
+ // Reset the list of functions
+ jQuery.readyList = null;
+ }
+ }
+ };
+
+ // If Mozilla is used
+ if ( jQuery.browser == "mozilla" || jQuery.browser == "opera" ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+
+ // If IE is used, use the excellent hack by Matthias Miller
+ // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
+ } else if ( jQuery.browser == "msie" ) {
+
+ // Only works if you document.write() it
+ document.write("<scr" + "ipt id=__ie_init defer=true " +
+ "src=https:///><\/script>");
+
+ // Use the defer script hack
+ var script = document.getElementById("__ie_init");
+ script.onreadystatechange = function() {
+ if ( this.readyState == "complete" )
+ jQuery.ready();
+ };
+
+ // Clear from memory
+ script = null;
+
+ // If Safari is used
+ } else if ( jQuery.browser == "safari" ) {
+ // Continually check to see if the document.readyState is valid
+ jQuery.safariTimer = setInterval(function(){
+ // loaded and complete are both valid states
+ if ( document.readyState == "loaded" ||
+ document.readyState == "complete" ) {
+
+ // If either one are found, remove the timer
+ clearInterval( jQuery.safariTimer );
+ jQuery.safariTimer = null;
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ }, 10);
+ }
+
+ // A fallback to window.onload, that will always work
+ jQuery.event.add( window, "load", jQuery.ready );
+
+})();