Mise en route du suivi.
[aidenligne_francais_universite.git] / dist / javascript / jquery-1.1.js
1 /* prevent execution of jQuery if included more than once */
2 if(typeof window.jQuery == "undefined") {
3 /*
4 * jQuery 1.1.1 - New Wave Javascript
5 *
6 * Copyright (c) 2007 John Resig (jquery.com)
7 * Dual licensed under the MIT (MIT-LICENSE.txt)
8 * and GPL (GPL-LICENSE.txt) licenses.
9 *
10 * $Date: 2007-02-03 20:32:16 +0100 (Sat, 03 Feb 2007) $
11 * $Rev: 1261 $
12 */
13
14 // Global undefined variable
15 window.undefined = window.undefined;
16 var jQuery = function(a,c) {
17 // If the context is global, return a new object
18 if ( window == this )
19 return new jQuery(a,c);
20
21 // Make sure that a selection was provided
22 a = a || document;
23
24 // HANDLE: $(function)
25 // Shortcut for document ready
26 if ( jQuery.isFunction(a) )
27 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
28
29 // Handle HTML strings
30 if ( typeof a == "string" ) {
31 // HANDLE: $(html) -> $(array)
32 var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
33 if ( m )
34 a = jQuery.clean( [ m[1] ] );
35
36 // HANDLE: $(expr)
37 else
38 return new jQuery( c ).find( a );
39 }
40
41 return this.setArray(
42 // HANDLE: $(array)
43 a.constructor == Array && a ||
44
45 // HANDLE: $(arraylike)
46 // Watch for when an array-like object is passed as the selector
47 (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) ||
48
49 // HANDLE: $(*)
50 [ a ] );
51 };
52
53 // Map over the $ in case of overwrite
54 if ( typeof $ != "undefined" )
55 jQuery._$ = $;
56
57 // Map the jQuery namespace to the '$' one
58 var $ = jQuery;
59
60 jQuery.fn = jQuery.prototype = {
61 jquery: "1.1.1",
62
63 size: function() {
64 return this.length;
65 },
66
67 length: 0,
68
69 get: function( num ) {
70 return num == undefined ?
71
72 // Return a 'clean' array
73 jQuery.makeArray( this ) :
74
75 // Return just the object
76 this[num];
77 },
78 pushStack: function( a ) {
79 var ret = jQuery(a);
80 ret.prevObject = this;
81 return ret;
82 },
83 setArray: function( a ) {
84 this.length = 0;
85 [].push.apply( this, a );
86 return this;
87 },
88 each: function( fn, args ) {
89 return jQuery.each( this, fn, args );
90 },
91 index: function( obj ) {
92 var pos = -1;
93 this.each(function(i){
94 if ( this == obj ) pos = i;
95 });
96 return pos;
97 },
98
99 attr: function( key, value, type ) {
100 var obj = key;
101
102 // Look for the case where we're accessing a style value
103 if ( key.constructor == String )
104 if ( value == undefined )
105 return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
106 else {
107 obj = {};
108 obj[ key ] = value;
109 }
110
111 // Check to see if we're setting style values
112 return this.each(function(index){
113 // Set all the styles
114 for ( var prop in obj )
115 jQuery.attr(
116 type ? this.style : this,
117 prop, jQuery.prop(this, obj[prop], type, index, prop)
118 );
119 });
120 },
121
122 css: function( key, value ) {
123 return this.attr( key, value, "curCSS" );
124 },
125
126 text: function(e) {
127 if ( typeof e == "string" )
128 return this.empty().append( document.createTextNode( e ) );
129
130 var t = "";
131 jQuery.each( e || this, function(){
132 jQuery.each( this.childNodes, function(){
133 if ( this.nodeType != 8 )
134 t += this.nodeType != 1 ?
135 this.nodeValue : jQuery.fn.text([ this ]);
136 });
137 });
138 return t;
139 },
140
141 wrap: function() {
142 // The elements to wrap the target around
143 var a = jQuery.clean(arguments);
144
145 // Wrap each of the matched elements individually
146 return this.each(function(){
147 // Clone the structure that we're using to wrap
148 var b = a[0].cloneNode(true);
149
150 // Insert it before the element to be wrapped
151 this.parentNode.insertBefore( b, this );
152
153 // Find the deepest point in the wrap structure
154 while ( b.firstChild )
155 b = b.firstChild;
156
157 // Move the matched element to within the wrap structure
158 b.appendChild( this );
159 });
160 },
161 append: function() {
162 return this.domManip(arguments, true, 1, function(a){
163 this.appendChild( a );
164 });
165 },
166 prepend: function() {
167 return this.domManip(arguments, true, -1, function(a){
168 this.insertBefore( a, this.firstChild );
169 });
170 },
171 before: function() {
172 return this.domManip(arguments, false, 1, function(a){
173 this.parentNode.insertBefore( a, this );
174 });
175 },
176 after: function() {
177 return this.domManip(arguments, false, -1, function(a){
178 this.parentNode.insertBefore( a, this.nextSibling );
179 });
180 },
181 end: function() {
182 return this.prevObject || jQuery([]);
183 },
184 find: function(t) {
185 return this.pushStack( jQuery.map( this, function(a){
186 return jQuery.find(t,a);
187 }), t );
188 },
189 clone: function(deep) {
190 return this.pushStack( jQuery.map( this, function(a){
191 return a.cloneNode( deep != undefined ? deep : true );
192 }) );
193 },
194
195 filter: function(t) {
196 return this.pushStack(
197 jQuery.isFunction( t ) &&
198 jQuery.grep(this, function(el, index){
199 return t.apply(el, [index])
200 }) ||
201
202 jQuery.multiFilter(t,this) );
203 },
204
205 not: function(t) {
206 return this.pushStack(
207 t.constructor == String &&
208 jQuery.multiFilter(t, this, true) ||
209
210 jQuery.grep(this, function(a) {
211 return ( t.constructor == Array || t.jquery )
212 ? jQuery.inArray( a, t ) < 0
213 : a != t;
214 })
215 );
216 },
217
218 add: function(t) {
219 return this.pushStack( jQuery.merge(
220 this.get(),
221 t.constructor == String ?
222 jQuery(t).get() :
223 t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
224 t : [t] )
225 );
226 },
227 is: function(expr) {
228 return expr ? jQuery.filter(expr,this).r.length > 0 : false;
229 },
230
231 val: function( val ) {
232 return val == undefined ?
233 ( this.length ? this[0].value : null ) :
234 this.attr( "value", val );
235 },
236
237 html: function( val ) {
238 return val == undefined ?
239 ( this.length ? this[0].innerHTML : null ) :
240 this.empty().append( val );
241 },
242 domManip: function(args, table, dir, fn){
243 var clone = this.length > 1;
244 var a = jQuery.clean(args);
245 if ( dir < 0 )
246 a.reverse();
247
248 return this.each(function(){
249 var obj = this;
250
251 if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
252 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
253
254 jQuery.each( a, function(){
255 fn.apply( obj, [ clone ? this.cloneNode(true) : this ] );
256 });
257
258 });
259 }
260 };
261
262 jQuery.extend = jQuery.fn.extend = function() {
263 // copy reference to target object
264 var target = arguments[0],
265 a = 1;
266
267 // extend jQuery itself if only one argument is passed
268 if ( arguments.length == 1 ) {
269 target = this;
270 a = 0;
271 }
272 var prop;
273 while (prop = arguments[a++])
274 // Extend the base object
275 for ( var i in prop ) target[i] = prop[i];
276
277 // Return the modified object
278 return target;
279 };
280
281 jQuery.extend({
282 noConflict: function() {
283 if ( jQuery._$ )
284 $ = jQuery._$;
285 return jQuery;
286 },
287
288 // This may seem like some crazy code, but trust me when I say that this
289 // is the only cross-browser way to do this. --John
290 isFunction: function( fn ) {
291 return !!fn && typeof fn != "string" &&
292 typeof fn[0] == "undefined" && /function/i.test( fn + "" );
293 },
294
295 nodeName: function( elem, name ) {
296 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
297 },
298 // args is for internal usage only
299 each: function( obj, fn, args ) {
300 if ( obj.length == undefined )
301 for ( var i in obj )
302 fn.apply( obj[i], args || [i, obj[i]] );
303 else
304 for ( var i = 0, ol = obj.length; i < ol; i++ )
305 if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
306 return obj;
307 },
308
309 prop: function(elem, value, type, index, prop){
310 // Handle executable functions
311 if ( jQuery.isFunction( value ) )
312 return value.call( elem, [index] );
313
314 // exclude the following css properties to add px
315 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
316
317 // Handle passing in a number to a CSS property
318 return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
319 value + "px" :
320 value;
321 },
322
323 className: {
324 // internal only, use addClass("class")
325 add: function( elem, c ){
326 jQuery.each( c.split(/\s+/), function(i, cur){
327 if ( !jQuery.className.has( elem.className, cur ) )
328 elem.className += ( elem.className ? " " : "" ) + cur;
329 });
330 },
331
332 // internal only, use removeClass("class")
333 remove: function( elem, c ){
334 elem.className = c ?
335 jQuery.grep( elem.className.split(/\s+/), function(cur){
336 return !jQuery.className.has( c, cur );
337 }).join(" ") : "";
338 },
339
340 // internal only, use is(".class")
341 has: function( t, c ) {
342 t = t.className || t;
343 return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
344 }
345 },
346 swap: function(e,o,f) {
347 for ( var i in o ) {
348 e.style["old"+i] = e.style[i];
349 e.style[i] = o[i];
350 }
351 f.apply( e, [] );
352 for ( var i in o )
353 e.style[i] = e.style["old"+i];
354 },
355
356 css: function(e,p) {
357 if ( p == "height" || p == "width" ) {
358 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
359
360 jQuery.each( d, function(){
361 old["padding" + this] = 0;
362 old["border" + this + "Width"] = 0;
363 });
364
365 jQuery.swap( e, old, function() {
366 if (jQuery.css(e,"display") != "none") {
367 oHeight = e.offsetHeight;
368 oWidth = e.offsetWidth;
369 } else {
370 e = jQuery(e.cloneNode(true))
371 .find(":radio").removeAttr("checked").end()
372 .css({
373 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
374 }).appendTo(e.parentNode)[0];
375
376 var parPos = jQuery.css(e.parentNode,"position");
377 if ( parPos == "" || parPos == "static" )
378 e.parentNode.style.position = "relative";
379
380 oHeight = e.clientHeight;
381 oWidth = e.clientWidth;
382
383 if ( parPos == "" || parPos == "static" )
384 e.parentNode.style.position = "static";
385
386 e.parentNode.removeChild(e);
387 }
388 });
389
390 return p == "height" ? oHeight : oWidth;
391 }
392
393 return jQuery.curCSS( e, p );
394 },
395
396 curCSS: function(elem, prop, force) {
397 var ret;
398
399 if (prop == "opacity" && jQuery.browser.msie)
400 return jQuery.attr(elem.style, "opacity");
401
402 if (prop == "float" || prop == "cssFloat")
403 prop = jQuery.browser.msie ? "styleFloat" : "cssFloat";
404
405 if (!force && elem.style[prop])
406 ret = elem.style[prop];
407
408 else if (document.defaultView && document.defaultView.getComputedStyle) {
409
410 if (prop == "cssFloat" || prop == "styleFloat")
411 prop = "float";
412
413 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
414 var cur = document.defaultView.getComputedStyle(elem, null);
415
416 if ( cur )
417 ret = cur.getPropertyValue(prop);
418 else if ( prop == "display" )
419 ret = "none";
420 else
421 jQuery.swap(elem, { display: "block" }, function() {
422 var c = document.defaultView.getComputedStyle(this, "");
423 ret = c && c.getPropertyValue(prop) || "";
424 });
425
426 } else if (elem.currentStyle) {
427
428 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
429 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
430
431 }
432
433 return ret;
434 },
435
436 clean: function(a) {
437 var r = [];
438
439 jQuery.each( a, function(i,arg){
440 if ( !arg ) return;
441
442 if ( arg.constructor == Number )
443 arg = arg.toString();
444
445 // Convert html string into DOM nodes
446 if ( typeof arg == "string" ) {
447 // Trim whitespace, otherwise indexOf won't work as expected
448 var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
449
450 var wrap =
451 // option or optgroup
452 !s.indexOf("<opt") &&
453 [1, "<select>", "</select>"] ||
454
455 (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
456 [1, "<table>", "</table>"] ||
457
458 !s.indexOf("<tr") &&
459 [2, "<table><tbody>", "</tbody></table>"] ||
460
461 // <thead> matched above
462 (!s.indexOf("<td") || !s.indexOf("<th")) &&
463 [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
464
465 [0,"",""];
466
467 // Go to html and back, then peel off extra wrappers
468 div.innerHTML = wrap[1] + s + wrap[2];
469
470 // Move to the right depth
471 while ( wrap[0]-- )
472 div = div.firstChild;
473
474 // Remove IE's autoinserted <tbody> from table fragments
475 if ( jQuery.browser.msie ) {
476
477 // String was a <table>, *may* have spurious <tbody>
478 if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
479 tb = div.firstChild && div.firstChild.childNodes;
480
481 // String was a bare <thead> or <tfoot>
482 else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
483 tb = div.childNodes;
484
485 for ( var n = tb.length-1; n >= 0 ; --n )
486 if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
487 tb[n].parentNode.removeChild(tb[n]);
488
489 }
490
491 arg = div.childNodes;
492 }
493
494 if ( arg.length === 0 )
495 return;
496
497 if ( arg[0] == undefined )
498 r.push( arg );
499 else
500 r = jQuery.merge( r, arg );
501
502 });
503
504 return r;
505 },
506
507 attr: function(elem, name, value){
508 var fix = {
509 "for": "htmlFor",
510 "class": "className",
511 "float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
512 cssFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
513 innerHTML: "innerHTML",
514 className: "className",
515 value: "value",
516 disabled: "disabled",
517 checked: "checked",
518 readonly: "readOnly",
519 selected: "selected"
520 };
521
522 // IE actually uses filters for opacity ... elem is actually elem.style
523 if ( name == "opacity" && jQuery.browser.msie && value != undefined ) {
524 // IE has trouble with opacity if it does not have layout
525 // Force it by setting the zoom level
526 elem.zoom = 1;
527
528 // Set the alpha filter to set the opacity
529 return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
530 ( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );
531
532 } else if ( name == "opacity" && jQuery.browser.msie )
533 return elem.filter ?
534 parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
535
536 // Mozilla doesn't play well with opacity 1
537 if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
538 value = 0.9999;
539
540 // Certain attributes only work when accessed via the old DOM 0 way
541 if ( fix[name] ) {
542 if ( value != undefined ) elem[fix[name]] = value;
543 return elem[fix[name]];
544
545 } else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
546 return elem.getAttributeNode(name).nodeValue;
547
548 // IE elem.getAttribute passes even for style
549 else if ( elem.tagName ) {
550 if ( value != undefined ) elem.setAttribute( name, value );
551 return elem.getAttribute( name );
552
553 } else {
554 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
555 if ( value != undefined ) elem[name] = value;
556 return elem[name];
557 }
558 },
559 trim: function(t){
560 return t.replace(/^\s+|\s+$/g, "");
561 },
562
563 makeArray: function( a ) {
564 var r = [];
565
566 if ( a.constructor != Array )
567 for ( var i = 0, al = a.length; i < al; i++ )
568 r.push( a[i] );
569 else
570 r = a.slice( 0 );
571
572 return r;
573 },
574
575 inArray: function( b, a ) {
576 for ( var i = 0, al = a.length; i < al; i++ )
577 if ( a[i] == b )
578 return i;
579 return -1;
580 },
581 merge: function(first, second) {
582 var r = [].slice.call( first, 0 );
583
584 // Now check for duplicates between the two arrays
585 // and only add the unique items
586 for ( var i = 0, sl = second.length; i < sl; i++ )
587 // Check for duplicates
588 if ( jQuery.inArray( second[i], r ) == -1 )
589 // The item is unique, add it
590 first.push( second[i] );
591
592 return first;
593 },
594 grep: function(elems, fn, inv) {
595 // If a string is passed in for the function, make a function
596 // for it (a handy shortcut)
597 if ( typeof fn == "string" )
598 fn = new Function("a","i","return " + fn);
599
600 var result = [];
601
602 // Go through the array, only saving the items
603 // that pass the validator function
604 for ( var i = 0, el = elems.length; i < el; i++ )
605 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
606 result.push( elems[i] );
607
608 return result;
609 },
610 map: function(elems, fn) {
611 // If a string is passed in for the function, make a function
612 // for it (a handy shortcut)
613 if ( typeof fn == "string" )
614 fn = new Function("a","return " + fn);
615
616 var result = [], r = [];
617
618 // Go through the array, translating each of the items to their
619 // new value (or values).
620 for ( var i = 0, el = elems.length; i < el; i++ ) {
621 var val = fn(elems[i],i);
622
623 if ( val !== null && val != undefined ) {
624 if ( val.constructor != Array ) val = [val];
625 result = result.concat( val );
626 }
627 }
628
629 var r = result.length ? [ result[0] ] : [];
630
631 check: for ( var i = 1, rl = result.length; i < rl; i++ ) {
632 for ( var j = 0; j < i; j++ )
633 if ( result[i] == r[j] )
634 continue check;
635
636 r.push( result[i] );
637 }
638
639 return r;
640 }
641 });
642
643 /*
644 * Whether the W3C compliant box model is being used.
645 *
646 * @property
647 * @name $.boxModel
648 * @type Boolean
649 * @cat JavaScript
650 */
651 new function() {
652 var b = navigator.userAgent.toLowerCase();
653
654 // Figure out what browser is being used
655 jQuery.browser = {
656 safari: /webkit/.test(b),
657 opera: /opera/.test(b),
658 msie: /msie/.test(b) && !/opera/.test(b),
659 mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
660 };
661
662 // Check to see if the W3C box model is being used
663 jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat";
664 };
665
666 jQuery.each({
667 parent: "a.parentNode",
668 parents: "jQuery.parents(a)",
669 next: "jQuery.nth(a,2,'nextSibling')",
670 prev: "jQuery.nth(a,2,'previousSibling')",
671 siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
672 children: "jQuery.sibling(a.firstChild)"
673 }, function(i,n){
674 jQuery.fn[ i ] = function(a) {
675 var ret = jQuery.map(this,n);
676 if ( a && typeof a == "string" )
677 ret = jQuery.multiFilter(a,ret);
678 return this.pushStack( ret );
679 };
680 });
681
682 jQuery.each({
683 appendTo: "append",
684 prependTo: "prepend",
685 insertBefore: "before",
686 insertAfter: "after"
687 }, function(i,n){
688 jQuery.fn[ i ] = function(){
689 var a = arguments;
690 return this.each(function(){
691 for ( var j = 0, al = a.length; j < al; j++ )
692 jQuery(a[j])[n]( this );
693 });
694 };
695 });
696
697 jQuery.each( {
698 removeAttr: function( key ) {
699 jQuery.attr( this, key, "" );
700 this.removeAttribute( key );
701 },
702 addClass: function(c){
703 jQuery.className.add(this,c);
704 },
705 removeClass: function(c){
706 jQuery.className.remove(this,c);
707 },
708 toggleClass: function( c ){
709 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
710 },
711 remove: function(a){
712 if ( !a || jQuery.filter( a, [this] ).r.length )
713 this.parentNode.removeChild( this );
714 },
715 empty: function() {
716 while ( this.firstChild )
717 this.removeChild( this.firstChild );
718 }
719 }, function(i,n){
720 jQuery.fn[ i ] = function() {
721 return this.each( n, arguments );
722 };
723 });
724
725 jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
726 jQuery.fn[ n ] = function(num,fn) {
727 return this.filter( ":" + n + "(" + num + ")", fn );
728 };
729 });
730
731 jQuery.each( [ "height", "width" ], function(i,n){
732 jQuery.fn[ n ] = function(h) {
733 return h == undefined ?
734 ( this.length ? jQuery.css( this[0], n ) : null ) :
735 this.css( n, h.constructor == String ? h : h + "px" );
736 };
737 });
738 jQuery.extend({
739 expr: {
740 "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
741 "#": "a.getAttribute('id')==m[2]",
742 ":": {
743 // Position Checks
744 lt: "i<m[3]-0",
745 gt: "i>m[3]-0",
746 nth: "m[3]-0==i",
747 eq: "m[3]-0==i",
748 first: "i==0",
749 last: "i==r.length-1",
750 even: "i%2==0",
751 odd: "i%2",
752
753 // Child Checks
754 "nth-child": "jQuery.nth(a.parentNode.firstChild,m[3],'nextSibling',a)==a",
755 "first-child": "jQuery.nth(a.parentNode.firstChild,1,'nextSibling')==a",
756 "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
757 "only-child": "jQuery.sibling(a.parentNode.firstChild).length==1",
758
759 // Parent Checks
760 parent: "a.firstChild",
761 empty: "!a.firstChild",
762
763 // Text Check
764 contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
765
766 // Visibility
767 visible: 'a.type!="hidden"&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
768 hidden: 'a.type=="hidden"||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
769
770 // Form attributes
771 enabled: "!a.disabled",
772 disabled: "a.disabled",
773 checked: "a.checked",
774 selected: "a.selected||jQuery.attr(a,'selected')",
775
776 // Form elements
777 text: "a.type=='text'",
778 radio: "a.type=='radio'",
779 checkbox: "a.type=='checkbox'",
780 file: "a.type=='file'",
781 password: "a.type=='password'",
782 submit: "a.type=='submit'",
783 image: "a.type=='image'",
784 reset: "a.type=='reset'",
785 button: 'a.type=="button"||jQuery.nodeName(a,"button")',
786 input: "/input|select|textarea|button/i.test(a.nodeName)"
787 },
788 ".": "jQuery.className.has(a,m[2])",
789 "@": {
790 "=": "z==m[4]",
791 "!=": "z!=m[4]",
792 "^=": "z&&!z.indexOf(m[4])",
793 "$=": "z&&z.substr(z.length - m[4].length,m[4].length)==m[4]",
794 "*=": "z&&z.indexOf(m[4])>=0",
795 "": "z",
796 _resort: function(m){
797 return ["", m[1], m[3], m[2], m[5]];
798 },
799 _prefix: "z=a[m[3]]||jQuery.attr(a,m[3]);"
800 },
801 "[": "jQuery.find(m[2],a).length"
802 },
803
804 // The regular expressions that power the parsing engine
805 parse: [
806 // Match: [@value='test'], [@foo]
807 /^\[ *(@)([a-z0-9_-]*) *([!*$^=]*) *('?"?)(.*?)\4 *\]/i,
808
809 // Match: [div], [div p]
810 /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
811
812 // Match: :contains('foo')
813 /^(:)([a-z0-9_-]*)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/i,
814
815 // Match: :even, :last-chlid
816 /^([:.#]*)([a-z0-9_*-]*)/i
817 ],
818
819 token: [
820 /^(\/?\.\.)/, "a.parentNode",
821 /^(>|\/)/, "jQuery.sibling(a.firstChild)",
822 /^(\+)/, "jQuery.nth(a,2,'nextSibling')",
823 /^(~)/, function(a){
824 var s = jQuery.sibling(a.parentNode.firstChild);
825 return s.slice(0, jQuery.inArray(a,s));
826 }
827 ],
828
829 multiFilter: function( expr, elems, not ) {
830 var old, cur = [];
831
832 while ( expr && expr != old ) {
833 old = expr;
834 var f = jQuery.filter( expr, elems, not );
835 expr = f.t.replace(/^\s*,\s*/, "" );
836 cur = not ? elems = f.r : jQuery.merge( cur, f.r );
837 }
838
839 return cur;
840 },
841 find: function( t, context ) {
842 // Quickly handle non-string expressions
843 if ( typeof t != "string" )
844 return [ t ];
845
846 // Make sure that the context is a DOM Element
847 if ( context && !context.nodeType )
848 context = null;
849
850 // Set the correct context (if none is provided)
851 context = context || document;
852
853 // Handle the common XPath // expression
854 if ( !t.indexOf("//") ) {
855 context = context.documentElement;
856 t = t.substr(2,t.length);
857
858 // And the / root expression
859 } else if ( !t.indexOf("/") ) {
860 context = context.documentElement;
861 t = t.substr(1,t.length);
862 if ( t.indexOf("/") >= 1 )
863 t = t.substr(t.indexOf("/"),t.length);
864 }
865
866 // Initialize the search
867 var ret = [context], done = [], last = null;
868
869 // Continue while a selector expression exists, and while
870 // we're no longer looping upon ourselves
871 while ( t && last != t ) {
872 var r = [];
873 last = t;
874
875 t = jQuery.trim(t).replace( /^\/\//i, "" );
876
877 var foundToken = false;
878
879 // An attempt at speeding up child selectors that
880 // point to a specific element tag
881 var re = /^[\/>]\s*([a-z0-9*-]+)/i;
882 var m = re.exec(t);
883
884 if ( m ) {
885 // Perform our own iteration and filter
886 jQuery.each( ret, function(){
887 for ( var c = this.firstChild; c; c = c.nextSibling )
888 if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
889 r.push( c );
890 });
891
892 ret = r;
893 t = t.replace( re, "" );
894 if ( t.indexOf(" ") == 0 ) continue;
895 foundToken = true;
896 } else {
897 // Look for pre-defined expression tokens
898 for ( var i = 0; i < jQuery.token.length; i += 2 ) {
899 // Attempt to match each, individual, token in
900 // the specified order
901 var re = jQuery.token[i];
902 var m = re.exec(t);
903
904 // If the token match was found
905 if ( m ) {
906 // Map it against the token's handler
907 r = ret = jQuery.map( ret, jQuery.isFunction( jQuery.token[i+1] ) ?
908 jQuery.token[i+1] :
909 function(a){ return eval(jQuery.token[i+1]); });
910
911 // And remove the token
912 t = jQuery.trim( t.replace( re, "" ) );
913 foundToken = true;
914 break;
915 }
916 }
917 }
918
919 // See if there's still an expression, and that we haven't already
920 // matched a token
921 if ( t && !foundToken ) {
922 // Handle multiple expressions
923 if ( !t.indexOf(",") ) {
924 // Clean the result set
925 if ( ret[0] == context ) ret.shift();
926
927 // Merge the result sets
928 jQuery.merge( done, ret );
929
930 // Reset the context
931 r = ret = [context];
932
933 // Touch up the selector string
934 t = " " + t.substr(1,t.length);
935
936 } else {
937 // Optomize for the case nodeName#idName
938 var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
939 var m = re2.exec(t);
940
941 // Re-organize the results, so that they're consistent
942 if ( m ) {
943 m = [ 0, m[2], m[3], m[1] ];
944
945 } else {
946 // Otherwise, do a traditional filter check for
947 // ID, class, and element selectors
948 re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
949 m = re2.exec(t);
950 }
951
952 // Try to do a global search by ID, where we can
953 if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
954 // Optimization for HTML document case
955 var oid = ret[ret.length-1].getElementById(m[2]);
956
957 // Do a quick check for node name (where applicable) so
958 // that div#foo searches will be really fast
959 ret = r = oid &&
960 (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
961
962 } else {
963 // Pre-compile a regular expression to handle class searches
964 if ( m[1] == "." )
965 var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
966
967 // We need to find all descendant elements, it is more
968 // efficient to use getAll() when we are already further down
969 // the tree - we try to recognize that here
970 jQuery.each( ret, function(){
971 // Grab the tag name being searched for
972 var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
973
974 // Handle IE7 being really dumb about <object>s
975 if ( jQuery.nodeName(this, "object") && tag == "*" )
976 tag = "param";
977
978 jQuery.merge( r,
979 m[1] != "" && ret.length != 1 ?
980 jQuery.getAll( this, [], m[1], m[2], rec ) :
981 this.getElementsByTagName( tag )
982 );
983 });
984
985 // It's faster to filter by class and be done with it
986 if ( m[1] == "." && ret.length == 1 )
987 r = jQuery.grep( r, function(e) {
988 return rec.test(e.className);
989 });
990
991 // Same with ID filtering
992 if ( m[1] == "#" && ret.length == 1 ) {
993 // Remember, then wipe out, the result set
994 var tmp = r;
995 r = [];
996
997 // Then try to find the element with the ID
998 jQuery.each( tmp, function(){
999 if ( this.getAttribute("id") == m[2] ) {
1000 r = [ this ];
1001 return false;
1002 }
1003 });
1004 }
1005
1006 ret = r;
1007 }
1008
1009 t = t.replace( re2, "" );
1010 }
1011
1012 }
1013
1014 // If a selector string still exists
1015 if ( t ) {
1016 // Attempt to filter it
1017 var val = jQuery.filter(t,r);
1018 ret = r = val.r;
1019 t = jQuery.trim(val.t);
1020 }
1021 }
1022
1023 // Remove the root context
1024 if ( ret && ret[0] == context ) ret.shift();
1025
1026 // And combine the results
1027 jQuery.merge( done, ret );
1028
1029 return done;
1030 },
1031
1032 filter: function(t,r,not) {
1033 // Look for common filter expressions
1034 while ( t && /^[a-z[({<*:.#]/i.test(t) ) {
1035
1036 var p = jQuery.parse, m;
1037
1038 jQuery.each( p, function(i,re){
1039
1040 // Look for, and replace, string-like sequences
1041 // and finally build a regexp out of it
1042 m = re.exec( t );
1043
1044 if ( m ) {
1045 // Remove what we just matched
1046 t = t.substring( m[0].length );
1047
1048 // Re-organize the first match
1049 if ( jQuery.expr[ m[1] ]._resort )
1050 m = jQuery.expr[ m[1] ]._resort( m );
1051
1052 return false;
1053 }
1054 });
1055
1056 // :not() is a special case that can be optimized by
1057 // keeping it out of the expression list
1058 if ( m[1] == ":" && m[2] == "not" )
1059 r = jQuery.filter(m[3], r, true).r;
1060
1061 // Handle classes as a special case (this will help to
1062 // improve the speed, as the regexp will only be compiled once)
1063 else if ( m[1] == "." ) {
1064
1065 var re = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");
1066 r = jQuery.grep( r, function(e){
1067 return re.test(e.className || "");
1068 }, not);
1069
1070 // Otherwise, find the expression to execute
1071 } else {
1072 var f = jQuery.expr[m[1]];
1073 if ( typeof f != "string" )
1074 f = jQuery.expr[m[1]][m[2]];
1075
1076 // Build a custom macro to enclose it
1077 eval("f = function(a,i){" +
1078 ( jQuery.expr[ m[1] ]._prefix || "" ) +
1079 "return " + f + "}");
1080
1081 // Execute it against the current filter
1082 r = jQuery.grep( r, f, not );
1083 }
1084 }
1085
1086 // Return an array of filtered elements (r)
1087 // and the modified expression string (t)
1088 return { r: r, t: t };
1089 },
1090
1091 getAll: function( o, r, token, name, re ) {
1092 for ( var s = o.firstChild; s; s = s.nextSibling )
1093 if ( s.nodeType == 1 ) {
1094 var add = true;
1095
1096 if ( token == "." )
1097 add = s.className && re.test(s.className);
1098 else if ( token == "#" )
1099 add = s.getAttribute("id") == name;
1100
1101 if ( add )
1102 r.push( s );
1103
1104 if ( token == "#" && r.length ) break;
1105
1106 if ( s.firstChild )
1107 jQuery.getAll( s, r, token, name, re );
1108 }
1109
1110 return r;
1111 },
1112 parents: function( elem ){
1113 var matched = [];
1114 var cur = elem.parentNode;
1115 while ( cur && cur != document ) {
1116 matched.push( cur );
1117 cur = cur.parentNode;
1118 }
1119 return matched;
1120 },
1121 nth: function(cur,result,dir,elem){
1122 result = result || 1;
1123 var num = 0;
1124 for ( ; cur; cur = cur[dir] ) {
1125 if ( cur.nodeType == 1 ) num++;
1126 if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||
1127 result == "odd" && num % 2 == 1 && cur == elem ) return cur;
1128 }
1129 },
1130 sibling: function( n, elem ) {
1131 var r = [];
1132
1133 for ( ; n; n = n.nextSibling ) {
1134 if ( n.nodeType == 1 && (!elem || n != elem) )
1135 r.push( n );
1136 }
1137
1138 return r;
1139 }
1140 });
1141 /*
1142 * A number of helper functions used for managing events.
1143 * Many of the ideas behind this code orignated from
1144 * Dean Edwards' addEvent library.
1145 */
1146 jQuery.event = {
1147
1148 // Bind an event to an element
1149 // Original by Dean Edwards
1150 add: function(element, type, handler, data) {
1151 // For whatever reason, IE has trouble passing the window object
1152 // around, causing it to be cloned in the process
1153 if ( jQuery.browser.msie && element.setInterval != undefined )
1154 element = window;
1155
1156 // if data is passed, bind to handler
1157 if( data )
1158 handler.data = data;
1159
1160 // Make sure that the function being executed has a unique ID
1161 if ( !handler.guid )
1162 handler.guid = this.guid++;
1163
1164 // Init the element's event structure
1165 if (!element.events)
1166 element.events = {};
1167
1168 // Get the current list of functions bound to this event
1169 var handlers = element.events[type];
1170
1171 // If it hasn't been initialized yet
1172 if (!handlers) {
1173 // Init the event handler queue
1174 handlers = element.events[type] = {};
1175
1176 // Remember an existing handler, if it's already there
1177 if (element["on" + type])
1178 handlers[0] = element["on" + type];
1179 }
1180
1181 // Add the function to the element's handler list
1182 handlers[handler.guid] = handler;
1183
1184 // And bind the global event handler to the element
1185 element["on" + type] = this.handle;
1186
1187 // Remember the function in a global list (for triggering)
1188 if (!this.global[type])
1189 this.global[type] = [];
1190 this.global[type].push( element );
1191 },
1192
1193 guid: 1,
1194 global: {},
1195
1196 // Detach an event or set of events from an element
1197 remove: function(element, type, handler) {
1198 if (element.events)
1199 if ( type && type.type )
1200 delete element.events[ type.type ][ type.handler.guid ];
1201 else if (type && element.events[type])
1202 if ( handler )
1203 delete element.events[type][handler.guid];
1204 else
1205 for ( var i in element.events[type] )
1206 delete element.events[type][i];
1207 else
1208 for ( var j in element.events )
1209 this.remove( element, j );
1210 },
1211
1212 trigger: function(type, data, element) {
1213 // Clone the incoming data, if any
1214 data = jQuery.makeArray(data || []);
1215
1216 // Handle a global trigger
1217 if ( !element )
1218 jQuery.each( this.global[type] || [], function(){
1219 jQuery.event.trigger( type, data, this );
1220 });
1221
1222 // Handle triggering a single element
1223 else {
1224 var handler = element["on" + type ], val,
1225 fn = jQuery.isFunction( element[ type ] );
1226
1227 if ( handler ) {
1228 // Pass along a fake event
1229 data.unshift( this.fix({ type: type, target: element }) );
1230
1231 // Trigger the event
1232 if ( (val = handler.apply( element, data )) !== false )
1233 this.triggered = true;
1234 }
1235
1236 if ( fn && val !== false )
1237 element[ type ]();
1238
1239 this.triggered = false;
1240 }
1241 },
1242
1243 handle: function(event) {
1244 // Handle the second event of a trigger and when
1245 // an event is called after a page has unloaded
1246 if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return;
1247
1248 // Empty object is for triggered events with no data
1249 event = jQuery.event.fix( event || window.event || {} );
1250
1251 // returned undefined or false
1252 var returnValue;
1253
1254 var c = this.events[event.type];
1255
1256 var args = [].slice.call( arguments, 1 );
1257 args.unshift( event );
1258
1259 for ( var j in c ) {
1260 // Pass in a reference to the handler function itself
1261 // So that we can later remove it
1262 args[0].handler = c[j];
1263 args[0].data = c[j].data;
1264
1265 if ( c[j].apply( this, args ) === false ) {
1266 event.preventDefault();
1267 event.stopPropagation();
1268 returnValue = false;
1269 }
1270 }
1271
1272 // Clean up added properties in IE to prevent memory leak
1273 if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
1274
1275 return returnValue;
1276 },
1277
1278 fix: function(event) {
1279 // Fix target property, if necessary
1280 if ( !event.target && event.srcElement )
1281 event.target = event.srcElement;
1282
1283 // Calculate pageX/Y if missing and clientX/Y available
1284 if ( event.pageX == undefined && event.clientX != undefined ) {
1285 var e = document.documentElement, b = document.body;
1286 event.pageX = event.clientX + (e.scrollLeft || b.scrollLeft);
1287 event.pageY = event.clientY + (e.scrollTop || b.scrollTop);
1288 }
1289
1290 // check if target is a textnode (safari)
1291 if (jQuery.browser.safari && event.target.nodeType == 3) {
1292 // store a copy of the original event object
1293 // and clone because target is read only
1294 var originalEvent = event;
1295 event = jQuery.extend({}, originalEvent);
1296
1297 // get parentnode from textnode
1298 event.target = originalEvent.target.parentNode;
1299
1300 // add preventDefault and stopPropagation since
1301 // they will not work on the clone
1302 event.preventDefault = function() {
1303 return originalEvent.preventDefault();
1304 };
1305 event.stopPropagation = function() {
1306 return originalEvent.stopPropagation();
1307 };
1308 }
1309
1310 // fix preventDefault and stopPropagation
1311 if (!event.preventDefault)
1312 event.preventDefault = function() {
1313 this.returnValue = false;
1314 };
1315
1316 if (!event.stopPropagation)
1317 event.stopPropagation = function() {
1318 this.cancelBubble = true;
1319 };
1320
1321 return event;
1322 }
1323 };
1324
1325 jQuery.fn.extend({
1326 bind: function( type, data, fn ) {
1327 return this.each(function(){
1328 jQuery.event.add( this, type, fn || data, data );
1329 });
1330 },
1331 one: function( type, data, fn ) {
1332 return this.each(function(){
1333 jQuery.event.add( this, type, function(event) {
1334 jQuery(this).unbind(event);
1335 return (fn || data).apply( this, arguments);
1336 }, data);
1337 });
1338 },
1339 unbind: function( type, fn ) {
1340 return this.each(function(){
1341 jQuery.event.remove( this, type, fn );
1342 });
1343 },
1344 trigger: function( type, data ) {
1345 return this.each(function(){
1346 jQuery.event.trigger( type, data, this );
1347 });
1348 },
1349 toggle: function() {
1350 // Save reference to arguments for access in closure
1351 var a = arguments;
1352
1353 return this.click(function(e) {
1354 // Figure out which function to execute
1355 this.lastToggle = this.lastToggle == 0 ? 1 : 0;
1356
1357 // Make sure that clicks stop
1358 e.preventDefault();
1359
1360 // and execute the function
1361 return a[this.lastToggle].apply( this, [e] ) || false;
1362 });
1363 },
1364 hover: function(f,g) {
1365
1366 // A private function for handling mouse 'hovering'
1367 function handleHover(e) {
1368 // Check if mouse(over|out) are still within the same parent element
1369 var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
1370
1371 // Traverse up the tree
1372 while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
1373
1374 // If we actually just moused on to a sub-element, ignore it
1375 if ( p == this ) return false;
1376
1377 // Execute the right function
1378 return (e.type == "mouseover" ? f : g).apply(this, [e]);
1379 }
1380
1381 // Bind the function to the two event listeners
1382 return this.mouseover(handleHover).mouseout(handleHover);
1383 },
1384 ready: function(f) {
1385 // If the DOM is already ready
1386 if ( jQuery.isReady )
1387 // Execute the function immediately
1388 f.apply( document, [jQuery] );
1389
1390 // Otherwise, remember the function for later
1391 else {
1392 // Add the function to the wait list
1393 jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } );
1394 }
1395
1396 return this;
1397 }
1398 });
1399
1400 jQuery.extend({
1401 /*
1402 * All the code that makes DOM Ready work nicely.
1403 */
1404 isReady: false,
1405 readyList: [],
1406
1407 // Handle when the DOM is ready
1408 ready: function() {
1409 // Make sure that the DOM is not already loaded
1410 if ( !jQuery.isReady ) {
1411 // Remember that the DOM is ready
1412 jQuery.isReady = true;
1413
1414 // If there are functions bound, to execute
1415 if ( jQuery.readyList ) {
1416 // Execute all of them
1417 jQuery.each( jQuery.readyList, function(){
1418 this.apply( document );
1419 });
1420
1421 // Reset the list of functions
1422 jQuery.readyList = null;
1423 }
1424 // Remove event lisenter to avoid memory leak
1425 if ( jQuery.browser.mozilla || jQuery.browser.opera )
1426 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
1427 }
1428 }
1429 });
1430
1431 new function(){
1432
1433 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
1434 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
1435 "submit,keydown,keypress,keyup,error").split(","), function(i,o){
1436
1437 // Handle event binding
1438 jQuery.fn[o] = function(f){
1439 return f ? this.bind(o, f) : this.trigger(o);
1440 };
1441
1442 });
1443
1444 // If Mozilla is used
1445 if ( jQuery.browser.mozilla || jQuery.browser.opera )
1446 // Use the handy event callback
1447 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
1448
1449 // If IE is used, use the excellent hack by Matthias Miller
1450 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
1451 else if ( jQuery.browser.msie ) {
1452
1453 // Only works if you document.write() it
1454 document.write("<scr" + "ipt id=__ie_init defer=true " +
1455 "src=//:><\/script>");
1456
1457 // Use the defer script hack
1458 var script = document.getElementById("__ie_init");
1459
1460 // script does not exist if jQuery is loaded dynamically
1461 if ( script )
1462 script.onreadystatechange = function() {
1463 if ( this.readyState != "complete" ) return;
1464 this.parentNode.removeChild( this );
1465 jQuery.ready();
1466 };
1467
1468 // Clear from memory
1469 script = null;
1470
1471 // If Safari is used
1472 } else if ( jQuery.browser.safari )
1473 // Continually check to see if the document.readyState is valid
1474 jQuery.safariTimer = setInterval(function(){
1475 // loaded and complete are both valid states
1476 if ( document.readyState == "loaded" ||
1477 document.readyState == "complete" ) {
1478
1479 // If either one are found, remove the timer
1480 clearInterval( jQuery.safariTimer );
1481 jQuery.safariTimer = null;
1482
1483 // and execute any waiting functions
1484 jQuery.ready();
1485 }
1486 }, 10);
1487
1488 // A fallback to window.onload, that will always work
1489 jQuery.event.add( window, "load", jQuery.ready );
1490
1491 };
1492
1493 // Clean up after IE to avoid memory leaks
1494 if (jQuery.browser.msie)
1495 jQuery(window).one("unload", function() {
1496 var global = jQuery.event.global;
1497 for ( var type in global ) {
1498 var els = global[type], i = els.length;
1499 if ( i && type != 'unload' )
1500 do
1501 jQuery.event.remove(els[i-1], type);
1502 while (--i);
1503 }
1504 });
1505 jQuery.fn.extend({
1506
1507 show: function(speed,callback){
1508 var hidden = this.filter(":hidden");
1509 speed ?
1510 hidden.animate({
1511 height: "show", width: "show", opacity: "show"
1512 }, speed, callback) :
1513
1514 hidden.each(function(){
1515 this.style.display = this.oldblock ? this.oldblock : "";
1516 if ( jQuery.css(this,"display") == "none" )
1517 this.style.display = "block";
1518 });
1519 return this;
1520 },
1521
1522 hide: function(speed,callback){
1523 var visible = this.filter(":visible");
1524 speed ?
1525 visible.animate({
1526 height: "hide", width: "hide", opacity: "hide"
1527 }, speed, callback) :
1528
1529 visible.each(function(){
1530 this.oldblock = this.oldblock || jQuery.css(this,"display");
1531 if ( this.oldblock == "none" )
1532 this.oldblock = "block";
1533 this.style.display = "none";
1534 });
1535 return this;
1536 },
1537
1538 // Save the old toggle function
1539 _toggle: jQuery.fn.toggle,
1540 toggle: function( fn, fn2 ){
1541 var args = arguments;
1542 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
1543 this._toggle( fn, fn2 ) :
1544 this.each(function(){
1545 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]
1546 .apply( jQuery(this), args );
1547 });
1548 },
1549 slideDown: function(speed,callback){
1550 return this.animate({height: "show"}, speed, callback);
1551 },
1552 slideUp: function(speed,callback){
1553 return this.animate({height: "hide"}, speed, callback);
1554 },
1555 slideToggle: function(speed, callback){
1556 return this.each(function(){
1557 var state = jQuery(this).is(":hidden") ? "show" : "hide";
1558 jQuery(this).animate({height: state}, speed, callback);
1559 });
1560 },
1561 fadeIn: function(speed, callback){
1562 return this.animate({opacity: "show"}, speed, callback);
1563 },
1564 fadeOut: function(speed, callback){
1565 return this.animate({opacity: "hide"}, speed, callback);
1566 },
1567 fadeTo: function(speed,to,callback){
1568 return this.animate({opacity: to}, speed, callback);
1569 },
1570 animate: function( prop, speed, easing, callback ) {
1571 return this.queue(function(){
1572
1573 this.curAnim = jQuery.extend({}, prop);
1574 var opt = jQuery.speed(speed, easing, callback);
1575
1576 for ( var p in prop ) {
1577 var e = new jQuery.fx( this, opt, p );
1578 if ( prop[p].constructor == Number )
1579 e.custom( e.cur(), prop[p] );
1580 else
1581 e[ prop[p] ]( prop );
1582 }
1583
1584 });
1585 },
1586 queue: function(type,fn){
1587 if ( !fn ) {
1588 fn = type;
1589 type = "fx";
1590 }
1591
1592 return this.each(function(){
1593 if ( !this.queue )
1594 this.queue = {};
1595
1596 if ( !this.queue[type] )
1597 this.queue[type] = [];
1598
1599 this.queue[type].push( fn );
1600
1601 if ( this.queue[type].length == 1 )
1602 fn.apply(this);
1603 });
1604 }
1605
1606 });
1607
1608 jQuery.extend({
1609
1610 speed: function(speed, easing, fn) {
1611 var opt = speed && speed.constructor == Object ? speed : {
1612 complete: fn || !fn && easing ||
1613 jQuery.isFunction( speed ) && speed,
1614 duration: speed,
1615 easing: fn && easing || easing && easing.constructor != Function && easing
1616 };
1617
1618 opt.duration = (opt.duration && opt.duration.constructor == Number ?
1619 opt.duration :
1620 { slow: 600, fast: 200 }[opt.duration]) || 400;
1621
1622 // Queueing
1623 opt.old = opt.complete;
1624 opt.complete = function(){
1625 jQuery.dequeue(this, "fx");
1626 if ( jQuery.isFunction( opt.old ) )
1627 opt.old.apply( this );
1628 };
1629
1630 return opt;
1631 },
1632
1633 easing: {},
1634
1635 queue: {},
1636
1637 dequeue: function(elem,type){
1638 type = type || "fx";
1639
1640 if ( elem.queue && elem.queue[type] ) {
1641 // Remove self
1642 elem.queue[type].shift();
1643
1644 // Get next function
1645 var f = elem.queue[type][0];
1646
1647 if ( f ) f.apply( elem );
1648 }
1649 },
1650
1651 /*
1652 * I originally wrote fx() as a clone of moo.fx and in the process
1653 * of making it small in size the code became illegible to sane
1654 * people. You've been warned.
1655 */
1656
1657 fx: function( elem, options, prop ){
1658
1659 var z = this;
1660
1661 // The styles
1662 var y = elem.style;
1663
1664 // Store display property
1665 var oldDisplay = jQuery.css(elem, "display");
1666
1667 // Make sure that nothing sneaks out
1668 y.overflow = "hidden";
1669
1670 // Simple function for setting a style value
1671 z.a = function(){
1672 if ( options.step )
1673 options.step.apply( elem, [ z.now ] );
1674
1675 if ( prop == "opacity" )
1676 jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
1677 else if ( parseInt(z.now) ) // My hate for IE will never die
1678 y[prop] = parseInt(z.now) + "px";
1679
1680 y.display = "block"; // Set display property to block for animation
1681 };
1682
1683 // Figure out the maximum number to run to
1684 z.max = function(){
1685 return parseFloat( jQuery.css(elem,prop) );
1686 };
1687
1688 // Get the current size
1689 z.cur = function(){
1690 var r = parseFloat( jQuery.curCSS(elem, prop) );
1691 return r && r > -10000 ? r : z.max();
1692 };
1693
1694 // Start an animation from one number to another
1695 z.custom = function(from,to){
1696 z.startTime = (new Date()).getTime();
1697 z.now = from;
1698 z.a();
1699
1700 z.timer = setInterval(function(){
1701 z.step(from, to);
1702 }, 13);
1703 };
1704
1705 // Simple 'show' function
1706 z.show = function(){
1707 if ( !elem.orig ) elem.orig = {};
1708
1709 // Remember where we started, so that we can go back to it later
1710 elem.orig[prop] = this.cur();
1711
1712 options.show = true;
1713
1714 // Begin the animation
1715 z.custom(0, elem.orig[prop]);
1716
1717 // Stupid IE, look what you made me do
1718 if ( prop != "opacity" )
1719 y[prop] = "1px";
1720 };
1721
1722 // Simple 'hide' function
1723 z.hide = function(){
1724 if ( !elem.orig ) elem.orig = {};
1725
1726 // Remember where we started, so that we can go back to it later
1727 elem.orig[prop] = this.cur();
1728
1729 options.hide = true;
1730
1731 // Begin the animation
1732 z.custom(elem.orig[prop], 0);
1733 };
1734
1735 //Simple 'toggle' function
1736 z.toggle = function() {
1737 if ( !elem.orig ) elem.orig = {};
1738
1739 // Remember where we started, so that we can go back to it later
1740 elem.orig[prop] = this.cur();
1741
1742 if(oldDisplay == "none") {
1743 options.show = true;
1744
1745 // Stupid IE, look what you made me do
1746 if ( prop != "opacity" )
1747 y[prop] = "1px";
1748
1749 // Begin the animation
1750 z.custom(0, elem.orig[prop]);
1751 } else {
1752 options.hide = true;
1753
1754 // Begin the animation
1755 z.custom(elem.orig[prop], 0);
1756 }
1757 };
1758
1759 // Each step of an animation
1760 z.step = function(firstNum, lastNum){
1761 var t = (new Date()).getTime();
1762
1763 if (t > options.duration + z.startTime) {
1764 // Stop the timer
1765 clearInterval(z.timer);
1766 z.timer = null;
1767
1768 z.now = lastNum;
1769 z.a();
1770
1771 if (elem.curAnim) elem.curAnim[ prop ] = true;
1772
1773 var done = true;
1774 for ( var i in elem.curAnim )
1775 if ( elem.curAnim[i] !== true )
1776 done = false;
1777
1778 if ( done ) {
1779 // Reset the overflow
1780 y.overflow = "";
1781
1782 // Reset the display
1783 y.display = oldDisplay;
1784 if (jQuery.css(elem, "display") == "none")
1785 y.display = "block";
1786
1787 // Hide the element if the "hide" operation was done
1788 if ( options.hide )
1789 y.display = "none";
1790
1791 // Reset the properties, if the item has been hidden or shown
1792 if ( options.hide || options.show )
1793 for ( var p in elem.curAnim )
1794 if (p == "opacity")
1795 jQuery.attr(y, p, elem.orig[p]);
1796 else
1797 y[p] = "";
1798 }
1799
1800 // If a callback was provided, execute it
1801 if ( done && jQuery.isFunction( options.complete ) )
1802 // Execute the complete function
1803 options.complete.apply( elem );
1804 } else {
1805 var n = t - this.startTime;
1806 // Figure out where in the animation we are and set the number
1807 var p = n / options.duration;
1808
1809 // If the easing function exists, then use it
1810 z.now = options.easing && jQuery.easing[options.easing] ?
1811 jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration) :
1812 // else use default linear easing
1813 ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
1814
1815 // Perform the next step of the animation
1816 z.a();
1817 }
1818 };
1819
1820 }
1821 });
1822 jQuery.fn.extend({
1823 loadIfModified: function( url, params, callback ) {
1824 this.load( url, params, callback, 1 );
1825 },
1826 load: function( url, params, callback, ifModified ) {
1827 if ( jQuery.isFunction( url ) )
1828 return this.bind("load", url);
1829
1830 callback = callback || function(){};
1831
1832 // Default to a GET request
1833 var type = "GET";
1834
1835 // If the second parameter was provided
1836 if ( params )
1837 // If it's a function
1838 if ( jQuery.isFunction( params ) ) {
1839 // We assume that it's the callback
1840 callback = params;
1841 params = null;
1842
1843 // Otherwise, build a param string
1844 } else {
1845 params = jQuery.param( params );
1846 type = "POST";
1847 }
1848
1849 var self = this;
1850
1851 // Request the remote document
1852 jQuery.ajax({
1853 url: url,
1854 type: type,
1855 data: params,
1856 ifModified: ifModified,
1857 complete: function(res, status){
1858 if ( status == "success" || !ifModified && status == "notmodified" )
1859 // Inject the HTML into all the matched elements
1860 self.attr("innerHTML", res.responseText)
1861 // Execute all the scripts inside of the newly-injected HTML
1862 .evalScripts()
1863 // Execute callback
1864 .each( callback, [res.responseText, status, res] );
1865 else
1866 callback.apply( self, [res.responseText, status, res] );
1867 }
1868 });
1869 return this;
1870 },
1871 serialize: function() {
1872 return jQuery.param( this );
1873 },
1874 evalScripts: function() {
1875 return this.find("script").each(function(){
1876 if ( this.src )
1877 jQuery.getScript( this.src );
1878 else
1879 jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" );
1880 }).end();
1881 }
1882
1883 });
1884
1885 // If IE is used, create a wrapper for the XMLHttpRequest object
1886 if ( !window.XMLHttpRequest )
1887 XMLHttpRequest = function(){
1888 return new ActiveXObject("Microsoft.XMLHTTP");
1889 };
1890
1891 // Attach a bunch of functions for handling common AJAX events
1892
1893 jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
1894 jQuery.fn[o] = function(f){
1895 return this.bind(o, f);
1896 };
1897 });
1898
1899 jQuery.extend({
1900 get: function( url, data, callback, type, ifModified ) {
1901 // shift arguments if data argument was ommited
1902 if ( jQuery.isFunction( data ) ) {
1903 callback = data;
1904 data = null;
1905 }
1906
1907 return jQuery.ajax({
1908 url: url,
1909 data: data,
1910 success: callback,
1911 dataType: type,
1912 ifModified: ifModified
1913 });
1914 },
1915 getIfModified: function( url, data, callback, type ) {
1916 return jQuery.get(url, data, callback, type, 1);
1917 },
1918 getScript: function( url, callback ) {
1919 return jQuery.get(url, null, callback, "script");
1920 },
1921 getJSON: function( url, data, callback ) {
1922 return jQuery.get(url, data, callback, "json");
1923 },
1924 post: function( url, data, callback, type ) {
1925 if ( jQuery.isFunction( data ) ) {
1926 callback = data;
1927 data = {};
1928 }
1929
1930 return jQuery.ajax({
1931 type: "POST",
1932 url: url,
1933 data: data,
1934 success: callback,
1935 dataType: type
1936 });
1937 },
1938
1939 // timeout (ms)
1940 //timeout: 0,
1941 ajaxTimeout: function( timeout ) {
1942 jQuery.ajaxSettings.timeout = timeout;
1943 },
1944 ajaxSetup: function( settings ) {
1945 jQuery.extend( jQuery.ajaxSettings, settings );
1946 },
1947
1948 ajaxSettings: {
1949 global: true,
1950 type: "GET",
1951 timeout: 0,
1952 contentType: "application/x-www-form-urlencoded",
1953 processData: true,
1954 async: true,
1955 data: null
1956 },
1957
1958 // Last-Modified header cache for next request
1959 lastModified: {},
1960 ajax: function( s ) {
1961 // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
1962 s = jQuery.extend({}, jQuery.ajaxSettings, s);
1963
1964 // if data available
1965 if ( s.data ) {
1966 // convert data if not already a string
1967 if (s.processData && typeof s.data != "string")
1968 s.data = jQuery.param(s.data);
1969 // append data to url for get requests
1970 if( s.type.toLowerCase() == "get" ) {
1971 // "?" + data or "&" + data (in case there are already params)
1972 s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;
1973 // IE likes to send both get and post data, prevent this
1974 s.data = null;
1975 }
1976 }
1977
1978 // Watch for a new set of requests
1979 if ( s.global && ! jQuery.active++ )
1980 jQuery.event.trigger( "ajaxStart" );
1981
1982 var requestDone = false;
1983
1984 // Create the request object
1985 var xml = new XMLHttpRequest();
1986
1987 // Open the socket
1988 xml.open(s.type, s.url, s.async);
1989
1990 // Set the correct header, if data is being sent
1991 if ( s.data )
1992 xml.setRequestHeader("Content-Type", s.contentType);
1993
1994 // Set the If-Modified-Since header, if ifModified mode.
1995 if ( s.ifModified )
1996 xml.setRequestHeader("If-Modified-Since",
1997 jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
1998
1999 // Set header so the called script knows that it's an XMLHttpRequest
2000 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
2001
2002 // Make sure the browser sends the right content length
2003 if ( xml.overrideMimeType )
2004 xml.setRequestHeader("Connection", "close");
2005
2006 // Allow custom headers/mimetypes
2007 if( s.beforeSend )
2008 s.beforeSend(xml);
2009
2010 if ( s.global )
2011 jQuery.event.trigger("ajaxSend", [xml, s]);
2012
2013 // Wait for a response to come back
2014 var onreadystatechange = function(isTimeout){
2015 // The transfer is complete and the data is available, or the request timed out
2016 if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
2017 requestDone = true;
2018 var status;
2019 try {
2020 status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?
2021 s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";
2022 // Make sure that the request was successful or notmodified
2023 if ( status != "error" ) {
2024 // Cache Last-Modified header, if ifModified mode.
2025 var modRes;
2026 try {
2027 modRes = xml.getResponseHeader("Last-Modified");
2028 } catch(e) {} // swallow exception thrown by FF if header is not available
2029
2030 if ( s.ifModified && modRes )
2031 jQuery.lastModified[s.url] = modRes;
2032
2033 // process the data (runs the xml through httpData regardless of callback)
2034 var data = jQuery.httpData( xml, s.dataType );
2035
2036 // If a local callback was specified, fire it and pass it the data
2037 if ( s.success )
2038 s.success( data, status );
2039
2040 // Fire the global callback
2041 if( s.global )
2042 jQuery.event.trigger( "ajaxSuccess", [xml, s] );
2043 } else
2044 jQuery.handleError(s, xml, status);
2045 } catch(e) {
2046 status = "error";
2047 jQuery.handleError(s, xml, status, e);
2048 }
2049
2050 // The request was completed
2051 if( s.global )
2052 jQuery.event.trigger( "ajaxComplete", [xml, s] );
2053
2054 // Handle the global AJAX counter
2055 if ( s.global && ! --jQuery.active )
2056 jQuery.event.trigger( "ajaxStop" );
2057
2058 // Process result
2059 if ( s.complete )
2060 s.complete(xml, status);
2061
2062 // Stop memory leaks
2063 xml.onreadystatechange = function(){};
2064 xml = null;
2065 }
2066 };
2067 xml.onreadystatechange = onreadystatechange;
2068
2069 // Timeout checker
2070 if ( s.timeout > 0 )
2071 setTimeout(function(){
2072 // Check to see if the request is still happening
2073 if ( xml ) {
2074 // Cancel the request
2075 xml.abort();
2076
2077 if( !requestDone )
2078 onreadystatechange( "timeout" );
2079 }
2080 }, s.timeout);
2081
2082 // save non-leaking reference
2083 var xml2 = xml;
2084
2085 // Send the data
2086 try {
2087 xml2.send(s.data);
2088 } catch(e) {
2089 jQuery.handleError(s, xml, null, e);
2090 }
2091
2092 // firefox 1.5 doesn't fire statechange for sync requests
2093 if ( !s.async )
2094 onreadystatechange();
2095
2096 // return XMLHttpRequest to allow aborting the request etc.
2097 return xml2;
2098 },
2099
2100 handleError: function( s, xml, status, e ) {
2101 // If a local callback was specified, fire it
2102 if ( s.error ) s.error( xml, status, e );
2103
2104 // Fire the global callback
2105 if ( s.global )
2106 jQuery.event.trigger( "ajaxError", [xml, s, e] );
2107 },
2108
2109 // Counter for holding the number of active queries
2110 active: 0,
2111
2112 // Determines if an XMLHttpRequest was successful or not
2113 httpSuccess: function( r ) {
2114 try {
2115 return !r.status && location.protocol == "file:" ||
2116 ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
2117 jQuery.browser.safari && r.status == undefined;
2118 } catch(e){}
2119 return false;
2120 },
2121
2122 // Determines if an XMLHttpRequest returns NotModified
2123 httpNotModified: function( xml, url ) {
2124 try {
2125 var xmlRes = xml.getResponseHeader("Last-Modified");
2126
2127 // Firefox always returns 200. check Last-Modified date
2128 return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
2129 jQuery.browser.safari && xml.status == undefined;
2130 } catch(e){}
2131 return false;
2132 },
2133
2134 /* Get the data out of an XMLHttpRequest.
2135 * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
2136 * otherwise return plain text.
2137 * (String) data - The type of data that you're expecting back,
2138 * (e.g. "xml", "html", "script")
2139 */
2140 httpData: function( r, type ) {
2141 var ct = r.getResponseHeader("content-type");
2142 var data = !type && ct && ct.indexOf("xml") >= 0;
2143 data = type == "xml" || data ? r.responseXML : r.responseText;
2144
2145 // If the type is "script", eval it in global context
2146 if ( type == "script" )
2147 jQuery.globalEval( data );
2148
2149 // Get the JavaScript object, if JSON is used.
2150 if ( type == "json" )
2151 eval( "data = " + data );
2152
2153 // evaluate scripts within html
2154 if ( type == "html" )
2155 jQuery("<div>").html(data).evalScripts();
2156
2157 return data;
2158 },
2159
2160 // Serialize an array of form elements or a set of
2161 // key/values into a query string
2162 param: function( a ) {
2163 var s = [];
2164
2165 // If an array was passed in, assume that it is an array
2166 // of form elements
2167 if ( a.constructor == Array || a.jquery )
2168 // Serialize the form elements
2169 jQuery.each( a, function(){
2170 s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
2171 });
2172
2173 // Otherwise, assume that it's an object of key/value pairs
2174 else
2175 // Serialize the key/values
2176 for ( var j in a )
2177 // If the value is an array then the key names need to be repeated
2178 if ( a[j] && a[j].constructor == Array )
2179 jQuery.each( a[j], function(){
2180 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
2181 });
2182 else
2183 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
2184
2185 // Return the resulting serialization
2186 return s.join("&");
2187 },
2188
2189 // evalulates a script in global context
2190 // not reliable for safari
2191 globalEval: function( data ) {
2192 if ( window.execScript )
2193 window.execScript( data );
2194 else if ( jQuery.browser.safari )
2195 // safari doesn't provide a synchronous global eval
2196 window.setTimeout( data, 0 );
2197 else
2198 eval.call( window, data );
2199 }
2200
2201 });
2202 }