~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/ext-2.2.1/air/samples/tasks/ext-2.0/adapter/ext/ext-base.js

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 0.30
 
3
 * Copyright(c) 2006-2009, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
/*
 
10
 * Ext JS Library 2.0.1
 
11
 * Copyright(c) 2006-2008, Ext JS, LLC.
 
12
 * licensing@extjs.com
 
13
 * 
 
14
 * http://extjs.com/license
 
15
 */
 
16
 
 
17
 
 
18
Ext = {version: '2.0.1'};
 
19
 
 
20
 
 
21
window["undefined"] = window["undefined"];
 
22
 
 
23
 
 
24
 
 
25
 
 
26
Ext.apply = function(o, c, defaults){
 
27
    if(defaults){
 
28
        
 
29
        Ext.apply(o, defaults);
 
30
    }
 
31
    if(o && c && typeof c == 'object'){
 
32
        for(var p in c){
 
33
            o[p] = c[p];
 
34
        }
 
35
    }
 
36
    return o;
 
37
};
 
38
 
 
39
(function(){
 
40
    var idSeed = 0;
 
41
    var ua = navigator.userAgent.toLowerCase();
 
42
 
 
43
    var isStrict = document.compatMode == "CSS1Compat",
 
44
        isOpera = ua.indexOf("opera") > -1,
 
45
        isSafari = (/webkit|khtml/).test(ua),
 
46
        isSafari3 = isSafari && ua.indexOf('webkit/5') != -1,
 
47
        isIE = !isOpera && ua.indexOf("msie") > -1,
 
48
        isIE7 = !isOpera && ua.indexOf("msie 7") > -1,
 
49
        isGecko = !isSafari && ua.indexOf("gecko") > -1,
 
50
        isBorderBox = isIE && !isStrict,
 
51
        isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
 
52
        isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
 
53
        isAir = (ua.indexOf("adobeair") != -1),
 
54
        isLinux = (ua.indexOf("linux") != -1),
 
55
        isSecure = window.location.href.toLowerCase().indexOf("https") === 0;
 
56
 
 
57
    
 
58
        if(isIE && !isIE7){
 
59
        try{
 
60
            document.execCommand("BackgroundImageCache", false, true);
 
61
        }catch(e){}
 
62
    }
 
63
 
 
64
    Ext.apply(Ext, {
 
65
        
 
66
        isStrict : isStrict,
 
67
        
 
68
        isSecure : isSecure,
 
69
        
 
70
        isReady : false,
 
71
 
 
72
        
 
73
        enableGarbageCollector : true,
 
74
 
 
75
        
 
76
        enableListenerCollection:false,
 
77
 
 
78
 
 
79
        
 
80
        SSL_SECURE_URL : "javascript:false",
 
81
 
 
82
        
 
83
        BLANK_IMAGE_URL : "http:/"+"/extjs.com/s.gif",
 
84
 
 
85
        
 
86
        emptyFn : function(){},
 
87
 
 
88
        
 
89
        applyIf : function(o, c){
 
90
            if(o && c){
 
91
                for(var p in c){
 
92
                    if(typeof o[p] == "undefined"){ o[p] = c[p]; }
 
93
                }
 
94
            }
 
95
            return o;
 
96
        },
 
97
 
 
98
        
 
99
        addBehaviors : function(o){
 
100
            if(!Ext.isReady){
 
101
                Ext.onReady(function(){
 
102
                    Ext.addBehaviors(o);
 
103
                });
 
104
                return;
 
105
            }
 
106
            var cache = {}; 
 
107
            for(var b in o){
 
108
                var parts = b.split('@');
 
109
                if(parts[1]){ 
 
110
                    var s = parts[0];
 
111
                    if(!cache[s]){
 
112
                        cache[s] = Ext.select(s);
 
113
                    }
 
114
                    cache[s].on(parts[1], o[b]);
 
115
                }
 
116
            }
 
117
            cache = null;
 
118
        },
 
119
 
 
120
        
 
121
        id : function(el, prefix){
 
122
            prefix = prefix || "ext-gen";
 
123
            el = Ext.getDom(el);
 
124
            var id = prefix + (++idSeed);
 
125
            return el ? (el.id ? el.id : (el.id = id)) : id;
 
126
        },
 
127
 
 
128
        
 
129
        extend : function(){
 
130
            
 
131
            var io = function(o){
 
132
                for(var m in o){
 
133
                    this[m] = o[m];
 
134
                }
 
135
            };
 
136
            var oc = Object.prototype.constructor;
 
137
            
 
138
            return function(sb, sp, overrides){
 
139
                if(typeof sp == 'object'){
 
140
                    overrides = sp;
 
141
                    sp = sb;
 
142
                    sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);};
 
143
                }
 
144
                var F = function(){}, sbp, spp = sp.prototype;
 
145
                F.prototype = spp;
 
146
                sbp = sb.prototype = new F();
 
147
                sbp.constructor=sb;
 
148
                sb.superclass=spp;
 
149
                if(spp.constructor == oc){
 
150
                    spp.constructor=sp;
 
151
                }
 
152
                sb.override = function(o){
 
153
                    Ext.override(sb, o);
 
154
                };
 
155
                sbp.override = io;
 
156
                Ext.override(sb, overrides);
 
157
                return sb;
 
158
            };
 
159
        }(),
 
160
 
 
161
        
 
162
        override : function(origclass, overrides){
 
163
            if(overrides){
 
164
                var p = origclass.prototype;
 
165
                for(var method in overrides){
 
166
                    p[method] = overrides[method];
 
167
                }
 
168
            }
 
169
        },
 
170
 
 
171
        
 
172
        namespace : function(){
 
173
            var a=arguments, o=null, i, j, d, rt;
 
174
            for (i=0; i<a.length; ++i) {
 
175
                d=a[i].split(".");
 
176
                rt = d[0];
 
177
                eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
 
178
                for (j=1; j<d.length; ++j) {
 
179
                    o[d[j]]=o[d[j]] || {};
 
180
                    o=o[d[j]];
 
181
                }
 
182
            }
 
183
        },
 
184
 
 
185
        
 
186
        urlEncode : function(o){
 
187
            if(!o){
 
188
                return "";
 
189
            }
 
190
            var buf = [];
 
191
            for(var key in o){
 
192
                var ov = o[key], k = encodeURIComponent(key);
 
193
                var type = typeof ov;
 
194
                if(type == 'undefined'){
 
195
                    buf.push(k, "=&");
 
196
                }else if(type != "function" && type != "object"){
 
197
                    buf.push(k, "=", encodeURIComponent(ov), "&");
 
198
                }else if(Ext.isArray(ov)){
 
199
                    if (ov.length) {
 
200
                            for(var i = 0, len = ov.length; i < len; i++) {
 
201
                                buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
 
202
                            }
 
203
                        } else {
 
204
                            buf.push(k, "=&");
 
205
                        }
 
206
                }
 
207
            }
 
208
            buf.pop();
 
209
            return buf.join("");
 
210
        },
 
211
 
 
212
        
 
213
        urlDecode : function(string, overwrite){
 
214
            if(!string || !string.length){
 
215
                return {};
 
216
            }
 
217
            var obj = {};
 
218
            var pairs = string.split('&');
 
219
            var pair, name, value;
 
220
            for(var i = 0, len = pairs.length; i < len; i++){
 
221
                pair = pairs[i].split('=');
 
222
                name = decodeURIComponent(pair[0]);
 
223
                value = decodeURIComponent(pair[1]);
 
224
                if(overwrite !== true){
 
225
                    if(typeof obj[name] == "undefined"){
 
226
                        obj[name] = value;
 
227
                    }else if(typeof obj[name] == "string"){
 
228
                        obj[name] = [obj[name]];
 
229
                        obj[name].push(value);
 
230
                    }else{
 
231
                        obj[name].push(value);
 
232
                    }
 
233
                }else{
 
234
                    obj[name] = value;
 
235
                }
 
236
            }
 
237
            return obj;
 
238
        },
 
239
 
 
240
        
 
241
        each : function(array, fn, scope){
 
242
            if(typeof array.length == "undefined" || typeof array == "string"){
 
243
                array = [array];
 
244
            }
 
245
            for(var i = 0, len = array.length; i < len; i++){
 
246
                if(fn.call(scope || array[i], array[i], i, array) === false){ return i; };
 
247
            }
 
248
        },
 
249
 
 
250
        
 
251
        combine : function(){
 
252
            var as = arguments, l = as.length, r = [];
 
253
            for(var i = 0; i < l; i++){
 
254
                var a = as[i];
 
255
                if(Ext.isArray(a)){
 
256
                    r = r.concat(a);
 
257
                }else if(a.length !== undefined && !a.substr){
 
258
                    r = r.concat(Array.prototype.slice.call(a, 0));
 
259
                }else{
 
260
                    r.push(a);
 
261
                }
 
262
            }
 
263
            return r;
 
264
        },
 
265
 
 
266
        
 
267
        escapeRe : function(s) {
 
268
            return s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
 
269
        },
 
270
 
 
271
        
 
272
        callback : function(cb, scope, args, delay){
 
273
            if(typeof cb == "function"){
 
274
                if(delay){
 
275
                    cb.defer(delay, scope, args || []);
 
276
                }else{
 
277
                    cb.apply(scope, args || []);
 
278
                }
 
279
            }
 
280
        },
 
281
 
 
282
        
 
283
        getDom : function(el){
 
284
            if(!el || !document){
 
285
                return null;
 
286
            }
 
287
            return el.dom ? el.dom : (typeof el == 'string' ? document.getElementById(el) : el);
 
288
        },
 
289
 
 
290
        
 
291
        getDoc : function(){
 
292
            return Ext.get(document);
 
293
        },
 
294
 
 
295
        
 
296
        getBody : function(){
 
297
            return Ext.get(document.body || document.documentElement);
 
298
        },
 
299
 
 
300
        
 
301
        getCmp : function(id){
 
302
            return Ext.ComponentMgr.get(id);
 
303
        },
 
304
 
 
305
        
 
306
        num : function(v, defaultValue){
 
307
            if(typeof v != 'number'){
 
308
                return defaultValue;
 
309
            }
 
310
            return v;
 
311
        },
 
312
 
 
313
        
 
314
        destroy : function(){
 
315
            for(var i = 0, a = arguments, len = a.length; i < len; i++) {
 
316
                var as = a[i];
 
317
                if(as){
 
318
                    if(as.dom){
 
319
                        as.removeAllListeners();
 
320
                        as.remove();
 
321
                        continue;
 
322
                    }
 
323
                    if(typeof as.destroy == 'function'){
 
324
                        as.destroy();
 
325
                    }
 
326
                }
 
327
            }
 
328
        },
 
329
 
 
330
        removeNode : isIE ? function(){
 
331
            var d;
 
332
            return function(n){
 
333
                if(n){
 
334
                    d = d || document.createElement('div');
 
335
                    d.appendChild(n);
 
336
                    d.innerHTML = '';
 
337
                }
 
338
            }
 
339
        }() : function(n){
 
340
            if(n && n.parentNode){
 
341
                n.parentNode.removeChild(n);
 
342
            }
 
343
        },
 
344
 
 
345
        
 
346
        
 
347
        type : function(o){
 
348
            if(o === undefined || o === null){
 
349
                return false;
 
350
            }
 
351
            if(o.htmlElement){
 
352
                return 'element';
 
353
            }
 
354
            var t = typeof o;
 
355
            if(t == 'object' && o.nodeName) {
 
356
                switch(o.nodeType) {
 
357
                    case 1: return 'element';
 
358
                    case 3: return (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
 
359
                }
 
360
            }
 
361
            if(t == 'object' || t == 'function') {
 
362
                switch(o.constructor) {
 
363
                    case Array: return 'array';
 
364
                    case RegExp: return 'regexp';
 
365
                }
 
366
                if(typeof o.length == 'number' && typeof o.item == 'function') {
 
367
                    return 'nodelist';
 
368
                }
 
369
            }
 
370
            return t;
 
371
        },
 
372
 
 
373
        
 
374
        isEmpty : function(v, allowBlank){
 
375
            return v === null || v === undefined || (!allowBlank ? v === '' : false);
 
376
        },
 
377
 
 
378
        value : function(v, defaultValue, allowBlank){
 
379
            return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
 
380
        },
 
381
 
 
382
                isArray : function(v){
 
383
                        return v && typeof v.pop == 'function';
 
384
                },
 
385
 
 
386
                isDate : function(v){
 
387
                        return v && typeof v.getFullYear == 'function';
 
388
                },
 
389
 
 
390
        
 
391
        isOpera : isOpera,
 
392
        
 
393
        isSafari : isSafari,
 
394
        
 
395
        isSafari3 : isSafari3,
 
396
        
 
397
        isSafari2 : isSafari && !isSafari3,
 
398
        
 
399
        isIE : isIE,
 
400
        
 
401
        isIE6 : isIE && !isIE7,
 
402
        
 
403
        isIE7 : isIE7,
 
404
        
 
405
        isGecko : isGecko,
 
406
        
 
407
        isBorderBox : isBorderBox,
 
408
        
 
409
        isLinux : isLinux,
 
410
        
 
411
        isWindows : isWindows,
 
412
        
 
413
        isMac : isMac,
 
414
        
 
415
        isAir : isAir,
 
416
 
 
417
    
 
418
        useShims : ((isIE && !isIE7) || (isGecko && isMac))
 
419
    });
 
420
 
 
421
    
 
422
    Ext.ns = Ext.namespace;
 
423
})();
 
