Upgrade to ExtJS 3.2.2 - Released 06/02/2010
[extjs.git] / adapter / ext / ext-base-debug-w-comments.js
1 /*!
2  * Ext JS Library 3.2.2
3  * Copyright(c) 2006-2010 Ext JS, Inc.
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 // for old browsers
8 window.undefined = window.undefined;
9
10 /**
11  * @class Ext
12  * Ext core utilities and functions.
13  * @singleton
14  */
15
16 Ext = {
17     /**
18      * The version of the framework
19      * @type String
20      */
21     version : '3.2.2',
22     versionDetail : {
23         major: 3,
24         minor: 2,
25         patch: 2
26     }
27 };
28
29 /**
30  * Copies all the properties of config to obj.
31  * @param {Object} obj The receiver of the properties
32  * @param {Object} config The source of the properties
33  * @param {Object} defaults A different object that will also be applied for default values
34  * @return {Object} returns obj
35  * @member Ext apply
36  */
37 Ext.apply = function(o, c, defaults){
38     // no "this" reference for friendly out of scope calls
39     if(defaults){
40         Ext.apply(o, defaults);
41     }
42     if(o && c && typeof c == 'object'){
43         for(var p in c){
44             o[p] = c[p];
45         }
46     }
47     return o;
48 };
49
50 (function(){
51     var idSeed = 0,
52         toString = Object.prototype.toString,
53         ua = navigator.userAgent.toLowerCase(),
54         check = function(r){
55             return r.test(ua);
56         },
57         DOC = document,
58         isStrict = DOC.compatMode == "CSS1Compat",
59         isOpera = check(/opera/),
60         isChrome = check(/\bchrome\b/),
61         isWebKit = check(/webkit/),
62         isSafari = !isChrome && check(/safari/),
63         isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
64         isSafari3 = isSafari && check(/version\/3/),
65         isSafari4 = isSafari && check(/version\/4/),
66         isIE = !isOpera && check(/msie/),
67         isIE7 = isIE && check(/msie 7/),
68         isIE8 = isIE && check(/msie 8/),
69         isIE6 = isIE && !isIE7 && !isIE8,
70         isGecko = !isWebKit && check(/gecko/),
71         isGecko2 = isGecko && check(/rv:1\.8/),
72         isGecko3 = isGecko && check(/rv:1\.9/),
73         isBorderBox = isIE && !isStrict,
74         isWindows = check(/windows|win32/),
75         isMac = check(/macintosh|mac os x/),
76         isAir = check(/adobeair/),
77         isLinux = check(/linux/),
78         isSecure = /^https/i.test(window.location.protocol);
79
80     // remove css image flicker
81     if(isIE6){
82         try{
83             DOC.execCommand("BackgroundImageCache", false, true);
84         }catch(e){}
85     }
86
87     Ext.apply(Ext, {
88         /**
89          * URL to a blank file used by Ext when in secure mode for iframe src and onReady src to prevent
90          * the IE insecure content warning (<tt>'about:blank'</tt>, except for IE in secure mode, which is <tt>'javascript:""'</tt>).
91          * @type String
92          */
93         SSL_SECURE_URL : isSecure && isIE ? 'javascript:""' : 'about:blank',
94         /**
95          * True if the browser is in strict (standards-compliant) mode, as opposed to quirks mode
96          * @type Boolean
97          */
98         isStrict : isStrict,
99         /**
100          * True if the page is running over SSL
101          * @type Boolean
102          */
103         isSecure : isSecure,
104         /**
105          * True when the document is fully initialized and ready for action
106          * @type Boolean
107          */
108         isReady : false,
109
110         /**
111          * True if the {@link Ext.Fx} Class is available
112          * @type Boolean
113          * @property enableFx
114          */
115
116         /**
117          * True to automatically uncache orphaned Ext.Elements periodically (defaults to true)
118          * @type Boolean
119          */
120         enableGarbageCollector : true,
121
122         /**
123          * True to automatically purge event listeners during garbageCollection (defaults to false).
124          * @type Boolean
125          */
126         enableListenerCollection : false,
127
128         /**
129          * EXPERIMENTAL - True to cascade listener removal to child elements when an element is removed.
130          * Currently not optimized for performance.
131          * @type Boolean
132          */
133         enableNestedListenerRemoval : false,
134
135         /**
136          * Indicates whether to use native browser parsing for JSON methods.
137          * This option is ignored if the browser does not support native JSON methods.
138          * <b>Note: Native JSON methods will not work with objects that have functions.
139          * Also, property names must be quoted, otherwise the data will not parse.</b> (Defaults to false)
140          * @type Boolean
141          */
142         USE_NATIVE_JSON : false,
143
144         /**
145          * Copies all the properties of config to obj if they don't already exist.
146          * @param {Object} obj The receiver of the properties
147          * @param {Object} config The source of the properties
148          * @return {Object} returns obj
149          */
150         applyIf : function(o, c){
151             if(o){
152                 for(var p in c){
153                     if(!Ext.isDefined(o[p])){
154                         o[p] = c[p];
155                     }
156                 }
157             }
158             return o;
159         },
160
161         /**
162          * Generates unique ids. If the element already has an id, it is unchanged
163          * @param {Mixed} el (optional) The element to generate an id for
164          * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
165          * @return {String} The generated Id.
166          */
167         id : function(el, prefix){
168             el = Ext.getDom(el, true) || {};
169             if (!el.id) {
170                 el.id = (prefix || "ext-gen") + (++idSeed);
171             }
172             return el.id;
173         },
174
175         /**
176          * <p>Extends one class to create a subclass and optionally overrides members with the passed literal. This method
177          * also adds the function "override()" to the subclass that can be used to override members of the class.</p>
178          * For example, to create a subclass of Ext GridPanel:
179          * <pre><code>
180 MyGridPanel = Ext.extend(Ext.grid.GridPanel, {
181     constructor: function(config) {
182
183 //      Create configuration for this Grid.
184         var store = new Ext.data.Store({...});
185         var colModel = new Ext.grid.ColumnModel({...});
186
187 //      Create a new config object containing our computed properties
188 //      *plus* whatever was in the config parameter.
189         config = Ext.apply({
190             store: store,
191             colModel: colModel
192         }, config);
193
194         MyGridPanel.superclass.constructor.call(this, config);
195
196 //      Your postprocessing here
197     },
198
199     yourMethod: function() {
200         // etc.
201     }
202 });
203 </code></pre>
204          *
205          * <p>This function also supports a 3-argument call in which the subclass's constructor is
206          * passed as an argument. In this form, the parameters are as follows:</p>
207          * <div class="mdetail-params"><ul>
208          * <li><code>subclass</code> : Function <div class="sub-desc">The subclass constructor.</div></li>
209          * <li><code>superclass</code> : Function <div class="sub-desc">The constructor of class being extended</div></li>
210          * <li><code>overrides</code> : Object <div class="sub-desc">A literal with members which are copied into the subclass's
211          * prototype, and are therefore shared among all instances of the new class.</div></li>
212          * </ul></div>
213          *
214          * @param {Function} superclass The constructor of class being extended.
215          * @param {Object} overrides <p>A literal with members which are copied into the subclass's
216          * prototype, and are therefore shared between all instances of the new class.</p>
217          * <p>This may contain a special member named <tt><b>constructor</b></tt>. This is used
218          * to define the constructor of the new class, and is returned. If this property is
219          * <i>not</i> specified, a constructor is generated and returned which just calls the
220          * superclass's constructor passing on its parameters.</p>
221          * <p><b>It is essential that you call the superclass constructor in any provided constructor. See example code.</b></p>
222          * @return {Function} The subclass constructor from the <code>overrides</code> parameter, or a generated one if not provided.
223          */
224         extend : function(){
225             // inline overrides
226             var io = function(o){
227                 for(var m in o){
228                     this[m] = o[m];
229                 }
230             };
231             var oc = Object.prototype.constructor;
232
233             return function(sb, sp, overrides){
234                 if(typeof sp == 'object'){
235                     overrides = sp;
236                     sp = sb;
237                     sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
238                 }
239                 var F = function(){},
240                     sbp,
241                     spp = sp.prototype;
242
243                 F.prototype = spp;
244                 sbp = sb.prototype = new F();
245                 sbp.constructor=sb;
246                 sb.superclass=spp;
247                 if(spp.constructor == oc){
248                     spp.constructor=sp;
249                 }
250                 sb.override = function(o){
251                     Ext.override(sb, o);
252                 };
253                 sbp.superclass = sbp.supr = (function(){
254                     return spp;
255                 });
256                 sbp.override = io;
257                 Ext.override(sb, overrides);
258                 sb.extend = function(o){return Ext.extend(sb, o);};
259                 return sb;
260             };
261         }(),
262
263         /**
264          * Adds a list of functions to the prototype of an existing class, overwriting any existing methods with the same name.
265          * Usage:<pre><code>
266 Ext.override(MyClass, {
267     newMethod1: function(){
268         // etc.
269     },
270     newMethod2: function(foo){
271         // etc.
272     }
273 });
274 </code></pre>
275          * @param {Object} origclass The class to override
276          * @param {Object} overrides The list of functions to add to origClass.  This should be specified as an object literal
277          * containing one or more methods.
278          * @method override
279          */
280         override : function(origclass, overrides){
281             if(overrides){
282                 var p = origclass.prototype;
283                 Ext.apply(p, overrides);
284                 if(Ext.isIE && overrides.hasOwnProperty('toString')){
285                     p.toString = overrides.toString;
286                 }
287             }
288         },
289
290         /**
291          * Creates namespaces to be used for scoping variables and classes so that they are not global.
292          * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
293          * <pre><code>
294 Ext.namespace('Company', 'Company.data');
295 Ext.namespace('Company.data'); // equivalent and preferable to above syntax
296 Company.Widget = function() { ... }
297 Company.data.CustomStore = function(config) { ... }
298 </code></pre>
299          * @param {String} namespace1
300          * @param {String} namespace2
301          * @param {String} etc
302          * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
303          * @method namespace
304          */
305         namespace : function(){
306             var o, d;
307             Ext.each(arguments, function(v) {
308                 d = v.split(".");
309                 o = window[d[0]] = window[d[0]] || {};
310                 Ext.each(d.slice(1), function(v2){
311                     o = o[v2] = o[v2] || {};
312                 });
313             });
314             return o;
315         },
316
317         /**
318          * Takes an object and converts it to an encoded URL. e.g. Ext.urlEncode({foo: 1, bar: 2}); would return "foo=1&bar=2".  Optionally, property values can be arrays, instead of keys and the resulting string that's returned will contain a name/value pair for each array value.
319          * @param {Object} o
320          * @param {String} pre (optional) A prefix to add to the url encoded string
321          * @return {String}
322          */
323         urlEncode : function(o, pre){
324             var empty,
325                 buf = [],
326                 e = encodeURIComponent;
327
328             Ext.iterate(o, function(key, item){
329                 empty = Ext.isEmpty(item);
330                 Ext.each(empty ? key : item, function(val){
331                     buf.push('&', e(key), '=', (!Ext.isEmpty(val) && (val != key || !empty)) ? (Ext.isDate(val) ? Ext.encode(val).replace(/"/g, '') : e(val)) : '');
332                 });
333             });
334             if(!pre){
335                 buf.shift();
336                 pre = '';
337             }
338             return pre + buf.join('');
339         },
340
341         /**
342          * Takes an encoded URL and and converts it to an object. Example: <pre><code>
343 Ext.urlDecode("foo=1&bar=2"); // returns {foo: "1", bar: "2"}
344 Ext.urlDecode("foo=1&bar=2&bar=3&bar=4", false); // returns {foo: "1", bar: ["2", "3", "4"]}
345 </code></pre>
346          * @param {String} string
347          * @param {Boolean} overwrite (optional) Items of the same name will overwrite previous values instead of creating an an array (Defaults to false).
348          * @return {Object} A literal with members
349          */
350         urlDecode : function(string, overwrite){
351             if(Ext.isEmpty(string)){
352                 return {};
353             }
354             var obj = {},
355                 pairs = string.split('&'),
356                 d = decodeURIComponent,
357                 name,
358                 value;
359             Ext.each(pairs, function(pair) {
360                 pair = pair.split('=');
361                 name = d(pair[0]);
362                 value = d(pair[1]);
363                 obj[name] = overwrite || !obj[name] ? value :
364                             [].concat(obj[name]).concat(value);
365             });
366             return obj;
367         },
368
369         /**
370          * Appends content to the query string of a URL, handling logic for whether to place
371          * a question mark or ampersand.
372          * @param {String} url The URL to append to.
373          * @param {String} s The content to append to the URL.
374          * @return (String) The resulting URL
375          */
376         urlAppend : function(url, s){
377             if(!Ext.isEmpty(s)){
378                 return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
379             }
380             return url;
381         },
382
383         /**
384          * Converts any iterable (numeric indices and a length property) into a true array
385          * Don't use this on strings. IE doesn't support "abc"[0] which this implementation depends on.
386          * For strings, use this instead: "abc".match(/./g) => [a,b,c];
387          * @param {Iterable} the iterable object to be turned into a true Array.
388          * @return (Array) array
389          */
390          toArray : function(){
391              return isIE ?
392                  function(a, i, j, res){
393                      res = [];
394                      for(var x = 0, len = a.length; x < len; x++) {
395                          res.push(a[x]);
396                      }
397                      return res.slice(i || 0, j || res.length);
398                  } :
399                  function(a, i, j){
400                      return Array.prototype.slice.call(a, i || 0, j || a.length);
401                  };
402          }(),
403
404         isIterable : function(v){
405             //check for array or arguments
406             if(Ext.isArray(v) || v.callee){
407                 return true;
408             }
409             //check for node list type
410             if(/NodeList|HTMLCollection/.test(toString.call(v))){
411                 return true;
412             }
413             //NodeList has an item and length property
414             //IXMLDOMNodeList has nextNode method, needs to be checked first.
415             return ((typeof v.nextNode != 'undefined' || v.item) && Ext.isNumber(v.length));
416         },
417
418         /**
419          * Iterates an array calling the supplied function.
420          * @param {Array/NodeList/Mixed} array The array to be iterated. If this
421          * argument is not really an array, the supplied function is called once.
422          * @param {Function} fn The function to be called with each item. If the
423          * supplied function returns false, iteration stops and this method returns
424          * the current <code>index</code>. This function is called with
425          * the following arguments:
426          * <div class="mdetail-params"><ul>
427          * <li><code>item</code> : <i>Mixed</i>
428          * <div class="sub-desc">The item at the current <code>index</code>
429          * in the passed <code>array</code></div></li>
430          * <li><code>index</code> : <i>Number</i>
431          * <div class="sub-desc">The current index within the array</div></li>
432          * <li><code>allItems</code> : <i>Array</i>
433          * <div class="sub-desc">The <code>array</code> passed as the first
434          * argument to <code>Ext.each</code>.</div></li>
435          * </ul></div>
436          * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed.
437          * Defaults to the <code>item</code> at the current <code>index</code>
438          * within the passed <code>array</code>.
439          * @return See description for the fn parameter.
440          */
441         each : function(array, fn, scope){
442             if(Ext.isEmpty(array, true)){
443                 return;
444             }
445             if(!Ext.isIterable(array) || Ext.isPrimitive(array)){
446                 array = [array];
447             }
448             for(var i = 0, len = array.length; i < len; i++){
449                 if(fn.call(scope || array[i], array[i], i, array) === false){
450                     return i;
451                 };
452             }
453         },
454
455         /**
456          * Iterates either the elements in an array, or each of the properties in an object.
457          * <b>Note</b>: If you are only iterating arrays, it is better to call {@link #each}.
458          * @param {Object/Array} object The object or array to be iterated
459          * @param {Function} fn The function to be called for each iteration.
460          * The iteration will stop if the supplied function returns false, or
461          * all array elements / object properties have been covered. The signature
462          * varies depending on the type of object being interated:
463          * <div class="mdetail-params"><ul>
464          * <li>Arrays : <tt>(Object item, Number index, Array allItems)</tt>
465          * <div class="sub-desc">
466          * When iterating an array, the supplied function is called with each item.</div></li>
467          * <li>Objects : <tt>(String key, Object value, Object)</tt>
468          * <div class="sub-desc">
469          * When iterating an object, the supplied function is called with each key-value pair in
470          * the object, and the iterated object</div></li>
471          * </ul></div>
472          * @param {Object} scope The scope (<code>this</code> reference) in which the specified function is executed. Defaults to
473          * the <code>object</code> being iterated.
474          */
475         iterate : function(obj, fn, scope){
476             if(Ext.isEmpty(obj)){
477                 return;
478             }
479             if(Ext.isIterable(obj)){
480                 Ext.each(obj, fn, scope);
481                 return;
482             }else if(typeof obj == 'object'){
483                 for(var prop in obj){
484                     if(obj.hasOwnProperty(prop)){
485                         if(fn.call(scope || obj, prop, obj[prop], obj) === false){
486                             return;
487                         };
488                     }
489                 }
490             }
491         },
492
493         /**
494          * Return the dom node for the passed String (id), dom node, or Ext.Element.
495          * Optional 'strict' flag is needed for IE since it can return 'name' and
496          * 'id' elements by using getElementById.
497          * Here are some examples:
498          * <pre><code>
499 // gets dom node based on id
500 var elDom = Ext.getDom('elId');
501 // gets dom node based on the dom node
502 var elDom1 = Ext.getDom(elDom);
503
504 // If we don&#39;t know if we are working with an
505 // Ext.Element or a dom node use Ext.getDom
506 function(el){
507     var dom = Ext.getDom(el);
508     // do something with the dom node
509 }
510          * </code></pre>
511          * <b>Note</b>: the dom node to be found actually needs to exist (be rendered, etc)
512          * when this method is called to be successful.
513          * @param {Mixed} el
514          * @return HTMLElement
515          */
516         getDom : function(el, strict){
517             if(!el || !DOC){
518                 return null;
519             }
520             if (el.dom){
521                 return el.dom;
522             } else {
523                 if (typeof el == 'string') {
524                     var e = DOC.getElementById(el);
525                     // IE returns elements with the 'name' and 'id' attribute.
526                     // we do a strict check to return the element with only the id attribute
527                     if (e && isIE && strict) {
528                         if (el == e.getAttribute('id')) {
529                             return e;
530                         } else {
531                             return null;
532                         }
533                     }
534                     return e;
535                 } else {
536                     return el;
537                 }
538             }
539         },
540
541         /**
542          * Returns the current document body as an {@link Ext.Element}.
543          * @return Ext.Element The document body
544          */
545         getBody : function(){
546             return Ext.get(DOC.body || DOC.documentElement);
547         },
548         
549         /**
550          * Returns the current document body as an {@link Ext.Element}.
551          * @return Ext.Element The document body
552          */
553         getHead : function() {
554             var head;
555             
556             return function() {
557                 if (head == undefined) {
558                     head = Ext.get(DOC.getElementsByTagName("head")[0]);
559                 }
560                 
561                 return head;
562             };
563         }(),
564
565         /**
566          * Removes a DOM node from the document.
567          */
568         /**
569          * <p>Removes this element from the document, removes all DOM event listeners, and deletes the cache reference.
570          * All DOM event listeners are removed from this element. If {@link Ext#enableNestedListenerRemoval} is
571          * <code>true</code>, then DOM event listeners are also removed from all child nodes. The body node
572          * will be ignored if passed in.</p>
573          * @param {HTMLElement} node The node to remove
574          */
575         removeNode : isIE && !isIE8 ? function(){
576             var d;
577             return function(n){
578                 if(n && n.tagName != 'BODY'){
579                     (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
580                     d = d || DOC.createElement('div');
581                     d.appendChild(n);
582                     d.innerHTML = '';
583                     delete Ext.elCache[n.id];
584                 }
585             };
586         }() : function(n){
587             if(n && n.parentNode && n.tagName != 'BODY'){
588                 (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n, true) : Ext.EventManager.removeAll(n);
589                 n.parentNode.removeChild(n);
590                 delete Ext.elCache[n.id];
591             }
592         },
593
594         /**
595          * <p>Returns true if the passed value is empty.</p>
596          * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
597          * <li>null</li>
598          * <li>undefined</li>
599          * <li>an empty array</li>
600          * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
601          * </ul></div>
602          * @param {Mixed} value The value to test
603          * @param {Boolean} allowBlank (optional) true to allow empty strings (defaults to false)
604          * @return {Boolean}
605          */
606         isEmpty : function(v, allowBlank){
607             return v === null || v === undefined || ((Ext.isArray(v) && !v.length)) || (!allowBlank ? v === '' : false);
608         },
609
610         /**
611          * Returns true if the passed value is a JavaScript array, otherwise false.
612          * @param {Mixed} value The value to test
613          * @return {Boolean}
614          */
615         isArray : function(v){
616             return toString.apply(v) === '[object Array]';
617         },
618
619         /**
620          * Returns true if the passed object is a JavaScript date object, otherwise false.
621          * @param {Object} object The object to test
622          * @return {Boolean}
623          */
624         isDate : function(v){
625             return toString.apply(v) === '[object Date]';
626         },
627
628         /**
629          * Returns true if the passed value is a JavaScript Object, otherwise false.
630          * @param {Mixed} value The value to test
631          * @return {Boolean}
632          */
633         isObject : function(v){
634             return !!v && Object.prototype.toString.call(v) === '[object Object]';
635         },
636
637         /**
638          * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
639          * @param {Mixed} value The value to test
640          * @return {Boolean}
641          */
642         isPrimitive : function(v){
643             return Ext.isString(v) || Ext.isNumber(v) || Ext.isBoolean(v);
644         },
645
646         /**
647          * Returns true if the passed value is a JavaScript Function, otherwise false.
648          * @param {Mixed} value The value to test
649          * @return {Boolean}
650          */
651         isFunction : function(v){
652             return toString.apply(v) === '[object Function]';
653         },
654
655         /**
656          * Returns true if the passed value is a number. Returns false for non-finite numbers.
657          * @param {Mixed} value The value to test
658          * @return {Boolean}
659          */
660         isNumber : function(v){
661             return typeof v === 'number' && isFinite(v);
662         },
663
664         /**
665          * Returns true if the passed value is a string.
666          * @param {Mixed} value The value to test
667          * @return {Boolean}
668          */
669         isString : function(v){
670             return typeof v === 'string';
671         },
672
673         /**
674          * Returns true if the passed value is a boolean.
675          * @param {Mixed} value The value to test
676          * @return {Boolean}
677          */
678         isBoolean : function(v){
679             return typeof v === 'boolean';
680         },
681
682         /**
683          * Returns true if the passed value is an HTMLElement
684          * @param {Mixed} value The value to test
685          * @return {Boolean}
686          */
687         isElement : function(v) {
688             return v ? !!v.tagName : false;
689         },
690
691         /**
692          * Returns true if the passed value is not undefined.
693          * @param {Mixed} value The value to test
694          * @return {Boolean}
695          */
696         isDefined : function(v){
697             return typeof v !== 'undefined';
698         },
699
700         /**
701          * True if the detected browser is Opera.
702          * @type Boolean
703          */
704         isOpera : isOpera,
705         /**
706          * True if the detected browser uses WebKit.
707          * @type Boolean
708          */
709         isWebKit : isWebKit,
710         /**
711          * True if the detected browser is Chrome.
712          * @type Boolean
713          */
714         isChrome : isChrome,
715         /**
716          * True if the detected browser is Safari.
717          * @type Boolean
718          */
719         isSafari : isSafari,
720         /**
721          * True if the detected browser is Safari 3.x.
722          * @type Boolean
723          */
724         isSafari3 : isSafari3,
725         /**
726          * True if the detected browser is Safari 4.x.
727          * @type Boolean
728          */
729         isSafari4 : isSafari4,
730         /**
731          * True if the detected browser is Safari 2.x.
732          * @type Boolean
733          */
734         isSafari2 : isSafari2,
735         /**
736          * True if the detected browser is Internet Explorer.
737          * @type Boolean
738          */
739         isIE : isIE,
740         /**
741          * True if the detected browser is Internet Explorer 6.x.
742          * @type Boolean
743          */
744         isIE6 : isIE6,
745         /**
746          * True if the detected browser is Internet Explorer 7.x.
747          * @type Boolean
748          */
749         isIE7 : isIE7,
750         /**
751          * True if the detected browser is Internet Explorer 8.x.
752          * @type Boolean
753          */
754         isIE8 : isIE8,
755         /**
756          * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
757          * @type Boolean
758          */
759         isGecko : isGecko,
760         /**
761          * True if the detected browser uses a pre-Gecko 1.9 layout engine (e.g. Firefox 2.x).
762          * @type Boolean
763          */
764         isGecko2 : isGecko2,
765         /**
766          * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
767          * @type Boolean
768          */
769         isGecko3 : isGecko3,
770         /**
771          * True if the detected browser is Internet Explorer running in non-strict mode.
772          * @type Boolean
773          */
774         isBorderBox : isBorderBox,
775         /**
776          * True if the detected platform is Linux.
777          * @type Boolean
778          */
779         isLinux : isLinux,
780         /**
781          * True if the detected platform is Windows.
782          * @type Boolean
783          */
784         isWindows : isWindows,
785         /**
786          * True if the detected platform is Mac OS.
787          * @type Boolean
788          */
789         isMac : isMac,
790         /**
791          * True if the detected platform is Adobe Air.
792          * @type Boolean
793          */
794         isAir : isAir
795     });
796
797     /**
798      * Creates namespaces to be used for scoping variables and classes so that they are not global.
799      * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
800      * <pre><code>
801 Ext.namespace('Company', 'Company.data');
802 Ext.namespace('Company.data'); // equivalent and preferable to above syntax
803 Company.Widget = function() { ... }
804 Company.data.CustomStore = function(config) { ... }
805 </code></pre>
806      * @param {String} namespace1
807      * @param {String} namespace2
808      * @param {String} etc
809      * @return {Object} The namespace object. (If multiple arguments are passed, this will be the last namespace created)
810      * @method ns
811      */
812     Ext.ns = Ext.namespace;
813 })();
814
815 Ext.ns("Ext.util", "Ext.lib", "Ext.data");
816
817 Ext.elCache = {};
818
819 /**
820  * @class Function
821  * These functions are available on every Function object (any JavaScript function).
822  */
823 Ext.apply(Function.prototype, {
824      /**
825      * Creates an interceptor function. The passed function is called before the original one. If it returns false,
826      * the original one is not called. The resulting function returns the results of the original function.
827      * The passed function is called with the parameters of the original function. Example usage:
828      * <pre><code>
829 var sayHi = function(name){
830     alert('Hi, ' + name);
831 }
832
833 sayHi('Fred'); // alerts "Hi, Fred"
834
835 // create a new function that validates input without
836 // directly modifying the original function:
837 var sayHiToFriend = sayHi.createInterceptor(function(name){
838     return name == 'Brian';
839 });
840
841 sayHiToFriend('Fred');  // no alert
842 sayHiToFriend('Brian'); // alerts "Hi, Brian"
843 </code></pre>
844      * @param {Function} fcn The function to call before the original
845      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
846      * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
847      * @return {Function} The new function
848      */
849     createInterceptor : function(fcn, scope){
850         var method = this;
851         return !Ext.isFunction(fcn) ?
852                 this :
853                 function() {
854                     var me = this,
855                         args = arguments;
856                     fcn.target = me;
857                     fcn.method = method;
858                     return (fcn.apply(scope || me || window, args) !== false) ?
859                             method.apply(me || window, args) :
860                             null;
861                 };
862     },
863
864      /**
865      * Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
866      * Call directly on any function. Example: <code>myFunction.createCallback(arg1, arg2)</code>
867      * Will create a function that is bound to those 2 args. <b>If a specific scope is required in the
868      * callback, use {@link #createDelegate} instead.</b> The function returned by createCallback always
869      * executes in the window scope.
870      * <p>This method is required when you want to pass arguments to a callback function.  If no arguments
871      * are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
872      * However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
873      * would simply execute immediately when the code is parsed. Example usage:
874      * <pre><code>
875 var sayHi = function(name){
876     alert('Hi, ' + name);
877 }
878
879 // clicking the button alerts "Hi, Fred"
880 new Ext.Button({
881     text: 'Say Hi',
882     renderTo: Ext.getBody(),
883     handler: sayHi.createCallback('Fred')
884 });
885 </code></pre>
886      * @return {Function} The new function
887     */
888     createCallback : function(/*args...*/){
889         // make args available, in function below
890         var args = arguments,
891             method = this;
892         return function() {
893             return method.apply(window, args);
894         };
895     },
896
897     /**
898      * Creates a delegate (callback) that sets the scope to obj.
899      * Call directly on any function. Example: <code>this.myFunction.createDelegate(this, [arg1, arg2])</code>
900      * Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
901      * callback points to obj. Example usage:
902      * <pre><code>
903 var sayHi = function(name){
904     // Note this use of "this.text" here.  This function expects to
905     // execute within a scope that contains a text property.  In this
906     // example, the "this" variable is pointing to the btn object that
907     // was passed in createDelegate below.
908     alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
909 }
910
911 var btn = new Ext.Button({
912     text: 'Say Hi',
913     renderTo: Ext.getBody()
914 });
915
916 // This callback will execute in the scope of the
917 // button instance. Clicking the button alerts
918 // "Hi, Fred. You clicked the "Say Hi" button."
919 btn.on('click', sayHi.createDelegate(btn, ['Fred']));
920 </code></pre>
921      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
922      * <b>If omitted, defaults to the browser window.</b>
923      * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
924      * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
925      * if a number the args are inserted at the specified position
926      * @return {Function} The new function
927      */
928     createDelegate : function(obj, args, appendArgs){
929         var method = this;
930         return function() {
931             var callArgs = args || arguments;
932             if (appendArgs === true){
933                 callArgs = Array.prototype.slice.call(arguments, 0);
934                 callArgs = callArgs.concat(args);
935             }else if (Ext.isNumber(appendArgs)){
936                 callArgs = Array.prototype.slice.call(arguments, 0); // copy arguments first
937                 var applyArgs = [appendArgs, 0].concat(args); // create method call params
938                 Array.prototype.splice.apply(callArgs, applyArgs); // splice them in
939             }
940             return method.apply(obj || window, callArgs);
941         };
942     },
943
944     /**
945      * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
946      * <pre><code>
947 var sayHi = function(name){
948     alert('Hi, ' + name);
949 }
950
951 // executes immediately:
952 sayHi('Fred');
953
954 // executes after 2 seconds:
955 sayHi.defer(2000, this, ['Fred']);
956
957 // this syntax is sometimes useful for deferring
958 // execution of an anonymous function:
959 (function(){
960     alert('Anonymous');
961 }).defer(100);
962 </code></pre>
963      * @param {Number} millis The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)
964      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
965      * <b>If omitted, defaults to the browser window.</b>
966      * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
967      * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
968      * if a number the args are inserted at the specified position
969      * @return {Number} The timeout id that can be used with clearTimeout
970      */
971     defer : function(millis, obj, args, appendArgs){
972         var fn = this.createDelegate(obj, args, appendArgs);
973         if(millis > 0){
974             return setTimeout(fn, millis);
975         }
976         fn();
977         return 0;
978     }
979 });
980
981 /**
982  * @class String
983  * These functions are available on every String object.
984  */
985 Ext.applyIf(String, {
986     /**
987      * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens.  Each
988      * token must be unique, and must increment in the format {0}, {1}, etc.  Example usage:
989      * <pre><code>
990 var cls = 'my-class', text = 'Some text';
991 var s = String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
992 // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
993      * </code></pre>
994      * @param {String} string The tokenized string to be formatted
995      * @param {String} value1 The value to replace token {0}
996      * @param {String} value2 Etc...
997      * @return {String} The formatted string
998      * @static
999      */
1000     format : function(format){
1001         var args = Ext.toArray(arguments, 1);
1002         return format.replace(/\{(\d+)\}/g, function(m, i){
1003             return args[i];
1004         });
1005     }
1006 });
1007
1008 /**
1009  * @class Array
1010  */
1011 Ext.applyIf(Array.prototype, {
1012     /**
1013      * Checks whether or not the specified object exists in the array.
1014      * @param {Object} o The object to check for
1015      * @param {Number} from (Optional) The index at which to begin the search
1016      * @return {Number} The index of o in the array (or -1 if it is not found)
1017      */
1018     indexOf : function(o, from){
1019         var len = this.length;
1020         from = from || 0;
1021         from += (from < 0) ? len : 0;
1022         for (; from < len; ++from){
1023             if(this[from] === o){
1024                 return from;
1025             }
1026         }
1027         return -1;
1028     },
1029
1030     /**
1031      * Removes the specified object from the array.  If the object is not found nothing happens.
1032      * @param {Object} o The object to remove
1033      * @return {Array} this array
1034      */
1035     remove : function(o){
1036         var index = this.indexOf(o);
1037         if(index != -1){
1038             this.splice(index, 1);
1039         }
1040         return this;
1041     }
1042 });
1043 /**
1044  * @class Ext
1045  */
1046
1047 Ext.ns("Ext.grid", "Ext.list", "Ext.dd", "Ext.tree", "Ext.form", "Ext.menu",
1048        "Ext.state", "Ext.layout", "Ext.app", "Ext.ux", "Ext.chart", "Ext.direct");
1049     /**
1050      * Namespace alloted for extensions to the framework.
1051      * @property ux
1052      * @type Object
1053      */
1054
1055 Ext.apply(Ext, function(){
1056     var E = Ext,
1057         idSeed = 0,
1058         scrollWidth = null;
1059
1060     return {
1061         /**
1062         * A reusable empty function
1063         * @property
1064         * @type Function
1065         */
1066         emptyFn : function(){},
1067
1068         /**
1069          * URL to a 1x1 transparent gif image used by Ext to create inline icons with CSS background images.
1070          * In older versions of IE, this defaults to "http://extjs.com/s.gif" and you should change this to a URL on your server.
1071          * For other browsers it uses an inline data URL.
1072          * @type String
1073          */
1074         BLANK_IMAGE_URL : Ext.isIE6 || Ext.isIE7 || Ext.isAir ?
1075                             'http:/' + '/www.extjs.com/s.gif' :
1076                             'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
1077
1078         extendX : function(supr, fn){
1079             return Ext.extend(supr, fn(supr.prototype));
1080         },
1081
1082         /**
1083          * Returns the current HTML document object as an {@link Ext.Element}.
1084          * @return Ext.Element The document
1085          */
1086         getDoc : function(){
1087             return Ext.get(document);
1088         },
1089
1090         /**
1091          * Utility method for validating that a value is numeric, returning the specified default value if it is not.
1092          * @param {Mixed} value Should be a number, but any type will be handled appropriately
1093          * @param {Number} defaultValue The value to return if the original value is non-numeric
1094          * @return {Number} Value, if numeric, else defaultValue
1095          */
1096         num : function(v, defaultValue){
1097             v = Number(Ext.isEmpty(v) || Ext.isArray(v) || typeof v == 'boolean' || (typeof v == 'string' && v.trim().length == 0) ? NaN : v);
1098             return isNaN(v) ? defaultValue : v;
1099         },
1100
1101         /**
1102          * <p>Utility method for returning a default value if the passed value is empty.</p>
1103          * <p>The value is deemed to be empty if it is<div class="mdetail-params"><ul>
1104          * <li>null</li>
1105          * <li>undefined</li>
1106          * <li>an empty array</li>
1107          * <li>a zero length string (Unless the <tt>allowBlank</tt> parameter is <tt>true</tt>)</li>
1108          * </ul></div>
1109          * @param {Mixed} value The value to test
1110          * @param {Mixed} defaultValue The value to return if the original value is empty
1111          * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
1112          * @return {Mixed} value, if non-empty, else defaultValue
1113          */
1114         value : function(v, defaultValue, allowBlank){
1115             return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
1116         },
1117
1118         /**
1119          * Escapes the passed string for use in a regular expression
1120          * @param {String} str
1121          * @return {String}
1122          */
1123         escapeRe : function(s) {
1124             return s.replace(/([-.*+?^${}()|[\]\/\\])/g, "\\$1");
1125         },
1126
1127         sequence : function(o, name, fn, scope){
1128             o[name] = o[name].createSequence(fn, scope);
1129         },
1130
1131         /**
1132          * Applies event listeners to elements by selectors when the document is ready.
1133          * The event name is specified with an <tt>&#64;</tt> suffix.
1134          * <pre><code>
1135 Ext.addBehaviors({
1136     // add a listener for click on all anchors in element with id foo
1137     '#foo a&#64;click' : function(e, t){
1138         // do something
1139     },
1140
1141     // add the same listener to multiple selectors (separated by comma BEFORE the &#64;)
1142     '#foo a, #bar span.some-class&#64;mouseover' : function(){
1143         // do something
1144     }
1145 });
1146          * </code></pre>
1147          * @param {Object} obj The list of behaviors to apply
1148          */
1149         addBehaviors : function(o){
1150             if(!Ext.isReady){
1151                 Ext.onReady(function(){
1152                     Ext.addBehaviors(o);
1153                 });
1154             } else {
1155                 var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
1156                     parts,
1157                     b,
1158                     s;
1159                 for (b in o) {
1160                     if ((parts = b.split('@'))[1]) { // for Object prototype breakers
1161                         s = parts[0];
1162                         if(!cache[s]){
1163                             cache[s] = Ext.select(s);
1164                         }
1165                         cache[s].on(parts[1], o[b]);
1166                     }
1167                 }
1168                 cache = null;
1169             }
1170         },
1171
1172         /**
1173          * Utility method for getting the width of the browser scrollbar. This can differ depending on
1174          * operating system settings, such as the theme or font size.
1175          * @param {Boolean} force (optional) true to force a recalculation of the value.
1176          * @return {Number} The width of the scrollbar.
1177          */
1178         getScrollBarWidth: function(force){
1179             if(!Ext.isReady){
1180                 return 0;
1181             }
1182
1183             if(force === true || scrollWidth === null){
1184                     // Append our div, do our calculation and then remove it
1185                 var div = Ext.getBody().createChild('<div class="x-hide-offsets" style="width:100px;height:50px;overflow:hidden;"><div style="height:200px;"></div></div>'),
1186                     child = div.child('div', true);
1187                 var w1 = child.offsetWidth;
1188                 div.setStyle('overflow', (Ext.isWebKit || Ext.isGecko) ? 'auto' : 'scroll');
1189                 var w2 = child.offsetWidth;
1190                 div.remove();
1191                 // Need to add 2 to ensure we leave enough space
1192                 scrollWidth = w1 - w2 + 2;
1193             }
1194             return scrollWidth;
1195         },
1196
1197
1198         // deprecated
1199         combine : function(){
1200             var as = arguments, l = as.length, r = [];
1201             for(var i = 0; i < l; i++){
1202                 var a = as[i];
1203                 if(Ext.isArray(a)){
1204                     r = r.concat(a);
1205                 }else if(a.length !== undefined && !a.substr){
1206                     r = r.concat(Array.prototype.slice.call(a, 0));
1207                 }else{
1208                     r.push(a);
1209                 }
1210             }
1211             return r;
1212         },
1213
1214         /**
1215          * Copies a set of named properties fom the source object to the destination object.
1216          * <p>example:<pre><code>
1217 ImageComponent = Ext.extend(Ext.BoxComponent, {
1218     initComponent: function() {
1219         this.autoEl = { tag: 'img' };
1220         MyComponent.superclass.initComponent.apply(this, arguments);
1221         this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
1222     }
1223 });
1224          * </code></pre>
1225          * @param {Object} dest The destination object.
1226          * @param {Object} source The source object.
1227          * @param {Array/String} names Either an Array of property names, or a comma-delimited list
1228          * of property names to copy.
1229          * @return {Object} The modified object.
1230         */
1231         copyTo : function(dest, source, names){
1232             if(typeof names == 'string'){
1233                 names = names.split(/[,;\s]/);
1234             }
1235             Ext.each(names, function(name){
1236                 if(source.hasOwnProperty(name)){
1237                     dest[name] = source[name];
1238                 }
1239             }, this);
1240             return dest;
1241         },
1242
1243         /**
1244          * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
1245          * DOM (if applicable) and calling their destroy functions (if available).  This method is primarily
1246          * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
1247          * {@link Ext.util.Observable} can be passed in.  Any number of elements and/or components can be
1248          * passed into this function in a single call as separate arguments.
1249          * @param {Mixed} arg1 An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
1250          * @param {Mixed} arg2 (optional)
1251          * @param {Mixed} etc... (optional)
1252          */
1253         destroy : function(){
1254             Ext.each(arguments, function(arg){
1255                 if(arg){
1256                     if(Ext.isArray(arg)){
1257                         this.destroy.apply(this, arg);
1258                     }else if(typeof arg.destroy == 'function'){
1259                         arg.destroy();
1260                     }else if(arg.dom){
1261                         arg.remove();
1262                     }
1263                 }
1264             }, this);
1265         },
1266
1267         /**
1268          * Attempts to destroy and then remove a set of named properties of the passed object.
1269          * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
1270          * @param {Mixed} arg1 The name of the property to destroy and remove from the object.
1271          * @param {Mixed} etc... More property names to destroy and remove.
1272          */
1273         destroyMembers : function(o, arg1, arg2, etc){
1274             for(var i = 1, a = arguments, len = a.length; i < len; i++) {
1275                 Ext.destroy(o[a[i]]);
1276                 delete o[a[i]];
1277             }
1278         },
1279
1280         /**
1281          * Creates a copy of the passed Array with falsy values removed.
1282          * @param {Array/NodeList} arr The Array from which to remove falsy values.
1283          * @return {Array} The new, compressed Array.
1284          */
1285         clean : function(arr){
1286             var ret = [];
1287             Ext.each(arr, function(v){
1288                 if(!!v){
1289                     ret.push(v);
1290                 }
1291             });
1292             return ret;
1293         },
1294
1295         /**
1296          * Creates a copy of the passed Array, filtered to contain only unique values.
1297          * @param {Array} arr The Array to filter
1298          * @return {Array} The new Array containing unique values.
1299          */
1300         unique : function(arr){
1301             var ret = [],
1302                 collect = {};
1303
1304             Ext.each(arr, function(v) {
1305                 if(!collect[v]){
1306                     ret.push(v);
1307                 }
1308                 collect[v] = true;
1309             });
1310             return ret;
1311         },
1312
1313         /**
1314          * Recursively flattens into 1-d Array. Injects Arrays inline.
1315          * @param {Array} arr The array to flatten
1316          * @return {Array} The new, flattened array.
1317          */
1318         flatten : function(arr){
1319             var worker = [];
1320             function rFlatten(a) {
1321                 Ext.each(a, function(v) {
1322                     if(Ext.isArray(v)){
1323                         rFlatten(v);
1324                     }else{
1325                         worker.push(v);
1326                     }
1327                 });
1328                 return worker;
1329             }
1330             return rFlatten(arr);
1331         },
1332
1333         /**
1334          * Returns the minimum value in the Array.
1335          * @param {Array|NodeList} arr The Array from which to select the minimum value.
1336          * @param {Function} comp (optional) a function to perform the comparision which determines minimization.
1337          *                   If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1
1338          * @return {Object} The minimum value in the Array.
1339          */
1340         min : function(arr, comp){
1341             var ret = arr[0];
1342             comp = comp || function(a,b){ return a < b ? -1 : 1; };
1343             Ext.each(arr, function(v) {
1344                 ret = comp(ret, v) == -1 ? ret : v;
1345             });
1346             return ret;
1347         },
1348
1349         /**
1350          * Returns the maximum value in the Array
1351          * @param {Array|NodeList} arr The Array from which to select the maximum value.
1352          * @param {Function} comp (optional) a function to perform the comparision which determines maximization.
1353          *                   If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1
1354          * @return {Object} The maximum value in the Array.
1355          */
1356         max : function(arr, comp){
1357             var ret = arr[0];
1358             comp = comp || function(a,b){ return a > b ? 1 : -1; };
1359             Ext.each(arr, function(v) {
1360                 ret = comp(ret, v) == 1 ? ret : v;
1361             });
1362             return ret;
1363         },
1364
1365         /**
1366          * Calculates the mean of the Array
1367          * @param {Array} arr The Array to calculate the mean value of.
1368          * @return {Number} The mean.
1369          */
1370         mean : function(arr){
1371            return arr.length > 0 ? Ext.sum(arr) / arr.length : undefined;
1372         },
1373
1374         /**
1375          * Calculates the sum of the Array
1376          * @param {Array} arr The Array to calculate the sum value of.
1377          * @return {Number} The sum.
1378          */
1379         sum : function(arr){
1380            var ret = 0;
1381            Ext.each(arr, function(v) {
1382                ret += v;
1383            });
1384            return ret;
1385         },
1386
1387         /**
1388          * Partitions the set into two sets: a true set and a false set.
1389          * Example:
1390          * Example2:
1391          * <pre><code>
1392 // Example 1:
1393 Ext.partition([true, false, true, true, false]); // [[true, true, true], [false, false]]
1394
1395 // Example 2:
1396 Ext.partition(
1397     Ext.query("p"),
1398     function(val){
1399         return val.className == "class1"
1400     }
1401 );
1402 // true are those paragraph elements with a className of "class1",
1403 // false set are those that do not have that className.
1404          * </code></pre>
1405          * @param {Array|NodeList} arr The array to partition
1406          * @param {Function} truth (optional) a function to determine truth.  If this is omitted the element
1407          *                   itself must be able to be evaluated for its truthfulness.
1408          * @return {Array} [true<Array>,false<Array>]
1409          */
1410         partition : function(arr, truth){
1411             var ret = [[],[]];
1412             Ext.each(arr, function(v, i, a) {
1413                 ret[ (truth && truth(v, i, a)) || (!truth && v) ? 0 : 1].push(v);
1414             });
1415             return ret;
1416         },
1417
1418         /**
1419          * Invokes a method on each item in an Array.
1420          * <pre><code>
1421 // Example:
1422 Ext.invoke(Ext.query("p"), "getAttribute", "id");
1423 // [el1.getAttribute("id"), el2.getAttribute("id"), ..., elN.getAttribute("id")]
1424          * </code></pre>
1425          * @param {Array|NodeList} arr The Array of items to invoke the method on.
1426          * @param {String} methodName The method name to invoke.
1427          * @param {...*} args Arguments to send into the method invocation.
1428          * @return {Array} The results of invoking the method on each item in the array.
1429          */
1430         invoke : function(arr, methodName){
1431             var ret = [],
1432                 args = Array.prototype.slice.call(arguments, 2);
1433             Ext.each(arr, function(v,i) {
1434                 if (v && typeof v[methodName] == 'function') {
1435                     ret.push(v[methodName].apply(v, args));
1436                 } else {
1437                     ret.push(undefined);
1438                 }
1439             });
1440             return ret;
1441         },
1442
1443         /**
1444          * Plucks the value of a property from each item in the Array
1445          * <pre><code>
1446 // Example:
1447 Ext.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
1448          * </code></pre>
1449          * @param {Array|NodeList} arr The Array of items to pluck the value from.
1450          * @param {String} prop The property name to pluck from each element.
1451          * @return {Array} The value from each item in the Array.
1452          */
1453         pluck : function(arr, prop){
1454             var ret = [];
1455             Ext.each(arr, function(v) {
1456                 ret.push( v[prop] );
1457             });
1458             return ret;
1459         },
1460
1461         /**
1462          * <p>Zips N sets together.</p>
1463          * <pre><code>
1464 // Example 1:
1465 Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
1466 // Example 2:
1467 Ext.zip(
1468     [ "+", "-", "+"],
1469     [  12,  10,  22],
1470     [  43,  15,  96],
1471     function(a, b, c){
1472         return "$" + a + "" + b + "." + c
1473     }
1474 ); // ["$+12.43", "$-10.15", "$+22.96"]
1475          * </code></pre>
1476          * @param {Arrays|NodeLists} arr This argument may be repeated. Array(s) to contribute values.
1477          * @param {Function} zipper (optional) The last item in the argument list. This will drive how the items are zipped together.
1478          * @return {Array} The zipped set.
1479          */
1480         zip : function(){
1481             var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
1482                 arrs = parts[0],
1483                 fn = parts[1][0],
1484                 len = Ext.max(Ext.pluck(arrs, "length")),
1485                 ret = [];
1486
1487             for (var i = 0; i < len; i++) {
1488                 ret[i] = [];
1489                 if(fn){
1490                     ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
1491                 }else{
1492                     for (var j = 0, aLen = arrs.length; j < aLen; j++){
1493                         ret[i].push( arrs[j][i] );
1494                     }
1495                 }
1496             }
1497             return ret;
1498         },
1499
1500         /**
1501          * This is shorthand reference to {@link Ext.ComponentMgr#get}.
1502          * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
1503          * @param {String} id The component {@link Ext.Component#id id}
1504          * @return Ext.Component The Component, <tt>undefined</tt> if not found, or <tt>null</tt> if a
1505          * Class was found.
1506         */
1507         getCmp : function(id){
1508             return Ext.ComponentMgr.get(id);
1509         },
1510
1511         /**
1512          * By default, Ext intelligently decides whether floating elements should be shimmed. If you are using flash,
1513          * you may want to set this to true.
1514          * @type Boolean
1515          */
1516         useShims: E.isIE6 || (E.isMac && E.isGecko2),
1517
1518         // inpired by a similar function in mootools library
1519         /**
1520          * Returns the type of object that is passed in. If the object passed in is null or undefined it
1521          * return false otherwise it returns one of the following values:<div class="mdetail-params"><ul>
1522          * <li><b>string</b>: If the object passed is a string</li>
1523          * <li><b>number</b>: If the object passed is a number</li>
1524          * <li><b>boolean</b>: If the object passed is a boolean value</li>
1525          * <li><b>date</b>: If the object passed is a Date object</li>
1526          * <li><b>function</b>: If the object passed is a function reference</li>
1527          * <li><b>object</b>: If the object passed is an object</li>
1528          * <li><b>array</b>: If the object passed is an array</li>
1529          * <li><b>regexp</b>: If the object passed is a regular expression</li>
1530          * <li><b>element</b>: If the object passed is a DOM Element</li>
1531          * <li><b>nodelist</b>: If the object passed is a DOM NodeList</li>
1532          * <li><b>textnode</b>: If the object passed is a DOM text node and contains something other than whitespace</li>
1533          * <li><b>whitespace</b>: If the object passed is a DOM text node and contains only whitespace</li>
1534          * </ul></div>
1535          * @param {Mixed} object
1536          * @return {String}
1537          */
1538         type : function(o){
1539             if(o === undefined || o === null){
1540                 return false;
1541             }
1542             if(o.htmlElement){
1543                 return 'element';
1544             }
1545             var t = typeof o;
1546             if(t == 'object' && o.nodeName) {
1547                 switch(o.nodeType) {
1548                     case 1: return 'element';
1549                     case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
1550                 }
1551             }
1552             if(t == 'object' || t == 'function') {
1553                 switch(o.constructor) {
1554                     case Array: return 'array';
1555                     case RegExp: return 'regexp';
1556                     case Date: return 'date';
1557                 }
1558                 if(typeof o.length == 'number' && typeof o.item == 'function') {
1559                     return 'nodelist';
1560                 }
1561             }
1562             return t;
1563         },
1564
1565         intercept : function(o, name, fn, scope){
1566             o[name] = o[name].createInterceptor(fn, scope);
1567         },
1568
1569         // internal
1570         callback : function(cb, scope, args, delay){
1571             if(typeof cb == 'function'){
1572                 if(delay){
1573                     cb.defer(delay, scope, args || []);
1574                 }else{
1575                     cb.apply(scope, args || []);
1576                 }
1577             }
1578         }
1579     };
1580 }());
1581
1582 /**
1583  * @class Function
1584  * These functions are available on every Function object (any JavaScript function).
1585  */
1586 Ext.apply(Function.prototype, {
1587     /**
1588      * Create a combined function call sequence of the original function + the passed function.
1589      * The resulting function returns the results of the original function.
1590      * The passed fcn is called with the parameters of the original function. Example usage:
1591      * <pre><code>
1592 var sayHi = function(name){
1593     alert('Hi, ' + name);
1594 }
1595
1596 sayHi('Fred'); // alerts "Hi, Fred"
1597
1598 var sayGoodbye = sayHi.createSequence(function(name){
1599     alert('Bye, ' + name);
1600 });
1601
1602 sayGoodbye('Fred'); // both alerts show
1603 </code></pre>
1604      * @param {Function} fcn The function to sequence
1605      * @param {Object} scope (optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
1606      * <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b>
1607      * @return {Function} The new function
1608      */
1609     createSequence : function(fcn, scope){
1610         var method = this;
1611         return (typeof fcn != 'function') ?
1612                 this :
1613                 function(){
1614                     var retval = method.apply(this || window, arguments);
1615                     fcn.apply(scope || this || window, arguments);
1616                     return retval;
1617                 };
1618     }
1619 });
1620
1621
1622 /**
1623  * @class String
1624  * These functions are available as static methods on the JavaScript String object.
1625  */
1626 Ext.applyIf(String, {
1627
1628     /**
1629      * Escapes the passed string for ' and \
1630      * @param {String} string The string to escape
1631      * @return {String} The escaped string
1632      * @static
1633      */
1634     escape : function(string) {
1635         return string.replace(/('|\\)/g, "\\$1");
1636     },
1637
1638     /**
1639      * Pads the left side of a string with a specified character.  This is especially useful
1640      * for normalizing number and date strings.  Example usage:
1641      * <pre><code>
1642 var s = String.leftPad('123', 5, '0');
1643 // s now contains the string: '00123'
1644      * </code></pre>
1645      * @param {String} string The original string
1646      * @param {Number} size The total length of the output string
1647      * @param {String} char (optional) The character with which to pad the original string (defaults to empty string " ")
1648      * @return {String} The padded string
1649      * @static
1650      */
1651     leftPad : function (val, size, ch) {
1652         var result = String(val);
1653         if(!ch) {
1654             ch = " ";
1655         }
1656         while (result.length < size) {
1657             result = ch + result;
1658         }
1659         return result;
1660     }
1661 });
1662
1663 /**
1664  * Utility function that allows you to easily switch a string between two alternating values.  The passed value
1665  * is compared to the current string, and if they are equal, the other value that was passed in is returned.  If
1666  * they are already different, the first value passed in is returned.  Note that this method returns the new value
1667  * but does not change the current string.
1668  * <pre><code>
1669 // alternate sort directions
1670 sort = sort.toggle('ASC', 'DESC');
1671
1672 // instead of conditional logic:
1673 sort = (sort == 'ASC' ? 'DESC' : 'ASC');
1674 </code></pre>
1675  * @param {String} value The value to compare to the current string
1676  * @param {String} other The new value to use if the string already equals the first value passed in
1677  * @return {String} The new value
1678  */
1679 String.prototype.toggle = function(value, other){
1680     return this == value ? other : value;
1681 };
1682
1683 /**
1684  * Trims whitespace from either end of a string, leaving spaces within the string intact.  Example:
1685  * <pre><code>
1686 var s = '  foo bar  ';
1687 alert('-' + s + '-');         //alerts "- foo bar -"
1688 alert('-' + s.trim() + '-');  //alerts "-foo bar-"
1689 </code></pre>
1690  * @return {String} The trimmed string
1691  */
1692 String.prototype.trim = function(){
1693     var re = /^\s+|\s+$/g;
1694     return function(){ return this.replace(re, ""); };
1695 }();
1696
1697 // here to prevent dependency on Date.js
1698 /**
1699  Returns the number of milliseconds between this date and date
1700  @param {Date} date (optional) Defaults to now
1701  @return {Number} The diff in milliseconds
1702  @member Date getElapsed
1703  */
1704 Date.prototype.getElapsed = function(date) {
1705     return Math.abs((date || new Date()).getTime()-this.getTime());
1706 };
1707
1708
1709 /**
1710  * @class Number
1711  */
1712 Ext.applyIf(Number.prototype, {
1713     /**
1714      * Checks whether or not the current number is within a desired range.  If the number is already within the
1715      * range it is returned, otherwise the min or max value is returned depending on which side of the range is
1716      * exceeded.  Note that this method returns the constrained value but does not change the current number.
1717      * @param {Number} min The minimum number in the range
1718      * @param {Number} max The maximum number in the range
1719      * @return {Number} The constrained value if outside the range, otherwise the current value
1720      */
1721     constrain : function(min, max){
1722         return Math.min(Math.max(this, min), max);
1723     }
1724 });
1725 /**
1726  * @class Ext.util.TaskRunner
1727  * Provides the ability to execute one or more arbitrary tasks in a multithreaded
1728  * manner.  Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
1729  * if needed, you can create separate instances of TaskRunner.  Any number of
1730  * separate tasks can be started at any time and will run independently of each
1731  * other. Example usage:
1732  * <pre><code>
1733 // Start a simple clock task that updates a div once per second
1734 var updateClock = function(){
1735     Ext.fly('clock').update(new Date().format('g:i:s A'));
1736
1737 var task = {
1738     run: updateClock,
1739     interval: 1000 //1 second
1740 }
1741 var runner = new Ext.util.TaskRunner();
1742 runner.start(task);
1743
1744 // equivalent using TaskMgr
1745 Ext.TaskMgr.start({
1746     run: updateClock,
1747     interval: 1000
1748 });
1749
1750  * </code></pre>
1751  * <p>See the {@link #start} method for details about how to configure a task object.</p>
1752  * Also see {@link Ext.util.DelayedTask}. 
1753  * 
1754  * @constructor
1755  * @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
1756  * (defaults to 10)
1757  */
1758 Ext.util.TaskRunner = function(interval){
1759     interval = interval || 10;
1760     var tasks = [], 
1761         removeQueue = [],
1762         id = 0,
1763         running = false,
1764
1765         // private
1766         stopThread = function(){
1767                 running = false;
1768                 clearInterval(id);
1769                 id = 0;
1770             },
1771
1772         // private
1773         startThread = function(){
1774                 if(!running){
1775                     running = true;
1776                     id = setInterval(runTasks, interval);
1777                 }
1778             },
1779
1780         // private
1781         removeTask = function(t){
1782                 removeQueue.push(t);
1783                 if(t.onStop){
1784                     t.onStop.apply(t.scope || t);
1785                 }
1786             },
1787             
1788         // private
1789         runTasks = function(){
1790                 var rqLen = removeQueue.length,
1791                         now = new Date().getTime();                                             
1792             
1793                 if(rqLen > 0){
1794                     for(var i = 0; i < rqLen; i++){
1795                         tasks.remove(removeQueue[i]);
1796                     }
1797                     removeQueue = [];
1798                     if(tasks.length < 1){
1799                         stopThread();
1800                         return;
1801                     }
1802                 }               
1803                 for(var i = 0, t, itime, rt, len = tasks.length; i < len; ++i){
1804                     t = tasks[i];
1805                     itime = now - t.taskRunTime;
1806                     if(t.interval <= itime){
1807                         rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
1808                         t.taskRunTime = now;
1809                         if(rt === false || t.taskRunCount === t.repeat){
1810                             removeTask(t);
1811                             return;
1812                         }
1813                     }
1814                     if(t.duration && t.duration <= (now - t.taskStartTime)){
1815                         removeTask(t);
1816                     }
1817                 }
1818             };
1819
1820     /**
1821      * Starts a new task.
1822      * @method start
1823      * @param {Object} task <p>A config object that supports the following properties:<ul>
1824      * <li><code>run</code> : Function<div class="sub-desc"><p>The function to execute each time the task is invoked. The
1825      * function will be called at each interval and passed the <code>args</code> argument if specified, and the
1826      * current invocation count if not.</p>
1827      * <p>If a particular scope (<code>this</code> reference) is required, be sure to specify it using the <code>scope</code> argument.</p>
1828      * <p>Return <code>false</code> from this function to terminate the task.</p></div></li>
1829      * <li><code>interval</code> : Number<div class="sub-desc">The frequency in milliseconds with which the task
1830      * should be invoked.</div></li>
1831      * <li><code>args</code> : Array<div class="sub-desc">(optional) An array of arguments to be passed to the function
1832      * specified by <code>run</code>. If not specified, the current invocation count is passed.</div></li>
1833      * <li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<tt>this</tt> reference) in which to execute the
1834      * <code>run</code> function. Defaults to the task config object.</div></li>
1835      * <li><code>duration</code> : Number<div class="sub-desc">(optional) The length of time in milliseconds to invoke
1836      * the task before stopping automatically (defaults to indefinite).</div></li>
1837      * <li><code>repeat</code> : Number<div class="sub-desc">(optional) The number of times to invoke the task before
1838      * stopping automatically (defaults to indefinite).</div></li>
1839      * </ul></p>
1840      * <p>Before each invocation, Ext injects the property <code>taskRunCount</code> into the task object so
1841      * that calculations based on the repeat count can be performed.</p>
1842      * @return {Object} The task
1843      */
1844     this.start = function(task){
1845         tasks.push(task);
1846         task.taskStartTime = new Date().getTime();
1847         task.taskRunTime = 0;
1848         task.taskRunCount = 0;
1849         startThread();
1850         return task;
1851     };
1852
1853     /**
1854      * Stops an existing running task.
1855      * @method stop
1856      * @param {Object} task The task to stop
1857      * @return {Object} The task
1858      */
1859     this.stop = function(task){
1860         removeTask(task);
1861         return task;
1862     };
1863
1864     /**
1865      * Stops all tasks that are currently running.
1866      * @method stopAll
1867      */
1868     this.stopAll = function(){
1869         stopThread();
1870         for(var i = 0, len = tasks.length; i < len; i++){
1871             if(tasks[i].onStop){
1872                 tasks[i].onStop();
1873             }
1874         }
1875         tasks = [];
1876         removeQueue = [];
1877     };
1878 };
1879
1880 /**
1881  * @class Ext.TaskMgr
1882  * @extends Ext.util.TaskRunner
1883  * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop arbitrary tasks.  See
1884  * {@link Ext.util.TaskRunner} for supported methods and task config properties.
1885  * <pre><code>
1886 // Start a simple clock task that updates a div once per second
1887 var task = {
1888     run: function(){
1889         Ext.fly('clock').update(new Date().format('g:i:s A'));
1890     },
1891     interval: 1000 //1 second
1892 }
1893 Ext.TaskMgr.start(task);
1894 </code></pre>
1895  * <p>See the {@link #start} method for details about how to configure a task object.</p>
1896  * @singleton
1897  */
1898 Ext.TaskMgr = new Ext.util.TaskRunner();(function(){
1899         var libFlyweight;
1900         
1901         function fly(el) {
1902         if (!libFlyweight) {
1903             libFlyweight = new Ext.Element.Flyweight();
1904         }
1905         libFlyweight.dom = el;
1906         return libFlyweight;
1907     }
1908     
1909     (function(){
1910         var doc = document,
1911                 isCSS1 = doc.compatMode == "CSS1Compat",
1912                 MAX = Math.max,         
1913         ROUND = Math.round,
1914                 PARSEINT = parseInt;
1915                 
1916         Ext.lib.Dom = {
1917             isAncestor : function(p, c) {
1918                     var ret = false;
1919                         
1920                         p = Ext.getDom(p);
1921                         c = Ext.getDom(c);
1922                         if (p && c) {
1923                                 if (p.contains) {
1924                                         return p.contains(c);
1925                                 } else if (p.compareDocumentPosition) {
1926                                         return !!(p.compareDocumentPosition(c) & 16);
1927                                 } else {
1928                                         while (c = c.parentNode) {
1929                                                 ret = c == p || ret;                                    
1930                                         }
1931                                 }                   
1932                         }       
1933                         return ret;
1934                 },
1935                 
1936         getViewWidth : function(full) {
1937             return full ? this.getDocumentWidth() : this.getViewportWidth();
1938         },
1939
1940         getViewHeight : function(full) {
1941             return full ? this.getDocumentHeight() : this.getViewportHeight();
1942         },
1943
1944         getDocumentHeight: function() {            
1945             return MAX(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, this.getViewportHeight());
1946         },
1947
1948         getDocumentWidth: function() {            
1949             return MAX(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, this.getViewportWidth());
1950         },
1951
1952         getViewportHeight: function(){
1953                 return Ext.isIE ? 
1954                            (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
1955                            self.innerHeight;
1956         },
1957
1958         getViewportWidth : function() {
1959                 return !Ext.isStrict && !Ext.isOpera ? doc.body.clientWidth :
1960                            Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
1961         },
1962         
1963         getY : function(el) {
1964             return this.getXY(el)[1];
1965         },
1966
1967         getX : function(el) {
1968             return this.getXY(el)[0];
1969         },
1970
1971         getXY : function(el) {
1972             var p, 
1973                 pe, 
1974                 b,
1975                 bt, 
1976                 bl,     
1977                 dbd,            
1978                 x = 0,
1979                 y = 0, 
1980                 scroll,
1981                 hasAbsolute, 
1982                 bd = (doc.body || doc.documentElement),
1983                 ret = [0,0];
1984                 
1985             el = Ext.getDom(el);
1986
1987             if(el != bd){
1988                     if (el.getBoundingClientRect) {
1989                         b = el.getBoundingClientRect();
1990                         scroll = fly(document).getScroll();
1991                         ret = [ROUND(b.left + scroll.left), ROUND(b.top + scroll.top)];
1992                     } else {  
1993                             p = el;             
1994                             hasAbsolute = fly(el).isStyle("position", "absolute");
1995                 
1996                             while (p) {
1997                                     pe = fly(p);                
1998                                 x += p.offsetLeft;
1999                                 y += p.offsetTop;
2000                 
2001                                 hasAbsolute = hasAbsolute || pe.isStyle("position", "absolute");
2002                                                 
2003                                 if (Ext.isGecko) {                                  
2004                                     y += bt = PARSEINT(pe.getStyle("borderTopWidth"), 10) || 0;
2005                                     x += bl = PARSEINT(pe.getStyle("borderLeftWidth"), 10) || 0;        
2006                 
2007                                     if (p != el && !pe.isStyle('overflow','visible')) {
2008                                         x += bl;
2009                                         y += bt;
2010                                     }
2011                                 }
2012                                 p = p.offsetParent;
2013                             }
2014                 
2015                             if (Ext.isSafari && hasAbsolute) {
2016                                 x -= bd.offsetLeft;
2017                                 y -= bd.offsetTop;
2018                             }
2019                 
2020                             if (Ext.isGecko && !hasAbsolute) {
2021                                 dbd = fly(bd);
2022                                 x += PARSEINT(dbd.getStyle("borderLeftWidth"), 10) || 0;
2023                                 y += PARSEINT(dbd.getStyle("borderTopWidth"), 10) || 0;
2024                             }
2025                 
2026                             p = el.parentNode;
2027                             while (p && p != bd) {
2028                                 if (!Ext.isOpera || (p.tagName != 'TR' && !fly(p).isStyle("display", "inline"))) {
2029                                     x -= p.scrollLeft;
2030                                     y -= p.scrollTop;
2031                                 }
2032                                 p = p.parentNode;
2033                             }
2034                             ret = [x,y];
2035                     }
2036                 }
2037             return ret
2038         },
2039
2040         setXY : function(el, xy) {
2041             (el = Ext.fly(el, '_setXY')).position();
2042             
2043             var pts = el.translatePoints(xy),
2044                 style = el.dom.style,
2045                 pos;                    
2046             
2047             for (pos in pts) {              
2048                     if(!isNaN(pts[pos])) style[pos] = pts[pos] + "px"
2049             }
2050         },
2051
2052         setX : function(el, x) {
2053             this.setXY(el, [x, false]);
2054         },
2055
2056         setY : function(el, y) {
2057             this.setXY(el, [false, y]);
2058         }
2059     };
2060 })();Ext.lib.Dom.getRegion = function(el) {
2061     return Ext.lib.Region.getRegion(el);
2062 };Ext.lib.Event = function() {
2063     var loadComplete = false,
2064         unloadListeners = {},
2065         retryCount = 0,
2066         onAvailStack = [],
2067         _interval,
2068         locked = false,
2069         win = window,
2070         doc = document,
2071
2072         // constants
2073         POLL_RETRYS = 200,
2074         POLL_INTERVAL = 20,
2075         TYPE = 0,
2076         FN = 1,
2077         OBJ = 2,
2078         ADJ_SCOPE = 3,
2079         SCROLLLEFT = 'scrollLeft',
2080         SCROLLTOP = 'scrollTop',
2081         UNLOAD = 'unload',
2082         MOUSEOVER = 'mouseover',
2083         MOUSEOUT = 'mouseout',
2084         // private
2085         doAdd = function() {
2086             var ret;
2087             if (win.addEventListener) {
2088                 ret = function(el, eventName, fn, capture) {
2089                     if (eventName == 'mouseenter') {
2090                         fn = fn.createInterceptor(checkRelatedTarget);
2091                         el.addEventListener(MOUSEOVER, fn, (capture));
2092                     } else if (eventName == 'mouseleave') {
2093                         fn = fn.createInterceptor(checkRelatedTarget);
2094                         el.addEventListener(MOUSEOUT, fn, (capture));
2095                     } else {
2096                         el.addEventListener(eventName, fn, (capture));
2097                     }
2098                     return fn;
2099                 };
2100             } else if (win.attachEvent) {
2101                 ret = function(el, eventName, fn, capture) {
2102                     el.attachEvent("on" + eventName, fn);
2103                     return fn;
2104                 };
2105             } else {
2106                 ret = function(){};
2107             }
2108             return ret;
2109         }(),
2110         // private
2111         doRemove = function(){
2112             var ret;
2113             if (win.removeEventListener) {
2114                 ret = function (el, eventName, fn, capture) {
2115                     if (eventName == 'mouseenter') {
2116                         eventName = MOUSEOVER;
2117                     } else if (eventName == 'mouseleave') {
2118                         eventName = MOUSEOUT;
2119                     }
2120                     el.removeEventListener(eventName, fn, (capture));
2121                 };
2122             } else if (win.detachEvent) {
2123                 ret = function (el, eventName, fn) {
2124                     el.detachEvent("on" + eventName, fn);
2125                 };
2126             } else {
2127                 ret = function(){};
2128             }
2129             return ret;
2130         }();
2131
2132     function checkRelatedTarget(e) {
2133         return !elContains(e.currentTarget, pub.getRelatedTarget(e));
2134     }
2135
2136     function elContains(parent, child) {
2137        if(parent && parent.firstChild){
2138          while(child) {
2139             if(child === parent) {
2140                 return true;
2141             }
2142             child = child.parentNode;
2143             if(child && (child.nodeType != 1)) {
2144                 child = null;
2145             }
2146           }
2147         }
2148         return false;
2149     }
2150
2151     // private
2152     function _tryPreloadAttach() {
2153         var ret = false,
2154             notAvail = [],
2155             element, i, v, override,
2156             tryAgain = !loadComplete || (retryCount > 0);
2157
2158         if(!locked){
2159             locked = true;
2160             
2161             for(i = 0; i < onAvailStack.length; ++i){
2162                 v = onAvailStack[i];
2163                 if(v && (element = doc.getElementById(v.id))){
2164                     if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
2165                         override = v.override;
2166                         element = override ? (override === true ? v.obj : override) : element;
2167                         v.fn.call(element, v.obj);
2168                         onAvailStack.remove(v);
2169                         --i;
2170                     }else{
2171                         notAvail.push(v);
2172                     }
2173                 }
2174             }
2175
2176             retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
2177
2178             if (tryAgain) {
2179                 startInterval();
2180             } else {
2181                 clearInterval(_interval);
2182                 _interval = null;
2183             }
2184             ret = !(locked = false);
2185         }
2186         return ret;
2187     }
2188
2189     // private
2190     function startInterval() {
2191         if(!_interval){
2192             var callback = function() {
2193                 _tryPreloadAttach();
2194             };
2195             _interval = setInterval(callback, POLL_INTERVAL);
2196         }
2197     }
2198
2199     // private
2200     function getScroll() {
2201         var dd = doc.documentElement,
2202             db = doc.body;
2203         if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
2204             return [dd[SCROLLLEFT], dd[SCROLLTOP]];
2205         }else if(db){
2206             return [db[SCROLLLEFT], db[SCROLLTOP]];
2207         }else{
2208             return [0, 0];
2209         }
2210     }
2211
2212     // private
2213     function getPageCoord (ev, xy) {
2214         ev = ev.browserEvent || ev;
2215         var coord  = ev['page' + xy];
2216         if (!coord && coord !== 0) {
2217             coord = ev['client' + xy] || 0;
2218
2219             if (Ext.isIE) {
2220                 coord += getScroll()[xy == "X" ? 0 : 1];
2221             }
2222         }
2223
2224         return coord;
2225     }
2226
2227     var pub =  {
2228         extAdapter: true,
2229         onAvailable : function(p_id, p_fn, p_obj, p_override) {
2230             onAvailStack.push({
2231                 id:         p_id,
2232                 fn:         p_fn,
2233                 obj:        p_obj,
2234                 override:   p_override,
2235                 checkReady: false });
2236
2237             retryCount = POLL_RETRYS;
2238             startInterval();
2239         },
2240
2241         // This function should ALWAYS be called from Ext.EventManager
2242         addListener: function(el, eventName, fn) {
2243             el = Ext.getDom(el);
2244             if (el && fn) {
2245                 if (eventName == UNLOAD) {
2246                     if (unloadListeners[el.id] === undefined) {
2247                         unloadListeners[el.id] = [];
2248                     }
2249                     unloadListeners[el.id].push([eventName, fn]);
2250                     return fn;
2251                 }
2252                 return doAdd(el, eventName, fn, false);
2253             }
2254             return false;
2255         },
2256
2257         // This function should ALWAYS be called from Ext.EventManager
2258         removeListener: function(el, eventName, fn) {
2259             el = Ext.getDom(el);
2260             var i, len, li, lis;
2261             if (el && fn) {
2262                 if(eventName == UNLOAD){
2263                     if((lis = unloadListeners[el.id]) !== undefined){
2264                         for(i = 0, len = lis.length; i < len; i++){
2265                             if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
2266                                 unloadListeners[el.id].splice(i, 1);
2267                             }
2268                         }
2269                     }
2270                     return;
2271                 }
2272                 doRemove(el, eventName, fn, false);
2273             }
2274         },
2275
2276         getTarget : function(ev) {
2277             ev = ev.browserEvent || ev;
2278             return this.resolveTextNode(ev.target || ev.srcElement);
2279         },
2280
2281         resolveTextNode : Ext.isGecko ? function(node){
2282             if(!node){
2283                 return;
2284             }
2285             // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
2286             var s = HTMLElement.prototype.toString.call(node);
2287             if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
2288                 return;
2289             }
2290             return node.nodeType == 3 ? node.parentNode : node;
2291         } : function(node){
2292             return node && node.nodeType == 3 ? node.parentNode : node;
2293         },
2294
2295         getRelatedTarget : function(ev) {
2296             ev = ev.browserEvent || ev;
2297             return this.resolveTextNode(ev.relatedTarget ||
2298                 (/(mouseout|mouseleave)/.test(ev.type) ? ev.toElement :
2299                  /(mouseover|mouseenter)/.test(ev.type) ? ev.fromElement : null));
2300         },
2301
2302         getPageX : function(ev) {
2303             return getPageCoord(ev, "X");
2304         },
2305
2306         getPageY : function(ev) {
2307             return getPageCoord(ev, "Y");
2308         },
2309
2310
2311         getXY : function(ev) {
2312             return [this.getPageX(ev), this.getPageY(ev)];
2313         },
2314
2315         stopEvent : function(ev) {
2316             this.stopPropagation(ev);
2317             this.preventDefault(ev);
2318         },
2319
2320         stopPropagation : function(ev) {
2321             ev = ev.browserEvent || ev;
2322             if (ev.stopPropagation) {
2323                 ev.stopPropagation();
2324             } else {
2325                 ev.cancelBubble = true;
2326             }
2327         },
2328
2329         preventDefault : function(ev) {
2330             ev = ev.browserEvent || ev;
2331             if (ev.preventDefault) {
2332                 ev.preventDefault();
2333             } else {
2334                 ev.returnValue = false;
2335             }
2336         },
2337
2338         getEvent : function(e) {
2339             e = e || win.event;
2340             if (!e) {
2341                 var c = this.getEvent.caller;
2342                 while (c) {
2343                     e = c.arguments[0];
2344                     if (e && Event == e.constructor) {
2345                         break;
2346                     }
2347                     c = c.caller;
2348                 }
2349             }
2350             return e;
2351         },
2352
2353         getCharCode : function(ev) {
2354             ev = ev.browserEvent || ev;
2355             return ev.charCode || ev.keyCode || 0;
2356         },
2357
2358         //clearCache: function() {},
2359         // deprecated, call from EventManager
2360         getListeners : function(el, eventName) {
2361             Ext.EventManager.getListeners(el, eventName);
2362         },
2363
2364         // deprecated, call from EventManager
2365         purgeElement : function(el, recurse, eventName) {
2366             Ext.EventManager.purgeElement(el, recurse, eventName);
2367         },
2368
2369         _load : function(e) {
2370             loadComplete = true;
2371             
2372             if (Ext.isIE && e !== true) {
2373                 // IE8 complains that _load is null or not an object
2374                 // so lets remove self via arguments.callee
2375                 doRemove(win, "load", arguments.callee);
2376             }
2377         },
2378
2379         _unload : function(e) {
2380              var EU = Ext.lib.Event,
2381                 i, v, ul, id, len, scope;
2382
2383             for (id in unloadListeners) {
2384                 ul = unloadListeners[id];
2385                 for (i = 0, len = ul.length; i < len; i++) {
2386                     v = ul[i];
2387                     if (v) {
2388                         try{
2389                             scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) :  win;
2390                             v[FN].call(scope, EU.getEvent(e), v[OBJ]);
2391                         }catch(ex){}
2392                     }
2393                 }
2394             };
2395
2396             Ext.EventManager._unload();
2397
2398             doRemove(win, UNLOAD, EU._unload);
2399         }
2400     };
2401
2402     // Initialize stuff.
2403     pub.on = pub.addListener;
2404     pub.un = pub.removeListener;
2405     if (doc && doc.body) {
2406         pub._load(true);
2407     } else {
2408         doAdd(win, "load", pub._load);
2409     }
2410     doAdd(win, UNLOAD, pub._unload);
2411     _tryPreloadAttach();
2412
2413     return pub;
2414 }();
2415 /*
2416 * Portions of this file are based on pieces of Yahoo User Interface Library
2417 * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
2418 * YUI licensed under the BSD License:
2419 * http://developer.yahoo.net/yui/license.txt
2420 */
2421 Ext.lib.Ajax = function() {
2422     var activeX = ['MSXML2.XMLHTTP.3.0',
2423                    'MSXML2.XMLHTTP',
2424                    'Microsoft.XMLHTTP'],
2425         CONTENTTYPE = 'Content-Type';
2426
2427     // private
2428     function setHeader(o) {
2429         var conn = o.conn,
2430             prop;
2431
2432         function setTheHeaders(conn, headers){
2433             for (prop in headers) {
2434                 if (headers.hasOwnProperty(prop)) {
2435                     conn.setRequestHeader(prop, headers[prop]);
2436                 }
2437             }
2438         }
2439
2440         if (pub.defaultHeaders) {
2441             setTheHeaders(conn, pub.defaultHeaders);
2442         }
2443
2444         if (pub.headers) {
2445             setTheHeaders(conn, pub.headers);
2446             delete pub.headers;
2447         }
2448     }
2449
2450     // private
2451     function createExceptionObject(tId, callbackArg, isAbort, isTimeout) {
2452         return {
2453             tId : tId,
2454             status : isAbort ? -1 : 0,
2455             statusText : isAbort ? 'transaction aborted' : 'communication failure',
2456             isAbort: isAbort,
2457             isTimeout: isTimeout,
2458             argument : callbackArg
2459         };
2460     }
2461
2462     // private
2463     function initHeader(label, value) {
2464         (pub.headers = pub.headers || {})[label] = value;
2465     }
2466
2467     // private
2468     function createResponseObject(o, callbackArg) {
2469         var headerObj = {},
2470             headerStr,
2471             conn = o.conn,
2472             t,
2473             s,
2474             // see: https://prototype.lighthouseapp.com/projects/8886/tickets/129-ie-mangles-http-response-status-code-204-to-1223
2475             isBrokenStatus = conn.status == 1223;
2476
2477         try {
2478             headerStr = o.conn.getAllResponseHeaders();
2479             Ext.each(headerStr.replace(/\r\n/g, '\n').split('\n'), function(v){
2480                 t = v.indexOf(':');
2481                 if(t >= 0){
2482                     s = v.substr(0, t).toLowerCase();
2483                     if(v.charAt(t + 1) == ' '){
2484                         ++t;
2485                     }
2486                     headerObj[s] = v.substr(t + 1);
2487                 }
2488             });
2489         } catch(e) {}
2490
2491         return {
2492             tId : o.tId,
2493             // Normalize the status and statusText when IE returns 1223, see the above link.
2494             status : isBrokenStatus ? 204 : conn.status,
2495             statusText : isBrokenStatus ? 'No Content' : conn.statusText,
2496             getResponseHeader : function(header){return headerObj[header.toLowerCase()];},
2497             getAllResponseHeaders : function(){return headerStr;},
2498             responseText : conn.responseText,
2499             responseXML : conn.responseXML,
2500             argument : callbackArg
2501         };
2502     }
2503
2504     // private
2505     function releaseObject(o) {
2506         if (o.tId) {
2507             pub.conn[o.tId] = null;
2508         }
2509         o.conn = null;
2510         o = null;
2511     }
2512
2513     // private
2514     function handleTransactionResponse(o, callback, isAbort, isTimeout) {
2515         if (!callback) {
2516             releaseObject(o);
2517             return;
2518         }
2519
2520         var httpStatus, responseObject;
2521
2522         try {
2523             if (o.conn.status !== undefined && o.conn.status != 0) {
2524                 httpStatus = o.conn.status;
2525             }
2526             else {
2527                 httpStatus = 13030;
2528             }
2529         }
2530         catch(e) {
2531             httpStatus = 13030;
2532         }
2533
2534         if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) {
2535             responseObject = createResponseObject(o, callback.argument);
2536             if (callback.success) {
2537                 if (!callback.scope) {
2538                     callback.success(responseObject);
2539                 }
2540                 else {
2541                     callback.success.apply(callback.scope, [responseObject]);
2542                 }
2543             }
2544         }
2545         else {
2546             switch (httpStatus) {
2547                 case 12002:
2548                 case 12029:
2549                 case 12030:
2550                 case 12031:
2551                 case 12152:
2552                 case 13030:
2553                     responseObject = createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false), isTimeout);
2554                     if (callback.failure) {
2555                         if (!callback.scope) {
2556                             callback.failure(responseObject);
2557                         }
2558                         else {
2559                             callback.failure.apply(callback.scope, [responseObject]);
2560                         }
2561                     }
2562                     break;
2563                 default:
2564                     responseObject = createResponseObject(o, callback.argument);
2565                     if (callback.failure) {
2566                         if (!callback.scope) {
2567                             callback.failure(responseObject);
2568                         }
2569                         else {
2570                             callback.failure.apply(callback.scope, [responseObject]);
2571                         }
2572                     }
2573             }
2574         }
2575
2576         releaseObject(o);
2577         responseObject = null;
2578     }
2579
2580     // private
2581     function handleReadyState(o, callback){
2582     callback = callback || {};
2583         var conn = o.conn,
2584             tId = o.tId,
2585             poll = pub.poll,
2586             cbTimeout = callback.timeout || null;
2587
2588         if (cbTimeout) {
2589             pub.conn[tId] = conn;
2590             pub.timeout[tId] = setTimeout(function() {
2591                 pub.abort(o, callback, true);
2592             }, cbTimeout);
2593         }
2594
2595         poll[tId] = setInterval(
2596             function() {
2597                 if (conn && conn.readyState == 4) {
2598                     clearInterval(poll[tId]);
2599                     poll[tId] = null;
2600
2601                     if (cbTimeout) {
2602                         clearTimeout(pub.timeout[tId]);
2603                         pub.timeout[tId] = null;
2604                     }
2605
2606                     handleTransactionResponse(o, callback);
2607                 }
2608             },
2609             pub.pollInterval);
2610     }
2611
2612     // private
2613     function asyncRequest(method, uri, callback, postData) {
2614         var o = getConnectionObject() || null;
2615
2616         if (o) {
2617             o.conn.open(method, uri, true);
2618
2619             if (pub.useDefaultXhrHeader) {
2620                 initHeader('X-Requested-With', pub.defaultXhrHeader);
2621             }
2622
2623             if(postData && pub.useDefaultHeader && (!pub.headers || !pub.headers[CONTENTTYPE])){
2624                 initHeader(CONTENTTYPE, pub.defaultPostHeader);
2625             }
2626
2627             if (pub.defaultHeaders || pub.headers) {
2628                 setHeader(o);
2629             }
2630
2631             handleReadyState(o, callback);
2632             o.conn.send(postData || null);
2633         }
2634         return o;
2635     }
2636
2637     // private
2638     function getConnectionObject() {
2639         var o;
2640
2641         try {
2642             if (o = createXhrObject(pub.transactionId)) {
2643                 pub.transactionId++;
2644             }
2645         } catch(e) {
2646         } finally {
2647             return o;
2648         }
2649     }
2650
2651     // private
2652     function createXhrObject(transactionId) {
2653         var http;
2654
2655         try {
2656             http = new XMLHttpRequest();
2657         } catch(e) {
2658             for (var i = 0; i < activeX.length; ++i) {
2659                 try {
2660                     http = new ActiveXObject(activeX[i]);
2661                     break;
2662                 } catch(e) {}
2663             }
2664         } finally {
2665             return {conn : http, tId : transactionId};
2666         }
2667     }
2668
2669     var pub = {
2670         request : function(method, uri, cb, data, options) {
2671             if(options){
2672                 var me = this,
2673                     xmlData = options.xmlData,
2674                     jsonData = options.jsonData,
2675                     hs;
2676
2677                 Ext.applyIf(me, options);
2678
2679                 if(xmlData || jsonData){
2680                     hs = me.headers;
2681                     if(!hs || !hs[CONTENTTYPE]){
2682                         initHeader(CONTENTTYPE, xmlData ? 'text/xml' : 'application/json');
2683                     }
2684                     data = xmlData || (!Ext.isPrimitive(jsonData) ? Ext.encode(jsonData) : jsonData);
2685                 }
2686             }
2687             return asyncRequest(method || options.method || "POST", uri, cb, data);
2688         },
2689
2690         serializeForm : function(form) {
2691             var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
2692                 hasSubmit = false,
2693                 encoder = encodeURIComponent,
2694                 name,
2695                 data = '',
2696                 type;
2697
2698             Ext.each(fElements, function(element) {
2699                 name = element.name;
2700                 type = element.type;
2701
2702                 if (!element.disabled && name){
2703                     if(/select-(one|multiple)/i.test(type)) {
2704                         Ext.each(element.options, function(opt) {
2705                             if (opt.selected) {
2706                                 data += String.format("{0}={1}&", encoder(name), encoder((opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttribute('value') !== null) ? opt.value : opt.text));
2707                             }
2708                         });
2709                     } else if(!(/file|undefined|reset|button/i.test(type))) {
2710                             if(!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)){
2711
2712                                 data += encoder(name) + '=' + encoder(element.value) + '&';
2713                                 hasSubmit = /submit/i.test(type);
2714                             }
2715                     }
2716                 }
2717             });
2718             return data.substr(0, data.length - 1);
2719         },
2720
2721         useDefaultHeader : true,
2722         defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',
2723         useDefaultXhrHeader : true,
2724         defaultXhrHeader : 'XMLHttpRequest',
2725         poll : {},
2726         timeout : {},
2727         conn: {},
2728         pollInterval : 50,
2729         transactionId : 0,
2730
2731 //  This is never called - Is it worth exposing this?
2732 //          setProgId : function(id) {
2733 //              activeX.unshift(id);
2734 //          },
2735
2736 //  This is never called - Is it worth exposing this?
2737 //          setDefaultPostHeader : function(b) {
2738 //              this.useDefaultHeader = b;
2739 //          },
2740
2741 //  This is never called - Is it worth exposing this?
2742 //          setDefaultXhrHeader : function(b) {
2743 //              this.useDefaultXhrHeader = b;
2744 //          },
2745
2746 //  This is never called - Is it worth exposing this?
2747 //          setPollingInterval : function(i) {
2748 //              if (typeof i == 'number' && isFinite(i)) {
2749 //                  this.pollInterval = i;
2750 //              }
2751 //          },
2752
2753 //  This is never called - Is it worth exposing this?
2754 //          resetDefaultHeaders : function() {
2755 //              this.defaultHeaders = null;
2756 //          },
2757
2758         abort : function(o, callback, isTimeout) {
2759             var me = this,
2760                 tId = o.tId,
2761                 isAbort = false;
2762
2763             if (me.isCallInProgress(o)) {
2764                 o.conn.abort();
2765                 clearInterval(me.poll[tId]);
2766                 me.poll[tId] = null;
2767                 clearTimeout(pub.timeout[tId]);
2768                 me.timeout[tId] = null;
2769
2770                 handleTransactionResponse(o, callback, (isAbort = true), isTimeout);
2771             }
2772             return isAbort;
2773         },
2774
2775         isCallInProgress : function(o) {
2776             // if there is a connection and readyState is not 0 or 4
2777             return o.conn && !{0:true,4:true}[o.conn.readyState];
2778         }
2779     };
2780     return pub;
2781 }();    Ext.lib.Region = function(t, r, b, l) {
2782                 var me = this;
2783         me.top = t;
2784         me[1] = t;
2785         me.right = r;
2786         me.bottom = b;
2787         me.left = l;
2788         me[0] = l;
2789     };
2790
2791     Ext.lib.Region.prototype = {
2792         contains : function(region) {
2793                 var me = this;
2794             return ( region.left >= me.left &&
2795                      region.right <= me.right &&
2796                      region.top >= me.top &&
2797                      region.bottom <= me.bottom );
2798
2799         },
2800
2801         getArea : function() {
2802                 var me = this;
2803             return ( (me.bottom - me.top) * (me.right - me.left) );
2804         },
2805
2806         intersect : function(region) {
2807             var me = this,
2808                 t = Math.max(me.top, region.top),
2809                 r = Math.min(me.right, region.right),
2810                 b = Math.min(me.bottom, region.bottom),
2811                 l = Math.max(me.left, region.left);
2812
2813             if (b >= t && r >= l) {
2814                 return new Ext.lib.Region(t, r, b, l);
2815             }
2816         },
2817         
2818         union : function(region) {
2819                 var me = this,
2820                 t = Math.min(me.top, region.top),
2821                 r = Math.max(me.right, region.right),
2822                 b = Math.max(me.bottom, region.bottom),
2823                 l = Math.min(me.left, region.left);
2824
2825             return new Ext.lib.Region(t, r, b, l);
2826         },
2827
2828         constrainTo : function(r) {
2829                 var me = this;
2830             me.top = me.top.constrain(r.top, r.bottom);
2831             me.bottom = me.bottom.constrain(r.top, r.bottom);
2832             me.left = me.left.constrain(r.left, r.right);
2833             me.right = me.right.constrain(r.left, r.right);
2834             return me;
2835         },
2836
2837         adjust : function(t, l, b, r) {
2838                 var me = this;
2839             me.top += t;
2840             me.left += l;
2841             me.right += r;
2842             me.bottom += b;
2843             return me;
2844         }
2845     };
2846
2847     Ext.lib.Region.getRegion = function(el) {
2848         var p = Ext.lib.Dom.getXY(el),
2849                 t = p[1],
2850                 r = p[0] + el.offsetWidth,
2851                 b = p[1] + el.offsetHeight,
2852                 l = p[0];
2853
2854         return new Ext.lib.Region(t, r, b, l);
2855     };  Ext.lib.Point = function(x, y) {
2856         if (Ext.isArray(x)) {
2857             y = x[1];
2858             x = x[0];
2859         }
2860         var me = this;
2861         me.x = me.right = me.left = me[0] = x;
2862         me.y = me.top = me.bottom = me[1] = y;
2863     };
2864
2865     Ext.lib.Point.prototype = new Ext.lib.Region();
2866 (function(){
2867     var EXTLIB = Ext.lib,
2868         noNegatives = /width|height|opacity|padding/i,
2869         offsetAttribute = /^((width|height)|(top|left))$/,
2870         defaultUnit = /width|height|top$|bottom$|left$|right$/i,
2871         offsetUnit =  /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i,
2872         isset = function(v){
2873             return typeof v !== 'undefined';
2874         },
2875         now = function(){
2876             return new Date();
2877         };
2878
2879     EXTLIB.Anim = {
2880         motion : function(el, args, duration, easing, cb, scope) {
2881             return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
2882         },
2883
2884         run : function(el, args, duration, easing, cb, scope, type) {
2885             type = type || Ext.lib.AnimBase;
2886             if (typeof easing == "string") {
2887                 easing = Ext.lib.Easing[easing];
2888             }
2889             var anim = new type(el, args, duration, easing);
2890             anim.animateX(function() {
2891                 if(Ext.isFunction(cb)){
2892                     cb.call(scope);
2893                 }
2894             });
2895             return anim;
2896         }
2897     };
2898
2899     EXTLIB.AnimBase = function(el, attributes, duration, method) {
2900         if (el) {
2901             this.init(el, attributes, duration, method);
2902         }
2903     };
2904
2905     EXTLIB.AnimBase.prototype = {
2906         doMethod: function(attr, start, end) {
2907             var me = this;
2908             return me.method(me.curFrame, start, end - start, me.totalFrames);
2909         },
2910
2911
2912         setAttr: function(attr, val, unit) {
2913             if (noNegatives.test(attr) && val < 0) {
2914                 val = 0;
2915             }
2916             Ext.fly(this.el, '_anim').setStyle(attr, val + unit);
2917         },
2918
2919
2920         getAttr: function(attr) {
2921             var el = Ext.fly(this.el),
2922                 val = el.getStyle(attr),
2923                 a = offsetAttribute.exec(attr) || [];
2924
2925             if (val !== 'auto' && !offsetUnit.test(val)) {
2926                 return parseFloat(val);
2927             }
2928
2929             return (!!(a[2]) || (el.getStyle('position') == 'absolute' && !!(a[3]))) ? el.dom['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)] : 0;
2930         },
2931
2932
2933         getDefaultUnit: function(attr) {
2934             return defaultUnit.test(attr) ? 'px' : '';
2935         },
2936
2937         animateX : function(callback, scope) {
2938             var me = this,
2939                 f = function() {
2940                 me.onComplete.removeListener(f);
2941                 if (Ext.isFunction(callback)) {
2942                     callback.call(scope || me, me);
2943                 }
2944             };
2945             me.onComplete.addListener(f, me);
2946             me.animate();
2947         },
2948
2949
2950         setRunAttr: function(attr) {
2951             var me = this,
2952                 a = this.attributes[attr],
2953                 to = a.to,
2954                 by = a.by,
2955                 from = a.from,
2956                 unit = a.unit,
2957                 ra = (this.runAttrs[attr] = {}),
2958                 end;
2959
2960             if (!isset(to) && !isset(by)){
2961                 return false;
2962             }
2963
2964             var start = isset(from) ? from : me.getAttr(attr);
2965             if (isset(to)) {
2966                 end = to;
2967             }else if(isset(by)) {
2968                 if (Ext.isArray(start)){
2969                     end = [];
2970                     for(var i=0,len=start.length; i<len; i++) {
2971                         end[i] = start[i] + by[i];
2972                     }
2973                 }else{
2974                     end = start + by;
2975                 }
2976             }
2977
2978             Ext.apply(ra, {
2979                 start: start,
2980                 end: end,
2981                 unit: isset(unit) ? unit : me.getDefaultUnit(attr)
2982             });
2983         },
2984
2985
2986         init: function(el, attributes, duration, method) {
2987             var me = this,
2988                 actualFrames = 0,
2989                 mgr = EXTLIB.AnimMgr;
2990
2991             Ext.apply(me, {
2992                 isAnimated: false,
2993                 startTime: null,
2994                 el: Ext.getDom(el),
2995                 attributes: attributes || {},
2996                 duration: duration || 1,
2997                 method: method || EXTLIB.Easing.easeNone,
2998                 useSec: true,
2999                 curFrame: 0,
3000                 totalFrames: mgr.fps,
3001                 runAttrs: {},
3002                 animate: function(){
3003                     var me = this,
3004                         d = me.duration;
3005
3006                     if(me.isAnimated){
3007                         return false;
3008                     }
3009
3010                     me.curFrame = 0;
3011                     me.totalFrames = me.useSec ? Math.ceil(mgr.fps * d) : d;
3012                     mgr.registerElement(me);
3013                 },
3014
3015                 stop: function(finish){
3016                     var me = this;
3017
3018                     if(finish){
3019                         me.curFrame = me.totalFrames;
3020                         me._onTween.fire();
3021                     }
3022                     mgr.stop(me);
3023                 }
3024             });
3025
3026             var onStart = function(){
3027                 var me = this,
3028                     attr;
3029
3030                 me.onStart.fire();
3031                 me.runAttrs = {};
3032                 for(attr in this.attributes){
3033                     this.setRunAttr(attr);
3034                 }
3035
3036                 me.isAnimated = true;
3037                 me.startTime = now();
3038                 actualFrames = 0;
3039             };
3040
3041
3042             var onTween = function(){
3043                 var me = this;
3044
3045                 me.onTween.fire({
3046                     duration: now() - me.startTime,
3047                     curFrame: me.curFrame
3048                 });
3049
3050                 var ra = me.runAttrs;
3051                 for (var attr in ra) {
3052                     this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
3053                 }
3054
3055                 ++actualFrames;
3056             };
3057
3058             var onComplete = function() {
3059                 var me = this,
3060                     actual = (now() - me.startTime) / 1000,
3061                     data = {
3062                         duration: actual,
3063                         frames: actualFrames,
3064                         fps: actualFrames / actual
3065                     };
3066
3067                 me.isAnimated = false;
3068                 actualFrames = 0;
3069                 me.onComplete.fire(data);
3070             };
3071
3072             me.onStart = new Ext.util.Event(me);
3073             me.onTween = new Ext.util.Event(me);
3074             me.onComplete = new Ext.util.Event(me);
3075             (me._onStart = new Ext.util.Event(me)).addListener(onStart);
3076             (me._onTween = new Ext.util.Event(me)).addListener(onTween);
3077             (me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
3078         }
3079     };
3080
3081
3082     Ext.lib.AnimMgr = new function() {
3083         var me = this,
3084             thread = null,
3085             queue = [],
3086             tweenCount = 0;
3087
3088
3089         Ext.apply(me, {
3090             fps: 1000,
3091             delay: 1,
3092             registerElement: function(tween){
3093                 queue.push(tween);
3094                 ++tweenCount;
3095                 tween._onStart.fire();
3096                 me.start();
3097             },
3098
3099             unRegister: function(tween, index){
3100                 tween._onComplete.fire();
3101                 index = index || getIndex(tween);
3102                 if (index != -1) {
3103                     queue.splice(index, 1);
3104                 }
3105
3106                 if (--tweenCount <= 0) {
3107                     me.stop();
3108                 }
3109             },
3110
3111             start: function(){
3112                 if(thread === null){
3113                     thread = setInterval(me.run, me.delay);
3114                 }
3115             },
3116
3117             stop: function(tween){
3118                 if(!tween){
3119                     clearInterval(thread);
3120                     for(var i = 0, len = queue.length; i < len; ++i){
3121                         if(queue[0].isAnimated){
3122                             me.unRegister(queue[0], 0);
3123                         }
3124                     }
3125
3126                     queue = [];
3127                     thread = null;
3128                     tweenCount = 0;
3129                 }else{
3130                     me.unRegister(tween);
3131                 }
3132             },
3133
3134             run: function(){
3135                 var tf, i, len, tween;
3136                 for(i = 0, len = queue.length; i<len; i++) {
3137                     tween = queue[i];
3138                     if(tween && tween.isAnimated){
3139                         tf = tween.totalFrames;
3140                         if(tween.curFrame < tf || tf === null){
3141                             ++tween.curFrame;
3142                             if(tween.useSec){
3143                                 correctFrame(tween);
3144                             }
3145                             tween._onTween.fire();
3146                         }else{
3147                             me.stop(tween);
3148                         }
3149                     }
3150                 }
3151             }
3152         });
3153
3154         var getIndex = function(anim) {
3155             var i, len;
3156             for(i = 0, len = queue.length; i<len; i++) {
3157                 if(queue[i] === anim) {
3158                     return i;
3159                 }
3160             }
3161             return -1;
3162         };
3163
3164         var correctFrame = function(tween) {
3165             var frames = tween.totalFrames,
3166                 frame = tween.curFrame,
3167                 duration = tween.duration,
3168                 expected = (frame * duration * 1000 / frames),
3169                 elapsed = (now() - tween.startTime),
3170                 tweak = 0;
3171
3172             if(elapsed < duration * 1000){
3173                 tweak = Math.round((elapsed / expected - 1) * frame);
3174             }else{
3175                 tweak = frames - (frame + 1);
3176             }
3177             if(tweak > 0 && isFinite(tweak)){
3178                 if(tween.curFrame + tweak >= frames){
3179                     tweak = frames - (frame + 1);
3180                 }
3181                 tween.curFrame += tweak;
3182             }
3183         };
3184     };
3185
3186     EXTLIB.Bezier = new function() {
3187
3188         this.getPosition = function(points, t) {
3189             var n = points.length,
3190                 tmp = [],
3191                 c = 1 - t,
3192                 i,
3193                 j;
3194
3195             for (i = 0; i < n; ++i) {
3196                 tmp[i] = [points[i][0], points[i][1]];
3197             }
3198
3199             for (j = 1; j < n; ++j) {
3200                 for (i = 0; i < n - j; ++i) {
3201                     tmp[i][0] = c * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
3202                     tmp[i][1] = c * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
3203                 }
3204             }
3205
3206             return [ tmp[0][0], tmp[0][1] ];
3207
3208         };
3209     };
3210
3211
3212     EXTLIB.Easing = {
3213         easeNone: function (t, b, c, d) {
3214             return c * t / d + b;
3215         },
3216
3217
3218         easeIn: function (t, b, c, d) {
3219             return c * (t /= d) * t + b;
3220         },
3221
3222
3223         easeOut: function (t, b, c, d) {
3224             return -c * (t /= d) * (t - 2) + b;
3225         }
3226     };
3227
3228     (function() {
3229         EXTLIB.Motion = function(el, attributes, duration, method) {
3230             if (el) {
3231                 EXTLIB.Motion.superclass.constructor.call(this, el, attributes, duration, method);
3232             }
3233         };
3234
3235         Ext.extend(EXTLIB.Motion, Ext.lib.AnimBase);
3236
3237         var superclass = EXTLIB.Motion.superclass,
3238             pointsRe = /^points$/i;
3239
3240         Ext.apply(EXTLIB.Motion.prototype, {
3241             setAttr: function(attr, val, unit){
3242                 var me = this,
3243                     setAttr = superclass.setAttr;
3244
3245                 if (pointsRe.test(attr)) {
3246                     unit = unit || 'px';
3247                     setAttr.call(me, 'left', val[0], unit);
3248                     setAttr.call(me, 'top', val[1], unit);
3249                 } else {
3250                     setAttr.call(me, attr, val, unit);
3251                 }
3252             },
3253
3254             getAttr: function(attr){
3255                 var me = this,
3256                     getAttr = superclass.getAttr;
3257
3258                 return pointsRe.test(attr) ? [getAttr.call(me, 'left'), getAttr.call(me, 'top')] : getAttr.call(me, attr);
3259             },
3260
3261             doMethod: function(attr, start, end){
3262                 var me = this;
3263
3264                 return pointsRe.test(attr)
3265                         ? EXTLIB.Bezier.getPosition(me.runAttrs[attr], me.method(me.curFrame, 0, 100, me.totalFrames) / 100)
3266                         : superclass.doMethod.call(me, attr, start, end);
3267             },
3268
3269             setRunAttr: function(attr){
3270                 if(pointsRe.test(attr)){
3271
3272                     var me = this,
3273                         el = this.el,
3274                         points = this.attributes.points,
3275                         control = points.control || [],
3276                         from = points.from,
3277                         to = points.to,
3278                         by = points.by,
3279                         DOM = EXTLIB.Dom,
3280                         start,
3281                         i,
3282                         end,
3283                         len,
3284                         ra;
3285
3286
3287                     if(control.length > 0 && !Ext.isArray(control[0])){
3288                         control = [control];
3289                     }else{
3290                         /*
3291                         var tmp = [];
3292                         for (i = 0,len = control.length; i < len; ++i) {
3293                             tmp[i] = control[i];
3294                         }
3295                         control = tmp;
3296                         */
3297                     }
3298
3299                     Ext.fly(el, '_anim').position();
3300                     DOM.setXY(el, isset(from) ? from : DOM.getXY(el));
3301                     start = me.getAttr('points');
3302
3303
3304                     if(isset(to)){
3305                         end = translateValues.call(me, to, start);
3306                         for (i = 0,len = control.length; i < len; ++i) {
3307                             control[i] = translateValues.call(me, control[i], start);
3308                         }
3309                     } else if (isset(by)) {
3310                         end = [start[0] + by[0], start[1] + by[1]];
3311
3312                         for (i = 0,len = control.length; i < len; ++i) {
3313                             control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
3314                         }
3315                     }
3316
3317                     ra = this.runAttrs[attr] = [start];
3318                     if (control.length > 0) {
3319                         ra = ra.concat(control);
3320                     }
3321
3322                     ra[ra.length] = end;
3323                 }else{
3324                     superclass.setRunAttr.call(this, attr);
3325                 }
3326             }
3327         });
3328
3329         var translateValues = function(val, start) {
3330             var pageXY = EXTLIB.Dom.getXY(this.el);
3331             return [val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1]];
3332         };
3333     })();
3334 })();// Easing functions
3335 (function(){
3336     // shortcuts to aid compression
3337     var abs = Math.abs,
3338         pi = Math.PI,
3339         asin = Math.asin,
3340         pow = Math.pow,
3341         sin = Math.sin,
3342         EXTLIB = Ext.lib;
3343
3344     Ext.apply(EXTLIB.Easing, {
3345
3346         easeBoth: function (t, b, c, d) {
3347             return ((t /= d / 2) < 1)  ?  c / 2 * t * t + b  :  -c / 2 * ((--t) * (t - 2) - 1) + b;
3348         },
3349
3350         easeInStrong: function (t, b, c, d) {
3351             return c * (t /= d) * t * t * t + b;
3352         },
3353
3354         easeOutStrong: function (t, b, c, d) {
3355             return -c * ((t = t / d - 1) * t * t * t - 1) + b;
3356         },
3357
3358         easeBothStrong: function (t, b, c, d) {
3359             return ((t /= d / 2) < 1)  ?  c / 2 * t * t * t * t + b  :  -c / 2 * ((t -= 2) * t * t * t - 2) + b;
3360         },
3361
3362         elasticIn: function (t, b, c, d, a, p) {
3363             if (t == 0 || (t /= d) == 1) {
3364                 return t == 0 ? b : b + c;
3365             }
3366             p = p || (d * .3);
3367
3368             var s;
3369             if (a >= abs(c)) {
3370                 s = p / (2 * pi) * asin(c / a);
3371             } else {
3372                 a = c;
3373                 s = p / 4;
3374             }
3375
3376             return -(a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b;
3377
3378         },
3379
3380         elasticOut: function (t, b, c, d, a, p) {
3381             if (t == 0 || (t /= d) == 1) {
3382                 return t == 0 ? b : b + c;
3383             }
3384             p = p || (d * .3);
3385
3386             var s;
3387             if (a >= abs(c)) {
3388                 s = p / (2 * pi) * asin(c / a);
3389             } else {
3390                 a = c;
3391                 s = p / 4;
3392             }
3393
3394             return a * pow(2, -10 * t) * sin((t * d - s) * (2 * pi) / p) + c + b;
3395         },
3396
3397         elasticBoth: function (t, b, c, d, a, p) {
3398             if (t == 0 || (t /= d / 2) == 2) {
3399                 return t == 0 ? b : b + c;
3400             }
3401
3402             p = p || (d * (.3 * 1.5));
3403
3404             var s;
3405             if (a >= abs(c)) {
3406                 s = p / (2 * pi) * asin(c / a);
3407             } else {
3408                 a = c;
3409                 s = p / 4;
3410             }
3411
3412             return t < 1 ?
3413                     -.5 * (a * pow(2, 10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p)) + b :
3414                     a * pow(2, -10 * (t -= 1)) * sin((t * d - s) * (2 * pi) / p) * .5 + c + b;
3415         },
3416
3417         backIn: function (t, b, c, d, s) {
3418             s = s ||  1.70158;
3419             return c * (t /= d) * t * ((s + 1) * t - s) + b;
3420         },
3421
3422
3423         backOut: function (t, b, c, d, s) {
3424             if (!s) {
3425                 s = 1.70158;
3426             }
3427             return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
3428         },
3429
3430
3431         backBoth: function (t, b, c, d, s) {
3432             s = s || 1.70158;
3433
3434             return ((t /= d / 2 ) < 1) ?
3435                     c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b :
3436                     c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
3437         },
3438
3439
3440         bounceIn: function (t, b, c, d) {
3441             return c - EXTLIB.Easing.bounceOut(d - t, 0, c, d) + b;
3442         },
3443
3444
3445         bounceOut: function (t, b, c, d) {
3446         if ((t /= d) < (1 / 2.75)) {
3447                 return c * (7.5625 * t * t) + b;
3448             } else if (t < (2 / 2.75)) {
3449                 return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
3450             } else if (t < (2.5 / 2.75)) {
3451                 return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
3452             }
3453             return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
3454         },
3455
3456
3457         bounceBoth: function (t, b, c, d) {
3458             return (t < d / 2) ?
3459                     EXTLIB.Easing.bounceIn(t * 2, 0, c, d) * .5 + b :
3460                     EXTLIB.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
3461         }
3462     });
3463 })();
3464
3465 (function() {
3466     var EXTLIB = Ext.lib;
3467     // Color Animation
3468     EXTLIB.Anim.color = function(el, args, duration, easing, cb, scope) {
3469         return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.ColorAnim);
3470     }
3471
3472     EXTLIB.ColorAnim = function(el, attributes, duration, method) {
3473         EXTLIB.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
3474     };
3475
3476     Ext.extend(EXTLIB.ColorAnim, EXTLIB.AnimBase);
3477
3478     var superclass = EXTLIB.ColorAnim.superclass,
3479         colorRE = /color$/i,
3480         transparentRE = /^transparent|rgba\(0, 0, 0, 0\)$/,
3481         rgbRE = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
3482         hexRE= /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
3483         hex3RE = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
3484         isset = function(v){
3485             return typeof v !== 'undefined';
3486         };
3487
3488     // private
3489     function parseColor(s) {
3490         var pi = parseInt,
3491             base,
3492             out = null,
3493             c;
3494
3495         if (s.length == 3) {
3496             return s;
3497         }
3498
3499         Ext.each([hexRE, rgbRE, hex3RE], function(re, idx){
3500             base = (idx % 2 == 0) ? 16 : 10;
3501             c = re.exec(s);
3502             if(c && c.length == 4){
3503                 out = [pi(c[1], base), pi(c[2], base), pi(c[3], base)];
3504                 return false;
3505             }
3506         });
3507         return out;
3508     }
3509
3510     Ext.apply(EXTLIB.ColorAnim.prototype, {
3511         getAttr : function(attr) {
3512             var me = this,
3513                 el = me.el,
3514                 val;
3515             if(colorRE.test(attr)){
3516                 while(el && transparentRE.test(val = Ext.fly(el).getStyle(attr))){
3517                     el = el.parentNode;
3518                     val = "fff";
3519                 }
3520             }else{
3521                 val = superclass.getAttr.call(me, attr);
3522             }
3523             return val;
3524         },
3525
3526         doMethod : function(attr, start, end) {
3527             var me = this,
3528                 val,
3529                 floor = Math.floor,
3530                 i,
3531                 len,
3532                 v;
3533
3534             if(colorRE.test(attr)){
3535                 val = [];
3536                 end = end || [];
3537
3538                 for(i = 0, len = start.length; i < len; i++) {
3539                     v = start[i];
3540                     val[i] = superclass.doMethod.call(me, attr, v, end[i]);
3541                 }
3542                 val = 'rgb(' + floor(val[0]) + ',' + floor(val[1]) + ',' + floor(val[2]) + ')';
3543             }else{
3544                 val = superclass.doMethod.call(me, attr, start, end);
3545             }
3546             return val;
3547         },
3548
3549         setRunAttr : function(attr) {
3550             var me = this,
3551                 a = me.attributes[attr],
3552                 to = a.to,
3553                 by = a.by,
3554                 ra;
3555
3556             superclass.setRunAttr.call(me, attr);
3557             ra = me.runAttrs[attr];
3558             if(colorRE.test(attr)){
3559                 var start = parseColor(ra.start),
3560                     end = parseColor(ra.end);
3561
3562                 if(!isset(to) && isset(by)){
3563                     end = parseColor(by);
3564                     for(var i=0,len=start.length; i<len; i++) {
3565                         end[i] = start[i] + end[i];
3566                     }
3567                 }
3568                 ra.start = start;
3569                 ra.end = end;
3570             }
3571         }
3572     });
3573 })();
3574
3575
3576 (function() {
3577     // Scroll Animation
3578     var EXTLIB = Ext.lib;
3579     EXTLIB.Anim.scroll = function(el, args, duration, easing, cb, scope) {
3580         return EXTLIB.Anim.run(el, args, duration, easing, cb, scope, EXTLIB.Scroll);
3581     };
3582
3583     EXTLIB.Scroll = function(el, attributes, duration, method) {
3584         if(el){
3585             EXTLIB.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
3586         }
3587     };
3588
3589     Ext.extend(EXTLIB.Scroll, EXTLIB.ColorAnim);
3590
3591     var superclass = EXTLIB.Scroll.superclass,
3592         SCROLL = 'scroll';
3593
3594     Ext.apply(EXTLIB.Scroll.prototype, {
3595
3596         doMethod : function(attr, start, end) {
3597             var val,
3598                 me = this,
3599                 curFrame = me.curFrame,
3600                 totalFrames = me.totalFrames;
3601
3602             if(attr == SCROLL){
3603                 val = [me.method(curFrame, start[0], end[0] - start[0], totalFrames),
3604                        me.method(curFrame, start[1], end[1] - start[1], totalFrames)];
3605             }else{
3606                 val = superclass.doMethod.call(me, attr, start, end);
3607             }
3608             return val;
3609         },
3610
3611         getAttr : function(attr) {
3612             var me = this;
3613
3614             if (attr == SCROLL) {
3615                 return [me.el.scrollLeft, me.el.scrollTop];
3616             }else{
3617                 return superclass.getAttr.call(me, attr);
3618             }
3619         },
3620
3621         setAttr : function(attr, val, unit) {
3622             var me = this;
3623
3624             if(attr == SCROLL){
3625                 me.el.scrollLeft = val[0];
3626                 me.el.scrollTop = val[1];
3627             }else{
3628                 superclass.setAttr.call(me, attr, val, unit);
3629             }
3630         }
3631     });
3632 })();   
3633         if(Ext.isIE) {
3634         function fnCleanUp() {
3635             var p = Function.prototype;
3636             delete p.createSequence;
3637             delete p.defer;
3638             delete p.createDelegate;
3639             delete p.createCallback;
3640             delete p.createInterceptor;
3641
3642             window.detachEvent("onunload", fnCleanUp);
3643         }
3644         window.attachEvent("onunload", fnCleanUp);
3645     }
3646 })();