source: branches/feature-module-update/html/js/jquery.js @ 15652

Revision 15652, 65.7 KB checked in by adachi, 17 years ago (diff)

jQueryを追加

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