424
 
 
425
Ext.ns("Ext", "Ext.util", "Ext.grid", "Ext.dd", "Ext.tree", "Ext.data",
 
426
                "Ext.form", "Ext.menu", "Ext.state", "Ext.lib", "Ext.layout", "Ext.app", "Ext.ux");
 
427
 
 
428
 
 
429
 
 
430
Ext.apply(Function.prototype, {
 
431
     
 
432
    createCallback : function(){
 
433
        
 
434
        var args = arguments;
 
435
        var method = this;
 
436
        return function() {
 
437
            return method.apply(window, args);
 
438
        };
 
439
    },
 
440
 
 
441
    
 
442
    createDelegate : function(obj, args, appendArgs){
 
443
        var method = this;
 
444
        return function() {
 
445
            var callArgs = args || arguments;
 
446
            if(appendArgs === true){
 
447
                callArgs = Array.prototype.slice.call(arguments, 0);
 
448
                callArgs = callArgs.concat(args);
 
449
            }else if(typeof appendArgs == "number"){
 
450
                callArgs = Array.prototype.slice.call(arguments, 0); 
 
451
                var applyArgs = [appendArgs, 0].concat(args); 
 
452
                Array.prototype.splice.apply(callArgs, applyArgs); 
 
453
            }
 
454
            return method.apply(obj || window, callArgs);
 
455
        };
 
456
    },
 
457
 
 
458
    
 
459
    defer : function(millis, obj, args, appendArgs){
 
460
        var fn = this.createDelegate(obj, args, appendArgs);
 
461
        if(millis){
 
462
            return setTimeout(fn, millis);
 
463
        }
 
464
        fn();
 
465
        return 0;
 
466
    },
 
467
    
 
468
    createSequence : function(fcn, scope){
 
469
        if(typeof fcn != "function"){
 
470
            return this;
 
471
        }
 
472
        var method = this;
 
473
        return function() {
 
474
            var retval = method.apply(this || window, arguments);
 
475
            fcn.apply(scope || this || window, arguments);
 
476
            return retval;
 
477
        };
 
478
    },
 
479
 
 
480
    
 
481
    createInterceptor : function(fcn, scope){
 
482
        if(typeof fcn != "function"){
 
483
            return this;
 
484
        }
 
485
        var method = this;
 
486
        return function() {
 
487
            fcn.target = this;
 
488
            fcn.method = method;
 
489
            if(fcn.apply(scope || this || window, arguments) === false){
 
490
                return;
 
491
            }
 
492
            return method.apply(this || window, arguments);
 
493
        };
 
494
    }
 
495
});
 
