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