Fix for #689
[jquery.git] / src / event / event.js
1 jQuery.fn.extend({
2
3         // We're overriding the old toggle function, so
4         // remember it for later
5         _toggle: jQuery.fn.toggle,
6         
7         /**
8          * Toggle between two function calls every other click.
9          * Whenever a matched element is clicked, the first specified function 
10          * is fired, when clicked again, the second is fired. All subsequent 
11          * clicks continue to rotate through the two functions.
12          *
13          * Use unbind("click") to remove.
14          *
15          * @example $("p").toggle(function(){
16          *   $(this).addClass("selected");
17          * },function(){
18          *   $(this).removeClass("selected");
19          * });
20          * 
21          * @name toggle
22          * @type jQuery
23          * @param Function even The function to execute on every even click.
24          * @param Function odd The function to execute on every odd click.
25          * @cat Events
26          */
27         toggle: function() {
28                 // save reference to arguments for access in closure
29                 var a = arguments;
30                 return typeof a[0] == "function" && typeof a[1] == "function" ? this.click(function(e) {
31                         // Figure out which function to execute
32                         this.lastToggle = this.lastToggle == 0 ? 1 : 0;
33                         
34                         // Make sure that clicks stop
35                         e.preventDefault();
36                         
37                         // and execute the function
38                         return a[this.lastToggle].apply( this, [e] ) || false;
39                 }) :
40                 
41                 // Otherwise, execute the old toggle function
42                 this._toggle.apply( this, arguments );
43         },
44         
45         /**
46          * A method for simulating hovering (moving the mouse on, and off,
47          * an object). This is a custom method which provides an 'in' to a 
48          * frequent task.
49          *
50          * Whenever the mouse cursor is moved over a matched 
51          * element, the first specified function is fired. Whenever the mouse 
52          * moves off of the element, the second specified function fires. 
53          * Additionally, checks are in place to see if the mouse is still within 
54          * the specified element itself (for example, an image inside of a div), 
55          * and if it is, it will continue to 'hover', and not move out 
56          * (a common error in using a mouseout event handler).
57          *
58          * @example $("p").hover(function(){
59          *   $(this).addClass("over");
60          * },function(){
61          *   $(this).addClass("out");
62          * });
63          *
64          * @name hover
65          * @type jQuery
66          * @param Function over The function to fire whenever the mouse is moved over a matched element.
67          * @param Function out The function to fire whenever the mouse is moved off of a matched element.
68          * @cat Events
69          */
70         hover: function(f,g) {
71                 
72                 // A private function for haandling mouse 'hovering'
73                 function handleHover(e) {
74                         // Check if mouse(over|out) are still within the same parent element
75                         var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
76         
77                         // Traverse up the tree
78                         while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
79                         
80                         // If we actually just moused on to a sub-element, ignore it
81                         if ( p == this ) return false;
82                         
83                         // Execute the right function
84                         return (e.type == "mouseover" ? f : g).apply(this, [e]);
85                 }
86                 
87                 // Bind the function to the two event listeners
88                 return this.mouseover(handleHover).mouseout(handleHover);
89         },
90         
91         /**
92          * Bind a function to be executed whenever the DOM is ready to be
93          * traversed and manipulated. This is probably the most important 
94          * function included in the event module, as it can greatly improve
95          * the response times of your web applications.
96          *
97          * In a nutshell, this is a solid replacement for using window.onload, 
98          * and attaching a function to that. By using this method, your bound Function 
99          * will be called the instant the DOM is ready to be read and manipulated, 
100          * which is exactly what 99.99% of all Javascript code needs to run.
101          * 
102          * Please ensure you have no code in your <body> onload event handler, 
103          * otherwise $(document).ready() may not fire.
104          *
105          * You can have as many $(document).ready events on your page as you like.
106          * The functions are then executed in the order they were added.
107          *
108          * @example $(document).ready(function(){ Your code here... });
109          *
110          * @name ready
111          * @type jQuery
112          * @param Function fn The function to be executed when the DOM is ready.
113          * @cat Events
114          */
115         ready: function(f) {
116                 // If the DOM is already ready
117                 if ( jQuery.isReady )
118                         // Execute the function immediately
119                         f.apply( document );
120                         
121                 // Otherwise, remember the function for later
122                 else {
123                         // Add the function to the wait list
124                         jQuery.readyList.push( f );
125                 }
126         
127                 return this;
128         }
129 });
130
131 jQuery.extend({
132         /*
133          * All the code that makes DOM Ready work nicely.
134          */
135         isReady: false,
136         readyList: [],
137         
138         // Handle when the DOM is ready
139         ready: function() {
140                 // Make sure that the DOM is not already loaded
141                 if ( !jQuery.isReady ) {
142                         // Remember that the DOM is ready
143                         jQuery.isReady = true;
144                         
145                         // If there are functions bound, to execute
146                         if ( jQuery.readyList ) {
147                                 // Execute all of them
148                                 for ( var i = 0; i < jQuery.readyList.length; i++ )
149                                         jQuery.readyList[i].apply( document );
150                                 
151                                 // Reset the list of functions
152                                 jQuery.readyList = null;
153                         }
154                         // Remove event lisenter to avoid memory leak
155                         if ( jQuery.browser.mozilla || jQuery.browser.opera )
156                                 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
157                 }
158         }
159 });
160
161 new function(){
162
163                 /**
164                  * Bind a function to the scroll event of each matched element.
165                  *
166                  * @example $("p").scroll( function() { alert("Hello"); } );
167                  * @before <p>Hello</p>
168                  * @result <p onscroll="alert('Hello');">Hello</p>
169                  *
170                  * @name scroll
171                  * @type jQuery
172                  * @param Function fn A function to bind to the scroll event on each of the matched elements.
173                  * @cat Events/Browser
174                  */
175
176                 /**
177                  * Trigger the scroll event of each matched element. This causes all of the functions
178                  * that have been bound to thet scroll event to be executed.
179                  *
180                  * @example $("p").scroll();
181                  * @before <p onscroll="alert('Hello');">Hello</p>
182                  * @result alert('Hello');
183                  *
184                  * @name scroll
185                  * @type jQuery
186                  * @cat Events/Browser
187                  */
188
189                 /**
190                  * Bind a function to the scroll event of each matched element, which will only be executed once.
191                  * Unlike a call to the normal .scroll() method, calling .onescroll() causes the bound function to be
192                  * only executed the first time it is triggered, and never again (unless it is re-bound).
193                  *
194                  * @example $("p").onescroll( function() { alert("Hello"); } );
195                  * @before <p onscroll="alert('Hello');">Hello</p>
196                  * @result alert('Hello'); // Only executed for the first scroll
197                  *
198                  * @name onescroll
199                  * @type jQuery
200                  * @param Function fn A function to bind to the scroll event on each of the matched elements.
201                  * @cat Events/Browser
202                  */
203
204                 /**
205                  * Removes a bound scroll event from each of the matched
206                  * elements. You must pass the identical function that was used in the original 
207                  * bind method.
208                  *
209                  * @example $("p").unscroll( myFunction );
210                  * @before <p onscroll="myFunction">Hello</p>
211                  * @result <p>Hello</p>
212                  *
213                  * @name unscroll
214                  * @type jQuery
215                  * @param Function fn A function to unbind from the scroll event on each of the matched elements.
216                  * @cat Events/Browser
217                  */
218
219                 /**
220                  * Removes all bound scroll events from each of the matched elements.
221                  *
222                  * @example $("p").unscroll();
223                  * @before <p onscroll="alert('Hello');">Hello</p>
224                  * @result <p>Hello</p>
225                  *
226                  * @name unscroll
227                  * @type jQuery
228                  * @cat Events/Browser
229                  */
230
231                 /**
232                  * Bind a function to the submit event of each matched element.
233                  *
234                  * @example $("#myform").submit( function() {
235                  *   return $("input", this).val().length > 0;
236                  * } );
237                  * @before <form id="myform"><input /></form>
238                  * @desc Prevents the form submission when the input has no value entered.
239                  *
240                  * @name submit
241                  * @type jQuery
242                  * @param Function fn A function to bind to the submit event on each of the matched elements.
243                  * @cat Events/Form
244                  */
245
246                 /**
247                  * Trigger the submit event of each matched element. This causes all of the functions
248                  * that have been bound to thet submit event to be executed.
249                  *
250                  * Note: This does not execute the submit method of the form element! If you need to
251                  * submit the form via code, you have to use the DOM method, eg. $("form")[0].submit();
252                  *
253                  * @example $("form").submit();
254                  * @desc Triggers all submit events registered for forms, but does not submit the form
255                  *
256                  * @name submit
257                  * @type jQuery
258                  * @cat Events/Form
259                  */
260
261                 /**
262                  * Bind a function to the submit event of each matched element, which will only be executed once.
263                  * Unlike a call to the normal .submit() method, calling .onesubmit() causes the bound function to be
264                  * only executed the first time it is triggered, and never again (unless it is re-bound).
265                  *
266                  * @example $("p").onesubmit( function() { alert("Hello"); } );
267                  * @before <p onsubmit="alert('Hello');">Hello</p>
268                  * @result alert('Hello'); // Only executed for the first submit
269                  *
270                  * @name onesubmit
271                  * @type jQuery
272                  * @param Function fn A function to bind to the submit event on each of the matched elements.
273                  * @cat Events/Form
274                  */
275
276                 /**
277                  * Removes a bound submit event from each of the matched
278                  * elements. You must pass the identical function that was used in the original 
279                  * bind method.
280                  *
281                  * @example $("p").unsubmit( myFunction );
282                  * @before <p onsubmit="myFunction">Hello</p>
283                  * @result <p>Hello</p>
284                  *
285                  * @name unsubmit
286                  * @type jQuery
287                  * @param Function fn A function to unbind from the submit event on each of the matched elements.
288                  * @cat Events/Form
289                  */
290
291                 /**
292                  * Removes all bound submit events from each of the matched elements.
293                  *
294                  * @example $("p").unsubmit();
295                  * @before <p onsubmit="alert('Hello');">Hello</p>
296                  * @result <p>Hello</p>
297                  *
298                  * @name unsubmit
299                  * @type jQuery
300                  * @cat Events/Form
301                  */
302
303                 /**
304                  * Bind a function to the focus event of each matched element.
305                  *
306                  * @example $("p").focus( function() { alert("Hello"); } );
307                  * @before <p>Hello</p>
308                  * @result <p onfocus="alert('Hello');">Hello</p>
309                  *
310                  * @name focus
311                  * @type jQuery
312                  * @param Function fn A function to bind to the focus event on each of the matched elements.
313                  * @cat Events/UI
314                  */
315
316                 /**
317                  * Trigger the focus event of each matched element. This causes all of the functions
318                  * that have been bound to thet focus event to be executed.
319                  *
320                  * Note: This does not execute the focus method of the underlying elements! If you need to
321                  * focus an element via code, you have to use the DOM method, eg. $("#myinput")[0].focus();
322                  *
323                  * @example $("p").focus();
324                  * @before <p onfocus="alert('Hello');">Hello</p>
325                  * @result alert('Hello');
326                  *
327                  * @name focus
328                  * @type jQuery
329                  * @cat Events/UI
330                  */
331
332                 /**
333                  * Bind a function to the focus event of each matched element, which will only be executed once.
334                  * Unlike a call to the normal .focus() method, calling .onefocus() causes the bound function to be
335                  * only executed the first time it is triggered, and never again (unless it is re-bound).
336                  *
337                  * @example $("p").onefocus( function() { alert("Hello"); } );
338                  * @before <p onfocus="alert('Hello');">Hello</p>
339                  * @result alert('Hello'); // Only executed for the first focus
340                  *
341                  * @name onefocus
342                  * @type jQuery
343                  * @param Function fn A function to bind to the focus event on each of the matched elements.
344                  * @cat Events/UI
345                  */
346
347                 /**
348                  * Removes a bound focus event from each of the matched
349                  * elements. You must pass the identical function that was used in the original 
350                  * bind method.
351                  *
352                  * @example $("p").unfocus( myFunction );
353                  * @before <p onfocus="myFunction">Hello</p>
354                  * @result <p>Hello</p>
355                  *
356                  * @name unfocus
357                  * @type jQuery
358                  * @param Function fn A function to unbind from the focus event on each of the matched elements.
359                  * @cat Events/UI
360                  */
361
362                 /**
363                  * Removes all bound focus events from each of the matched elements.
364                  *
365                  * @example $("p").unfocus();
366                  * @before <p onfocus="alert('Hello');">Hello</p>
367                  * @result <p>Hello</p>
368                  *
369                  * @name unfocus
370                  * @type jQuery
371                  * @cat Events/UI
372                  */
373
374                 /**
375                  * Bind a function to the keydown event of each matched element.
376                  *
377                  * @example $("p").keydown( function() { alert("Hello"); } );
378                  * @before <p>Hello</p>
379                  * @result <p onkeydown="alert('Hello');">Hello</p>
380                  *
381                  * @name keydown
382                  * @type jQuery
383                  * @param Function fn A function to bind to the keydown event on each of the matched elements.
384                  * @cat Events/Keyboard
385                  */
386
387                 /**
388                  * Trigger the keydown event of each matched element. This causes all of the functions
389                  * that have been bound to thet keydown event to be executed.
390                  *
391                  * @example $("p").keydown();
392                  * @before <p onkeydown="alert('Hello');">Hello</p>
393                  * @result alert('Hello');
394                  *
395                  * @name keydown
396                  * @type jQuery
397                  * @cat Events/Keyboard
398                  */
399
400                 /**
401                  * Bind a function to the keydown event of each matched element, which will only be executed once.
402                  * Unlike a call to the normal .keydown() method, calling .onekeydown() causes the bound function to be
403                  * only executed the first time it is triggered, and never again (unless it is re-bound).
404                  *
405                  * @example $("p").onekeydown( function() { alert("Hello"); } );
406                  * @before <p onkeydown="alert('Hello');">Hello</p>
407                  * @result alert('Hello'); // Only executed for the first keydown
408                  *
409                  * @name onekeydown
410                  * @type jQuery
411                  * @param Function fn A function to bind to the keydown event on each of the matched elements.
412                  * @cat Events/Keyboard
413                  */
414
415                 /**
416                  * Removes a bound keydown event from each of the matched
417                  * elements. You must pass the identical function that was used in the original 
418                  * bind method.
419                  *
420                  * @example $("p").unkeydown( myFunction );
421                  * @before <p onkeydown="myFunction">Hello</p>
422                  * @result <p>Hello</p>
423                  *
424                  * @name unkeydown
425                  * @type jQuery
426                  * @param Function fn A function to unbind from the keydown event on each of the matched elements.
427                  * @cat Events/Keyboard
428                  */
429
430                 /**
431                  * Removes all bound keydown events from each of the matched elements.
432                  *
433                  * @example $("p").unkeydown();
434                  * @before <p onkeydown="alert('Hello');">Hello</p>
435                  * @result <p>Hello</p>
436                  *
437                  * @name unkeydown
438                  * @type jQuery
439                  * @cat Events/Keyboard
440                  */
441
442                 /**
443                  * Bind a function to the dblclick event of each matched element.
444                  *
445                  * @example $("p").dblclick( function() { alert("Hello"); } );
446                  * @before <p>Hello</p>
447                  * @result <p ondblclick="alert('Hello');">Hello</p>
448                  *
449                  * @name dblclick
450                  * @type jQuery
451                  * @param Function fn A function to bind to the dblclick event on each of the matched elements.
452                  * @cat Events/Mouse
453                  */
454
455                 /**
456                  * Trigger the dblclick event of each matched element. This causes all of the functions
457                  * that have been bound to thet dblclick event to be executed.
458                  *
459                  * @example $("p").dblclick();
460                  * @before <p ondblclick="alert('Hello');">Hello</p>
461                  * @result alert('Hello');
462                  *
463                  * @name dblclick
464                  * @type jQuery
465                  * @cat Events/Mouse
466                  */
467
468                 /**
469                  * Bind a function to the dblclick event of each matched element, which will only be executed once.
470                  * Unlike a call to the normal .dblclick() method, calling .onedblclick() causes the bound function to be
471                  * only executed the first time it is triggered, and never again (unless it is re-bound).
472                  *
473                  * @example $("p").onedblclick( function() { alert("Hello"); } );
474                  * @before <p ondblclick="alert('Hello');">Hello</p>
475                  * @result alert('Hello'); // Only executed for the first dblclick
476                  *
477                  * @name onedblclick
478                  * @type jQuery
479                  * @param Function fn A function to bind to the dblclick event on each of the matched elements.
480                  * @cat Events/Mouse
481                  */
482
483                 /**
484                  * Removes a bound dblclick event from each of the matched
485                  * elements. You must pass the identical function that was used in the original 
486                  * bind method.
487                  *
488                  * @example $("p").undblclick( myFunction );
489                  * @before <p ondblclick="myFunction">Hello</p>
490                  * @result <p>Hello</p>
491                  *
492                  * @name undblclick
493                  * @type jQuery
494                  * @param Function fn A function to unbind from the dblclick event on each of the matched elements.
495                  * @cat Events/Mouse
496                  */
497
498                 /**
499                  * Removes all bound dblclick events from each of the matched elements.
500                  *
501                  * @example $("p").undblclick();
502                  * @before <p ondblclick="alert('Hello');">Hello</p>
503                  * @result <p>Hello</p>
504                  *
505                  * @name undblclick
506                  * @type jQuery
507                  * @cat Events/Mouse
508                  */
509
510                 /**
511                  * Bind a function to the keypress event of each matched element.
512                  *
513                  * @example $("p").keypress( function() { alert("Hello"); } );
514                  * @before <p>Hello</p>
515                  * @result <p onkeypress="alert('Hello');">Hello</p>
516                  *
517                  * @name keypress
518                  * @type jQuery
519                  * @param Function fn A function to bind to the keypress event on each of the matched elements.
520                  * @cat Events/Keyboard
521                  */
522
523                 /**
524                  * Trigger the keypress event of each matched element. This causes all of the functions
525                  * that have been bound to thet keypress event to be executed.
526                  *
527                  * @example $("p").keypress();
528                  * @before <p onkeypress="alert('Hello');">Hello</p>
529                  * @result alert('Hello');
530                  *
531                  * @name keypress
532                  * @type jQuery
533                  * @cat Events/Keyboard
534                  */
535
536                 /**
537                  * Bind a function to the keypress event of each matched element, which will only be executed once.
538                  * Unlike a call to the normal .keypress() method, calling .onekeypress() causes the bound function to be
539                  * only executed the first time it is triggered, and never again (unless it is re-bound).
540                  *
541                  * @example $("p").onekeypress( function() { alert("Hello"); } );
542                  * @before <p onkeypress="alert('Hello');">Hello</p>
543                  * @result alert('Hello'); // Only executed for the first keypress
544                  *
545                  * @name onekeypress
546                  * @type jQuery
547                  * @param Function fn A function to bind to the keypress event on each of the matched elements.
548                  * @cat Events/Keyboard
549                  */
550
551                 /**
552                  * Removes a bound keypress event from each of the matched
553                  * elements. You must pass the identical function that was used in the original 
554                  * bind method.
555                  *
556                  * @example $("p").unkeypress( myFunction );
557                  * @before <p onkeypress="myFunction">Hello</p>
558                  * @result <p>Hello</p>
559                  *
560                  * @name unkeypress
561                  * @type jQuery
562                  * @param Function fn A function to unbind from the keypress event on each of the matched elements.
563                  * @cat Events/Keyboard
564                  */
565
566                 /**
567                  * Removes all bound keypress events from each of the matched elements.
568                  *
569                  * @example $("p").unkeypress();
570                  * @before <p onkeypress="alert('Hello');">Hello</p>
571                  * @result <p>Hello</p>
572                  *
573                  * @name unkeypress
574                  * @type jQuery
575                  * @cat Events/Keyboard
576                  */
577
578                 /**
579                  * Bind a function to the error event of each matched element.
580                  *
581                  * @example $("p").error( function() { alert("Hello"); } );
582                  * @before <p>Hello</p>
583                  * @result <p onerror="alert('Hello');">Hello</p>
584                  *
585                  * @name error
586                  * @type jQuery
587                  * @param Function fn A function to bind to the error event on each of the matched elements.
588                  * @cat Events/Browser
589                  */
590
591                 /**
592                  * Trigger the error event of each matched element. This causes all of the functions
593                  * that have been bound to thet error event to be executed.
594                  *
595                  * @example $("p").error();
596                  * @before <p onerror="alert('Hello');">Hello</p>
597                  * @result alert('Hello');
598                  *
599                  * @name error
600                  * @type jQuery
601                  * @cat Events/Browser
602                  */
603
604                 /**
605                  * Bind a function to the error event of each matched element, which will only be executed once.
606                  * Unlike a call to the normal .error() method, calling .oneerror() causes the bound function to be
607                  * only executed the first time it is triggered, and never again (unless it is re-bound).
608                  *
609                  * @example $("p").oneerror( function() { alert("Hello"); } );
610                  * @before <p onerror="alert('Hello');">Hello</p>
611                  * @result alert('Hello'); // Only executed for the first error
612                  *
613                  * @name oneerror
614                  * @type jQuery
615                  * @param Function fn A function to bind to the error event on each of the matched elements.
616                  * @cat Events/Browser
617                  */
618
619                 /**
620                  * Removes a bound error event from each of the matched
621                  * elements. You must pass the identical function that was used in the original 
622                  * bind method.
623                  *
624                  * @example $("p").unerror( myFunction );
625                  * @before <p onerror="myFunction">Hello</p>
626                  * @result <p>Hello</p>
627                  *
628                  * @name unerror
629                  * @type jQuery
630                  * @param Function fn A function to unbind from the error event on each of the matched elements.
631                  * @cat Events/Browser
632                  */
633
634                 /**
635                  * Removes all bound error events from each of the matched elements.
636                  *
637                  * @example $("p").unerror();
638                  * @before <p onerror="alert('Hello');">Hello</p>
639                  * @result <p>Hello</p>
640                  *
641                  * @name unerror
642                  * @type jQuery
643                  * @cat Events/Browser
644                  */
645
646                 /**
647                  * Bind a function to the blur event of each matched element.
648                  *
649                  * @example $("p").blur( function() { alert("Hello"); } );
650                  * @before <p>Hello</p>
651                  * @result <p onblur="alert('Hello');">Hello</p>
652                  *
653                  * @name blur
654                  * @type jQuery
655                  * @param Function fn A function to bind to the blur event on each of the matched elements.
656                  * @cat Events/UI
657                  */
658
659                 /**
660                  * Trigger the blur event of each matched element. This causes all of the functions
661                  * that have been bound to thet blur event to be executed.
662                  *
663                  * Note: This does not execute the blur method of the underlying elements! If you need to
664                  * blur an element via code, you have to use the DOM method, eg. $("#myinput")[0].blur();
665                  *
666                  * @example $("p").blur();
667                  * @before <p onblur="alert('Hello');">Hello</p>
668                  * @result alert('Hello');
669                  *
670                  * @name blur
671                  * @type jQuery
672                  * @cat Events/UI
673                  */
674
675                 /**
676                  * Bind a function to the blur event of each matched element, which will only be executed once.
677                  * Unlike a call to the normal .blur() method, calling .oneblur() causes the bound function to be
678                  * only executed the first time it is triggered, and never again (unless it is re-bound).
679                  *
680                  * @example $("p").oneblur( function() { alert("Hello"); } );
681                  * @before <p onblur="alert('Hello');">Hello</p>
682                  * @result alert('Hello'); // Only executed for the first blur
683                  *
684                  * @name oneblur
685                  * @type jQuery
686                  * @param Function fn A function to bind to the blur event on each of the matched elements.
687                  * @cat Events/UI
688                  */
689
690                 /**
691                  * Removes a bound blur event from each of the matched
692                  * elements. You must pass the identical function that was used in the original 
693                  * bind method.
694                  *
695                  * @example $("p").unblur( myFunction );
696                  * @before <p onblur="myFunction">Hello</p>
697                  * @result <p>Hello</p>
698                  *
699                  * @name unblur
700                  * @type jQuery
701                  * @param Function fn A function to unbind from the blur event on each of the matched elements.
702                  * @cat Events/UI
703                  */
704
705                 /**
706                  * Removes all bound blur events from each of the matched elements.
707                  *
708                  * @example $("p").unblur();
709                  * @before <p onblur="alert('Hello');">Hello</p>
710                  * @result <p>Hello</p>
711                  *
712                  * @name unblur
713                  * @type jQuery
714                  * @cat Events/UI
715                  */
716
717                 /**
718                  * Bind a function to the load event of each matched element.
719                  *
720                  * @example $("p").load( function() { alert("Hello"); } );
721                  * @before <p>Hello</p>
722                  * @result <p onload="alert('Hello');">Hello</p>
723                  *
724                  * @name load
725                  * @type jQuery
726                  * @param Function fn A function to bind to the load event on each of the matched elements.
727                  * @cat Events/Browser
728                  */
729
730                 /**
731                  * Trigger the load event of each matched element. This causes all of the functions
732                  * that have been bound to thet load event to be executed.
733                  *
734                  * Marked as private: Calling load() without arguments throws exception because the ajax load
735                  * does not handle it.
736                  *
737                  * @example $("p").load();
738                  * @before <p onload="alert('Hello');">Hello</p>
739                  * @result alert('Hello');
740                  *
741                  * @name load
742                  * @private
743                  * @type jQuery
744                  * @cat Events/Browser
745                  */
746
747                 /**
748                  * Bind a function to the load event of each matched element, which will only be executed once.
749                  * Unlike a call to the normal .load() method, calling .oneload() causes the bound function to be
750                  * only executed the first time it is triggered, and never again (unless it is re-bound).
751                  *
752                  * @example $("p").oneload( function() { alert("Hello"); } );
753                  * @before <p onload="alert('Hello');">Hello</p>
754                  * @result alert('Hello'); // Only executed for the first load
755                  *
756                  * @name oneload
757                  * @type jQuery
758                  * @param Function fn A function to bind to the load event on each of the matched elements.
759                  * @cat Events/Browser
760                  */
761
762                 /**
763                  * Removes a bound load event from each of the matched
764                  * elements. You must pass the identical function that was used in the original 
765                  * bind method.
766                  *
767                  * @example $("p").unload( myFunction );
768                  * @before <p onload="myFunction">Hello</p>
769                  * @result <p>Hello</p>
770                  *
771                  * @name unload
772                  * @type jQuery
773                  * @param Function fn A function to unbind from the load event on each of the matched elements.
774                  * @cat Events/Browser
775                  */
776
777                 /**
778                  * Removes all bound load events from each of the matched elements.
779                  *
780                  * @example $("p").unload();
781                  * @before <p onload="alert('Hello');">Hello</p>
782                  * @result <p>Hello</p>
783                  *
784                  * @name unload
785                  * @type jQuery
786                  * @cat Events/Browser
787                  */
788
789                 /**
790                  * Bind a function to the select event of each matched element.
791                  *
792                  * @example $("p").select( function() { alert("Hello"); } );
793                  * @before <p>Hello</p>
794                  * @result <p onselect="alert('Hello');">Hello</p>
795                  *
796                  * @name select
797                  * @type jQuery
798                  * @param Function fn A function to bind to the select event on each of the matched elements.
799                  * @cat Events/Form
800                  */
801
802                 /**
803                  * Trigger the select event of each matched element. This causes all of the functions
804                  * that have been bound to thet select event to be executed.
805                  *
806                  * @example $("p").select();
807                  * @before <p onselect="alert('Hello');">Hello</p>
808                  * @result alert('Hello');
809                  *
810                  * @name select
811                  * @type jQuery
812                  * @cat Events/Form
813                  */
814
815                 /**
816                  * Bind a function to the select event of each matched element, which will only be executed once.
817                  * Unlike a call to the normal .select() method, calling .oneselect() causes the bound function to be
818                  * only executed the first time it is triggered, and never again (unless it is re-bound).
819                  *
820                  * @example $("p").oneselect( function() { alert("Hello"); } );
821                  * @before <p onselect="alert('Hello');">Hello</p>
822                  * @result alert('Hello'); // Only executed for the first select
823                  *
824                  * @name oneselect
825                  * @type jQuery
826                  * @param Function fn A function to bind to the select event on each of the matched elements.
827                  * @cat Events/Form
828                  */
829
830                 /**
831                  * Removes a bound select event from each of the matched
832                  * elements. You must pass the identical function that was used in the original 
833                  * bind method.
834                  *
835                  * @example $("p").unselect( myFunction );
836                  * @before <p onselect="myFunction">Hello</p>
837                  * @result <p>Hello</p>
838                  *
839                  * @name unselect
840                  * @type jQuery
841                  * @param Function fn A function to unbind from the select event on each of the matched elements.
842                  * @cat Events/Form
843                  */
844
845                 /**
846                  * Removes all bound select events from each of the matched elements.
847                  *
848                  * @example $("p").unselect();
849                  * @before <p onselect="alert('Hello');">Hello</p>
850                  * @result <p>Hello</p>
851                  *
852                  * @name unselect
853                  * @type jQuery
854                  * @cat Events/Form
855                  */
856
857                 /**
858                  * Bind a function to the mouseup event of each matched element.
859                  *
860                  * @example $("p").mouseup( function() { alert("Hello"); } );
861                  * @before <p>Hello</p>
862                  * @result <p onmouseup="alert('Hello');">Hello</p>
863                  *
864                  * @name mouseup
865                  * @type jQuery
866                  * @param Function fn A function to bind to the mouseup event on each of the matched elements.
867                  * @cat Events/Mouse
868                  */
869
870                 /**
871                  * Trigger the mouseup event of each matched element. This causes all of the functions
872                  * that have been bound to thet mouseup event to be executed.
873                  *
874                  * @example $("p").mouseup();
875                  * @before <p onmouseup="alert('Hello');">Hello</p>
876                  * @result alert('Hello');
877                  *
878                  * @name mouseup
879                  * @type jQuery
880                  * @cat Events/Mouse
881                  */
882
883                 /**
884                  * Bind a function to the mouseup event of each matched element, which will only be executed once.
885                  * Unlike a call to the normal .mouseup() method, calling .onemouseup() causes the bound function to be
886                  * only executed the first time it is triggered, and never again (unless it is re-bound).
887                  *
888                  * @example $("p").onemouseup( function() { alert("Hello"); } );
889                  * @before <p onmouseup="alert('Hello');">Hello</p>
890                  * @result alert('Hello'); // Only executed for the first mouseup
891                  *
892                  * @name onemouseup
893                  * @type jQuery
894                  * @param Function fn A function to bind to the mouseup event on each of the matched elements.
895                  * @cat Events/Mouse
896                  */
897
898                 /**
899                  * Removes a bound mouseup event from each of the matched
900                  * elements. You must pass the identical function that was used in the original 
901                  * bind method.
902                  *
903                  * @example $("p").unmouseup( myFunction );
904                  * @before <p onmouseup="myFunction">Hello</p>
905                  * @result <p>Hello</p>
906                  *
907                  * @name unmouseup
908                  * @type jQuery
909                  * @param Function fn A function to unbind from the mouseup event on each of the matched elements.
910                  * @cat Events/Mouse
911                  */
912
913                 /**
914                  * Removes all bound mouseup events from each of the matched elements.
915                  *
916                  * @example $("p").unmouseup();
917                  * @before <p onmouseup="alert('Hello');">Hello</p>
918                  * @result <p>Hello</p>
919                  *
920                  * @name unmouseup
921                  * @type jQuery
922                  * @cat Events/Mouse
923                  */
924
925                 /**
926                  * Bind a function to the unload event of each matched element.
927                  *
928                  * @example $("p").unload( function() { alert("Hello"); } );
929                  * @before <p>Hello</p>
930                  * @result <p onunload="alert('Hello');">Hello</p>
931                  *
932                  * @name unload
933                  * @type jQuery
934                  * @param Function fn A function to bind to the unload event on each of the matched elements.
935                  * @cat Events/Browser
936                  */
937
938                 /**
939                  * Trigger the unload event of each matched element. This causes all of the functions
940                  * that have been bound to thet unload event to be executed.
941                  *
942                  * @example $("p").unload();
943                  * @before <p onunload="alert('Hello');">Hello</p>
944                  * @result alert('Hello');
945                  *
946                  * @name unload
947                  * @type jQuery
948                  * @cat Events/Browser
949                  */
950
951                 /**
952                  * Bind a function to the unload event of each matched element, which will only be executed once.
953                  * Unlike a call to the normal .unload() method, calling .oneunload() causes the bound function to be
954                  * only executed the first time it is triggered, and never again (unless it is re-bound).
955                  *
956                  * @example $("p").oneunload( function() { alert("Hello"); } );
957                  * @before <p onunload="alert('Hello');">Hello</p>
958                  * @result alert('Hello'); // Only executed for the first unload
959                  *
960                  * @name oneunload
961                  * @type jQuery
962                  * @param Function fn A function to bind to the unload event on each of the matched elements.
963                  * @cat Events/Browser
964                  */
965
966                 /**
967                  * Removes a bound unload event from each of the matched
968                  * elements. You must pass the identical function that was used in the original 
969                  * bind method.
970                  *
971                  * @example $("p").ununload( myFunction );
972                  * @before <p onunload="myFunction">Hello</p>
973                  * @result <p>Hello</p>
974                  *
975                  * @name ununload
976                  * @type jQuery
977                  * @param Function fn A function to unbind from the unload event on each of the matched elements.
978                  * @cat Events/Browser
979                  */
980
981                 /**
982                  * Removes all bound unload events from each of the matched elements.
983                  *
984                  * @example $("p").ununload();
985                  * @before <p onunload="alert('Hello');">Hello</p>
986                  * @result <p>Hello</p>
987                  *
988                  * @name ununload
989                  * @type jQuery
990                  * @cat Events/Browser
991                  */
992
993                 /**
994                  * Bind a function to the change event of each matched element.
995                  *
996                  * @example $("p").change( function() { alert("Hello"); } );
997                  * @before <p>Hello</p>
998                  * @result <p onchange="alert('Hello');">Hello</p>
999                  *
1000                  * @name change
1001                  * @type jQuery
1002                  * @param Function fn A function to bind to the change event on each of the matched elements.
1003                  * @cat Events/Form
1004                  */
1005
1006                 /**
1007                  * Trigger the change event of each matched element. This causes all of the functions
1008                  * that have been bound to thet change event to be executed.
1009                  *
1010                  * @example $("p").change();
1011                  * @before <p onchange="alert('Hello');">Hello</p>
1012                  * @result alert('Hello');
1013                  *
1014                  * @name change
1015                  * @type jQuery
1016                  * @cat Events/Form
1017                  */
1018
1019                 /**
1020                  * Bind a function to the change event of each matched element, which will only be executed once.
1021                  * Unlike a call to the normal .change() method, calling .onechange() causes the bound function to be
1022                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1023                  *
1024                  * @example $("p").onechange( function() { alert("Hello"); } );
1025                  * @before <p onchange="alert('Hello');">Hello</p>
1026                  * @result alert('Hello'); // Only executed for the first change
1027                  *
1028                  * @name onechange
1029                  * @type jQuery
1030                  * @param Function fn A function to bind to the change event on each of the matched elements.
1031                  * @cat Events/Form
1032                  */
1033
1034                 /**
1035                  * Removes a bound change event from each of the matched
1036                  * elements. You must pass the identical function that was used in the original 
1037                  * bind method.
1038                  *
1039                  * @example $("p").unchange( myFunction );
1040                  * @before <p onchange="myFunction">Hello</p>
1041                  * @result <p>Hello</p>
1042                  *
1043                  * @name unchange
1044                  * @type jQuery
1045                  * @param Function fn A function to unbind from the change event on each of the matched elements.
1046                  * @cat Events/Form
1047                  */
1048
1049                 /**
1050                  * Removes all bound change events from each of the matched elements.
1051                  *
1052                  * @example $("p").unchange();
1053                  * @before <p onchange="alert('Hello');">Hello</p>
1054                  * @result <p>Hello</p>
1055                  *
1056                  * @name unchange
1057                  * @type jQuery
1058                  * @cat Events/Form
1059                  */
1060
1061                 /**
1062                  * Bind a function to the mouseout event of each matched element.
1063                  *
1064                  * @example $("p").mouseout( function() { alert("Hello"); } );
1065                  * @before <p>Hello</p>
1066                  * @result <p onmouseout="alert('Hello');">Hello</p>
1067                  *
1068                  * @name mouseout
1069                  * @type jQuery
1070                  * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1071                  * @cat Events/Mouse
1072                  */
1073
1074                 /**
1075                  * Trigger the mouseout event of each matched element. This causes all of the functions
1076                  * that have been bound to thet mouseout event to be executed.
1077                  *
1078                  * @example $("p").mouseout();
1079                  * @before <p onmouseout="alert('Hello');">Hello</p>
1080                  * @result alert('Hello');
1081                  *
1082                  * @name mouseout
1083                  * @type jQuery
1084                  * @cat Events/Mouse
1085                  */
1086
1087                 /**
1088                  * Bind a function to the mouseout event of each matched element, which will only be executed once.
1089                  * Unlike a call to the normal .mouseout() method, calling .onemouseout() causes the bound function to be
1090                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1091                  *
1092                  * @example $("p").onemouseout( function() { alert("Hello"); } );
1093                  * @before <p onmouseout="alert('Hello');">Hello</p>
1094                  * @result alert('Hello'); // Only executed for the first mouseout
1095                  *
1096                  * @name onemouseout
1097                  * @type jQuery
1098                  * @param Function fn A function to bind to the mouseout event on each of the matched elements.
1099                  * @cat Events/Mouse
1100                  */
1101
1102                 /**
1103                  * Removes a bound mouseout event from each of the matched
1104                  * elements. You must pass the identical function that was used in the original 
1105                  * bind method.
1106                  *
1107                  * @example $("p").unmouseout( myFunction );
1108                  * @before <p onmouseout="myFunction">Hello</p>
1109                  * @result <p>Hello</p>
1110                  *
1111                  * @name unmouseout
1112                  * @type jQuery
1113                  * @param Function fn A function to unbind from the mouseout event on each of the matched elements.
1114                  * @cat Events/Mouse
1115                  */
1116
1117                 /**
1118                  * Removes all bound mouseout events from each of the matched elements.
1119                  *
1120                  * @example $("p").unmouseout();
1121                  * @before <p onmouseout="alert('Hello');">Hello</p>
1122                  * @result <p>Hello</p>
1123                  *
1124                  * @name unmouseout
1125                  * @type jQuery
1126                  * @cat Events/Mouse
1127                  */
1128
1129                 /**
1130                  * Bind a function to the keyup event of each matched element.
1131                  *
1132                  * @example $("p").keyup( function() { alert("Hello"); } );
1133                  * @before <p>Hello</p>
1134                  * @result <p onkeyup="alert('Hello');">Hello</p>
1135                  *
1136                  * @name keyup
1137                  * @type jQuery
1138                  * @param Function fn A function to bind to the keyup event on each of the matched elements.
1139                  * @cat Events/Keyboard
1140                  */
1141
1142                 /**
1143                  * Trigger the keyup event of each matched element. This causes all of the functions
1144                  * that have been bound to thet keyup event to be executed.
1145                  *
1146                  * @example $("p").keyup();
1147                  * @before <p onkeyup="alert('Hello');">Hello</p>
1148                  * @result alert('Hello');
1149                  *
1150                  * @name keyup
1151                  * @type jQuery
1152                  * @cat Events/Keyboard
1153                  */
1154
1155                 /**
1156                  * Bind a function to the keyup event of each matched element, which will only be executed once.
1157                  * Unlike a call to the normal .keyup() method, calling .onekeyup() causes the bound function to be
1158                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1159                  *
1160                  * @example $("p").onekeyup( function() { alert("Hello"); } );
1161                  * @before <p onkeyup="alert('Hello');">Hello</p>
1162                  * @result alert('Hello'); // Only executed for the first keyup
1163                  *
1164                  * @name onekeyup
1165                  * @type jQuery
1166                  * @param Function fn A function to bind to the keyup event on each of the matched elements.
1167                  * @cat Events/Keyboard
1168                  */
1169
1170                 /**
1171                  * Removes a bound keyup event from each of the matched
1172                  * elements. You must pass the identical function that was used in the original 
1173                  * bind method.
1174                  *
1175                  * @example $("p").unkeyup( myFunction );
1176                  * @before <p onkeyup="myFunction">Hello</p>
1177                  * @result <p>Hello</p>
1178                  *
1179                  * @name unkeyup
1180                  * @type jQuery
1181                  * @param Function fn A function to unbind from the keyup event on each of the matched elements.
1182                  * @cat Events/Keyboard
1183                  */
1184
1185                 /**
1186                  * Removes all bound keyup events from each of the matched elements.
1187                  *
1188                  * @example $("p").unkeyup();
1189                  * @before <p onkeyup="alert('Hello');">Hello</p>
1190                  * @result <p>Hello</p>
1191                  *
1192                  * @name unkeyup
1193                  * @type jQuery
1194                  * @cat Events/Keyboard
1195                  */
1196
1197                 /**
1198                  * Bind a function to the click event of each matched element.
1199                  *
1200                  * @example $("p").click( function() { alert("Hello"); } );
1201                  * @before <p>Hello</p>
1202                  * @result <p onclick="alert('Hello');">Hello</p>
1203                  *
1204                  * @name click
1205                  * @type jQuery
1206                  * @param Function fn A function to bind to the click event on each of the matched elements.
1207                  * @cat Events/Mouse
1208                  */
1209
1210                 /**
1211                  * Trigger the click event of each matched element. This causes all of the functions
1212                  * that have been bound to thet click event to be executed.
1213                  *
1214                  * @example $("p").click();
1215                  * @before <p onclick="alert('Hello');">Hello</p>
1216                  * @result alert('Hello');
1217                  *
1218                  * @name click
1219                  * @type jQuery
1220                  * @cat Events/Mouse
1221                  */
1222
1223                 /**
1224                  * Bind a function to the click event of each matched element, which will only be executed once.
1225                  * Unlike a call to the normal .click() method, calling .oneclick() causes the bound function to be
1226                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1227                  *
1228                  * @example $("p").oneclick( function() { alert("Hello"); } );
1229                  * @before <p onclick="alert('Hello');">Hello</p>
1230                  * @result alert('Hello'); // Only executed for the first click
1231                  *
1232                  * @name oneclick
1233                  * @type jQuery
1234                  * @param Function fn A function to bind to the click event on each of the matched elements.
1235                  * @cat Events/Mouse
1236                  */
1237
1238                 /**
1239                  * Removes a bound click event from each of the matched
1240                  * elements. You must pass the identical function that was used in the original 
1241                  * bind method.
1242                  *
1243                  * @example $("p").unclick( myFunction );
1244                  * @before <p onclick="myFunction">Hello</p>
1245                  * @result <p>Hello</p>
1246                  *
1247                  * @name unclick
1248                  * @type jQuery
1249                  * @param Function fn A function to unbind from the click event on each of the matched elements.
1250                  * @cat Events/Mouse
1251                  */
1252
1253                 /**
1254                  * Removes all bound click events from each of the matched elements.
1255                  *
1256                  * @example $("p").unclick();
1257                  * @before <p onclick="alert('Hello');">Hello</p>
1258                  * @result <p>Hello</p>
1259                  *
1260                  * @name unclick
1261                  * @type jQuery
1262                  * @cat Events/Mouse
1263                  */
1264
1265                 /**
1266                  * Bind a function to the resize event of each matched element.
1267                  *
1268                  * @example $("p").resize( function() { alert("Hello"); } );
1269                  * @before <p>Hello</p>
1270                  * @result <p onresize="alert('Hello');">Hello</p>
1271                  *
1272                  * @name resize
1273                  * @type jQuery
1274                  * @param Function fn A function to bind to the resize event on each of the matched elements.
1275                  * @cat Events/Browser
1276                  */
1277
1278                 /**
1279                  * Trigger the resize event of each matched element. This causes all of the functions
1280                  * that have been bound to thet resize event to be executed.
1281                  *
1282                  * @example $("p").resize();
1283                  * @before <p onresize="alert('Hello');">Hello</p>
1284                  * @result alert('Hello');
1285                  *
1286                  * @name resize
1287                  * @type jQuery
1288                  * @cat Events/Browser
1289                  */
1290
1291                 /**
1292                  * Bind a function to the resize event of each matched element, which will only be executed once.
1293                  * Unlike a call to the normal .resize() method, calling .oneresize() causes the bound function to be
1294                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1295                  *
1296                  * @example $("p").oneresize( function() { alert("Hello"); } );
1297                  * @before <p onresize="alert('Hello');">Hello</p>
1298                  * @result alert('Hello'); // Only executed for the first resize
1299                  *
1300                  * @name oneresize
1301                  * @type jQuery
1302                  * @param Function fn A function to bind to the resize event on each of the matched elements.
1303                  * @cat Events/Browser
1304                  */
1305
1306                 /**
1307                  * Removes a bound resize event from each of the matched
1308                  * elements. You must pass the identical function that was used in the original 
1309                  * bind method.
1310                  *
1311                  * @example $("p").unresize( myFunction );
1312                  * @before <p onresize="myFunction">Hello</p>
1313                  * @result <p>Hello</p>
1314                  *
1315                  * @name unresize
1316                  * @type jQuery
1317                  * @param Function fn A function to unbind from the resize event on each of the matched elements.
1318                  * @cat Events/Browser
1319                  */
1320
1321                 /**
1322                  * Removes all bound resize events from each of the matched elements.
1323                  *
1324                  * @example $("p").unresize();
1325                  * @before <p onresize="alert('Hello');">Hello</p>
1326                  * @result <p>Hello</p>
1327                  *
1328                  * @name unresize
1329                  * @type jQuery
1330                  * @cat Events/Browser
1331                  */
1332
1333                 /**
1334                  * Bind a function to the mousemove event of each matched element.
1335                  *
1336                  * @example $("p").mousemove( function() { alert("Hello"); } );
1337                  * @before <p>Hello</p>
1338                  * @result <p onmousemove="alert('Hello');">Hello</p>
1339                  *
1340                  * @name mousemove
1341                  * @type jQuery
1342                  * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1343                  * @cat Events/Mouse
1344                  */
1345
1346                 /**
1347                  * Trigger the mousemove event of each matched element. This causes all of the functions
1348                  * that have been bound to thet mousemove event to be executed.
1349                  *
1350                  * @example $("p").mousemove();
1351                  * @before <p onmousemove="alert('Hello');">Hello</p>
1352                  * @result alert('Hello');
1353                  *
1354                  * @name mousemove
1355                  * @type jQuery
1356                  * @cat Events/Mouse
1357                  */
1358
1359                 /**
1360                  * Bind a function to the mousemove event of each matched element, which will only be executed once.
1361                  * Unlike a call to the normal .mousemove() method, calling .onemousemove() causes the bound function to be
1362                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1363                  *
1364                  * @example $("p").onemousemove( function() { alert("Hello"); } );
1365                  * @before <p onmousemove="alert('Hello');">Hello</p>
1366                  * @result alert('Hello'); // Only executed for the first mousemove
1367                  *
1368                  * @name onemousemove
1369                  * @type jQuery
1370                  * @param Function fn A function to bind to the mousemove event on each of the matched elements.
1371                  * @cat Events/Mouse
1372                  */
1373
1374                 /**
1375                  * Removes a bound mousemove event from each of the matched
1376                  * elements. You must pass the identical function that was used in the original 
1377                  * bind method.
1378                  *
1379                  * @example $("p").unmousemove( myFunction );
1380                  * @before <p onmousemove="myFunction">Hello</p>
1381                  * @result <p>Hello</p>
1382                  *
1383                  * @name unmousemove
1384                  * @type jQuery
1385                  * @param Function fn A function to unbind from the mousemove event on each of the matched elements.
1386                  * @cat Events/Mouse
1387                  */
1388
1389                 /**
1390                  * Removes all bound mousemove events from each of the matched elements.
1391                  *
1392                  * @example $("p").unmousemove();
1393                  * @before <p onmousemove="alert('Hello');">Hello</p>
1394                  * @result <p>Hello</p>
1395                  *
1396                  * @name unmousemove
1397                  * @type jQuery
1398                  * @cat Events/Mouse
1399                  */
1400
1401                 /**
1402                  * Bind a function to the mousedown event of each matched element.
1403                  *
1404                  * @example $("p").mousedown( function() { alert("Hello"); } );
1405                  * @before <p>Hello</p>
1406                  * @result <p onmousedown="alert('Hello');">Hello</p>
1407                  *
1408                  * @name mousedown
1409                  * @type jQuery
1410                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1411                  * @cat Events/Mouse
1412                  */
1413
1414                 /**
1415                  * Trigger the mousedown event of each matched element. This causes all of the functions
1416                  * that have been bound to thet mousedown event to be executed.
1417                  *
1418                  * @example $("p").mousedown();
1419                  * @before <p onmousedown="alert('Hello');">Hello</p>
1420                  * @result alert('Hello');
1421                  *
1422                  * @name mousedown
1423                  * @type jQuery
1424                  * @cat Events/Mouse
1425                  */
1426
1427                 /**
1428                  * Bind a function to the mousedown event of each matched element, which will only be executed once.
1429                  * Unlike a call to the normal .mousedown() method, calling .onemousedown() causes the bound function to be
1430                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1431                  *
1432                  * @example $("p").onemousedown( function() { alert("Hello"); } );
1433                  * @before <p onmousedown="alert('Hello');">Hello</p>
1434                  * @result alert('Hello'); // Only executed for the first mousedown
1435                  *
1436                  * @name onemousedown
1437                  * @type jQuery
1438                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1439                  * @cat Events/Mouse
1440                  */
1441
1442                 /**
1443                  * Removes a bound mousedown event from each of the matched
1444                  * elements. You must pass the identical function that was used in the original 
1445                  * bind method.
1446                  *
1447                  * @example $("p").unmousedown( myFunction );
1448                  * @before <p onmousedown="myFunction">Hello</p>
1449                  * @result <p>Hello</p>
1450                  *
1451                  * @name unmousedown
1452                  * @type jQuery
1453                  * @param Function fn A function to unbind from the mousedown event on each of the matched elements.
1454                  * @cat Events/Mouse
1455                  */
1456
1457                 /**
1458                  * Removes all bound mousedown events from each of the matched elements.
1459                  *
1460                  * @example $("p").unmousedown();
1461                  * @before <p onmousedown="alert('Hello');">Hello</p>
1462                  * @result <p>Hello</p>
1463                  *
1464                  * @name unmousedown
1465                  * @type jQuery
1466                  * @cat Events/Mouse
1467                  */
1468                  
1469                 /**
1470                  * Bind a function to the mouseover event of each matched element.
1471                  *
1472                  * @example $("p").mouseover( function() { alert("Hello"); } );
1473                  * @before <p>Hello</p>
1474                  * @result <p onmouseover="alert('Hello');">Hello</p>
1475                  *
1476                  * @name mouseover
1477                  * @type jQuery
1478                  * @param Function fn A function to bind to the mousedown event on each of the matched elements.
1479                  * @cat Events/Mouse
1480                  */
1481
1482                 /**
1483                  * Trigger the mouseover event of each matched element. This causes all of the functions
1484                  * that have been bound to thet mousedown event to be executed.
1485                  *
1486                  * @example $("p").mouseover();
1487                  * @before <p onmouseover="alert('Hello');">Hello</p>
1488                  * @result alert('Hello');
1489                  *
1490                  * @name mouseover
1491                  * @type jQuery
1492                  * @cat Events/Mouse
1493                  */
1494
1495                 /**
1496                  * Bind a function to the mouseover event of each matched element, which will only be executed once.
1497                  * Unlike a call to the normal .mouseover() method, calling .onemouseover() causes the bound function to be
1498                  * only executed the first time it is triggered, and never again (unless it is re-bound).
1499                  *
1500                  * @example $("p").onemouseover( function() { alert("Hello"); } );
1501                  * @before <p onmouseover="alert('Hello');">Hello</p>
1502                  * @result alert('Hello'); // Only executed for the first mouseover
1503                  *
1504                  * @name onemouseover
1505                  * @type jQuery
1506                  * @param Function fn A function to bind to the mouseover event on each of the matched elements.
1507                  * @cat Events/Mouse
1508                  */
1509
1510                 /**
1511                  * Removes a bound mouseover event from each of the matched
1512                  * elements. You must pass the identical function that was used in the original 
1513                  * bind method.
1514                  *
1515                  * @example $("p").unmouseover( myFunction );
1516                  * @before <p onmouseover="myFunction">Hello</p>
1517                  * @result <p>Hello</p>
1518                  *
1519                  * @name unmouseover
1520                  * @type jQuery
1521                  * @param Function fn A function to unbind from the mouseover event on each of the matched elements.
1522                  * @cat Events/Mouse
1523                  */
1524
1525                 /**
1526                  * Removes all bound mouseover events from each of the matched elements.
1527                  *
1528                  * @example $("p").unmouseover();
1529                  * @before <p onmouseover="alert('Hello');">Hello</p>
1530                  * @result <p>Hello</p>
1531                  *
1532                  * @name unmouseover
1533                  * @type jQuery
1534                  * @cat Events/Mouse
1535                  */
1536
1537         var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1538                 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + 
1539                 "submit,keydown,keypress,keyup,error").split(",");
1540
1541         // Go through all the event names, but make sure that
1542         // it is enclosed properly
1543         for ( var i = 0; i < e.length; i++ ) new function(){
1544                         
1545                 var o = e[i];
1546                 
1547                 // Handle event binding
1548                 jQuery.fn[o] = function(f){
1549                         return f ? this.bind(o, f) : this.trigger(o);
1550                 };
1551                 
1552                 // Handle event unbinding
1553                 jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
1554                 
1555                 // Finally, handle events that only fire once
1556                 jQuery.fn["one"+o] = function(f){
1557                         // save cloned reference to this
1558                         var element = jQuery(this);
1559                         var handler = function() {
1560                                 // unbind itself when executed
1561                                 element.unbind(o, handler);
1562                                 element = null;
1563                                 // apply original handler with the same arguments
1564                                 return f.apply(this, arguments);
1565                         };
1566                         return this.bind(o, handler);
1567                 };
1568                         
1569         };
1570         
1571         // If Mozilla is used
1572         if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
1573                 // Use the handy event callback
1574                 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
1575         
1576         // If IE is used, use the excellent hack by Matthias Miller
1577         // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1578         } else if ( jQuery.browser.msie ) {
1579         
1580                 // Only works if you document.write() it
1581                 document.write("<scr" + "ipt id=__ie_init defer=true " + 
1582                         "src=//:><\/script>");
1583         
1584                 // Use the defer script hack
1585                 var script = document.getElementById("__ie_init");
1586                 if (script) // script does not exist if jQuery is loaded dynamically
1587                         script.onreadystatechange = function() {
1588                                 if ( this.readyState != "complete" ) return;
1589                                 this.parentNode.removeChild( this );
1590                                 jQuery.ready();
1591                         };
1592         
1593                 // Clear from memory
1594                 script = null;
1595         
1596         // If Safari  is used
1597         } else if ( jQuery.browser.safari ) {
1598                 // Continually check to see if the document.readyState is valid
1599                 jQuery.safariTimer = setInterval(function(){
1600                         // loaded and complete are both valid states
1601                         if ( document.readyState == "loaded" || 
1602                                 document.readyState == "complete" ) {
1603         
1604                                 // If either one are found, remove the timer
1605                                 clearInterval( jQuery.safariTimer );
1606                                 jQuery.safariTimer = null;
1607         
1608                                 // and execute any waiting functions
1609                                 jQuery.ready();
1610                         }
1611                 }, 10);
1612         } 
1613
1614         // A fallback to window.onload, that will always work
1615         jQuery.event.add( window, "load", jQuery.ready );
1616         
1617 };
1618
1619 // Clean up after IE to avoid memory leaks
1620 if (jQuery.browser.msie) jQuery(window).unload(function() {
1621         var event = jQuery.event, global = event.global;
1622         for (var type in global) {
1623                 var els = global[type], i = els.length;
1624                 if (i>0) do if (type != 'unload') event.remove(els[i-1], type); while (--i);
1625         }
1626 });