496
 
 
497
 
 
498
Ext.applyIf(String, {
 
499
 
 
500
    
 
501
    escape : function(string) {
 
502
        return string.replace(/('|\\)/g, "\\$1");
 
503
    },
 
504
 
 
505
    
 
506
    leftPad : function (val, size, ch) {
 
507
        var result = new String(val);
 
508
        if(!ch) {
 
509
            ch = " ";
 
510
        }
 
511
        while (result.length < size) {
 
512
            result = ch + result;
 
513
        }
 
514
        return result.toString();
 
515
    },
 
516
 
 
517
    
 
518
    format : function(format){
 
519
        var args = Array.prototype.slice.call(arguments, 1);
 
520
        return format.replace(/\{(\d+)\}/g, function(m, i){
 
521
            return args[i];
 
522
        });
 
523
    }
 
524
});
 
525
 
 
526
 
 
527
String.prototype.toggle = function(value, other){
 
528
    return this == value ? other : value;
 
529
};
 
530
 
 
531
 
 
532
String.prototype.trim = function(){
 
533
    var re = /^\s+|\s+$/g;
 
534
    return function(){ return this.replace(re, ""); };
 
535
}();
 
536
 
 
537
Ext.applyIf(Number.prototype, {
 
538
    
 
539
    constrain : function(min, max){
 
540
        return Math.min(Math.max(this, min), max);
 
541
    }
 
542
});
 
543
 
 
544
Ext.applyIf(Array.prototype, {
 
545
    
 
546
    indexOf : function(o){
 
547
       for (var i = 0, len = this.length; i < len; i++){
 
548
              if(this[i] == o) return i;
 
549
       }
 
550
           return -1;
 
551
    },
 
552
 
 
553
    
 
554
    remove : function(o){
 
555
       var index = this.indexOf(o);
 
556
       if(index != -1){
 
557
           this.splice(index, 1);
 
558
       }
 
559
       return this;
 
560
    }
 
561
});
 
562
 
 
563
 
 
564
Date.prototype.getElapsed = function(date) {
 
565
        return Math.abs((date || new Date()).getTime()-this.getTime());
 
566
};
 
567
 
 
568
(function() {
 
569
    var libFlyweight;
 
570
 
 
571
    Ext.lib.Dom = {
 
572
        getViewWidth : function(full) {
 
573
            return full ? this.getDocumentWidth() : this.getViewportWidth();
 
574
        },
 
575
 
 
576
        getViewHeight : function(full) {
 
577
            return full ? this.getDocumentHeight() : this.getViewportHeight();
 
578
        },
 
579
 
 
580
        getDocumentHeight: function() {
 
581
            var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
 
582
            return Math.max(scrollHeight, this.getViewportHeight());
 
583
        },
 
584
 
 
585
        getDocumentWidth: function() {
 
586
            var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
 
587
            return Math.max(scrollWidth, this.getViewportWidth());
 
588
        },
 
589
 
 
590
        getViewportHeight: function(){
 
591
            if(Ext.isIE){
 
592
                return Ext.isStrict ? document.documentElement.clientHeight :
 
593
                         document.body.clientHeight;
 
594
            }else{
 
595
                return self.innerHeight;
 
596
            }
 
597
        },
 
598
 
 
599
        getViewportWidth: function() {
 
600
            if(Ext.isIE){
 
601
                return Ext.isStrict ? document.documentElement.clientWidth :
 
602
                         document.body.clientWidth;
 
603
            }else{
 
604
                return self.innerWidth;
 
605
            }
 
606
        },
 
607
 
 
608
        isAncestor : function(p, c) {
 
609
            p = Ext.getDom(p);
 
610
            c = Ext.getDom(c);
 
611
            if (!p || !c) {
 
612
                return false;
 
613
            }
 
614
 
 
615
            if (p.contains && !Ext.isSafari) {
 
616
                return p.contains(c);
 
617
            } else if (p.compareDocumentPosition) {
 
618
                return !!(p.compareDocumentPosition(c) & 16);
 
619
            } else {
 
620
                var parent = c.parentNode;
 
621
                while (parent) {
 
622
                    if (parent == p) {
 
623
                        return true;
 
624
                    }
 
625
                    else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
 
626
                        return false;
 
627
                    }
 
628
                    parent = parent.parentNode;
 
629
                }
 
630
                return false;
 
631
            }
 
632
        },
 
633
 
 
634
        getRegion : function(el) {
 
635
            return Ext.lib.Region.getRegion(el);
 
636
        },
 
637
 
 
638
        getY : function(el) {
 
639
            return this.getXY(el)[1];
 
640
        },
 
641
 
 
642
        getX : function(el) {
 
643
            return this.getXY(el)[0];
 
644
        },
 
645
 
 
646
 
 
647
        getXY : function(el) {
 
648
            var p, pe, b, scroll, bd = (document.body || document.documentElement);
 
649
            el = Ext.getDom(el);
 
650
 
 
651
            if(el == bd){
 
652
                return [0, 0];
 
653
            }
 
654
 
 
655
            if (el.getBoundingClientRect) {
 
656
                b = el.getBoundingClientRect();
 
657
                scroll = fly(document).getScroll();
 
658
                return [b.left + scroll.left, b.top + scroll.top];
 
659
            }
 
660
            var x = 0, y = 0;
 
661
            
 
662
            p = el;
 
663
 
 
664
            var hasAbsolute = fly(el).getStyle("position") == "absolute";
 
665
 
 
666
            while (p) {
 
667
 
 
668
                x += p.offsetLeft;
 
669
                y += p.offsetTop;
 
670
 
 
671
                if (!hasAbsolute && fly(p).getStyle("position") == "absolute") {
 
672
                    hasAbsolute = true;
 
673
                }
 
674
 
 
675
                if (Ext.isGecko) {
 
676
                    pe = fly(p);
 
677
                    
 
678
                    var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
 
679
                    var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
 
680
 
 
681
 
 
682
                    x += bl;
 
683
                    y += bt;
 
684
 
 
685
 
 
686
                    if (p != el && pe.getStyle('overflow') != 'visible') {
 
687
                        x += bl;
 
688
                        y += bt;
 
689
                    }
 
690
                }
 
691
                p = p.offsetParent;
 
692
            }
 
693
 
 
694
            if (Ext.isSafari && hasAbsolute) {
 
695
                x -= bd.offsetLeft;
 
696
                y -= bd.offsetTop;
 
697
            }
 
698
 
 
699
            if (Ext.isGecko && !hasAbsolute) {
 
700
                var dbd = fly(bd);
 
701
                x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
 
702
                y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
 
703
            }
 
704
 
 
705
            p = el.parentNode;
 
706
            while (p && p != bd) {
 
707
                if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) {
 
708
                    x -= p.scrollLeft;
 
709
                    y -= p.scrollTop;
 
710
                }
 
711
                p = p.parentNode;
 
712
            }
 
713
            return [x, y];
 
714
        },
 
715
 
 
716
        setXY : function(el, xy) {
 
717
            el = Ext.fly(el, '_setXY');
 
718
            el.position();
 
719
            var pts = el.translatePoints(xy);
 
720
            if (xy[0] !== false) {
 
721
                el.dom.style.left = pts.left + "px";
 
722
            }
 
723
            if (xy[1] !== false) {
 
724
                el.dom.style.top = pts.top + "px";
 
725
            }
 
726
        },
 
727
 
 
728
        setX : function(el, x) {
 
729
            this.setXY(el, [x, false]);
 
730
        },
 
731
 
 
732
        setY : function(el, y) {
 
733
            this.setXY(el, [false, y]);
 
734
        }
 
735
    };
 
736
 
 
737
 
 
738
    Ext.lib.Event = function() {
 
739
        var loadComplete = false;
 
740
        var listeners = [];
 
741
        var unloadListeners = [];
 
742
        var retryCount = 0;
 
743
        var onAvailStack = [];
 
744
        var counter = 0;
 
745
        var lastError = null;
 
746
 
 
747
        return {
 
748
            POLL_RETRYS: 200,
 
749
            POLL_INTERVAL: 20,
 
750
            EL: 0,
 
751
            TYPE: 1,
 
752
            FN: 2,
 
753
            WFN: 3,
 
754
            OBJ: 3,
 
755
            ADJ_SCOPE: 4,
 
756
            _interval: null,
 
757
 
 
758
            startInterval: function() {
 
759
                if (!this._interval) {
 
760
                    var self = this;
 
761
                    var callback = function() {
 
762
                        self._tryPreloadAttach();
 
763
                    };
 
764
                    this._interval = setInterval(callback, this.POLL_INTERVAL);
 
765
 
 
766
                }
 
767
            },
 
768
 
 
769
            onAvailable: function(p_id, p_fn, p_obj, p_override) {
 
770
                onAvailStack.push({ id:         p_id,
 
771
                    fn:         p_fn,
 
772
                    obj:        p_obj,
 
773
                    override:   p_override,
 
774
                    checkReady: false    });
 
775
 
 
776
                retryCount = this.POLL_RETRYS;
 
777
                this.startInterval();
 
778
            },
 
779
 
 
780
 
 
781
            addListener: function(el, eventName, fn) {
 
782
                el = Ext.getDom(el);
 
783
                if (!el || !fn) {
 
784
                    return false;
 
785
                }
 
786
 
 
787
                if ("unload" == eventName) {
 
788
                    unloadListeners[unloadListeners.length] =
 
789
                    [el, eventName, fn];
 
790
                    return true;
 
791
                }
 
792
 
 
793
                
 
794
                var wrappedFn = function(e) {
 
795
                    return typeof Ext != 'undefined' ? fn(Ext.lib.Event.getEvent(e)) : false;
 
796
                };
 
797
 
 
798
                var li = [el, eventName, fn, wrappedFn];
 
799
 
 
800
                var index = listeners.length;
 
801
                listeners[index] = li;
 
802
 
 
803
                this.doAdd(el, eventName, wrappedFn, false);
 
804
                return true;
 
805
 
 
806
            },
 
807
 
 
808
 
 
809
            removeListener: function(el, eventName, fn) {
 
810
                var i, len;
 
811
 
 
812
                el = Ext.getDom(el);
 
813
 
 
814
                if(!fn) {
 
815
                    return this.purgeElement(el, false, eventName);
 
816
                }
 
817
 
 
818
 
 
819
                if ("unload" == eventName) {
 
820
 
 
821
                    for (i = 0,len = unloadListeners.length; i < len; i++) {
 
822
                        var li = unloadListeners[i];
 
823
                        if (li &&
 
824
                            li[0] == el &&
 
825
                            li[1] == eventName &&
 
826
                            li[2] == fn) {
 
827
                            unloadListeners.splice(i, 1);
 
828
                            return true;
 
829
                        }
 
830
                    }
 
831
 
 
832
                    return false;
 
833
                }
 
834
 
 
835
                var cacheItem = null;
 
836
 
 
837
 
 
838
                var index = arguments[3];
 
839
 
 
840
                if ("undefined" == typeof index) {
 
841
                    index = this._getCacheIndex(el, eventName, fn);
 
842
                }
 
843
 
 
844
                if (index >= 0) {
 
845
                    cacheItem = listeners[index];
 
846
                }
 
847
 
 
848
                if (!el || !cacheItem) {
 
849
                    return false;
 
850
                }
 
851
 
 
852
                this.doRemove(el, eventName, cacheItem[this.WFN], false);
 
853
 
 
854
                delete listeners[index][this.WFN];
 
855
                delete listeners[index][this.FN];
 
856
                listeners.splice(index, 1);
 
857
 
 
858
                return true;
 
859
 
 
860
            },
 
861
 
 
862
 
 
863
            getTarget: function(ev, resolveTextNode) {
 
864
                ev = ev.browserEvent || ev;
 
865
                var t = ev.target || ev.srcElement;
 
866
                return this.resolveTextNode(t);
 
867
            },
 
868
 
 
869
 
 
870
            resolveTextNode: function(node) {
 
871
                if (Ext.isSafari && node && 3 == node.nodeType) {
 
872
                    return node.parentNode;
 
873
                } else {
 
874
                    return node;
 
875
                }
 
876
            },
 
877
 
 
878
 
 
879
            getPageX: function(ev) {
 
880
                ev = ev.browserEvent || ev;
 
881
                var x = ev.pageX;
 
882
                if (!x && 0 !== x) {
 
883
                    x = ev.clientX || 0;
 
884
 
 
885
                    if (Ext.isIE) {
 
886
                        x += this.getScroll()[1];
 
887
                    }
 
888
                }
 
889
 
 
890
                return x;
 
891
            },
 
892
 
 
893
 
 
894
            getPageY: function(ev) {
 
895
                ev = ev.browserEvent || ev;
 
896
                var y = ev.pageY;
 
897
                if (!y && 0 !== y) {
 
898
                    y = ev.clientY || 0;
 
899
 
 
900
                    if (Ext.isIE) {
 
901
                        y += this.getScroll()[0];
 
902
                    }
 
903
                }
 
904
 
 
905
 
 
906
                return y;
 
907
            },
 
908
 
 
909
 
 
910
            getXY: function(ev) {
 
911
                ev = ev.browserEvent || ev;
 
912
                return [this.getPageX(ev), this.getPageY(ev)];
 
913
            },
 
914
 
 
915
 
 
916
            getRelatedTarget: function(ev) {
 
917
                ev = ev.browserEvent || ev;
 
918
                var t = ev.relatedTarget;
 
919
                if (!t) {
 
920
                    if (ev.type == "mouseout") {
 
921
                        t = ev.toElement;
 
922
                    } else if (ev.type == "mouseover") {
 
923
                        t = ev.fromElement;
 
924
                    }
 
925
                }
 
926
 
 
927
                return this.resolveTextNode(t);
 
928
            },
 
929
 
 
930
 
 
931
            getTime: function(ev) {
 
932
                ev = ev.browserEvent || ev;
 
933
                if (!ev.time) {
 
934
                    var t = new Date().getTime();
 
935
                    try {
 
936
                        ev.time = t;
 
937
                    } catch(ex) {
 
938
                        this.lastError = ex;
 
939
                        return t;
 
940
                    }
 
941
                }
 
942
 
 
943
                return ev.time;
 
944
            },
 
945
 
 
946
 
 
947
            stopEvent: function(ev) {
 
948
                this.stopPropagation(ev);
 
949
                this.preventDefault(ev);
 
950
            },
 
951
 
 
952
 
 
953
            stopPropagation: function(ev) {
 
954
                ev = ev.browserEvent || ev;
 
955
                if (ev.stopPropagation) {
 
956
                    ev.stopPropagation();
 
957
                } else {
 
958
                    ev.cancelBubble = true;
 
959
                }
 
960
            },
 
961
 
 
962
 
 
963
            preventDefault: function(ev) {
 
964
                ev = ev.browserEvent || ev;
 
965
                if(ev.preventDefault) {
 
966
                    ev.preventDefault();
 
967
                } else {
 
968
                    ev.returnValue = false;
 
969
                }
 
970
            },
 
971
 
 
972
 
 
973
            getEvent: function(e) {
 
974
                var ev = e || window.event;
 
975
                if (!ev) {
 
976
                    var c = this.getEvent.caller;
 
977
                    while (c) {
 
978
                        ev = c.arguments[0];
 
979
                        if (ev && Event == ev.constructor) {
 
980
                            break;
 
981
                        }
 
982
                        c = c.caller;
 
983
                    }
 
984
                }
 
985
                return ev;
 
986
            },
 
987
 
 
988
 
 
989
            getCharCode: function(ev) {
 
990
                ev = ev.browserEvent || ev;
 
991
                return ev.charCode || ev.keyCode || 0;
 
992
            },
 
993
 
 
994
 
 
995
            _getCacheIndex: function(el, eventName, fn) {
 
996
                for (var i = 0,len = listeners.length; i < len; ++i) {
 
997
                    var li = listeners[i];
 
998
                    if (li &&
 
999
                        li[this.FN] == fn &&
 
1000
                        li[this.EL] == el &&
 
1001
                        li[this.TYPE] == eventName) {
 
1002
                        return i;
 
1003
                    }
 
1004
                }
 
1005
 
 
1006
                return -1;
 
1007
            },
 
1008
 
 
1009
 
 
1010
            elCache: {},
 
1011
 
 
1012
 
 
1013
            getEl: function(id) {
 
1014
                return document.getElementById(id);
 
1015
            },
 
1016
 
 
1017
 
 
1018
            clearCache: function() {
 
1019
            },
 
1020
 
 
1021
 
 
1022
            _load: function(e) {
 
1023
                loadComplete = true;
 
1024
                var EU = Ext.lib.Event;
 
1025
 
 
1026
 
 
1027
                if (Ext.isIE) {
 
1028
                    EU.doRemove(window, "load", EU._load);
 
1029
                }
 
1030
            },
 
1031
 
 
1032
 
 
1033
            _tryPreloadAttach: function() {
 
1034
 
 
1035
                if (this.locked) {
 
1036
                    return false;
 
1037
                }
 
1038
 
 
1039
                this.locked = true;
 
1040
 
 
1041
 
 
1042
                var tryAgain = !loadComplete;
 
1043
                if (!tryAgain) {
 
1044
                    tryAgain = (retryCount > 0);
 
1045
                }
 
1046
 
 
1047
 
 
1048
                var notAvail = [];
 
1049
                for (var i = 0,len = onAvailStack.length; i < len; ++i) {
 
1050
                    var item = onAvailStack[i];
 
1051
                    if (item) {
 
1052
                        var el = this.getEl(item.id);
 
1053
 
 
1054
                        if (el) {
 
1055
                            if (!item.checkReady ||
 
1056
                                loadComplete ||
 
1057
                                el.nextSibling ||
 
1058
                                (document && document.body)) {
 
1059
 
 
1060
                                var scope = el;
 
1061
                                if (item.override) {
 
1062
                                    if (item.override === true) {
 
1063
                                        scope = item.obj;
 
1064
                                    } else {
 
1065
                                        scope = item.override;
 
1066
                                    }
 
1067
                                }
 
1068
                                item.fn.call(scope, item.obj);
 
1069
                                onAvailStack[i] = null;
 
1070
                            }
 
1071
                        } else {
 
1072
                            notAvail.push(item);
 
1073
                        }
 
1074
                    }
 
1075
                }
 
1076
 
 
1077
                retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
 
1078
 
 
1079
                if (tryAgain) {
 
1080
 
 
1081
                    this.startInterval();
 
1082
                } else {
 
1083
                    clearInterval(this._interval);
 
1084
                    this._interval = null;
 
1085
                }
 
1086
 
 
1087
                this.locked = false;
 
1088
 
 
1089
                return true;
 
1090
 
 
1091
            },
 
1092
 
 
1093
 
 
1094
            purgeElement: function(el, recurse, eventName) {
 
1095
                var elListeners = this.getListeners(el, eventName);
 
1096
                if (elListeners) {
 
1097
                    for (var i = 0,len = elListeners.length; i < len; ++i) {
 
1098
                        var l = elListeners[i];
 
1099
                        this.removeListener(el, l.type, l.fn);
 
1100
                    }
 
1101
                }
 
1102
 
 
1103
                if (recurse && el && el.childNodes) {
 
1104
                    for (i = 0,len = el.childNodes.length; i < len; ++i) {
 
1105
                        this.purgeElement(el.childNodes[i], recurse, eventName);
 
1106
                    }
 
1107
                }
 
1108
            },
 
1109
 
 
1110
 
 
1111
            getListeners: function(el, eventName) {
 
1112
                var results = [], searchLists;
 
1113
                if (!eventName) {
 
1114
                    searchLists = [listeners, unloadListeners];
 
1115
                } else if (eventName == "unload") {
 
1116
                    searchLists = [unloadListeners];
 
1117
                } else {
 
1118
                    searchLists = [listeners];
 
1119
                }
 
1120
 
 
1121
                for (var j = 0; j < searchLists.length; ++j) {
 
1122
                    var searchList = searchLists[j];
 
1123
                    if (searchList && searchList.length > 0) {
 
1124
                        for (var i = 0,len = searchList.length; i < len; ++i) {
 
1125
                            var l = searchList[i];
 
1126
                            if (l && l[this.EL] === el &&
 
1127
                                (!eventName || eventName === l[this.TYPE])) {
 
1128
                                results.push({
 
1129
                                    type:   l[this.TYPE],
 
1130
                                    fn:     l[this.FN],
 
1131
                                    obj:    l[this.OBJ],
 
1132
                                    adjust: l[this.ADJ_SCOPE],
 
1133
                                    index:  i
 
1134
                                });
 
1135
                            }
 
1136
                        }
 
1137
                    }
 
1138
                }
 
1139
 
 
1140
                return (results.length) ? results : null;
 
1141
            },
 
1142
 
 
1143
 
 
1144
            _unload: function(e) {
 
1145
 
 
1146
                var EU = Ext.lib.Event, i, j, l, len, index;
 
1147
 
 
1148
                for (i = 0,len = unloadListeners.length; i < len; ++i) {
 
1149
                    l = unloadListeners[i];
 
1150
                    if (l) {
 
1151
                        var scope = window;
 
1152
                        if (l[EU.ADJ_SCOPE]) {
 
1153
                            if (l[EU.ADJ_SCOPE] === true) {
 
1154
                                scope = l[EU.OBJ];
 
1155
                            } else {
 
1156
                                scope = l[EU.ADJ_SCOPE];
 
1157
                            }
 
1158
                        }
 
1159
                        l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
 
1160
                        unloadListeners[i] = null;
 
1161
                        l = null;
 
1162
                        scope = null;
 
1163
                    }
 
1164
                }
 
1165
 
 
1166
                unloadListeners = null;
 
1167
 
 
1168
                if (listeners && listeners.length > 0) {
 
1169
                    j = listeners.length;
 
1170
                    while (j) {
 
1171
                        index = j - 1;
 
1172
                        l = listeners[index];
 
1173
                        if (l) {
 
1174
                            EU.removeListener(l[EU.EL], l[EU.TYPE],
 
1175
                                    l[EU.FN], index);
 
1176
                        }
 
1177
                        j = j - 1;
 
1178
                    }
 
1179
                    l = null;
 
1180
 
 
1181
                    EU.clearCache();
 
1182
                }
 
1183
 
 
1184
                EU.doRemove(window, "unload", EU._unload);
 
1185
 
 
1186
            },
 
1187
 
 
1188
 
 
1189
            getScroll: function() {
 
1190
                var dd = document.documentElement, db = document.body;
 
1191
                if (dd && (dd.scrollTop || dd.scrollLeft)) {
 
1192
                    return [dd.scrollTop, dd.scrollLeft];
 
1193
                } else if (db) {
 
1194
                    return [db.scrollTop, db.scrollLeft];
 
1195
                } else {
 
1196
                    return [0, 0];
 
1197
                }
 
1198
            },
 
1199
 
 
1200
 
 
1201
            doAdd: function () {
 
1202
                if (window.addEventListener) {
 
1203
                    return function(el, eventName, fn, capture) {
 
1204
                        el.addEventListener(eventName, fn, (capture));
 
1205
                    };
 
1206
                } else if (window.attachEvent) {
 
1207
                    return function(el, eventName, fn, capture) {
 
1208
                        el.attachEvent("on" + eventName, fn);
 
1209
                    };
 
1210
                } else {
 
1211
                    return function() {
 
1212
                    };
 
1213
                }
 
1214
            }(),
 
1215
 
 
1216
 
 
1217
            doRemove: function() {
 
1218
                if (window.removeEventListener) {
 
1219
                    return function (el, eventName, fn, capture) {
 
1220
                        el.removeEventListener(eventName, fn, (capture));
 
1221
                    };
 
1222
                } else if (window.detachEvent) {
 
1223
                    return function (el, eventName, fn) {
 
1224
                        el.detachEvent("on" + eventName, fn);
 
1225
                    };
 
1226
                } else {
 
1227
                    return function() {
 
1228
                    };
 
1229
                }
 
1230
            }()
 
1231
        };
 
1232
 
 
1233
    }();
 
1234
 
 
1235
    var E = Ext.lib.Event;
 
1236
    E.on = E.addListener;
 
1237
    E.un = E.removeListener;
 
1238
    if (document && document.body) {
 
1239
        E._load();
 
1240
    } else {
 
1241
        E.doAdd(window, "load", E._load);
 
1242
    }
 
1243
    E.doAdd(window, "unload", E._unload);
 
1244
    E._tryPreloadAttach();
 
1245
 
 
1246
    Ext.lib.Ajax = {
 
1247
        request : function(method, uri, cb, data, options) {
 
1248
            if(options){
 
1249
                var hs = options.headers;
 
1250
                if(hs){
 
1251
                    for(var h in hs){
 
1252
                        if(hs.hasOwnProperty(h)){
 
1253
                            this.initHeader(h, hs[h], false);
 
1254
                        }
 
1255
                    }
 
1256
                }
 
1257
                if(options.xmlData){
 
1258
                    this.initHeader('Content-Type', 'text/xml', false);
 
1259
                    method = 'POST';
 
1260
                    data = options.xmlData;
 
1261
                }else if(options.jsonData){
 
1262
                    this.initHeader('Content-Type', 'text/javascript', false);
 
1263
                    method = 'POST';
 
1264
                    data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData;
 
1265
                }
 
1266
            }
 
1267
 
 
1268
            return this.asyncRequest(method, uri, cb, data);
 
1269
        },
 
1270
 
 
1271
        serializeForm : function(form) {
 
1272
            if(typeof form == 'string') {
 
1273
                form = (document.getElementById(form) || document.forms[form]);
 
1274
            }
 
1275
 
 
1276
            var el, name, val, disabled, data = '', hasSubmit = false;
 
1277
            for (var i = 0; i < form.elements.length; i++) {
 
1278
                el = form.elements[i];
 
1279
                disabled = form.elements[i].disabled;
 
1280
                name = form.elements[i].name;
 
1281
                val = form.elements[i].value;
 
1282
 
 
1283
                if (!disabled && name){
 
1284
                    switch (el.type)
 
1285
                            {
 
1286
                        case 'select-one':
 
1287
                        case 'select-multiple':
 
1288
                            for (var j = 0; j < el.options.length; j++) {
 
1289
                                if (el.options[j].selected) {
 
1290
                                    if (Ext.isIE) {
 
1291
                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
 
1292
                                    }
 
1293
                                    else {
 
1294
                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
 
1295
                                    }
 
1296
                                }
 
1297
                            }
 
1298
                            break;
 
1299
                        case 'radio':
 
1300
                        case 'checkbox':
 
1301
                            if (el.checked) {
 
1302
                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
 
1303
                            }
 
1304
                            break;
 
1305
                        case 'file':
 
1306
 
 
1307
                        case undefined:
 
1308
 
 
1309
                        case 'reset':
 
1310
 
 
1311
                        case 'button':
 
1312
 
 
1313
                            break;
 
1314
                        case 'submit':
 
1315
                            if(hasSubmit == false) {
 
1316
                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
 
1317
                                hasSubmit = true;
 
1318
                            }
 
1319
                            break;
 
1320
                        default:
 
1321
                            data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
 
1322
                            break;
 
1323
                    }
 
1324
                }
 
1325
            }
 
1326
            data = data.substr(0, data.length - 1);
 
1327
            return data;
 
1328
        },
 
1329
 
 
1330
        headers:{},
 
1331
 
 
1332
        hasHeaders:false,
 
1333
 
 
1334
        useDefaultHeader:true,
 
1335
 
 
1336
        defaultPostHeader:'application/x-www-form-urlencoded',
 
1337
 
 
1338
        useDefaultXhrHeader:true,
 
1339
 
 
1340
        defaultXhrHeader:'XMLHttpRequest',
 
1341
 
 
1342
        hasDefaultHeaders:true,
 
1343
 
 
1344
        defaultHeaders:{},
 
1345
 
 
1346
        poll:{},
 
1347
 
 
1348
        timeout:{},
 
1349
 
 
1350
        pollInterval:50,
 
1351
 
 
1352
        transactionId:0,
 
1353
 
 
1354
        setProgId:function(id)
 
1355
        {
 
1356
            this.activeX.unshift(id);
 
1357
        },
 
1358
 
 
1359
        setDefaultPostHeader:function(b)
 
1360
        {
 
1361
            this.useDefaultHeader = b;
 
1362
        },
 
1363
 
 
1364
        setDefaultXhrHeader:function(b)
 
1365
        {
 
1366
            this.useDefaultXhrHeader = b;
 
1367
        },
 
1368
 
 
1369
        setPollingInterval:function(i)
 
1370
        {
 
1371
            if (typeof i == 'number' && isFinite(i)) {
 
1372
                this.pollInterval = i;
 
1373
            }
 
1374
        },
 
1375
 
 
1376
        createXhrObject:function(transactionId)
 
1377
        {
 
1378
            var obj,http;
 
1379
            try
 
1380
            {
 
1381
 
 
1382
                http = new XMLHttpRequest();
 
1383
 
 
1384
                obj = { conn:http, tId:transactionId };
 
1385
            }
 
1386
            catch(e)
 
1387
            {
 
1388
                for (var i = 0; i < this.activeX.length; ++i) {
 
1389
                    try
 
1390
                    {
 
1391
 
 
1392
                        http = new ActiveXObject(this.activeX[i]);
 
1393
 
 
1394
                        obj = { conn:http, tId:transactionId };
 
1395
                        break;
 
1396
                    }
 
1397
                    catch(e) {
 
1398
                    }
 
1399
                }
 
1400
            }
 
1401
            finally
 
1402
            {
 
1403
                return obj;
 
1404
            }
 
1405
        },
 
1406
 
 
1407
        getConnectionObject:function()
 
1408
        {
 
1409
            var o;
 
1410
            var tId = this.transactionId;
 
1411
 
 
1412
            try
 
1413
            {
 
1414
                o = this.createXhrObject(tId);
 
1415
                if (o) {
 
1416
                    this.transactionId++;
 
1417
                }
 
1418
            }
 
1419
            catch(e) {
 
1420
            }
 
1421
            finally
 
1422
            {
 
1423
                return o;
 
1424
            }
 
1425
        },
 
1426
 
 
1427
        asyncRequest:function(method, uri, callback, postData)
 
1428
        {
 
1429
            var o = this.getConnectionObject();
 
1430
 
 
1431
            if (!o) {
 
1432
                return null;
 
1433
            }
 
1434
            else {
 
1435
                o.conn.open(method, uri, true);
 
1436
 
 
1437
                if (this.useDefaultXhrHeader) {
 
1438
                    if (!this.defaultHeaders['X-Requested-With']) {
 
1439
                        this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
 
1440
                    }
 
1441
                }
 
1442
 
 
1443
                if(postData && this.useDefaultHeader){
 
1444
                    this.initHeader('Content-Type', this.defaultPostHeader);
 
1445
                }
 
1446
 
 
1447
                 if (this.hasDefaultHeaders || this.hasHeaders) {
 
1448
                    this.setHeader(o);
 
1449
                }
 
1450
 
 
1451
                this.handleReadyState(o, callback);
 
1452
                o.conn.send(postData || null);
 
1453
 
 
1454
                return o;
 
1455
            }
 
1456
        },
 
1457
 
 
1458
        handleReadyState:function(o, callback)
 
1459
        {
 
1460
            var oConn = this;
 
1461
 
 
1462
            if (callback && callback.timeout) {
 
1463
                this.timeout[o.tId] = window.setTimeout(function() {
 
1464
                    oConn.abort(o, callback, true);
 
1465
                }, callback.timeout);
 
1466
            }
 
1467
 
 
1468
            this.poll[o.tId] = window.setInterval(
 
1469
                    function() {
 
1470
                        if (o.conn && o.conn.readyState == 4) {
 
1471
                            window.clearInterval(oConn.poll[o.tId]);
 
1472
                            delete oConn.poll[o.tId];
 
1473
 
 
1474
                            if (callback && callback.timeout) {
 
1475
                                window.clearTimeout(oConn.timeout[o.tId]);
 
1476
                                delete oConn.timeout[o.tId];
 
1477
                            }
 
1478
 
 
1479
                            oConn.handleTransactionResponse(o, callback);
 
1480
                        }
 
1481
                    }
 
1482
                    , this.pollInterval);
 
1483
        },
 
1484
 
 
1485
        handleTransactionResponse:function(o, callback, isAbort)
 
1486
        {
 
1487
 
 
1488
            if (!callback) {
 
1489
                this.releaseObject(o);
 
1490
                return;
 
1491
            }
 
1492
 
 
1493
            var httpStatus, responseObject;
 
1494
 
 
1495
            try
 
1496
            {
 
1497
                if (o.conn.status !== undefined && o.conn.status != 0) {
 
1498
                    httpStatus = o.conn.status;
 
1499
                }
 
1500
                else {
 
1501
                    httpStatus = 13030;
 
1502
                }
 
1503
            }
 
1504
            catch(e) {
 
1505
 
 
1506
 
 
1507
                httpStatus = 13030;
 
1508
            }
 
1509
 
 
1510
            if (httpStatus >= 200 && httpStatus < 300) {
 
1511
                responseObject = this.createResponseObject(o, callback.argument);
 
1512
                if (callback.success) {
 
1513
                    if (!callback.scope) {
 
1514
                        callback.success(responseObject);
 
1515
                    }
 
1516
                    else {
 
1517
 
 
1518
 
 
1519
                        callback.success.apply(callback.scope, [responseObject]);
 
1520
                    }
 
1521
                }
 
1522
            }
 
1523
            else {
 
1524
                switch (httpStatus) {
 
1525
 
 
1526
                    case 12002:
 
1527
                    case 12029:
 
1528
                    case 12030:
 
1529
                    case 12031:
 
1530
                    case 12152:
 
1531
                    case 13030:
 
1532
                        responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
 
1533
                        if (callback.failure) {
 
1534
                            if (!callback.scope) {
 
1535
                                callback.failure(responseObject);
 
1536
                            }
 
1537
                            else {
 
1538
                                callback.failure.apply(callback.scope, [responseObject]);
 
1539
                            }
 
1540
                        }
 
1541
                        break;
 
1542
                    default:
 
1543
                        responseObject = this.createResponseObject(o, callback.argument);
 
1544
                        if (callback.failure) {
 
1545
                            if (!callback.scope) {
 
1546
                                callback.failure(responseObject);
 
1547
                            }
 
1548
                            else {
 
1549
                                callback.failure.apply(callback.scope, [responseObject]);
 
1550
                            }
 
1551
                        }
 
1552
                }
 
1553
            }
 
1554
 
 
1555
            this.releaseObject(o);
 
1556
            responseObject = null;
 
1557
        },
 
1558
 
 
1559
        createResponseObject:function(o, callbackArg)
 
1560
        {
 
1561
            var obj = {};
 
1562
            var headerObj = {};
 
1563
 
 
1564
            try
 
1565
            {
 
1566
                var headerStr = o.conn.getAllResponseHeaders();
 
1567
                var header = headerStr.split('\n');
 
1568
                for (var i = 0; i < header.length; i++) {
 
1569
                    var delimitPos = header[i].indexOf(':');
 
1570
                    if (delimitPos != -1) {
 
1571
                        headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
 
1572
                    }
 
1573
                }
 
1574
            }
 
1575
            catch(e) {
 
1576
            }
 
1577
 
 
1578
            obj.tId = o.tId;
 
1579
            obj.status = o.conn.status;
 
1580
            obj.statusText = o.conn.statusText;
 
1581
            obj.getResponseHeader = headerObj;
 
1582
            obj.getAllResponseHeaders = headerStr;
 
1583
            obj.responseText = o.conn.responseText;
 
1584
            obj.responseXML = o.conn.responseXML;
 
1585
 
 
1586
            if (typeof callbackArg !== undefined) {
 
1587
                obj.argument = callbackArg;
 
1588
            }
 
1589
 
 
1590
            return obj;
 
1591
        },
 
1592
 
 
1593
        createExceptionObject:function(tId, callbackArg, isAbort)
 
1594
        {
 
1595
            var COMM_CODE = 0;
 
1596
            var COMM_ERROR = 'communication failure';
 
1597
            var ABORT_CODE = -1;
 
1598
            var ABORT_ERROR = 'transaction aborted';
 
1599
 
 
1600
            var obj = {};
 
1601
 
 
1602
            obj.tId = tId;
 
1603
            if (isAbort) {
 
1604
                obj.status = ABORT_CODE;
 
1605
                obj.statusText = ABORT_ERROR;
 
1606
            }
 
1607
            else {
 
1608
                obj.status = COMM_CODE;
 
1609
                obj.statusText = COMM_ERROR;
 
1610
            }
 
1611
 
 
1612
            if (callbackArg) {
 
1613
                obj.argument = callbackArg;
 
1614
            }
 
1615
 
 
1616
            return obj;
 
1617
        },
 
1618
 
 
1619
        initHeader:function(label, value, isDefault)
 
1620
        {
 
1621
            var headerObj = (isDefault) ? this.defaultHeaders : this.headers;
 
1622
 
 
1623
            if (headerObj[label] === undefined) {
 
1624
                headerObj[label] = value;
 
1625
            }
 
1626
            else {
 
1627
 
 
1628
 
 
1629
                headerObj[label] = value + "," + headerObj[label];
 
1630
            }
 
1631
 
 
1632
            if (isDefault) {
 
1633
                this.hasDefaultHeaders = true;
 
1634
            }
 
1635
            else {
 
1636
                this.hasHeaders = true;
 
1637
            }
 
1638
        },
 
1639
 
 
1640
 
 
1641
        setHeader:function(o)
 
1642
        {
 
1643
            if (this.hasDefaultHeaders) {
 
1644
                for (var prop in this.defaultHeaders) {
 
1645
                    if (this.defaultHeaders.hasOwnProperty(prop)) {
 
1646
                        o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
 
1647
                    }
 
1648
                }
 
1649
            }
 
1650
 
 
1651
            if (this.hasHeaders) {
 
1652
                for (var prop in this.headers) {
 
1653
                    if (this.headers.hasOwnProperty(prop)) {
 
1654
                        o.conn.setRequestHeader(prop, this.headers[prop]);
 
1655
                    }
 
1656
                }
 
1657
                this.headers = {};
 
1658
                this.hasHeaders = false;
 
1659
            }
 
1660
        },
 
1661
 
 
1662
        resetDefaultHeaders:function() {
 
1663
            delete this.defaultHeaders;
 
1664
            this.defaultHeaders = {};
 
1665
            this.hasDefaultHeaders = false;
 
1666
        },
 
1667
 
 
1668
        abort:function(o, callback, isTimeout)
 
1669
        {
 
1670
            if (this.isCallInProgress(o)) {
 
1671
                o.conn.abort();
 
1672
                window.clearInterval(this.poll[o.tId]);
 
1673
                delete this.poll[o.tId];
 
1674
                if (isTimeout) {
 
1675
                    delete this.timeout[o.tId];
 
1676
                }
 
1677
 
 
1678
                this.handleTransactionResponse(o, callback, true);
 
1679
 
 
1680
                return true;
 
1681
            }
 
1682
            else {
 
1683
                return false;
 
1684
            }
 
1685
        },
 
1686
 
 
1687
 
 
1688
        isCallInProgress:function(o)
 
1689
        {
 
1690
 
 
1691
 
 
1692
            if (o.conn) {
 
1693
                return o.conn.readyState != 4 && o.conn.readyState != 0;
 
1694
            }
 
1695
            else {
 
1696
 
 
1697
                return false;
 
1698
            }
 
1699
        },
 
1700
 
 
1701
 
 
1702
        releaseObject:function(o)
 
1703
        {
 
1704
 
 
1705
            o.conn = null;
 
1706
 
 
1707
            o = null;
 
1708
        },
 
1709
 
 
1710
        activeX:[
 
1711
        'MSXML2.XMLHTTP.3.0',
 
1712
        'MSXML2.XMLHTTP',
 
1713
        'Microsoft.XMLHTTP'
 
1714
        ]
 
1715
 
 
1716
 
 
1717
    };
 
1718
 
 
1719
 
 
1720
    Ext.lib.Region = function(t, r, b, l) {
 
1721
        this.top = t;
 
1722
        this[1] = t;
 
1723
        this.right = r;
 
1724
        this.bottom = b;
 
1725
        this.left = l;
 
1726
        this[0] = l;
 
1727
    };
 
1728
 
 
1729
    Ext.lib.Region.prototype = {
 
1730
        contains : function(region) {
 
1731
            return ( region.left >= this.left &&
 
1732
                     region.right <= this.right &&
 
1733
                     region.top >= this.top &&
 
1734
                     region.bottom <= this.bottom    );
 
1735
 
 
1736
        },
 
1737
 
 
1738
        getArea : function() {
 
1739
            return ( (this.bottom - this.top) * (this.right - this.left) );
 
1740
        },
 
1741
 
 
1742
        intersect : function(region) {
 
1743
            var t = Math.max(this.top, region.top);
 
1744
            var r = Math.min(this.right, region.right);
 
1745
            var b = Math.min(this.bottom, region.bottom);
 
1746
            var l = Math.max(this.left, region.left);
 
1747
 
 
1748
            if (b >= t && r >= l) {
 
1749
                return new Ext.lib.Region(t, r, b, l);
 
1750
            } else {
 
1751
                return null;
 
1752
            }
 
1753
        },
 
1754
        union : function(region) {
 
1755
            var t = Math.min(this.top, region.top);
 
1756
            var r = Math.max(this.right, region.right);
 
1757
            var b = Math.max(this.bottom, region.bottom);
 
1758
            var l = Math.min(this.left, region.left);
 
1759
 
 
1760
            return new Ext.lib.Region(t, r, b, l);
 
1761
        },
 
1762
 
 
1763
        constrainTo : function(r) {
 
1764
            this.top = this.top.constrain(r.top, r.bottom);
 
1765
            this.bottom = this.bottom.constrain(r.top, r.bottom);
 
1766
            this.left = this.left.constrain(r.left, r.right);
 
1767
            this.right = this.right.constrain(r.left, r.right);
 
1768
            return this;
 
1769
        },
 
1770
 
 
1771
        adjust : function(t, l, b, r) {
 
1772
            this.top += t;
 
1773
            this.left += l;
 
1774
            this.right += r;
 
1775
            this.bottom += b;
 
1776
            return this;
 
1777
        }
 
1778
    };
 
1779
 
 
1780
    Ext.lib.Region.getRegion = function(el) {
 
1781
        var p = Ext.lib.Dom.getXY(el);
 
1782
 
 
1783
        var t = p[1];
 
1784
        var r = p[0] + el.offsetWidth;
 
1785
        var b = p[1] + el.offsetHeight;
 
1786
        var l = p[0];
 
1787
 
 
1788
        return new Ext.lib.Region(t, r, b, l);
 
1789
    };
 
1790
 
 
1791
    Ext.lib.Point = function(x, y) {
 
1792
        if (Ext.isArray(x)) {
 
1793
            y = x[1];
 
1794
            x = x[0];
 
1795
        }
 
1796
        this.x = this.right = this.left = this[0] = x;
 
1797
        this.y = this.top = this.bottom = this[1] = y;
 
1798
    };
 
1799
 
 
1800
    Ext.lib.Point.prototype = new Ext.lib.Region();
 
1801
 
 
1802
 
 
1803
    Ext.lib.Anim = {
 
1804
        scroll : function(el, args, duration, easing, cb, scope) {
 
1805
            return this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll);
 
1806
        },
 
1807
 
 
1808
        motion : function(el, args, duration, easing, cb, scope) {
 
1809
            return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion);
 
1810
        },
 
1811
 
 
1812
        color : function(el, args, duration, easing, cb, scope) {
 
1813
            return this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim);
 
1814
        },
 
