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