// prevent execution of jquery if included more than once if(typeof window.jquery == "undefined") { /* * jquery 1.1.3.1 - new wave javascript * * copyright (c) 2007 john resig (jquery.com) * dual licensed under the mit (mit-license.txt) * and gpl (gpl-license.txt) licenses. * * $date: 2007-07-05 00:43:24 -0400 (thu, 05 jul 2007) $ * $rev: 2243 $ */ // global undefined variable window.undefined = window.undefined; var jquery = function(a,c) { // if the context is global, return a new object if ( window == this || !this.init ) return new jquery(a,c); return this.init(a,c); }; // map over the $ in case of overwrite if ( typeof $ != "undefined" ) jquery._$ = $; // map the jquery namespace to the '$' one var $ = jquery; jquery.fn = jquery.prototype = { init: function(a,c) { // make sure that a selection was provided a = a || document; // handle: $(function) // shortcut for document ready if ( jquery.isfunction(a) ) return new jquery(document)[ jquery.fn.ready ? "ready" : "load" ]( a ); // handle html strings if ( typeof a == "string" ) { // handle: $(html) -> $(array) var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a); if ( m ) a = jquery.clean( [ m[1] ] ); // handle: $(expr) else return new jquery( c ).find( a ); } return this.setarray( // handle: $(array) a.constructor == array && a || // handle: $(arraylike) // watch for when an array-like object is passed as the selector (a.jquery || a.length && a != window && !a.nodetype && a[0] != undefined && a[0].nodetype) && jquery.makearray( a ) || // handle: $(*) [ a ] ); }, jquery: "1.1.3.1", size: function() { return this.length; }, length: 0, get: function( num ) { return num == undefined ? // return a 'clean' array jquery.makearray( this ) : // return just the object this[num]; }, pushstack: function( a ) { var ret = jquery(a); ret.prevobject = this; return ret; }, setarray: function( a ) { this.length = 0; [].push.apply( this, a ); return this; }, each: function( fn, args ) { return jquery.each( this, fn, args ); }, index: function( obj ) { var pos = -1; this.each(function(i){ if ( this == obj ) pos = i; }); return pos; }, attr: function( key, value, type ) { var obj = key; // look for the case where we're accessing a style value if ( key.constructor == string ) if ( value == undefined ) return this.length && jquery[ type || "attr" ]( this[0], key ) || undefined; else { obj = {}; obj[ key ] = value; } // check to see if we're setting style values return this.each(function(index){ // set all the styles for ( var prop in obj ) jquery.attr( type ? this.style : this, prop, jquery.prop(this, obj[prop], type, index, prop) ); }); }, css: function( key, value ) { return this.attr( key, value, "curcss" ); }, text: function(e) { if ( typeof e == "string" ) return this.empty().append( document.createtextnode( e ) ); var t = ""; jquery.each( e || this, function(){ jquery.each( this.childnodes, function(){ if ( this.nodetype != 8 ) t += this.nodetype != 1 ? this.nodevalue : jquery.fn.text([ this ]); }); }); return t; }, wrap: function() { // the elements to wrap the target around var a, args = arguments; // wrap each of the matched elements individually return this.each(function(){ if ( !a ) a = jquery.clean(args, this.ownerdocument); // clone the structure that we're using to wrap var b = a[0].clonenode(true); // insert it before the element to be wrapped this.parentnode.insertbefore( b, this ); // find the deepest point in the wrap structure while ( b.firstchild ) b = b.firstchild; // move the matched element to within the wrap structure b.appendchild( this ); }); }, append: function() { return this.dommanip(arguments, true, 1, function(a){ this.appendchild( a ); }); }, prepend: function() { return this.dommanip(arguments, true, -1, function(a){ this.insertbefore( a, this.firstchild ); }); }, before: function() { return this.dommanip(arguments, false, 1, function(a){ this.parentnode.insertbefore( a, this ); }); }, after: function() { return this.dommanip(arguments, false, -1, function(a){ this.parentnode.insertbefore( a, this.nextsibling ); }); }, end: function() { return this.prevobject || jquery([]); }, find: function(t) { var data = jquery.map(this, function(a){ return jquery.find(t,a); }); return this.pushstack( /[^+>] [^+>]/.test( t ) || t.indexof("..") > -1 ? jquery.unique( data ) : data ); }, clone: function(deep) { // need to remove events on the element and its descendants var $this = this.add(this.find("*")); $this.each(function() { this._$events = {}; for (var type in this.$events) this._$events[type] = jquery.extend({},this.$events[type]); }).unbind(); // do the clone var r = this.pushstack( jquery.map( this, function(a){ return a.clonenode( deep != undefined ? deep : true ); }) ); // add the events back to the original and its descendants $this.each(function() { var events = this._$events; for (var type in events) for (var handler in events[type]) jquery.event.add(this, type, events[type][handler], events[type][handler].data); this._$events = null; }); // return the cloned set return r; }, filter: function(t) { return this.pushstack( jquery.isfunction( t ) && jquery.grep(this, function(el, index){ return t.apply(el, [index]) }) || jquery.multifilter(t,this) ); }, not: function(t) { return this.pushstack( t.constructor == string && jquery.multifilter(t, this, true) || jquery.grep(this, function(a) { return ( t.constructor == array || t.jquery ) ? jquery.inarray( a, t ) < 0 : a != t; }) ); }, add: function(t) { return this.pushstack( jquery.merge( this.get(), t.constructor == string ? jquery(t).get() : t.length != undefined && (!t.nodename || t.nodename == "form") ? t : [t] ) ); }, is: function(expr) { return expr ? jquery.multifilter(expr,this).length > 0 : false; }, val: function( val ) { return val == undefined ? ( this.length ? this[0].value : null ) : this.attr( "value", val ); }, html: function( val ) { return val == undefined ? ( this.length ? this[0].innerhtml : null ) : this.empty().append( val ); }, dommanip: function(args, table, dir, fn){ var clone = this.length > 1, a; return this.each(function(){ if ( !a ) { a = jquery.clean(args, this.ownerdocument); if ( dir < 0 ) a.reverse(); } var obj = this; if ( table && jquery.nodename(this, "table") && jquery.nodename(a[0], "tr") ) obj = this.getelementsbytagname("tbody")[0] || this.appendchild(document.createelement("tbody")); jquery.each( a, function(){ fn.apply( obj, [ clone ? this.clonenode(true) : this ] ); }); }); } }; jquery.extend = jquery.fn.extend = function() { // copy reference to target object var target = arguments[0], a = 1; // extend jquery itself if only one argument is passed if ( arguments.length == 1 ) { target = this; a = 0; } var prop; while ( (prop = arguments[a++]) != null ) // extend the base object for ( var i in prop ) target[i] = prop[i]; // return the modified object return target; }; jquery.extend({ noconflict: function() { if ( jquery._$ ) $ = jquery._$; return jquery; }, // this may seem like some crazy code, but trust me when i say that this // is the only cross-browser way to do this. --john isfunction: function( fn ) { return !!fn && typeof fn != "string" && !fn.nodename && fn.constructor != array && /function/i.test( fn + "" ); }, // check if an element is in a xml document isxmldoc: function(elem) { return elem.tagname && elem.ownerdocument && !elem.ownerdocument.body; }, nodename: function( elem, name ) { return elem.nodename && elem.nodename.touppercase() == name.touppercase(); }, // args is for internal usage only each: function( obj, fn, args ) { if ( obj.length == undefined ) for ( var i in obj ) fn.apply( obj[i], args || [i, obj[i]] ); else for ( var i = 0, ol = obj.length; i < ol; i++ ) if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break; return obj; }, prop: function(elem, value, type, index, prop){ // handle executable functions if ( jquery.isfunction( value ) ) value = value.call( elem, [index] ); // exclude the following css properties to add px var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i; // handle passing in a number to a css property return value && value.constructor == number && type == "curcss" && !exclude.test(prop) ? value + "px" : value; }, classname: { // internal only, use addclass("class") add: function( elem, c ){ jquery.each( c.split(/\s+/), function(i, cur){ if ( !jquery.classname.has( elem.classname, cur ) ) elem.classname += ( elem.classname ? " " : "" ) + cur; }); }, // internal only, use removeclass("class") remove: function( elem, c ){ elem.classname = c != undefined ? jquery.grep( elem.classname.split(/\s+/), function(cur){ return !jquery.classname.has( c, cur ); }).join(" ") : ""; }, // internal only, use is(".class") has: function( t, c ) { return jquery.inarray( c, (t.classname || t).tostring().split(/\s+/) ) > -1; } }, swap: function(e,o,f) { for ( var i in o ) { e.style["old"+i] = e.style[i]; e.style[i] = o[i]; } f.apply( e, [] ); for ( var i in o ) e.style[i] = e.style["old"+i]; }, css: function(e,p) { if ( p == "height" || p == "width" ) { var old = {}, oheight, owidth, d = ["top","bottom","right","left"]; jquery.each( d, function(){ old["padding" + this] = 0; old["border" + this + "width"] = 0; }); jquery.swap( e, old, function() { if ( jquery(e).is(':visible') ) { oheight = e.offsetheight; owidth = e.offsetwidth; } else { e = jquery(e.clonenode(true)) .find(":radio").removeattr("checked").end() .css({ visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0" }).appendto(e.parentnode)[0]; var parpos = jquery.css(e.parentnode,"position") || "static"; if ( parpos == "static" ) e.parentnode.style.position = "relative"; oheight = e.clientheight; owidth = e.clientwidth; if ( parpos == "static" ) e.parentnode.style.position = "static"; e.parentnode.removechild(e); } }); return p == "height" ? oheight : owidth; } return jquery.curcss( e, p ); }, curcss: function(elem, prop, force) { var ret; if (prop == "opacity" && jquery.browser.msie) { ret = jquery.attr(elem.style, "opacity"); return ret == "" ? "1" : ret; } if (prop.match(/float/i)) prop = jquery.stylefloat; if (!force && elem.style[prop]) ret = elem.style[prop]; else if (document.defaultview && document.defaultview.getcomputedstyle) { if (prop.match(/float/i)) prop = "float"; prop = prop.replace(/([a-z])/g,"-$1").tolowercase(); var cur = document.defaultview.getcomputedstyle(elem, null); if ( cur ) ret = cur.getpropertyvalue(prop); else if ( prop == "display" ) ret = "none"; else jquery.swap(elem, { display: "block" }, function() { var c = document.defaultview.getcomputedstyle(this, ""); ret = c && c.getpropertyvalue(prop) || ""; }); } else if (elem.currentstyle) { var newprop = prop.replace(/\-(\w)/g,function(m,c){return c.touppercase();}); ret = elem.currentstyle[prop] || elem.currentstyle[newprop]; } return ret; }, clean: function(a, doc) { var r = []; doc = doc || document; jquery.each( a, function(i,arg){ if ( !arg ) return; if ( arg.constructor == number ) arg = arg.tostring(); // convert html string into dom nodes if ( typeof arg == "string" ) { // trim whitespace, otherwise indexof won't work as expected var s = jquery.trim(arg).tolowercase(), div = doc.createelement("div"), tb = []; var wrap = // option or optgroup !s.indexof("", ""] || !s.indexof("", ""] || (!s.indexof("", ""] || !s.indexof("", ""] || // matched above (!s.indexof("", ""] || !s.indexof("", ""] || [0,"",""]; // go to html and back, then peel off extra wrappers div.innerhtml = wrap[1] + arg + wrap[2]; // move to the right depth while ( wrap[0]-- ) div = div.firstchild; // remove ie's autoinserted from table fragments if ( jquery.browser.msie ) { // string was a , *may* have spurious if ( !s.indexof(" or else if ( wrap[1] == "
" && s.indexof("= 0 ; --n ) if ( jquery.nodename(tb[n], "tbody") && !tb[n].childnodes.length ) tb[n].parentnode.removechild(tb[n]); } arg = jquery.makearray( div.childnodes ); } if ( 0 === arg.length && (!jquery.nodename(arg, "form") && !jquery.nodename(arg, "select")) ) return; if ( arg[0] == undefined || jquery.nodename(arg, "form") || arg.options ) r.push( arg ); else r = jquery.merge( r, arg ); }); return r; }, attr: function(elem, name, value){ var fix = jquery.isxmldoc(elem) ? {} : jquery.props; // certain attributes only work when accessed via the old dom 0 way if ( fix[name] ) { if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; } else if ( value == undefined && jquery.browser.msie && jquery.nodename(elem, "form") && (name == "action" || name == "method") ) return elem.getattributenode(name).nodevalue; // ie elem.getattribute passes even for style else if ( elem.tagname ) { if ( value != undefined ) elem.setattribute( name, value ); if ( jquery.browser.msie && /href|src/.test(name) && !jquery.isxmldoc(elem) ) return elem.getattribute( name, 2 ); return elem.getattribute( name ); // elem is actually elem.style ... set the style } else { // ie actually uses filters for opacity if ( name == "opacity" && jquery.browser.msie ) { if ( value != undefined ) { // ie has trouble with opacity if it does not have layout // force it by setting the zoom level elem.zoom = 1; // set the alpha filter to set the opacity elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") + (parsefloat(value).tostring() == "nan" ? "" : "alpha(opacity=" + value * 100 + ")"); } return elem.filter ? (parsefloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).tostring() : ""; } name = name.replace(/-([a-z])/ig,function(z,b){return b.touppercase();}); if ( value != undefined ) elem[name] = value; return elem[name]; } }, trim: function(t){ return t.replace(/^\s+|\s+$/g, ""); }, makearray: function( a ) { var r = []; // need to use typeof to fight safari childnodes crashes if ( typeof a != "array" ) for ( var i = 0, al = a.length; i < al; i++ ) r.push( a[i] ); else r = a.slice( 0 ); return r; }, inarray: function( b, a ) { for ( var i = 0, al = a.length; i < al; i++ ) if ( a[i] == b ) return i; return -1; }, merge: function(first, second) { // we have to loop this way because ie & opera overwrite the length // expando of getelementsbytagname for ( var i = 0; second[i]; i++ ) first.push(second[i]); return first; }, unique: function(first) { var r = [], num = jquery.mergenum++; for ( var i = 0, fl = first.length; i < fl; i++ ) if ( num != first[i].mergenum ) { first[i].mergenum = num; r.push(first[i]); } return r; }, mergenum: 0, grep: function(elems, fn, inv) { // if a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) fn = new function("a","i","return " + fn); var result = []; // go through the array, only saving the items // that pass the validator function for ( var i = 0, el = elems.length; i < el; i++ ) if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) ) result.push( elems[i] ); return result; }, map: function(elems, fn) { // if a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) fn = new function("a","return " + fn); var result = []; // go through the array, translating each of the items to their // new value (or values). for ( var i = 0, el = elems.length; i < el; i++ ) { var val = fn(elems[i],i); if ( val !== null && val != undefined ) { if ( val.constructor != array ) val = [val]; result = result.concat( val ); } } return result; } }); /* * whether the w3c compliant box model is being used. * * @property * @name $.boxmodel * @type boolean * @cat javascript */ new function() { var b = navigator.useragent.tolowercase(); // figure out what browser is being used jquery.browser = { version: (b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], safari: /webkit/.test(b), opera: /opera/.test(b), msie: /msie/.test(b) && !/opera/.test(b), mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b) }; // check to see if the w3c box model is being used jquery.boxmodel = !jquery.browser.msie || document.compatmode == "css1compat"; jquery.stylefloat = jquery.browser.msie ? "stylefloat" : "cssfloat", jquery.props = { "for": "htmlfor", "class": "classname", "float": jquery.stylefloat, cssfloat: jquery.stylefloat, stylefloat: jquery.stylefloat, innerhtml: "innerhtml", classname: "classname", value: "value", disabled: "disabled", checked: "checked", readonly: "readonly", selected: "selected", maxlength: "maxlength" }; }; jquery.each({ parent: "a.parentnode", parents: "jquery.parents(a)", next: "jquery.nth(a,2,'nextsibling')", prev: "jquery.nth(a,2,'previoussibling')", siblings: "jquery.sibling(a.parentnode.firstchild,a)", children: "jquery.sibling(a.firstchild)" }, function(i,n){ jquery.fn[ i ] = function(a) { var ret = jquery.map(this,n); if ( a && typeof a == "string" ) ret = jquery.multifilter(a,ret); return this.pushstack( ret ); }; }); jquery.each({ appendto: "append", prependto: "prepend", insertbefore: "before", insertafter: "after" }, function(i,n){ jquery.fn[ i ] = function(){ var a = arguments; return this.each(function(){ for ( var j = 0, al = a.length; j < al; j++ ) jquery(a[j])[n]( this ); }); }; }); jquery.each( { removeattr: function( key ) { jquery.attr( this, key, "" ); this.removeattribute( key ); }, addclass: function(c){ jquery.classname.add(this,c); }, removeclass: function(c){ jquery.classname.remove(this,c); }, toggleclass: function( c ){ jquery.classname[ jquery.classname.has(this,c) ? "remove" : "add" ](this, c); }, remove: function(a){ if ( !a || jquery.filter( a, [this] ).r.length ) this.parentnode.removechild( this ); }, empty: function() { while ( this.firstchild ) this.removechild( this.firstchild ); } }, function(i,n){ jquery.fn[ i ] = function() { return this.each( n, arguments ); }; }); jquery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){ jquery.fn[ n ] = function(num,fn) { return this.filter( ":" + n + "(" + num + ")", fn ); }; }); jquery.each( [ "height", "width" ], function(i,n){ jquery.fn[ n ] = function(h) { return h == undefined ? ( this.length ? jquery.css( this[0], n ) : null ) : this.css( n, h.constructor == string ? h : h + "px" ); }; }); jquery.extend({ expr: { "": "m[2]=='*'||jquery.nodename(a,m[2])", "#": "a.getattribute('id')==m[2]", ":": { // position checks lt: "im[3]-0", nth: "m[3]-0==i", eq: "m[3]-0==i", first: "i==0", last: "i==r.length-1", even: "i%2==0", odd: "i%2", // child checks "first-child": "a.parentnode.getelementsbytagname('*')[0]==a", "last-child": "jquery.nth(a.parentnode.lastchild,1,'previoussibling')==a", "only-child": "!jquery.nth(a.parentnode.lastchild,2,'previoussibling')", // parent checks parent: "a.firstchild", empty: "!a.firstchild", // text check contains: "(a.textcontent||a.innertext||'').indexof(m[3])>=0", // visibility visible: '"hidden"!=a.type&&jquery.css(a,"display")!="none"&&jquery.css(a,"visibility")!="hidden"', hidden: '"hidden"==a.type||jquery.css(a,"display")=="none"||jquery.css(a,"visibility")=="hidden"', // form attributes enabled: "!a.disabled", disabled: "a.disabled", checked: "a.checked", selected: "a.selected||jquery.attr(a,'selected')", // form elements text: "'text'==a.type", radio: "'radio'==a.type", checkbox: "'checkbox'==a.type", file: "'file'==a.type", password: "'password'==a.type", submit: "'submit'==a.type", image: "'image'==a.type", reset: "'reset'==a.type", button: '"button"==a.type||jquery.nodename(a,"button")', input: "/input|select|textarea|button/i.test(a.nodename)" }, "[": "jquery.find(m[2],a).length" }, // the regular expressions that power the parsing engine parse: [ // match: [@value='test'], [@foo] /^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, // match: [div], [div p] /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/, // match: :contains('foo') /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/, // match: :even, :last-chlid, #id, .class new regexp("^([:.#]*)(" + ( jquery.chars = jquery.browser.safari && jquery.browser.version < "3.0.0" ? "\\w" : "(?:[\\w\u0128-\uffff*_-]|\\\\.)" ) + "+)") ], multifilter: function( expr, elems, not ) { var old, cur = []; while ( expr && expr != old ) { old = expr; var f = jquery.filter( expr, elems, not ); expr = f.t.replace(/^\s*,\s*/, "" ); cur = not ? elems = f.r : jquery.merge( cur, f.r ); } return cur; }, find: function( t, context ) { // quickly handle non-string expressions if ( typeof t != "string" ) return [ t ]; // make sure that the context is a dom element if ( context && !context.nodetype ) context = null; // set the correct context (if none is provided) context = context || document; // handle the common xpath // expression if ( !t.indexof("//") ) { context = context.documentelement; t = t.substr(2,t.length); // and the / root expression } else if ( !t.indexof("/") && !context.ownerdocument ) { context = context.documentelement; t = t.substr(1,t.length); if ( t.indexof("/") >= 1 ) t = t.substr(t.indexof("/"),t.length); } // initialize the search var ret = [context], done = [], last; // continue while a selector expression exists, and while // we're no longer looping upon ourselves while ( t && last != t ) { var r = []; last = t; t = jquery.trim(t).replace( /^\/\//, "" ); var foundtoken = false; // an attempt at speeding up child selectors that // point to a specific element tag var re = new regexp("^[/>]\\s*(" + jquery.chars + "+)"); var m = re.exec(t); if ( m ) { var nodename = m[1].touppercase(); // perform our own iteration and filter for ( var i = 0; ret[i]; i++ ) for ( var c = ret[i].firstchild; c; c = c.nextsibling ) if ( c.nodetype == 1 && (nodename == "*" || c.nodename.touppercase() == nodename.touppercase()) ) r.push( c ); ret = r; t = t.replace( re, "" ); if ( t.indexof(" ") == 0 ) continue; foundtoken = true; } else { re = /^((\/?\.\.)|([>\/+~]))\s*([a-z]*)/i; if ( (m = re.exec(t)) != null ) { r = []; var nodename = m[4], mergenum = jquery.mergenum++; m = m[1]; for ( var j = 0, rl = ret.length; j < rl; j++ ) if ( m.indexof("..") < 0 ) { var n = m == "~" || m == "+" ? ret[j].nextsibling : ret[j].firstchild; for ( ; n; n = n.nextsibling ) if ( n.nodetype == 1 ) { if ( m == "~" && n.mergenum == mergenum ) break; if (!nodename || n.nodename.touppercase() == nodename.touppercase() ) { if ( m == "~" ) n.mergenum = mergenum; r.push( n ); } if ( m == "+" ) break; } } else r.push( ret[j].parentnode ); ret = r; // and remove the token t = jquery.trim( t.replace( re, "" ) ); foundtoken = true; } } // see if there's still an expression, and that we haven't already // matched a token if ( t && !foundtoken ) { // handle multiple expressions if ( !t.indexof(",") ) { // clean the result set if ( context == ret[0] ) ret.shift(); // merge the result sets done = jquery.merge( done, ret ); // reset the context r = ret = [context]; // touch up the selector string t = " " + t.substr(1,t.length); } else { // optomize for the case nodename#idname var re2 = new regexp("^(" + jquery.chars + "+)(#)(" + jquery.chars + "+)"); var m = re2.exec(t); // re-organize the results, so that they're consistent if ( m ) { m = [ 0, m[2], m[3], m[1] ]; } else { // otherwise, do a traditional filter check for // id, class, and element selectors re2 = new regexp("^([#.]?)(" + jquery.chars + "*)"); m = re2.exec(t); } m[2] = m[2].replace(/\\/g, ""); var elem = ret[ret.length-1]; // try to do a global search by id, where we can if ( m[1] == "#" && elem && elem.getelementbyid ) { // optimization for html document case var oid = elem.getelementbyid(m[2]); // do a quick check for the existence of the actual id attribute // to avoid selecting by the name attribute in ie // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form if ( (jquery.browser.msie||jquery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] ) oid = jquery('[@id="'+m[2]+'"]', elem)[0]; // do a quick check for node name (where applicable) so // that div#foo searches will be really fast ret = r = oid && (!m[3] || jquery.nodename(oid, m[3])) ? [oid] : []; } else { // we need to find all descendant elements for ( var i = 0; ret[i]; i++ ) { // grab the tag name being searched for var tag = m[1] != "" || m[0] == "" ? "*" : m[2]; // handle ie7 being really dumb about s if ( tag == "*" && ret[i].nodename.tolowercase() == "object" ) tag = "param"; r = jquery.merge( r, ret[i].getelementsbytagname( tag )); } // it's faster to filter by class and be done with it if ( m[1] == "." ) r = jquery.classfilter( r, m[2] ); // same with id filtering if ( m[1] == "#" ) { var tmp = []; // try to find the element with the id for ( var i = 0; r[i]; i++ ) if ( r[i].getattribute("id") == m[2] ) { tmp = [ r[i] ]; break; } r = tmp; } ret = r; } t = t.replace( re2, "" ); } } // if a selector string still exists if ( t ) { // attempt to filter it var val = jquery.filter(t,r); ret = r = val.r; t = jquery.trim(val.t); } } // an error occurred with the selector; // just return an empty set instead if ( t ) ret = []; // remove the root context if ( ret && context == ret[0] ) ret.shift(); // and combine the results done = jquery.merge( done, ret ); return done; }, classfilter: function(r,m,not){ m = " " + m + " "; var tmp = []; for ( var i = 0; r[i]; i++ ) { var pass = (" " + r[i].classname + " ").indexof( m ) >= 0; if ( !not && pass || not && !pass ) tmp.push( r[i] ); } return tmp; }, filter: function(t,r,not) { var last; // look for common filter expressions while ( t && t != last ) { last = t; var p = jquery.parse, m; for ( var i = 0; p[i]; i++ ) { m = p[i].exec( t ); if ( m ) { // remove what we just matched t = t.substring( m[0].length ); m[2] = m[2].replace(/\\/g, ""); break; } } if ( !m ) break; // :not() is a special case that can be optimized by // keeping it out of the expression list if ( m[1] == ":" && m[2] == "not" ) r = jquery.filter(m[3], r, true).r; // we can get a big speed boost by filtering by class here else if ( m[1] == "." ) r = jquery.classfilter(r, m[2], not); else if ( m[1] == "@" ) { var tmp = [], type = m[3]; for ( var i = 0, rl = r.length; i < rl; i++ ) { var a = r[i], z = a[ jquery.props[m[2]] || m[2] ]; if ( z == null || /href|src/.test(m[2]) ) z = jquery.attr(a,m[2]) || ''; if ( (type == "" && !!z || type == "=" && z == m[5] || type == "!=" && z != m[5] || type == "^=" && z && !z.indexof(m[5]) || type == "$=" && z.substr(z.length - m[5].length) == m[5] || (type == "*=" || type == "~=") && z.indexof(m[5]) >= 0) ^ not ) tmp.push( a ); } r = tmp; // we can get a speed boost by handling nth-child here } else if ( m[1] == ":" && m[2] == "nth-child" ) { var num = jquery.mergenum++, tmp = [], test = /(\d*)n\+?(\d*)/.exec( m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" || !/\d/.test(m[3]) && "n+" + m[3] || m[3]), first = (test[1] || 1) - 0, last = test[2] - 0; for ( var i = 0, rl = r.length; i < rl; i++ ) { var node = r[i], parentnode = node.parentnode; if ( num != parentnode.mergenum ) { var c = 1; for ( var n = parentnode.firstchild; n; n = n.nextsibling ) if ( n.nodetype == 1 ) n.nodeindex = c++; parentnode.mergenum = num; } var add = false; if ( first == 1 ) { if ( last == 0 || node.nodeindex == last ) add = true; } else if ( (node.nodeindex + last) % first == 0 ) add = true; if ( add ^ not ) tmp.push( node ); } r = tmp; // otherwise, find the expression to execute } else { var f = jquery.expr[m[1]]; if ( typeof f != "string" ) f = jquery.expr[m[1]][m[2]]; // build a custom macro to enclose it eval("f = function(a,i){return " + f + "}"); // execute it against the current filter r = jquery.grep( r, f, not ); } } // return an array of filtered elements (r) // and the modified expression string (t) return { r: r, t: t }; }, parents: function( elem ){ var matched = []; var cur = elem.parentnode; while ( cur && cur != document ) { matched.push( cur ); cur = cur.parentnode; } return matched; }, nth: function(cur,result,dir,elem){ result = result || 1; var num = 0; for ( ; cur; cur = cur[dir] ) if ( cur.nodetype == 1 && ++num == result ) break; return cur; }, sibling: function( n, elem ) { var r = []; for ( ; n; n = n.nextsibling ) { if ( n.nodetype == 1 && (!elem || n != elem) ) r.push( n ); } return r; } }); /* * a number of helper functions used for managing events. * many of the ideas behind this code orignated from * dean edwards' addevent library. */ jquery.event = { // bind an event to an element // original by dean edwards add: function(element, type, handler, data) { // for whatever reason, ie has trouble passing the window object // around, causing it to be cloned in the process if ( jquery.browser.msie && element.setinterval != undefined ) element = window; // make sure that the function being executed has a unique id if ( !handler.guid ) handler.guid = this.guid++; // if data is passed, bind to handler if( data != undefined ) { // create temporary function pointer to original handler var fn = handler; // create unique handler function, wrapped around original handler handler = function() { // pass arguments and context to original handler return fn.apply(this, arguments); }; // store data in unique handler handler.data = data; // set the guid of unique handler to the same of original handler, so it can be removed handler.guid = fn.guid; } // init the element's event structure if (!element.$events) element.$events = {}; if (!element.$handle) element.$handle = function() { // returned undefined or false var val; // handle the second event of a trigger and when // an event is called after a page has unloaded if ( typeof jquery == "undefined" || jquery.event.triggered ) return val; val = jquery.event.handle.apply(element, arguments); return val; }; // get the current list of functions bound to this event var handlers = element.$events[type]; // init the event handler queue if (!handlers) { handlers = element.$events[type] = {}; // and bind the global event handler to the element if (element.addeventlistener) element.addeventlistener(type, element.$handle, false); else element.attachevent("on" + type, element.$handle); } // add the function to the element's handler list handlers[handler.guid] = handler; // remember the function in a global list (for triggering) if (!this.global[type]) this.global[type] = []; // only add the element to the global list once if (jquery.inarray(element, this.global[type]) == -1) this.global[type].push( element ); }, guid: 1, global: {}, // detach an event or set of events from an element remove: function(element, type, handler) { var events = element.$events, ret, index; if ( events ) { // type is actually an event object here if ( type && type.type ) { handler = type.handler; type = type.type; } if ( !type ) { for ( type in events ) this.remove( element, type ); } else if ( events[type] ) { // remove the given handler for the given type if ( handler ) delete events[type][handler.guid]; // remove all handlers for the given type else for ( handler in element.$events[type] ) delete events[type][handler]; // remove generic event handler if no more handlers exist for ( ret in events[type] ) break; if ( !ret ) { if (element.removeeventlistener) element.removeeventlistener(type, element.$handle, false); else element.detachevent("on" + type, element.$handle); ret = null; delete events[type]; // remove element from the global event type cache while ( this.global[type] && ( (index = jquery.inarray(element, this.global[type])) >= 0 ) ) delete this.global[type][index]; } } // remove the expando if it's no longer used for ( ret in events ) break; if ( !ret ) element.$handle = element.$events = null; } }, trigger: function(type, data, element) { // clone the incoming data, if any data = jquery.makearray(data || []); // handle a global trigger if ( !element ) jquery.each( this.global[type] || [], function(){ jquery.event.trigger( type, data, this ); }); // handle triggering a single element else { var val, ret, fn = jquery.isfunction( element[ type ] || null ); // pass along a fake event data.unshift( this.fix({ type: type, target: element }) ); // trigger the event if ( jquery.isfunction(element.$handle) && (val = element.$handle.apply( element, data )) !== false ) this.triggered = true; if ( fn && val !== false && !jquery.nodename(element, 'a') ) element[ type ](); this.triggered = false; } }, handle: function(event) { // returned undefined or false var val; // empty object is for triggered events with no data event = jquery.event.fix( event || window.event || {} ); var c = this.$events && this.$events[event.type], args = [].slice.call( arguments, 1 ); args.unshift( event ); for ( var j in c ) { // pass in a reference to the handler function itself // so that we can later remove it args[0].handler = c[j]; args[0].data = c[j].data; if ( c[j].apply( this, args ) === false ) { event.preventdefault(); event.stoppropagation(); val = false; } } // clean up added properties in ie to prevent memory leak if (jquery.browser.msie) event.target = event.preventdefault = event.stoppropagation = event.handler = event.data = null; return val; }, fix: function(event) { // store a copy of the original event object // and clone to set read-only properties var originalevent = event; event = jquery.extend({}, originalevent); // add preventdefault and stoppropagation since // they will not work on the clone event.preventdefault = function() { // if preventdefault exists run it on the original event if (originalevent.preventdefault) return originalevent.preventdefault(); // otherwise set the returnvalue property of the original event to false (ie) originalevent.returnvalue = false; }; event.stoppropagation = function() { // if stoppropagation exists run it on the original event if (originalevent.stoppropagation) return originalevent.stoppropagation(); // otherwise set the cancelbubble property of the original event to true (ie) originalevent.cancelbubble = true; }; // fix target property, if necessary if ( !event.target && event.srcelement ) event.target = event.srcelement; // check if target is a textnode (safari) if (jquery.browser.safari && event.target.nodetype == 3) event.target = originalevent.target.parentnode; // add relatedtarget, if necessary if ( !event.relatedtarget && event.fromelement ) event.relatedtarget = event.fromelement == event.target ? event.toelement : event.fromelement; // calculate pagex/y if missing and clientx/y available if ( event.pagex == null && event.clientx != null ) { var e = document.documentelement, b = document.body; event.pagex = event.clientx + (e && e.scrollleft || b.scrollleft); event.pagey = event.clienty + (e && e.scrolltop || b.scrolltop); } // add which for key events if ( !event.which && (event.charcode || event.keycode) ) event.which = event.charcode || event.keycode; // add metakey to non-mac browsers (use ctrl for pc's and meta for macs) if ( !event.metakey && event.ctrlkey ) event.metakey = event.ctrlkey; // add which for click: 1 == left; 2 == middle; 3 == right // note: button is not normalized, so don't use it if ( !event.which && event.button ) event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); return event; } }; jquery.fn.extend({ bind: function( type, data, fn ) { return type == "unload" ? this.one(type, data, fn) : this.each(function(){ jquery.event.add( this, type, fn || data, fn && data ); }); }, one: function( type, data, fn ) { return this.each(function(){ jquery.event.add( this, type, function(event) { jquery(this).unbind(event); return (fn || data).apply( this, arguments); }, fn && data); }); }, unbind: function( type, fn ) { return this.each(function(){ jquery.event.remove( this, type, fn ); }); }, trigger: function( type, data ) { return this.each(function(){ jquery.event.trigger( type, data, this ); }); }, toggle: function() { // save reference to arguments for access in closure var a = arguments; return this.click(function(e) { // figure out which function to execute this.lasttoggle = 0 == this.lasttoggle ? 1 : 0; // make sure that clicks stop e.preventdefault(); // and execute the function return a[this.lasttoggle].apply( this, [e] ) || false; }); }, hover: function(f,g) { // a private function for handling mouse 'hovering' function handlehover(e) { // check if mouse(over|out) are still within the same parent element var p = e.relatedtarget; // traverse up the tree while ( p && p != this ) try { p = p.parentnode } catch(e) { p = this; }; // if we actually just moused on to a sub-element, ignore it if ( p == this ) return false; // execute the right function return (e.type == "mouseover" ? f : g).apply(this, [e]); } // bind the function to the two event listeners return this.mouseover(handlehover).mouseout(handlehover); }, ready: function(f) { // if the dom is already ready if ( jquery.isready ) // execute the function immediately f.apply( document, [jquery] ); // otherwise, remember the function for later else // add the function to the wait list jquery.readylist.push( function() { return f.apply(this, [jquery]) } ); return this; } }); jquery.extend({ /* * all the code that makes dom ready work nicely. */ isready: false, readylist: [], // handle when the dom is ready ready: function() { // make sure that the dom is not already loaded if ( !jquery.isready ) { // remember that the dom is ready jquery.isready = true; // if there are functions bound, to execute if ( jquery.readylist ) { // execute all of them jquery.each( jquery.readylist, function(){ this.apply( document ); }); // reset the list of functions jquery.readylist = null; } // remove event listener to avoid memory leak if ( jquery.browser.mozilla || jquery.browser.opera ) document.removeeventlistener( "domcontentloaded", jquery.ready, false ); // remove script element used by ie hack if( !window.frames.length ) // don't remove if frames are present (#1187) jquery(window).load(function(){ jquery("#__ie_init").remove(); }); } } }); new function(){ jquery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + "submit,keydown,keypress,keyup,error").split(","), function(i,o){ // handle event binding jquery.fn[o] = function(f){ return f ? this.bind(o, f) : this.trigger(o); }; }); // if mozilla is used if ( jquery.browser.mozilla || jquery.browser.opera ) // use the handy event callback document.addeventlistener( "domcontentloaded", jquery.ready, false ); // if ie is used, use the excellent hack by matthias miller // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited else if ( jquery.browser.msie ) { // only works if you document.write() it document.write("<\/script>"); // use the defer script hack var script = document.getelementbyid("__ie_init"); // script does not exist if jquery is loaded dynamically if ( script ) script.onreadystatechange = function() { if ( this.readystate != "complete" ) return; jquery.ready(); }; // clear from memory script = null; // if safari is used } else if ( jquery.browser.safari ) // continually check to see if the document.readystate is valid jquery.safaritimer = setinterval(function(){ // loaded and complete are both valid states if ( document.readystate == "loaded" || document.readystate == "complete" ) { // if either one are found, remove the timer clearinterval( jquery.safaritimer ); jquery.safaritimer = null; // and execute any waiting functions jquery.ready(); } }, 10); // a fallback to window.onload, that will always work jquery.event.add( window, "load", jquery.ready ); }; // clean up after ie to avoid memory leaks if (jquery.browser.msie) jquery(window).one("unload", function() { var global = jquery.event.global; for ( var type in global ) { var els = global[type], i = els.length; if ( i && type != 'unload' ) do els[i-1] && jquery.event.remove(els[i-1], type); while (--i); } }); jquery.fn.extend({ loadifmodified: function( url, params, callback ) { this.load( url, params, callback, 1 ); }, load: function( url, params, callback, ifmodified ) { if ( jquery.isfunction( url ) ) return this.bind("load", url); callback = callback || function(){}; // default to a get request var type = "get"; // if the second parameter was provided if ( params ) // if it's a function if ( jquery.isfunction( params ) ) { // we assume that it's the callback callback = params; params = null; // otherwise, build a param string } else { params = jquery.param( params ); type = "post"; } var self = this; // request the remote document jquery.ajax({ url: url, type: type, data: params, ifmodified: ifmodified, complete: function(res, status){ if ( status == "success" || !ifmodified && status == "notmodified" ) // inject the html into all the matched elements self.attr("innerhtml", res.responsetext) // execute all the scripts inside of the newly-injected html .evalscripts() // execute callback .each( callback, [res.responsetext, status, res] ); else callback.apply( self, [res.responsetext, status, res] ); } }); return this; }, serialize: function() { return jquery.param( this ); }, evalscripts: function() { return this.find("script").each(function(){ if ( this.src ) jquery.getscript( this.src ); else jquery.globaleval( this.text || this.textcontent || this.innerhtml || "" ); }).end(); } }); // attach a bunch of functions for handling common ajax events jquery.each( "ajaxstart,ajaxstop,ajaxcomplete,ajaxerror,ajaxsuccess,ajaxsend".split(","), function(i,o){ jquery.fn[o] = function(f){ return this.bind(o, f); }; }); jquery.extend({ get: function( url, data, callback, type, ifmodified ) { // shift arguments if data argument was ommited if ( jquery.isfunction( data ) ) { callback = data; data = null; } return jquery.ajax({ type: "get", url: url, data: data, success: callback, datatype: type, ifmodified: ifmodified }); }, getifmodified: function( url, data, callback, type ) { return jquery.get(url, data, callback, type, 1); }, getscript: function( url, callback ) { return jquery.get(url, null, callback, "script"); }, getjson: function( url, data, callback ) { return jquery.get(url, data, callback, "json"); }, post: function( url, data, callback, type ) { if ( jquery.isfunction( data ) ) { callback = data; data = {}; } return jquery.ajax({ type: "post", url: url, data: data, success: callback, datatype: type }); }, ajaxtimeout: function( timeout ) { jquery.ajaxsettings.timeout = timeout; }, ajaxsetup: function( settings ) { jquery.extend( jquery.ajaxsettings, settings ); }, ajaxsettings: { global: true, type: "get", timeout: 0, contenttype: "application/x-www-form-urlencoded", processdata: true, async: true, data: null }, // last-modified header cache for next request lastmodified: {}, ajax: function( s ) { // todo introduce global settings, allowing the client to modify them for all requests, not only timeout s = jquery.extend({}, jquery.ajaxsettings, s); // if data available if ( s.data ) { // convert data if not already a string if (s.processdata && typeof s.data != "string") s.data = jquery.param(s.data); // append data to url for get requests if( s.type.tolowercase() == "get" ) { // "?" + data or "&" + data (in case there are already params) s.url += ((s.url.indexof("?") > -1) ? "&" : "?") + s.data; // ie likes to send both get and post data, prevent this s.data = null; } } // watch for a new set of requests if ( s.global && ! jquery.active++ ) jquery.event.trigger( "ajaxstart" ); var requestdone = false; // create the request object; microsoft failed to properly // implement the xmlhttprequest in ie7, so we use the activexobject when it is available var xml = window.activexobject ? new activexobject("microsoft.xmlhttp") : new xmlhttprequest(); // open the socket xml.open(s.type, s.url, s.async); // set the correct header, if data is being sent if ( s.data ) xml.setrequestheader("content-type", s.contenttype); // set the if-modified-since header, if ifmodified mode. if ( s.ifmodified ) xml.setrequestheader("if-modified-since", jquery.lastmodified[s.url] || "thu, 01 jan 1970 00:00:00 gmt" ); // set header so the called script knows that it's an xmlhttprequest xml.setrequestheader("x-requested-with", "xmlhttprequest"); // allow custom headers/mimetypes if( s.beforesend ) s.beforesend(xml); if ( s.global ) jquery.event.trigger("ajaxsend", [xml, s]); // wait for a response to come back var onreadystatechange = function(istimeout){ // the transfer is complete and the data is available, or the request timed out if ( xml && (xml.readystate == 4 || istimeout == "timeout") ) { requestdone = true; // clear poll interval if (ival) { clearinterval(ival); ival = null; } var status; try { status = jquery.httpsuccess( xml ) && istimeout != "timeout" ? s.ifmodified && jquery.httpnotmodified( xml, s.url ) ? "notmodified" : "success" : "error"; // make sure that the request was successful or notmodified if ( status != "error" ) { // cache last-modified header, if ifmodified mode. var modres; try { modres = xml.getresponseheader("last-modified"); } catch(e) {} // swallow exception thrown by ff if header is not available if ( s.ifmodified && modres ) jquery.lastmodified[s.url] = modres; // process the data (runs the xml through httpdata regardless of callback) var data = jquery.httpdata( xml, s.datatype ); // if a local callback was specified, fire it and pass it the data if ( s.success ) s.success( data, status ); // fire the global callback if( s.global ) jquery.event.trigger( "ajaxsuccess", [xml, s] ); } else jquery.handleerror(s, xml, status); } catch(e) { status = "error"; jquery.handleerror(s, xml, status, e); } // the request was completed if( s.global ) jquery.event.trigger( "ajaxcomplete", [xml, s] ); // handle the global ajax counter if ( s.global && ! --jquery.active ) jquery.event.trigger( "ajaxstop" ); // process result if ( s.complete ) s.complete(xml, status); // stop memory leaks if(s.async) xml = null; } }; // don't attach the handler to the request, just poll it instead var ival = setinterval(onreadystatechange, 13); // timeout checker if ( s.timeout > 0 ) settimeout(function(){ // check to see if the request is still happening if ( xml ) { // cancel the request xml.abort(); if( !requestdone ) onreadystatechange( "timeout" ); } }, s.timeout); // send the data try { xml.send(s.data); } catch(e) { jquery.handleerror(s, xml, null, e); } // firefox 1.5 doesn't fire statechange for sync requests if ( !s.async ) onreadystatechange(); // return xmlhttprequest to allow aborting the request etc. return xml; }, handleerror: function( s, xml, status, e ) { // if a local callback was specified, fire it if ( s.error ) s.error( xml, status, e ); // fire the global callback if ( s.global ) jquery.event.trigger( "ajaxerror", [xml, s, e] ); }, // counter for holding the number of active queries active: 0, // determines if an xmlhttprequest was successful or not httpsuccess: function( r ) { try { return !r.status && location.protocol == "file:" || ( r.status >= 200 && r.status < 300 ) || r.status == 304 || jquery.browser.safari && r.status == undefined; } catch(e){} return false; }, // determines if an xmlhttprequest returns notmodified httpnotmodified: function( xml, url ) { try { var xmlres = xml.getresponseheader("last-modified"); // firefox always returns 200. check last-modified date return xml.status == 304 || xmlres == jquery.lastmodified[url] || jquery.browser.safari && xml.status == undefined; } catch(e){} return false; }, /* get the data out of an xmlhttprequest. * return parsed xml if content-type header is "xml" and type is "xml" or omitted, * otherwise return plain text. * (string) data - the type of data that you're expecting back, * (e.g. "xml", "html", "script") */ httpdata: function( r, type ) { var ct = r.getresponseheader("content-type"); var data = !type && ct && ct.indexof("xml") >= 0; data = type == "xml" || data ? r.responsexml : r.responsetext; // if the type is "script", eval it in global context if ( type == "script" ) jquery.globaleval( data ); // get the javascript object, if json is used. if ( type == "json" ) data = eval("(" + data + ")"); // evaluate scripts within html if ( type == "html" ) jquery("
").html(data).evalscripts(); return data; }, // serialize an array of form elements or a set of // key/values into a query string param: function( a ) { var s = []; // if an array was passed in, assume that it is an array // of form elements if ( a.constructor == array || a.jquery ) // serialize the form elements jquery.each( a, function(){ s.push( encodeuricomponent(this.name) + "=" + encodeuricomponent( this.value ) ); }); // otherwise, assume that it's an object of key/value pairs else // serialize the key/values for ( var j in a ) // if the value is an array then the key names need to be repeated if ( a[j] && a[j].constructor == array ) jquery.each( a[j], function(){ s.push( encodeuricomponent(j) + "=" + encodeuricomponent( this ) ); }); else s.push( encodeuricomponent(j) + "=" + encodeuricomponent( a[j] ) ); // return the resulting serialization return s.join("&"); }, // evalulates a script in global context // not reliable for safari globaleval: function( data ) { if ( window.execscript ) window.execscript( data ); else if ( jquery.browser.safari ) // safari doesn't provide a synchronous global eval window.settimeout( data, 0 ); else eval.call( window, data ); } }); jquery.fn.extend({ show: function(speed,callback){ return speed ? this.animate({ height: "show", width: "show", opacity: "show" }, speed, callback) : this.filter(":hidden").each(function(){ this.style.display = this.oldblock ? this.oldblock : ""; if ( jquery.css(this,"display") == "none" ) this.style.display = "block"; }).end(); }, hide: function(speed,callback){ return speed ? this.animate({ height: "hide", width: "hide", opacity: "hide" }, speed, callback) : this.filter(":visible").each(function(){ this.oldblock = this.oldblock || jquery.css(this,"display"); if ( this.oldblock == "none" ) this.oldblock = "block"; this.style.display = "none"; }).end(); }, // save the old toggle function _toggle: jquery.fn.toggle, toggle: function( fn, fn2 ){ return jquery.isfunction(fn) && jquery.isfunction(fn2) ? this._toggle( fn, fn2 ) : fn ? this.animate({ height: "toggle", width: "toggle", opacity: "toggle" }, fn, fn2) : this.each(function(){ jquery(this)[ jquery(this).is(":hidden") ? "show" : "hide" ](); }); }, slidedown: function(speed,callback){ return this.animate({height: "show"}, speed, callback); }, slideup: function(speed,callback){ return this.animate({height: "hide"}, speed, callback); }, slidetoggle: function(speed, callback){ return this.animate({height: "toggle"}, speed, callback); }, fadein: function(speed, callback){ return this.animate({opacity: "show"}, speed, callback); }, fadeout: function(speed, callback){ return this.animate({opacity: "hide"}, speed, callback); }, fadeto: function(speed,to,callback){ return this.animate({opacity: to}, speed, callback); }, animate: function( prop, speed, easing, callback ) { return this.queue(function(){ var hidden = jquery(this).is(":hidden"), opt = jquery.speed(speed, easing, callback), self = this; for ( var p in prop ) { if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) return jquery.isfunction(opt.complete) && opt.complete.apply(this); if ( p == "height" || p == "width" ) { // store display property opt.display = jquery.css(this, "display"); // make sure that nothing sneaks out opt.overflow = this.style.overflow; } } if ( opt.overflow != null ) this.style.overflow = "hidden"; this.curanim = jquery.extend({}, prop); jquery.each( prop, function(name, val){ var e = new jquery.fx( self, opt, name ); if ( val.constructor == number ) e.custom( e.cur(), val ); else e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); }); }); }, queue: function(type,fn){ if ( !fn ) { fn = type; type = "fx"; } return this.each(function(){ if ( !this.queue ) this.queue = {}; if ( !this.queue[type] ) this.queue[type] = []; this.queue[type].push( fn ); if ( this.queue[type].length == 1 ) fn.apply(this); }); } }); jquery.extend({ speed: function(speed, easing, fn) { var opt = speed && speed.constructor == object ? speed : { complete: fn || !fn && easing || jquery.isfunction( speed ) && speed, duration: speed, easing: fn && easing || easing && easing.constructor != function && easing || (jquery.easing.swing ? "swing" : "linear") }; opt.duration = (opt.duration && opt.duration.constructor == number ? opt.duration : { slow: 600, fast: 200 }[opt.duration]) || 400; // queueing opt.old = opt.complete; opt.complete = function(){ jquery.dequeue(this, "fx"); if ( jquery.isfunction( opt.old ) ) opt.old.apply( this ); }; return opt; }, easing: { linear: function( p, n, firstnum, diff ) { return firstnum + diff * p; }, swing: function( p, n, firstnum, diff ) { return ((-math.cos(p*math.pi)/2) + 0.5) * diff + firstnum; } }, queue: {}, dequeue: function(elem,type){ type = type || "fx"; if ( elem.queue && elem.queue[type] ) { // remove self elem.queue[type].shift(); // get next function var f = elem.queue[type][0]; if ( f ) f.apply( elem ); } }, timers: [], /* * i originally wrote fx() as a clone of moo.fx and in the process * of making it small in size the code became illegible to sane * people. you've been warned. */ fx: function( elem, options, prop ){ var z = this; // the styles var y = elem.style; // simple function for setting a style value z.a = function(){ if ( options.step ) options.step.apply( elem, [ z.now ] ); if ( prop == "opacity" ) jquery.attr(y, "opacity", z.now); // let attr handle opacity else { y[prop] = parseint(z.now) + "px"; y.display = "block"; // set display property to block for animation } }; // figure out the maximum number to run to z.max = function(){ return parsefloat( jquery.css(elem,prop) ); }; // get the current size z.cur = function(){ var r = parsefloat( jquery.curcss(elem, prop) ); return r && r > -10000 ? r : z.max(); }; // start an animation from one number to another z.custom = function(from,to){ z.starttime = (new date()).gettime(); z.now = from; z.a(); jquery.timers.push(function(){ return z.step(from, to); }); if ( jquery.timers.length == 1 ) { var timer = setinterval(function(){ var timers = jquery.timers; for ( var i = 0; i < timers.length; i++ ) if ( !timers[i]() ) timers.splice(i--, 1); if ( !timers.length ) clearinterval( timer ); }, 13); } }; // simple 'show' function z.show = function(){ if ( !elem.orig ) elem.orig = {}; // remember where we started, so that we can go back to it later elem.orig[prop] = jquery.attr( elem.style, prop ); options.show = true; // begin the animation z.custom(0, this.cur()); // make sure that we start at a small width/height to avoid any // flash of content if ( prop != "opacity" ) y[prop] = "1px"; // start by showing the element jquery(elem).show(); }; // simple 'hide' function z.hide = function(){ if ( !elem.orig ) elem.orig = {}; // remember where we started, so that we can go back to it later elem.orig[prop] = jquery.attr( elem.style, prop ); options.hide = true; // begin the animation z.custom(this.cur(), 0); }; // each step of an animation z.step = function(firstnum, lastnum){ var t = (new date()).gettime(); if (t > options.duration + z.starttime) { z.now = lastnum; z.a(); if (elem.curanim) elem.curanim[ prop ] = true; var done = true; for ( var i in elem.curanim ) if ( elem.curanim[i] !== true ) done = false; if ( done ) { if ( options.display != null ) { // reset the overflow y.overflow = options.overflow; // reset the display y.display = options.display; if ( jquery.css(elem, "display") == "none" ) y.display = "block"; } // hide the element if the "hide" operation was done if ( options.hide ) y.display = "none"; // reset the properties, if the item has been hidden or shown if ( options.hide || options.show ) for ( var p in elem.curanim ) jquery.attr(y, p, elem.orig[p]); } // if a callback was provided, execute it if ( done && jquery.isfunction( options.complete ) ) // execute the complete function options.complete.apply( elem ); return false; } else { var n = t - this.starttime; // figure out where in the animation we are and set the number var p = n / options.duration; // perform the easing function, defaults to swing z.now = jquery.easing[options.easing](p, n, firstnum, (lastnum-firstnum), options.duration); // perform the next step of the animation z.a(); } return true; }; } }); }