1815
 
 
1816
        run : function(el, args, duration, easing, cb, scope, type) {
 
1817
            type = type || Ext.lib.AnimBase;
 
1818
            if (typeof easing == "string") {
 
1819
                easing = Ext.lib.Easing[easing];
 
1820
            }
 
1821
            var anim = new type(el, args, duration, easing);
 
1822
            anim.animateX(function() {
 
1823
                Ext.callback(cb, scope);
 
1824
            });
 
1825
            return anim;
 
1826
        }
 
1827
    };
 
1828
 
 
1829
 
 
1830
    function fly(el) {
 
1831
        if (!libFlyweight) {
 
1832
            libFlyweight = new Ext.Element.Flyweight();
 
1833
        }
 
1834
        libFlyweight.dom = el;
 
1835
        return libFlyweight;
 
1836
    }
 
1837
 
 
1838
 
 
1839
    if(Ext.isIE) {
 
1840
        function fnCleanUp() {
 
1841
            var p = Function.prototype;
 
1842
            delete p.createSequence;
 
1843
            delete p.defer;
 
1844
            delete p.createDelegate;
 
1845
            delete p.createCallback;
 
1846
            delete p.createInterceptor;
 
1847
 
 
1848
            window.detachEvent("onunload", fnCleanUp);
 
1849
        }
 
1850
        window.attachEvent("onunload", fnCleanUp);
 
1851
    }
 
