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