1852
 
 
1853
    Ext.lib.AnimBase = function(el, attributes, duration, method) {
 
1854
        if (el) {
 
1855
            this.init(el, attributes, duration, method);
 
1856
        }
 
1857
    };
 
1858
 
 
1859
    Ext.lib.AnimBase.prototype = {
 
1860
 
 
1861
        toString: function() {
 
1862
            var el = this.getEl();
 
1863
            var id = el.id || el.tagName;
 
1864
            return ("Anim " + id);
 
1865
        },
 
1866
 
 
1867
        patterns: {
 
1868
            noNegatives:        /width|height|opacity|padding/i,
 
1869
            offsetAttribute:  /^((width|height)|(top|left))$/,
 
1870
            defaultUnit:        /width|height|top$|bottom$|left$|right$/i,
 
1871
            offsetUnit:         /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
 
1872
        },
 
1873
 
 
1874
 
 
1875
        doMethod: function(attr, start, end) {
 
1876
            return this.method(this.currentFrame, start, end - start, this.totalFrames);
 
1877
        },
 
1878
 
 
1879
 
 
1880
        setAttribute: function(attr, val, unit) {
 
1881
            if (this.patterns.noNegatives.test(attr)) {
 
1882
                val = (val > 0) ? val : 0;
 
1883
            }
 
1884
 
 
1885
            Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit);
 
1886
        },
 
1887
 
 
1888
 
 
1889
        getAttribute: function(attr) {
 
1890
            var el = this.getEl();
 
1891
            var val = fly(el).getStyle(attr);
 
1892
 
 
1893
            if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
 
1894
                return parseFloat(val);
 
1895
            }
 
1896
 
 
1897
            var a = this.patterns.offsetAttribute.exec(attr) || [];
 
1898
            var pos = !!( a[3] );
 
1899
            var box = !!( a[2] );
 
1900
 
 
1901
 
 
1902
            if (box || (fly(el).getStyle('position') == 'absolute' && pos)) {
 
1903
                val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
 
1904
            } else {
 
1905
                val = 0;
 
1906
            }
 
1907
 
 
1908
            return val;
 
1909
        },
 
1910
 
 
1911
 
 
1912
        getDefaultUnit: function(attr) {
 
1913
            if (this.patterns.defaultUnit.test(attr)) {
 
1914
                return 'px';
 
1915
            }
 
1916
 
 
1917
            return '';
 
1918
        },
 
1919
 
 
1920
        animateX : function(callback, scope) {
 
1921
            var f = function() {
 
1922
                this.onComplete.removeListener(f);
 
1923
                if (typeof callback == "function") {
 
1924
                    callback.call(scope || this, this);
 
1925
                }
 
1926
            };
 
1927
            this.onComplete.addListener(f, this);
 
1928
            this.animate();
 
1929
        },
 
1930
 
 
1931
 
 
1932
        setRuntimeAttribute: function(attr) {
 
1933
            var start;
 
1934
            var end;
 
1935
            var attributes = this.attributes;
 
1936
 
 
1937
            this.runtimeAttributes[attr] = {};
 
1938
 
 
1939
            var isset = function(prop) {
 
1940
                return (typeof prop !== 'undefined');
 
1941
            };
 
1942
 
 
1943
            if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) {
 
1944
                return false;
 
1945
            }
 
1946
 
 
1947
            start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
 
1948
 
 
1949
 
 
1950
            if (isset(attributes[attr]['to'])) {
 
1951
                end = attributes[attr]['to'];
 
1952
            } else if (isset(attributes[attr]['by'])) {
 
1953
                if (start.constructor == Array) {
 
1954
                    end = [];
 
1955
                    for (var i = 0, len = start.length; i < len; ++i) {
 
1956
                        end[i] = start[i] + attributes[attr]['by'][i];
 
1957
                    }
 
1958
                } else {
 
1959
                    end = start + attributes[attr]['by'];
 
1960
                }
 
1961
            }
 
1962
 
 
1963
            this.runtimeAttributes[attr].start = start;
 
1964
            this.runtimeAttributes[attr].end = end;
 
1965
 
 
1966
 
 
1967
            this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
 
1968
        },
 
1969
 
 
1970
 
 
1971
        init: function(el, attributes, duration, method) {
 
1972
 
 
1973
            var isAnimated = false;
 
1974
 
 
1975
 
 
1976
            var startTime = null;
 
1977
 
 
1978
 
 
1979
            var actualFrames = 0;
 
1980
 
 
1981
 
 
1982
            el = Ext.getDom(el);
 
1983
 
 
1984
 
 
1985
            this.attributes = attributes || {};
 
1986
 
 
1987
 
 
1988
            this.duration = duration || 1;
 
1989
 
 
1990
 
 
1991
            this.method = method || Ext.lib.Easing.easeNone;
 
1992
 
 
1993
 
 
1994
            this.useSeconds = true;
 
1995
 
 
1996
 
 
1997
            this.currentFrame = 0;
 
1998
 
 
1999
 
 
2000
            this.totalFrames = Ext.lib.AnimMgr.fps;
 
2001
 
 
2002
 
 
2003
            this.getEl = function() {
 
2004
                return el;
 
2005
            };
 
2006
 
 
2007
 
 
2008
            this.isAnimated = function() {
 
2009
                return isAnimated;
 
2010
            };
 
2011
 
 
2012
 
 
2013
            this.getStartTime = function() {
 
2014
                return startTime;
 
2015
            };
 
2016
 
 
2017
            this.runtimeAttributes = {};
 
2018
 
 
2019
 
 
2020
            this.animate = function() {
 
2021
                if (this.isAnimated()) {
 
2022
                    return false;
 
2023
                }
 
2024
 
 
2025
                this.currentFrame = 0;
 
2026
 
 
2027
                this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration;
 
2028
 
 
2029
                Ext.lib.AnimMgr.registerElement(this);
 
2030
            };
 
2031
 
 
2032
 
 
2033
            this.stop = function(finish) {
 
2034
                if (finish) {
 
2035
                    this.currentFrame = this.totalFrames;
 
2036
                    this._onTween.fire();
 
2037
                }
 
2038
                Ext.lib.AnimMgr.stop(this);
 
2039
            };
 
2040
 
 
2041
            var onStart = function() {
 
2042
                this.onStart.fire();
 
2043
 
 
2044
                this.runtimeAttributes = {};
 
2045
                for (var attr in this.attributes) {
 
2046
                    this.setRuntimeAttribute(attr);
 
2047
                }
 
2048
 
 
2049
                isAnimated = true;
 
2050
                actualFrames = 0;
 
2051
                startTime = new Date();
 
2052
            };
 
2053
 
 
2054
 
 
2055
            var onTween = function() {
 
2056
                var data = {
 
2057
                    duration: new Date() - this.getStartTime(),
 
2058
                    currentFrame: this.currentFrame
 
2059
                };
 
2060
 
 
2061
                data.toString = function() {
 
2062
                    return (
 
2063
                            'duration: ' + data.duration +
 
2064
                            ', currentFrame: ' + data.currentFrame
 
2065
                            );
 
2066
                };
 
2067
 
 
2068
                this.onTween.fire(data);
 
2069
 
 
2070
                var runtimeAttributes = this.runtimeAttributes;
 
2071
 
 
2072
                for (var attr in runtimeAttributes) {
 
2073
                    this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
 
2074
                }
 
2075
 
 
2076
                actualFrames += 1;
 
2077
            };
 
2078
 
 
2079
            var onComplete = function() {
 
2080
                var actual_duration = (new Date() - startTime) / 1000 ;
 
2081
 
 
2082
                var data = {
 
2083
                    duration: actual_duration,
 
2084
                    frames: actualFrames,
 
2085
                    fps: actualFrames / actual_duration
 
2086
                };
 
2087
 
 
2088
                data.toString = function() {
 
2089
                    return (
 
2090
                            'duration: ' + data.duration +
 
2091
                            ', frames: ' + data.frames +
 
2092
                            ', fps: ' + data.fps
 
2093
                            );
 
2094
                };
 
2095
 
 
2096
                isAnimated = false;
 
2097
                actualFrames = 0;
 
2098
                this.onComplete.fire(data);
 
2099
            };
 
2100
 
 
2101
 
 
2102
            this._onStart = new Ext.util.Event(this);
 
2103
            this.onStart = new Ext.util.Event(this);
 
2104
            this.onTween = new Ext.util.Event(this);
 
2105
            this._onTween = new Ext.util.Event(this);
 
2106
            this.onComplete = new Ext.util.Event(this);
 
2107
            this._onComplete = new Ext.util.Event(this);
 
2108
            this._onStart.addListener(onStart);
 
2109
            this._onTween.addListener(onTween);
 
2110
            this._onComplete.addListener(onComplete);
 
2111
        }
 
2112
    };
 
2113
 
 
2114
 
 
2115
    Ext.lib.AnimMgr = new function() {
 
2116
 
 
2117
        var thread = null;
 
2118
 
 
2119
 
 
2120
        var queue = [];
 
2121
 
 
2122
 
 
2123
        var tweenCount = 0;
 
2124
 
 
2125
 
 
2126
        this.fps = 1000;
 
2127
 
 
2128
 
 
2129
        this.delay = 1;
 
2130
 
 
2131
 
 
2132
        this.registerElement = function(tween) {
 
2133
            queue[queue.length] = tween;
 
2134
            tweenCount += 1;
 
2135
            tween._onStart.fire();
 
2136
            this.start();
 
2137
        };
 
2138
 
 
2139
 
 
2140
        this.unRegister = function(tween, index) {
 
2141
            tween._onComplete.fire();
 
2142
            index = index || getIndex(tween);
 
2143
            if (index != -1) {
 
2144
                queue.splice(index, 1);
 
2145
            }
 
2146
 
 
2147
            tweenCount -= 1;
 
2148
            if (tweenCount <= 0) {
 
2149
                this.stop();
 
2150
            }
 
2151
        };
 
2152
 
 
2153
 
 
2154
        this.start = function() {
 
2155
            if (thread === null) {
 
2156
                thread = setInterval(this.run, this.delay);
 
2157
            }
 
2158
        };
 
2159
 
 
2160
 
 
2161
        this.stop = function(tween) {
 
2162
            if (!tween) {
 
2163
                clearInterval(thread);
 
2164
 
 
2165
                for (var i = 0, len = queue.length; i < len; ++i) {
 
2166
                    if (queue[0].isAnimated()) {
 
2167
                        this.unRegister(queue[0], 0);
 
2168
                    }
 
2169
                }
 
2170
 
 
2171
                queue = [];
 
2172
                thread = null;
 
2173
                tweenCount = 0;
 
2174
            }
 
2175
            else {
 
2176
                this.unRegister(tween);
 
2177
            }
 
2178
        };
 
2179
 
 
2180
 
 
2181
        this.run = function() {
 
2182
            for (var i = 0, len = queue.length; i < len; ++i) {
 
2183
                var tween = queue[i];
 
2184
                if (!tween || !tween.isAnimated()) {
 
2185
                    continue;
 
2186
                }
 
2187
 
 
2188
                if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
 
2189
                {
 
2190
                    tween.currentFrame += 1;
 
2191
 
 
2192
                    if (tween.useSeconds) {
 
2193
                        correctFrame(tween);
 
2194
                    }
 
2195
                    tween._onTween.fire();
 
2196
                }
 
2197
                else {
 
2198
                    Ext.lib.AnimMgr.stop(tween, i);
 
2199
                }
 
2200
            }
 
2201
        };
 
2202
 
 
2203
        var getIndex = function(anim) {
 
2204
            for (var i = 0, len = queue.length; i < len; ++i) {
 
2205
                if (queue[i] == anim) {
 
2206
                    return i;
 
2207
                }
 
2208
            }
 
2209
            return -1;
 
2210
        };
 
2211
 
 
2212
 
 
2213
        var correctFrame = function(tween) {
 
2214
            var frames = tween.totalFrames;
 
2215
            var frame = tween.currentFrame;
 
2216
            var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
 
2217
            var elapsed = (new Date() - tween.getStartTime());
 
2218
            var tweak = 0;
 
2219
 
 
2220
            if (elapsed < tween.duration * 1000) {
 
2221
                tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
 
2222
            } else {
 
2223
                tweak = frames - (frame + 1);
 
2224
            }
 
2225
            if (tweak > 0 && isFinite(tweak)) {
 
2226
                if (tween.currentFrame + tweak >= frames) {
 
2227
                    tweak = frames - (frame + 1);
 
2228
                }
 
2229
 
 
2230
                tween.currentFrame += tweak;
 
2231
            }
 
2232
        };
 
2233
    };
 
2234
 
 
2235
    Ext.lib.Bezier = new function() {
 
2236
 
 
2237
        this.getPosition = function(points, t) {
 
2238
            var n = points.length;
 
2239
            var tmp = [];
 
2240
 
 
2241
            for (var i = 0; i < n; ++i) {
 
2242
                tmp[i] = [points[i][0], points[i][1]];
 
2243
            }
 
2244
 
 
2245
            for (var j = 1; j < n; ++j) {
 
2246
                for (i = 0; i < n - j; ++i) {
 
2247
                    tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
 
2248
                    tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
 
2249
                }
 
2250
            }
 
2251
 
 
2252
            return [ tmp[0][0], tmp[0][1] ];
 
2253
 
 
2254
        };
 
2255
    };
 
2256
    (function() {
 
2257
 
 
2258
        Ext.lib.ColorAnim = function(el, attributes, duration, method) {
 
2259
            Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
 
2260
        };
 
2261
 
 
2262
        Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase);
 
2263
 
 
2264
 
 
2265
        var Y = Ext.lib;
 
2266
        var superclass = Y.ColorAnim.superclass;
 
2267
        var proto = Y.ColorAnim.prototype;
 
2268
 
 
2269
        proto.toString = function() {
 
2270
            var el = this.getEl();
 
2271
            var id = el.id || el.tagName;
 
2272
            return ("ColorAnim " + id);
 
2273
        };
 
2274
 
 
2275
        proto.patterns.color = /color$/i;
 
2276
        proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
 
2277
        proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
 
2278
        proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
 
2279
        proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
 
2280
 
 
2281
 
 
2282
        proto.parseColor = function(s) {
 
2283
            if (s.length == 3) {
 
2284
                return s;
 
2285
            }
 
2286
 
 
2287
            var c = this.patterns.hex.exec(s);
 
2288
            if (c && c.length == 4) {
 
2289
                return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
 
2290
            }
 
2291
 
 
2292
            c = this.patterns.rgb.exec(s);
 
2293
            if (c && c.length == 4) {
 
2294
                return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
 
2295
            }
 
2296
 
 
2297
            c = this.patterns.hex3.exec(s);
 
2298
            if (c && c.length == 4) {
 
2299
                return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
 
2300
            }
 
2301
 
 
2302
            return null;
 
2303
        };
 
2304
 
 
2305
        proto.getAttribute = function(attr) {
 
2306
            var el = this.getEl();
 
2307
            if (this.patterns.color.test(attr)) {
 
2308
                var val = fly(el).getStyle(attr);
 
2309
 
 
2310
                if (this.patterns.transparent.test(val)) {
 
2311
                    var parent = el.parentNode;
 
2312
                    val = fly(parent).getStyle(attr);
 
2313
 
 
2314
                    while (parent && this.patterns.transparent.test(val)) {
 
2315
                        parent = parent.parentNode;
 
2316
                        val = fly(parent).getStyle(attr);
 
2317
                        if (parent.tagName.toUpperCase() == 'HTML') {
 
2318
                            val = '#fff';
 
2319
                        }
 
2320
                    }
 
2321
                }
 
2322
            } else {
 
2323
                val = superclass.getAttribute.call(this, attr);
 
2324
            }
 
2325
 
 
2326
            return val;
 
2327
        };
 
2328
 
 
2329
        proto.doMethod = function(attr, start, end) {
 
2330
            var val;
 
2331
 
 
2332
            if (this.patterns.color.test(attr)) {
 
2333
                val = [];
 
2334
                for (var i = 0, len = start.length; i < len; ++i) {
 
2335
                    val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
 
2336
                }
 
2337
 
 
2338
                val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1]) + ',' + Math.floor(val[2]) + ')';
 
2339
            }
 
2340
            else {
 
2341
                val = superclass.doMethod.call(this, attr, start, end);
 
2342
            }
 
2343
 
 
2344
            return val;
 
2345
        };
 
2346
 
 
2347
        proto.setRuntimeAttribute = function(attr) {
 
2348
            superclass.setRuntimeAttribute.call(this, attr);
 
2349
 
 
2350
            if (this.patterns.color.test(attr)) {
 
2351
                var attributes = this.attributes;
 
2352
                var start = this.parseColor(this.runtimeAttributes[attr].start);
 
2353
                var end = this.parseColor(this.runtimeAttributes[attr].end);
 
2354
 
 
2355
                if (typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined') {
 
2356
                    end = this.parseColor(attributes[attr].by);
 
2357
 
 
2358
                    for (var i = 0, len = start.length; i < len; ++i) {
 
2359
                        end[i] = start[i] + end[i];
 
2360
                    }
 
2361
                }
 
2362
 
 
2363
                this.runtimeAttributes[attr].start = start;
 
2364
                this.runtimeAttributes[attr].end = end;
 
2365
            }
 
2366
        };
 
2367
    })();
 
2368
 
 
2369
 
 
2370
    Ext.lib.Easing = {
 
2371
 
 
2372
 
 
2373
        easeNone: function (t, b, c, d) {
 
2374
            return c * t / d + b;
 
2375
        },
 
2376
 
 
2377
 
 
2378
        easeIn: function (t, b, c, d) {
 
2379
            return c * (t /= d) * t + b;
 
2380
        },
 
2381
 
 
2382
 
 
2383
        easeOut: function (t, b, c, d) {
 
2384
            return -c * (t /= d) * (t - 2) + b;
 
2385
        },
 
2386
 
 
2387
 
 
2388
        easeBoth: function (t, b, c, d) {
 
2389
            if ((t /= d / 2) < 1) {
 
2390
                return c / 2 * t * t + b;
 
2391
            }
 
2392
 
 
2393
            return -c / 2 * ((--t) * (t - 2) - 1) + b;
 
2394
        },
 
2395
 
 
2396
 
 
2397
        easeInStrong: function (t, b, c, d) {
 
2398
            return c * (t /= d) * t * t * t + b;
 
2399
        },
 
2400
 
 
2401
 
 
2402
        easeOutStrong: function (t, b, c, d) {
 
2403
            return -c * ((t = t / d - 1) * t * t * t - 1) + b;
 
2404
        },
 
2405
 
 
2406
 
 
2407
        easeBothStrong: function (t, b, c, d) {
 
2408
            if ((t /= d / 2) < 1) {
 
2409
                return c / 2 * t * t * t * t + b;
 
2410
            }
 
2411
 
 
2412
            return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
 
2413
        },
 
2414
 
 
2415
 
 
2416
 
 
2417
        elasticIn: function (t, b, c, d, a, p) {
 
2418
            if (t == 0) {
 
2419
                return b;
 
2420
            }
 
2421
            if ((t /= d) == 1) {
 
2422
                return b + c;
 
2423
            }
 
2424
            if (!p) {
 
2425
                p = d * .3;
 
2426
            }
 
2427
 
 
2428
            if (!a || a < Math.abs(c)) {
 
2429
                a = c;
 
2430
                var s = p / 4;
 
2431
            }
 
2432
            else {
 
2433
                var s = p / (2 * Math.PI) * Math.asin(c / a);
 
2434
            }
 
2435
 
 
2436
            return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
 
2437
        },
 
2438
 
 
2439
 
 
2440
        elasticOut: function (t, b, c, d, a, p) {
 
2441
            if (t == 0) {
 
2442
                return b;
 
2443
            }
 
2444
            if ((t /= d) == 1) {
 
2445
                return b + c;
 
2446
            }
 
2447
            if (!p) {
 
2448
                p = d * .3;
 
2449
            }
 
2450
 
 
2451
            if (!a || a < Math.abs(c)) {
 
2452
                a = c;
 
2453
                var s = p / 4;
 
2454
            }
 
2455
            else {
 
2456
                var s = p / (2 * Math.PI) * Math.asin(c / a);
 
2457
            }
 
2458
 
 
2459
            return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
 
2460
        },
 
2461
 
 
2462
 
 
2463
        elasticBoth: function (t, b, c, d, a, p) {
 
2464
            if (t == 0) {
 
2465
                return b;
 
2466
            }
 
2467
 
 
2468
            if ((t /= d / 2) == 2) {
 
2469
                return b + c;
 
2470
            }
 
2471
 
 
2472
            if (!p) {
 
2473
                p = d * (.3 * 1.5);
 
2474
            }
 
2475
 
 
2476
            if (!a || a < Math.abs(c)) {
 
2477
                a = c;
 
2478
                var s = p / 4;
 
2479
            }
 
2480
            else {
 
2481
                var s = p / (2 * Math.PI) * Math.asin(c / a);
 
2482
            }
 
2483
 
 
2484
            if (t < 1) {
 
2485
                return -.5 * (a * Math.pow(2, 10 * (t -= 1)) *
 
2486
                              Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
 
2487
            }
 
2488
            return a * Math.pow(2, -10 * (t -= 1)) *
 
2489
                   Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
 
2490
        },
 
2491
 
 
2492
 
 
2493
 
 
2494
        backIn: function (t, b, c, d, s) {
 
2495
            if (typeof s == 'undefined') {
 
2496
                s = 1.70158;
 
2497
            }
 
2498
            return c * (t /= d) * t * ((s + 1) * t - s) + b;
 
2499
        },
 
2500
 
 
2501
 
 
2502
        backOut: function (t, b, c, d, s) {
 
2503
            if (typeof s == 'undefined') {
 
2504
                s = 1.70158;
 
2505
            }
 
2506
            return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
 
2507
        },
 
2508
 
 
2509
 
 
2510
        backBoth: function (t, b, c, d, s) {
 
2511
            if (typeof s == 'undefined') {
 
2512
                s = 1.70158;
 
2513
            }
 
2514
 
 
2515
            if ((t /= d / 2 ) < 1) {
 
2516
                return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
 
2517
            }
 
2518
            return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
 
2519
        },
 
2520
 
 
2521
 
 
2522
        bounceIn: function (t, b, c, d) {
 
2523
            return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b;
 
2524
        },
 
2525
 
 
2526
 
 
2527
        bounceOut: function (t, b, c, d) {
 
2528
            if ((t /= d) < (1 / 2.75)) {
 
2529
                return c * (7.5625 * t * t) + b;
 
2530
            } else if (t < (2 / 2.75)) {
 
2531
                return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
 
2532
            } else if (t < (2.5 / 2.75)) {
 
2533
                return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
 
2534
            }
 
2535
            return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
 
2536
        },
 
2537
 
 
2538
 
 
2539
        bounceBoth: function (t, b, c, d) {
 
2540
            if (t < d / 2) {
 
2541
                return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
 
2542
            }
 
2543
            return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
 
2544
        }
 
2545
    };
 
2546
 
 
2547
    (function() {
 
2548
        Ext.lib.Motion = function(el, attributes, duration, method) {
 
2549
            if (el) {
 
2550
                Ext.lib.Motion.superclass.constructor.call(this, el, attributes, duration, method);
 
2551
            }
 
2552
        };
 
2553
 
 
2554
        Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim);
 
2555
 
 
2556
 
 
2557
        var Y = Ext.lib;
 
2558
        var superclass = Y.Motion.superclass;
 
2559
        var proto = Y.Motion.prototype;
 
2560
 
 
2561
        proto.toString = function() {
 
2562
            var el = this.getEl();
 
2563
            var id = el.id || el.tagName;
 
2564
            return ("Motion " + id);
 
2565
        };
 
2566
 
 
2567
        proto.patterns.points = /^points$/i;
 
2568
 
 
2569
        proto.setAttribute = function(attr, val, unit) {
 
2570
            if (this.patterns.points.test(attr)) {
 
2571
                unit = unit || 'px';
 
2572
                superclass.setAttribute.call(this, 'left', val[0], unit);
 
2573
                superclass.setAttribute.call(this, 'top', val[1], unit);
 
2574
            } else {
 
2575
                superclass.setAttribute.call(this, attr, val, unit);
 
2576
            }
 
2577
        };
 
2578
 
 
2579
        proto.getAttribute = function(attr) {
 
2580
            if (this.patterns.points.test(attr)) {
 
2581
                var val = [
 
2582
                        superclass.getAttribute.call(this, 'left'),
 
2583
                        superclass.getAttribute.call(this, 'top')
 
2584
                        ];
 
2585
            } else {
 
2586
                val = superclass.getAttribute.call(this, attr);
 
2587
            }
 
2588
 
 
2589
            return val;
 
2590
        };
 
2591
 
 
2592
        proto.doMethod = function(attr, start, end) {
 
2593
            var val = null;
 
2594
 
 
2595
            if (this.patterns.points.test(attr)) {
 
2596
                var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
 
2597
                val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
 
2598
            } else {
 
2599
                val = superclass.doMethod.call(this, attr, start, end);
 
2600
            }
 
2601
            return val;
 
2602
        };
 
2603
 
 
2604
        proto.setRuntimeAttribute = function(attr) {
 
2605
            if (this.patterns.points.test(attr)) {
 
2606
                var el = this.getEl();
 
2607
                var attributes = this.attributes;
 
2608
                var start;
 
2609
                var control = attributes['points']['control'] || [];
 
2610
                var end;
 
2611
                var i, len;
 
2612
 
 
2613
                if (control.length > 0 && !Ext.isArray(control[0])) {
 
2614
                    control = [control];
 
2615
                } else {
 
2616
                    var tmp = [];
 
2617
                    for (i = 0,len = control.length; i < len; ++i) {
 
2618
                        tmp[i] = control[i];
 
2619
                    }
 
2620
                    control = tmp;
 
2621
                }
 
2622
 
 
2623
                Ext.fly(el).position();
 
2624
 
 
2625
                if (isset(attributes['points']['from'])) {
 
2626
                    Ext.lib.Dom.setXY(el, attributes['points']['from']);
 
2627
                }
 
2628
                else {
 
2629
                    Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el));
 
2630
                }
 
2631
 
 
2632
                start = this.getAttribute('points');
 
2633
 
 
2634
 
 
2635
                if (isset(attributes['points']['to'])) {
 
2636
                    end = translateValues.call(this, attributes['points']['to'], start);
 
2637
 
 
2638
                    var pageXY = Ext.lib.Dom.getXY(this.getEl());
 
2639
                    for (i = 0,len = control.length; i < len; ++i) {
 
2640
                        control[i] = translateValues.call(this, control[i], start);
 
2641
                    }
 
2642
 
 
2643
 
 
2644
                } else if (isset(attributes['points']['by'])) {
 
2645
                    end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
 
2646
 
 
2647
                    for (i = 0,len = control.length; i < len; ++i) {
 
2648
                        control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
 
2649
                    }
 
2650
                }
 
2651
 
 
2652
                this.runtimeAttributes[attr] = [start];
 
2653
 
 
2654
                if (control.length > 0) {
 
2655
                    this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
 
2656
                }
 
2657
 
 
2658
                this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
 
2659
            }
 
2660
            else {
 
2661
                superclass.setRuntimeAttribute.call(this, attr);
 
2662
            }
 
2663
        };
 
2664
 
 
2665
        var translateValues = function(val, start) {
 
2666
            var pageXY = Ext.lib.Dom.getXY(this.getEl());
 
2667
            val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
 
2668
 
 
2669
            return val;
 
2670
        };
 
2671
 
 
2672
        var isset = function(prop) {
 
2673
            return (typeof prop !== 'undefined');
 
2674
        };
 
2675
    })();
 
2676
 
 
2677
 
 
2678
    (function() {
 
2679
        Ext.lib.Scroll = function(el, attributes, duration, method) {
 
2680
            if (el) {
 
2681
                Ext.lib.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
 
2682
            }
 
2683
        };
 
2684
 
 
2685
        Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim);
 
2686
 
 
2687
 
 
2688
        var Y = Ext.lib;
 
2689
        var superclass = Y.Scroll.superclass;
 
2690
        var proto = Y.Scroll.prototype;
 
2691
 
 
2692
        proto.toString = function() {
 
2693
            var el = this.getEl();
 
2694
            var id = el.id || el.tagName;
 
2695
            return ("Scroll " + id);
 
2696
        };
 
2697
 
 
2698
        proto.doMethod = function(attr, start, end) {
 
2699
            var val = null;
 
2700
 
 
2701
            if (attr == 'scroll') {
 
2702
                val = [
 
2703
                        this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
 
2704
                        this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
 
2705
                        ];
 
2706
 
 
2707
            } else {
 
2708
                val = superclass.doMethod.call(this, attr, start, end);
 
2709
            }
 
2710
            return val;
 
2711
        };
 
2712
 
 
2713
        proto.getAttribute = function(attr) {
 
2714
            var val = null;
 
2715
            var el = this.getEl();
 
2716
 
 
2717
            if (attr == 'scroll') {
 
2718
                val = [ el.scrollLeft, el.scrollTop ];
 
2719
            } else {
 
2720
                val = superclass.getAttribute.call(this, attr);
 
2721
            }
 
2722
 
 
2723
            return val;
 
2724
        };
 
2725
 
 
2726
        proto.setAttribute = function(attr, val, unit) {
 
2727
            var el = this.getEl();
 
2728
 
 
2729
            if (attr == 'scroll') {
 
2730
                el.scrollLeft = val[0];
 
2731
                el.scrollTop = val[1];
 
2732
            } else {
 
2733
                superclass.setAttribute.call(this, attr, val, unit);
 
2734
            }
 
2735
        };
 
2736
    })();
 
2737
 
 
2738
 
 
2739
})();