sync
[roojs1] / roojs-core.js
1
2
3  
4
5
6
7
8
9 window["undefined"] = window["undefined"];
10
11
12
13 var  Roo = {}; 
14
15
16
17  
18 Roo.apply = function(o, c, A){
19     if(A){
20         
21         Roo.apply(o, A);
22     }
23     if(o && c && typeof  c == 'object'){
24         for(var  p  in  c){
25             o[p] = c[p];
26         }
27     }
28     return  o;
29 };
30
31
32 (function(){
33     var  B = 0;
34     var  ua = navigator.userAgent.toLowerCase();
35
36     var  C = document.compatMode == "CSS1Compat",
37         D = ua.indexOf("opera") > -1,
38         E = (/webkit|khtml/).test(ua),
39         F = ua.indexOf("msie") > -1,
40         G = ua.indexOf("msie 7") > -1,
41         H = !E && ua.indexOf("gecko") > -1,
42         I = F && !C,
43         J = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
44         K = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
45         L = (ua.indexOf("linux") != -1),
46         M = window.location.href.toLowerCase().indexOf("https") === 0;
47
48     
49         if(F && !G){
50         try{
51             document.execCommand("BackgroundImageCache", false, true);
52         }catch(e){}
53     }
54
55
56     Roo.apply(Roo, {
57         
58
59         isStrict : C,
60         
61
62         isSecure : M,
63         
64
65         isReady : false,
66         
67
68         
69         debug: false,
70
71         
72
73         enableGarbageCollector : true,
74
75         
76
77         enableListenerCollection:false,
78
79         
80
81         SSL_SECURE_URL : "javascript:false",
82
83         
84
85         BLANK_IMAGE_URL : "http:/"+"/localhost/s.gif",
86
87         emptyFn : function(){},
88
89         
90
91         applyIf : function(o, c){
92             if(o && c){
93                 for(var  p  in  c){
94                     if(typeof  o[p] == "undefined"){ o[p] = c[p]; }
95                 }
96             }
97             return  o;
98         },
99
100         
101
102         addBehaviors : function(o){
103             if(!Roo.isReady){
104                 Roo.onReady(function(){
105                     Roo.addBehaviors(o);
106                 });
107                 return;
108             }
109             var  N = {}; 
110             for(var  b  in  o){
111                 var  parts = b.split('@');
112                 if(parts[1]){ 
113                     var  s = parts[0];
114                     if(!N[s]){
115                         N[s] = Roo.select(s);
116                     }
117
118                     N[s].on(parts[1], o[b]);
119                 }
120             }
121
122             N = null;
123         },
124
125         
126
127         id : function(el, O){
128             O = O || "roo-gen";
129             el = Roo.getDom(el);
130             var  id = O + (++B);
131             return  el ? (el.id ? el.id : (el.id = id)) : id;
132         },
133          
134        
135         
136
137         extend : function(){
138             
139             var  io = function(o){
140                 for(var  m  in  o){
141                     this[m] = o[m];
142                 }
143             };
144             return  function(sb, sp, P){
145                 if(typeof  sp == 'object'){ 
146                     P = sp;
147                     sp = sb;
148                     sb = function(){sp.apply(this, arguments);};
149                 }
150                 var  F = function(){}, sbp, spp = sp.prototype;
151                 F.prototype = spp;
152                 sbp = sb.prototype = new  F();
153                 sbp.constructor=sb;
154                 sb.superclass=spp;
155                 
156                 if(spp.constructor == Object.prototype.constructor){
157                     spp.constructor=sp;
158                    
159                 }
160
161                 
162                 sb.override = function(o){
163                     Roo.override(sb, o);
164                 };
165                 sbp.override = io;
166                 Roo.override(sb, P);
167                 return  sb;
168             };
169         }(),
170
171         
172
173         override : function(P, Q){
174             if(Q){
175                 var  p = P.prototype;
176                 for(var  method  in  Q){
177                     p[method] = Q[method];
178                 }
179             }
180         },
181         
182
183         namespace : function(){
184             var  a=arguments, o=null, i, j, d, rt;
185             for (i=0; i<a.length; ++i) {
186                 d=a[i].split(".");
187                 rt = d[0];
188                 
189
190                 eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
191                 for (j=1; j<d.length; ++j) {
192                     o[d[j]]=o[d[j]] || {};
193                     o=o[d[j]];
194                 }
195             }
196         },
197         
198
199          
200         factory : function(c, ns)
201         {
202             
203             if (!c.xtype   || (!ns && !c.xns) ||  (c.xns === false)) { 
204                 return  c;
205             }
206
207             ns = c.xns ? c.xns : ns; 
208             if (c.constructor == ns[c.xtype]) {
209                 return  c;
210             }
211             if (ns[c.xtype]) {
212                 if (Roo.debug) Roo.log("Roo.Factory(" + c.xtype + ")");
213                 var  ret = new  ns[c.xtype](c);
214                 ret.xns = false;
215                 return  ret;
216             }
217
218             c.xns = false; 
219             return  c;
220         },
221          
222
223         log : function(s)
224         {
225             if ((typeof(console) == 'undefined') || (typeof(console.log) == 'undefined')) {
226                 return; 
227             }
228
229             console.log(s);
230             
231         },
232         
233
234         urlEncode : function(o){
235             if(!o){
236                 return  "";
237             }
238             var  R = [];
239             for(var  key  in  o){
240                 var  ov = o[key], k = encodeURIComponent(key);
241                 var  type = typeof  ov;
242                 if(type == 'undefined'){
243                     R.push(k, "=&");
244                 }else  if(type != "function" && type != "object"){
245                     R.push(k, "=", encodeURIComponent(ov), "&");
246                 }else  if(ov  instanceof  Array){
247                     if (ov.length) {
248                             for(var  i = 0, len = ov.length; i < len; i++) {
249                                 R.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
250                             }
251                         } else  {
252                             R.push(k, "=&");
253                         }
254                 }
255             }
256
257             R.pop();
258             return  R.join("");
259         },
260
261         
262
263         urlDecode : function(S, T){
264             if(!S || !S.length){
265                 return  {};
266             }
267             var  U = {};
268             var  V = S.split('&');
269             var  W, X, Y;
270             for(var  i = 0, len = V.length; i < len; i++){
271                 W = V[i].split('=');
272                 X = decodeURIComponent(W[0]);
273                 Y = decodeURIComponent(W[1]);
274                 if(T !== true){
275                     if(typeof  U[X] == "undefined"){
276                         U[X] = Y;
277                     }else  if(typeof  U[X] == "string"){
278                         U[X] = [U[X]];
279                         U[X].push(Y);
280                     }else {
281                         U[X].push(Y);
282                     }
283                 }else {
284                     U[X] = Y;
285                 }
286             }
287             return  U;
288         },
289
290         
291
292         each : function(Z, fn, f){
293             if(typeof  Z.length == "undefined" || typeof  Z == "string"){
294                 Z = [Z];
295             }
296             for(var  i = 0, len = Z.length; i < len; i++){
297                 if(fn.call(f || Z[i], Z[i], i, Z) === false){ return  i; };
298             }
299         },
300
301         
302         combine : function(){
303             var  as = arguments, l = as.length, r = [];
304             for(var  i = 0; i < l; i++){
305                 var  a = as[i];
306                 if(a  instanceof  Array){
307                     r = r.concat(a);
308                 }else  if(a.length !== undefined && !a.substr){
309                     r = r.concat(Array.prototype.slice.call(a, 0));
310                 }else {
311                     r.push(a);
312                 }
313             }
314             return  r;
315         },
316
317         
318
319         escapeRe : function(s) {
320             return  s.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1");
321         },
322
323         
324         callback : function(cb, g, h, n){
325             if(typeof  cb == "function"){
326                 if(n){
327                     cb.defer(n, g, h || []);
328                 }else {
329                     cb.apply(g, h || []);
330                 }
331             }
332         },
333
334         
335
336         getDom : function(el){
337             if(!el){
338                 return  null;
339             }
340             return  el.dom ? el.dom : (typeof  el == 'string' ? document.getElementById(el) : el);
341         },
342
343         
344
345         getCmp : function(id){
346             return  Roo.ComponentMgr.get(id);
347         },
348          
349         num : function(v, q){
350             if(typeof  v != 'number'){
351                 return  q;
352             }
353             return  v;
354         },
355
356         destroy : function(){
357             for(var  i = 0, a = arguments, len = a.length; i < len; i++) {
358                 var  as = a[i];
359                 if(as){
360                     if(as.dom){
361                         as.removeAllListeners();
362                         as.remove();
363                         continue;
364                     }
365                     if(typeof  as.purgeListeners == 'function'){
366                         as.purgeListeners();
367                     }
368                     if(typeof  as.destroy == 'function'){
369                         as.destroy();
370                     }
371                 }
372             }
373         },
374
375         
376         
377
378         type : function(o){
379             if(o === undefined || o === null){
380                 return  false;
381             }
382             if(o.htmlElement){
383                 return  'element';
384             }
385             var  t = typeof  o;
386             if(t == 'object' && o.nodeName) {
387                 switch(o.nodeType) {
388                     case  1: return  'element';
389                     case  3: return  (/\S/).test(o.nodeValue) ? 'textnode' : 'whitespace';
390                 }
391             }
392             if(t == 'object' || t == 'function') {
393                 switch(o.constructor) {
394                     case  Array: return  'array';
395                     case  RegExp: return  'regexp';
396                 }
397                 if(typeof  o.length == 'number' && typeof  o.item == 'function') {
398                     return  'nodelist';
399                 }
400             }
401             return  t;
402         },
403
404         
405
406         isEmpty : function(v, u){
407             return  v === null || v === undefined || (!u ? v === '' : false);
408         },
409         
410         
411
412         isOpera : D,
413         
414
415         isSafari : E,
416         
417
418         isIE : F,
419         
420
421         isIE7 : G,
422         
423
424         isGecko : H,
425         
426
427         isBorderBox : I,
428         
429
430         isWindows : J,
431         
432
433         isLinux : L,
434         
435
436         isMac : K,
437
438         
439
440         useShims : ((F && !G) || (H && K))
441     });
442
443
444 })();
445
446 Roo.namespace("Roo", "Roo.util", "Roo.grid", "Roo.dd", "Roo.tree", "Roo.data",
447                 "Roo.form", "Roo.menu", "Roo.state", "Roo.lib", "Roo.layout", "Roo.app", "Roo.ux");
448
449
450
451
452 (function() {    
453     
454     if(Roo.isIE) {
455         function  A() {
456             var  p = Function.prototype;
457             delete  p.createSequence;
458             delete  p.defer;
459             delete  p.createDelegate;
460             delete  p.createCallback;
461             delete  p.createInterceptor;
462
463             window.detachEvent("onunload", A);
464         }
465
466         window.attachEvent("onunload", A);
467     }
468 })();
469
470
471
472
473 Roo.apply(Function.prototype, {
474      
475
476     createCallback : function(
477 ){
478         
479         var  B = arguments;
480         var  C = this;
481         return  function() {
482             return  C.apply(window, B);
483         };
484     },
485
486     
487
488     createDelegate : function(D, E, F){
489         var  G = this;
490         return  function() {
491             var  H = E || arguments;
492             if(F === true){
493                 H = Array.prototype.slice.call(arguments, 0);
494                 H = H.concat(E);
495             }else  if(typeof  F == "number"){
496                 H = Array.prototype.slice.call(arguments, 0); 
497                 var  applyArgs = [F, 0].concat(E); 
498                 Array.prototype.splice.apply(H, applyArgs); 
499             }
500             return  G.apply(D || window, H);
501         };
502     },
503
504     
505
506     defer : function(H, I, J, K){
507         var  fn = this.createDelegate(I, J, K);
508         if(H){
509             return  setTimeout(fn, H);
510         }
511
512         fn();
513         return  0;
514     },
515     
516
517     createSequence : function(L, M){
518         if(typeof  L != "function"){
519             return  this;
520         }
521         var  N = this;
522         return  function() {
523             var  O = N.apply(this || window, arguments);
524             L.apply(M || this || window, arguments);
525             return  O;
526         };
527     },
528
529     
530
531     createInterceptor : function(O, P){
532         if(typeof  O != "function"){
533             return  this;
534         }
535         var  Q = this;
536         return  function() {
537             O.target = this;
538             O.method = Q;
539             if(O.apply(P || this || window, arguments) === false){
540                 return;
541             }
542             return  Q.apply(this || window, arguments);
543         };
544     }
545 });
546
547
548
549
550 Roo.applyIf(String, {
551     
552     
553
554     
555     
556
557     escape : function(A) {
558         return  A.replace(/('|\\)/g, "\\$1");
559     },
560
561     
562
563     leftPad : function (B, C, ch) {
564         var  D = new  String(B);
565         if(ch === null || ch === undefined || ch === '') {
566             ch = " ";
567         }
568         while (D.length < C) {
569             D = ch + D;
570         }
571         return  D;
572     },
573
574     
575
576     format : function(E){
577         var  F = Array.prototype.slice.call(arguments, 1);
578         return  E.replace(/\{(\d+)\}/g, function(m, i){
579             return  Roo.util.Format.htmlEncode(F[i]);
580         });
581     }
582 });
583
584
585
586  
587 String.prototype.toggle = function(G, H){
588     return  this == G ? H : G;
589 };
590
591
592
593  
594
595 Roo.applyIf(Number.prototype, {
596     
597
598     constrain : function(A, B){
599         return  Math.min(Math.max(this, A), B);
600     }
601 });
602
603
604  
605
606 Roo.applyIf(Array.prototype, {
607     
608
609     indexOf : function(o){
610        for (var  i = 0, len = this.length; i < len; i++){
611               if(this[i] == o) return  i;
612        }
613            return  -1;
614     },
615
616     
617
618     remove : function(o){
619        var  A = this.indexOf(o);
620        if(A != -1){
621            this.splice(A, 1);
622        }
623     },
624     
625
626     map : function(B )
627     {
628         var  C = this.length >>> 0;
629         if (typeof  B != "function")
630             throw  new  TypeError();
631
632         var  D = new  Array(C);
633         var  E = arguments[1];
634         for (var  i = 0; i < C; i++)
635         {
636             if (i  in  this)
637                 D[i] = B.call(E, this[i], i, this);
638         }
639
640         return  D;
641     }
642     
643 });
644
645
646  
647
648
649
650
651
652
653
654
655  
656  
657  
658
659
660 Date.prototype.getElapsed = function(A) {
661         return  Math.abs((A || new  Date()).getTime()-this.getTime());
662 };
663
664
665
666
667 Date.parseFunctions = {count:0};
668
669 Date.parseRegexes = [];
670
671 Date.formatFunctions = {count:0};
672
673
674 Date.prototype.dateFormat = function(B) {
675     if (Date.formatFunctions[B] == null) {
676         Date.createNewFormat(B);
677     }
678     var  C = Date.formatFunctions[B];
679     return  this[C]();
680 };
681
682
683
684
685 Date.prototype.format = Date.prototype.dateFormat;
686
687
688 Date.createNewFormat = function(D) {
689     var  E = "format" + Date.formatFunctions.count++;
690     Date.formatFunctions[D] = E;
691     var  F = "Date.prototype." + E + " = function(){return ";
692     var  G = false;
693     var  ch = '';
694     for (var  i = 0; i < D.length; ++i) {
695         ch = D.charAt(i);
696         if (!G && ch == "\\") {
697             G = true;
698         }
699         else  if (G) {
700             G = false;
701             F += "'" + String.escape(ch) + "' + ";
702         }
703         else  {
704             F += Date.getFormatCode(ch);
705         }
706     }
707     
708
709     eval(F.substring(0, F.length - 3) + ";}");
710 };
711
712
713 Date.getFormatCode = function(H) {
714     switch (H) {
715     case  "d":
716         return  "String.leftPad(this.getDate(), 2, '0') + ";
717     case  "D":
718         return  "Date.dayNames[this.getDay()].substring(0, 3) + ";
719     case  "j":
720         return  "this.getDate() + ";
721     case  "l":
722         return  "Date.dayNames[this.getDay()] + ";
723     case  "S":
724         return  "this.getSuffix() + ";
725     case  "w":
726         return  "this.getDay() + ";
727     case  "z":
728         return  "this.getDayOfYear() + ";
729     case  "W":
730         return  "this.getWeekOfYear() + ";
731     case  "F":
732         return  "Date.monthNames[this.getMonth()] + ";
733     case  "m":
734         return  "String.leftPad(this.getMonth() + 1, 2, '0') + ";
735     case  "M":
736         return  "Date.monthNames[this.getMonth()].substring(0, 3) + ";
737     case  "n":
738         return  "(this.getMonth() + 1) + ";
739     case  "t":
740         return  "this.getDaysInMonth() + ";
741     case  "L":
742         return  "(this.isLeapYear() ? 1 : 0) + ";
743     case  "Y":
744         return  "this.getFullYear() + ";
745     case  "y":
746         return  "('' + this.getFullYear()).substring(2, 4) + ";
747     case  "a":
748         return  "(this.getHours() < 12 ? 'am' : 'pm') + ";
749     case  "A":
750         return  "(this.getHours() < 12 ? 'AM' : 'PM') + ";
751     case  "g":
752         return  "((this.getHours() % 12) ? this.getHours() % 12 : 12) + ";
753     case  "G":
754         return  "this.getHours() + ";
755     case  "h":
756         return  "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0') + ";
757     case  "H":
758         return  "String.leftPad(this.getHours(), 2, '0') + ";
759     case  "i":
760         return  "String.leftPad(this.getMinutes(), 2, '0') + ";
761     case  "s":
762         return  "String.leftPad(this.getSeconds(), 2, '0') + ";
763     case  "O":
764         return  "this.getGMTOffset() + ";
765     case  "T":
766         return  "this.getTimezone() + ";
767     case  "Z":
768         return  "(this.getTimezoneOffset() * -60) + ";
769     default:
770         return  "'" + String.escape(H) + "' + ";
771     }
772 };
773
774
775
776 Date.parseDate = function(I, J) {
777     if (Date.parseFunctions[J] == null) {
778         Date.createParser(J);
779     }
780     var  K = Date.parseFunctions[J];
781     return  Date[K](I);
782 };
783
784
785 Date.createParser = function(L) {
786     var  M = "parse" + Date.parseFunctions.count++;
787     var  N = Date.parseRegexes.length;
788     var  O = 1;
789     Date.parseFunctions[L] = M;
790
791     var  P = "Date." + M + " = function(input){\n"
792         + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, o, z, v;\n"
793         + "var d = new Date();\n"
794         + "y = d.getFullYear();\n"
795         + "m = d.getMonth();\n"
796         + "d = d.getDate();\n"
797         + "var results = input.match(Date.parseRegexes[" + N + "]);\n"
798         + "if (results && results.length > 0) {";
799     var  Q = "";
800
801     var  R = false;
802     var  ch = '';
803     for (var  i = 0; i < L.length; ++i) {
804         ch = L.charAt(i);
805         if (!R && ch == "\\") {
806             R = true;
807         }
808         else  if (R) {
809             R = false;
810             Q += String.escape(ch);
811         }
812         else  {
813             var  obj = Date.formatCodeToRegex(ch, O);
814             O += obj.g;
815             Q += obj.s;
816             if (obj.g && obj.c) {
817                 P += obj.c;
818             }
819         }
820     }
821
822
823     P += "if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
824         + "{v = new Date(y, m, d, h, i, s);}\n"
825         + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
826         + "{v = new Date(y, m, d, h, i);}\n"
827         + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0)\n"
828         + "{v = new Date(y, m, d, h);}\n"
829         + "else if (y >= 0 && m >= 0 && d > 0)\n"
830         + "{v = new Date(y, m, d);}\n"
831         + "else if (y >= 0 && m >= 0)\n"
832         + "{v = new Date(y, m);}\n"
833         + "else if (y >= 0)\n"
834         + "{v = new Date(y);}\n"
835         + "}return (v && (z || o))?\n" 
836         + "    ((z)? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :\n" 
837         + "        v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : v\n" 
838         + ";}";
839
840     Date.parseRegexes[N] = new  RegExp("^" + Q + "$");
841     
842
843     eval(P);
844 };
845
846
847 Date.formatCodeToRegex = function(S, T) {
848     switch (S) {
849     case  "D":
850         return  {g:0,
851         c:null,
852         s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
853     case  "j":
854         return  {g:1,
855             c:"d = parseInt(results[" + T + "], 10);\n",
856             s:"(\\d{1,2})"}; 
857     case  "d":
858         return  {g:1,
859             c:"d = parseInt(results[" + T + "], 10);\n",
860             s:"(\\d{2})"}; 
861     case  "l":
862         return  {g:0,
863             c:null,
864             s:"(?:" + Date.dayNames.join("|") + ")"};
865     case  "S":
866         return  {g:0,
867             c:null,
868             s:"(?:st|nd|rd|th)"};
869     case  "w":
870         return  {g:0,
871             c:null,
872             s:"\\d"};
873     case  "z":
874         return  {g:0,
875             c:null,
876             s:"(?:\\d{1,3})"};
877     case  "W":
878         return  {g:0,
879             c:null,
880             s:"(?:\\d{2})"};
881     case  "F":
882         return  {g:1,
883             c:"m = parseInt(Date.monthNumbers[results[" + T + "].substring(0, 3)], 10);\n",
884             s:"(" + Date.monthNames.join("|") + ")"};
885     case  "M":
886         return  {g:1,
887             c:"m = parseInt(Date.monthNumbers[results[" + T + "]], 10);\n",
888             s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
889     case  "n":
890         return  {g:1,
891             c:"m = parseInt(results[" + T + "], 10) - 1;\n",
892             s:"(\\d{1,2})"}; 
893     case  "m":
894         return  {g:1,
895             c:"m = parseInt(results[" + T + "], 10) - 1;\n",
896             s:"(\\d{2})"}; 
897     case  "t":
898         return  {g:0,
899             c:null,
900             s:"\\d{1,2}"};
901     case  "L":
902         return  {g:0,
903             c:null,
904             s:"(?:1|0)"};
905     case  "Y":
906         return  {g:1,
907             c:"y = parseInt(results[" + T + "], 10);\n",
908             s:"(\\d{4})"};
909     case  "y":
910         return  {g:1,
911             c:"var ty = parseInt(results[" + T + "], 10);\n"
912                 + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
913             s:"(\\d{1,2})"};
914     case  "a":
915         return  {g:1,
916             c:"if (results[" + T + "] == 'am') {\n"
917                 + "if (h == 12) { h = 0; }\n"
918                 + "} else { if (h < 12) { h += 12; }}",
919             s:"(am|pm)"};
920     case  "A":
921         return  {g:1,
922             c:"if (results[" + T + "] == 'AM') {\n"
923                 + "if (h == 12) { h = 0; }\n"
924                 + "} else { if (h < 12) { h += 12; }}",
925             s:"(AM|PM)"};
926     case  "g":
927     case  "G":
928         return  {g:1,
929             c:"h = parseInt(results[" + T + "], 10);\n",
930             s:"(\\d{1,2})"}; 
931     case  "h":
932     case  "H":
933         return  {g:1,
934             c:"h = parseInt(results[" + T + "], 10);\n",
935             s:"(\\d{2})"}; 
936     case  "i":
937         return  {g:1,
938             c:"i = parseInt(results[" + T + "], 10);\n",
939             s:"(\\d{2})"};
940     case  "s":
941         return  {g:1,
942             c:"s = parseInt(results[" + T + "], 10);\n",
943             s:"(\\d{2})"};
944     case  "O":
945         return  {g:1,
946             c:[
947                 "o = results[", T, "];\n",
948                 "var sn = o.substring(0,1);\n", 
949                 "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);\n", 
950                 "var mn = o.substring(3,5) % 60;\n", 
951                 "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n", 
952                 "    (sn + String.leftPad(hr, 2, 0) + String.leftPad(mn, 2, 0)) : null;\n"
953             ].join(""),
954             s:"([+\-]\\d{4})"};
955     case  "T":
956         return  {g:0,
957             c:null,
958             s:"[A-Z]{1,4}"}; 
959     case  "Z":
960         return  {g:1,
961             c:"z = results[" + T + "];\n" 
962                   + "z = (-43200 <= z*1 && z*1 <= 50400)? z : null;\n",
963             s:"([+\-]?\\d{1,5})"}; 
964     default:
965         return  {g:0,
966             c:null,
967             s:String.escape(S)};
968     }
969 };
970
971
972
973 Date.prototype.getTimezone = function() {
974     return  this.toString().replace(/^.*? ([A-Z]{1,4})[\-+][0-9]{4} .*$/, "$1");
975 };
976
977
978
979 Date.prototype.getGMTOffset = function() {
980     return  (this.getTimezoneOffset() > 0 ? "-" : "+")
981         + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0")
982         + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
983 };
984
985
986
987 Date.prototype.getDayOfYear = function() {
988     var  U = 0;
989     Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
990     for (var  i = 0; i < this.getMonth(); ++i) {
991         U += Date.daysInMonth[i];
992     }
993     return  U + this.getDate() - 1;
994 };
995
996
997
998 Date.prototype.getWeekOfYear = function() {
999     
1000     var  V = this.getDayOfYear() + (4 - this.getDay());
1001     
1002     var  W = new  Date(this.getFullYear(), 0, 1);
1003     var  X = (7 - W.getDay() + 4);
1004     return  String.leftPad(((V - X) / 7) + 1, 2, "0");
1005 };
1006
1007
1008
1009 Date.prototype.isLeapYear = function() {
1010     var  Y = this.getFullYear();
1011     return  ((Y & 3) == 0 && (Y % 100 || (Y % 400 == 0 && Y)));
1012 };
1013
1014
1015
1016 Date.prototype.getFirstDayOfMonth = function() {
1017     var  Z = (this.getDay() - (this.getDate() - 1)) % 7;
1018     return  (Z < 0) ? (Z + 7) : Z;
1019 };
1020
1021
1022
1023 Date.prototype.getLastDayOfMonth = function() {
1024     var  a = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
1025     return  (a < 0) ? (a + 7) : a;
1026 };
1027
1028
1029
1030
1031 Date.prototype.getFirstDateOfMonth = function() {
1032     return  new  Date(this.getFullYear(), this.getMonth(), 1);
1033 };
1034
1035
1036
1037 Date.prototype.getLastDateOfMonth = function() {
1038     return  new  Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
1039 };
1040
1041
1042 Date.prototype.getDaysInMonth = function() {
1043     Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
1044     return  Date.daysInMonth[this.getMonth()];
1045 };
1046
1047
1048
1049 Date.prototype.getSuffix = function() {
1050     switch (this.getDate()) {
1051         case  1:
1052         case  21:
1053         case  31:
1054             return  "st";
1055         case  2:
1056         case  22:
1057             return  "nd";
1058         case  3:
1059         case  23:
1060             return  "rd";
1061         default:
1062             return  "th";
1063     }
1064 };
1065
1066
1067 Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
1068
1069
1070
1071 Date.monthNames =
1072    ["January",
1073     "February",
1074     "March",
1075     "April",
1076     "May",
1077     "June",
1078     "July",
1079     "August",
1080     "September",
1081     "October",
1082     "November",
1083     "December"];
1084
1085
1086
1087 Date.dayNames =
1088    ["Sunday",
1089     "Monday",
1090     "Tuesday",
1091     "Wednesday",
1092     "Thursday",
1093     "Friday",
1094     "Saturday"];
1095
1096
1097 Date.y2kYear = 50;
1098
1099 Date.monthNumbers = {
1100     Jan:0,
1101     Feb:1,
1102     Mar:2,
1103     Apr:3,
1104     May:4,
1105     Jun:5,
1106     Jul:6,
1107     Aug:7,
1108     Sep:8,
1109     Oct:9,
1110     Nov:10,
1111     Dec:11};
1112
1113
1114
1115 Date.prototype.clone = function() {
1116         return  new  Date(this.getTime());
1117 };
1118
1119
1120
1121 Date.prototype.clearTime = function(b){
1122     if(b){
1123         return  this.clone().clearTime();
1124     }
1125
1126     this.setHours(0);
1127     this.setMinutes(0);
1128     this.setSeconds(0);
1129     this.setMilliseconds(0);
1130     return  this;
1131 };
1132
1133
1134
1135 if(Roo.isSafari){
1136     Date.brokenSetMonth = Date.prototype.setMonth;
1137         Date.prototype.setMonth = function(c){
1138                 if(c <= -1){
1139                         var  n = Math.ceil(-c);
1140                         var  back_year = Math.ceil(n/12);
1141                         var  month = (n % 12) ? 12 - n % 12 : 0 ;
1142                         this.setFullYear(this.getFullYear() - back_year);
1143                         return  Date.brokenSetMonth.call(this, month);
1144                 } else  {
1145                         return  Date.brokenSetMonth.apply(this, arguments);
1146                 }
1147         };
1148 }
1149
1150
1151
1152
1153 Date.MILLI = "ms";
1154
1155
1156 Date.SECOND = "s";
1157
1158
1159 Date.MINUTE = "mi";
1160
1161
1162 Date.HOUR = "h";
1163
1164
1165 Date.DAY = "d";
1166
1167
1168 Date.MONTH = "mo";
1169
1170
1171 Date.YEAR = "y";
1172
1173
1174
1175 Date.prototype.add = function(e, f){
1176   var  d = this.clone();
1177   if (!e || f === 0) return  d;
1178   switch(e.toLowerCase()){
1179     case  Date.MILLI:
1180       d.setMilliseconds(this.getMilliseconds() + f);
1181       break;
1182     case  Date.SECOND:
1183       d.setSeconds(this.getSeconds() + f);
1184       break;
1185     case  Date.MINUTE:
1186       d.setMinutes(this.getMinutes() + f);
1187       break;
1188     case  Date.HOUR:
1189       d.setHours(this.getHours() + f);
1190       break;
1191     case  Date.DAY:
1192       d.setDate(this.getDate() + f);
1193       break;
1194     case  Date.MONTH:
1195       var  a = this.getDate();
1196       if(a > 28){
1197           a = Math.min(a, this.getFirstDateOfMonth().add('mo', f).getLastDateOfMonth().getDate());
1198       }
1199
1200       d.setDate(a);
1201       d.setMonth(this.getMonth() + f);
1202       break;
1203     case  Date.YEAR:
1204       d.setFullYear(this.getFullYear() + f);
1205       break;
1206   }
1207   return  d;
1208 };
1209
1210
1211
1212 Roo.lib.Dom = {
1213     getViewWidth : function(A) {
1214         return  A ? this.getDocumentWidth() : this.getViewportWidth();
1215     },
1216
1217     getViewHeight : function(B) {
1218         return  B ? this.getDocumentHeight() : this.getViewportHeight();
1219     },
1220
1221     getDocumentHeight: function() {
1222         var  C = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight;
1223         return  Math.max(C, this.getViewportHeight());
1224     },
1225
1226     getDocumentWidth: function() {
1227         var  D = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth;
1228         return  Math.max(D, this.getViewportWidth());
1229     },
1230
1231     getViewportHeight: function() {
1232         var  E = self.innerHeight;
1233         var  F = document.compatMode;
1234
1235         if ((F || Roo.isIE) && !Roo.isOpera) {
1236             E = (F == "CSS1Compat") ?
1237                      document.documentElement.clientHeight :
1238                      document.body.clientHeight;
1239         }
1240
1241         return  E;
1242     },
1243
1244     getViewportWidth: function() {
1245         var  G = self.innerWidth;
1246         var  H = document.compatMode;
1247
1248         if (H || Roo.isIE) {
1249             G = (H == "CSS1Compat") ?
1250                     document.documentElement.clientWidth :
1251                     document.body.clientWidth;
1252         }
1253         return  G;
1254     },
1255
1256     isAncestor : function(p, c) {
1257         p = Roo.getDom(p);
1258         c = Roo.getDom(c);
1259         if (!p || !c) {
1260             return  false;
1261         }
1262
1263         if (p.contains && !Roo.isSafari) {
1264             return  p.contains(c);
1265         } else  if (p.compareDocumentPosition) {
1266             return  !!(p.compareDocumentPosition(c) & 16);
1267         } else  {
1268             var  parent = c.parentNode;
1269             while (parent) {
1270                 if (parent == p) {
1271                     return  true;
1272                 }
1273                 else  if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") {
1274                     return  false;
1275                 }
1276
1277                 parent = parent.parentNode;
1278             }
1279             return  false;
1280         }
1281     },
1282
1283     getRegion : function(el) {
1284         return  Roo.lib.Region.getRegion(el);
1285     },
1286
1287     getY : function(el) {
1288         return  this.getXY(el)[1];
1289     },
1290
1291     getX : function(el) {
1292         return  this.getXY(el)[0];
1293     },
1294
1295     getXY : function(el) {
1296         var  p, pe, b, I, bd = document.body;
1297         el = Roo.getDom(el);
1298         var  J = Roo.lib.AnimBase.fly;
1299         if (el.getBoundingClientRect) {
1300             b = el.getBoundingClientRect();
1301             I = J(document).getScroll();
1302             return  [b.left + I.left, b.top + I.top];
1303         }
1304         var  x = 0, y = 0;
1305
1306         p = el;
1307
1308         var  K = J(el).getStyle("position") == "absolute";
1309
1310         while (p) {
1311
1312             x += p.offsetLeft;
1313             y += p.offsetTop;
1314
1315             if (!K && J(p).getStyle("position") == "absolute") {
1316                 K = true;
1317             }
1318
1319             if (Roo.isGecko) {
1320                 pe = J(p);
1321
1322                 var  bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0;
1323                 var  bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0;
1324
1325
1326                 x += bl;
1327                 y += bt;
1328
1329
1330                 if (p != el && pe.getStyle('overflow') != 'visible') {
1331                     x += bl;
1332                     y += bt;
1333                 }
1334             }
1335
1336             p = p.offsetParent;
1337         }
1338
1339         if (Roo.isSafari && K) {
1340             x -= bd.offsetLeft;
1341             y -= bd.offsetTop;
1342         }
1343
1344         if (Roo.isGecko && !K) {
1345             var  dbd = J(bd);
1346             x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0;
1347             y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0;
1348         }
1349
1350
1351         p = el.parentNode;
1352         while (p && p != bd) {
1353             if (!Roo.isOpera || (p.tagName != 'TR' && J(p).getStyle("display") != "inline")) {
1354                 x -= p.scrollLeft;
1355                 y -= p.scrollTop;
1356             }
1357
1358             p = p.parentNode;
1359         }
1360         return  [x, y];
1361     },
1362  
1363   
1364
1365
1366     setXY : function(el, xy) {
1367         el = Roo.fly(el, '_setXY');
1368         el.position();
1369         var  L = el.translatePoints(xy);
1370         if (xy[0] !== false) {
1371             el.dom.style.left = L.left + "px";
1372         }
1373         if (xy[1] !== false) {
1374             el.dom.style.top = L.top + "px";
1375         }
1376     },
1377
1378     setX : function(el, x) {
1379         this.setXY(el, [x, false]);
1380     },
1381
1382     setY : function(el, y) {
1383         this.setXY(el, [false, y]);
1384     }
1385 };
1386
1387
1388
1389
1390 Roo.lib.Event = function() {
1391     var  A = false;
1392     var  B = [];
1393     var  C = [];
1394     var  D = 0;
1395     var  E = [];
1396     var  F = 0;
1397     var  G = null;
1398
1399     return  {
1400         POLL_RETRYS: 200,
1401         POLL_INTERVAL: 20,
1402         EL: 0,
1403         TYPE: 1,
1404         FN: 2,
1405         WFN: 3,
1406         OBJ: 3,
1407         ADJ_SCOPE: 4,
1408         _interval: null,
1409
1410         startInterval: function() {
1411             if (!this._interval) {
1412                 var  self = this;
1413                 var  callback = function() {
1414                     self._tryPreloadAttach();
1415                 };
1416                 this._interval = setInterval(callback, this.POLL_INTERVAL);
1417
1418             }
1419         },
1420
1421         onAvailable: function(h, k, m, n) {
1422             E.push({ id:         h,
1423                 fn:         k,
1424                 obj:        m,
1425                 override:   n,
1426                 checkReady: false    });
1427
1428             D = this.POLL_RETRYS;
1429             this.startInterval();
1430         },
1431
1432
1433         addListener: function(el, o, fn) {
1434             el = Roo.getDom(el);
1435             if (!el || !fn) {
1436                 return  false;
1437             }
1438
1439             if ("unload" == o) {
1440                 C[C.length] =
1441                 [el, o, fn];
1442                 return  true;
1443             }
1444
1445             var  p = function(e) {
1446                 return  fn(Roo.lib.Event.getEvent(e));
1447             };
1448
1449             var  li = [el, o, fn, p];
1450
1451             var  q = B.length;
1452             B[q] = li;
1453
1454             this.doAdd(el, o, p, false);
1455             return  true;
1456
1457         },
1458
1459
1460         removeListener: function(el, r, fn) {
1461             var  i, s;
1462
1463             el = Roo.getDom(el);
1464
1465             if(!fn) {
1466                 return  this.purgeElement(el, false, r);
1467             }
1468
1469
1470             if ("unload" == r) {
1471
1472                 for (i = 0,s = C.length; i < s; i++) {
1473                     var  li = C[i];
1474                     if (li &&
1475                         li[0] == el &&
1476                         li[1] == r &&
1477                         li[2] == fn) {
1478                         C.splice(i, 1);
1479                         return  true;
1480                     }
1481                 }
1482
1483                 return  false;
1484             }
1485
1486             var  u = null;
1487
1488
1489             var  v = arguments[3];
1490
1491             if ("undefined" == typeof  v) {
1492                 v = this._getCacheIndex(el, r, fn);
1493             }
1494
1495             if (v >= 0) {
1496                 u = B[v];
1497             }
1498
1499             if (!el || !u) {
1500                 return  false;
1501             }
1502
1503
1504             this.doRemove(el, r, u[this.WFN], false);
1505
1506             delete  B[v][this.WFN];
1507             delete  B[v][this.FN];
1508             B.splice(v, 1);
1509
1510             return  true;
1511
1512         },
1513
1514
1515         getTarget: function(ev, w) {
1516             ev = ev.browserEvent || ev;
1517             var  t = ev.target || ev.srcElement;
1518             return  this.resolveTextNode(t);
1519         },
1520
1521
1522         resolveTextNode: function(z) {
1523             if (Roo.isSafari && z && 3 == z.nodeType) {
1524                 return  z.parentNode;
1525             } else  {
1526                 return  z;
1527             }
1528         },
1529
1530
1531         getPageX: function(ev) {
1532             ev = ev.browserEvent || ev;
1533             var  x = ev.pageX;
1534             if (!x && 0 !== x) {
1535                 x = ev.clientX || 0;
1536
1537                 if (Roo.isIE) {
1538                     x += this.getScroll()[1];
1539                 }
1540             }
1541
1542             return  x;
1543         },
1544
1545
1546         getPageY: function(ev) {
1547             ev = ev.browserEvent || ev;
1548             var  y = ev.pageY;
1549             if (!y && 0 !== y) {
1550                 y = ev.clientY || 0;
1551
1552                 if (Roo.isIE) {
1553                     y += this.getScroll()[0];
1554                 }
1555             }
1556
1557
1558             return  y;
1559         },
1560
1561
1562         getXY: function(ev) {
1563             ev = ev.browserEvent || ev;
1564             return  [this.getPageX(ev), this.getPageY(ev)];
1565         },
1566
1567
1568         getRelatedTarget: function(ev) {
1569             ev = ev.browserEvent || ev;
1570             var  t = ev.relatedTarget;
1571             if (!t) {
1572                 if (ev.type == "mouseout") {
1573                     t = ev.toElement;
1574                 } else  if (ev.type == "mouseover") {
1575                     t = ev.fromElement;
1576                 }
1577             }
1578
1579             return  this.resolveTextNode(t);
1580         },
1581
1582
1583         getTime: function(ev) {
1584             ev = ev.browserEvent || ev;
1585             if (!ev.time) {
1586                 var  t = new  Date().getTime();
1587                 try {
1588                     ev.time = t;
1589                 } catch(ex) {
1590                     this.lastError = ex;
1591                     return  t;
1592                 }
1593             }
1594
1595             return  ev.time;
1596         },
1597
1598
1599         stopEvent: function(ev) {
1600             this.stopPropagation(ev);
1601             this.preventDefault(ev);
1602         },
1603
1604
1605         stopPropagation: function(ev) {
1606             ev = ev.browserEvent || ev;
1607             if (ev.stopPropagation) {
1608                 ev.stopPropagation();
1609             } else  {
1610                 ev.cancelBubble = true;
1611             }
1612         },
1613
1614
1615         preventDefault: function(ev) {
1616             ev = ev.browserEvent || ev;
1617             if(ev.preventDefault) {
1618                 ev.preventDefault();
1619             } else  {
1620                 ev.returnValue = false;
1621             }
1622         },
1623
1624
1625         getEvent: function(e) {
1626             var  ev = e || window.event;
1627             if (!ev) {
1628                 var  c = this.getEvent.caller;
1629                 while (c) {
1630                     ev = c.arguments[0];
1631                     if (ev && Event == ev.constructor) {
1632                         break;
1633                     }
1634
1635                     c = c.caller;
1636                 }
1637             }
1638             return  ev;
1639         },
1640
1641
1642         getCharCode: function(ev) {
1643             ev = ev.browserEvent || ev;
1644             return  ev.charCode || ev.keyCode || 0;
1645         },
1646
1647
1648         _getCacheIndex: function(el, AA, fn) {
1649             for (var  i = 0,s = B.length; i < s; ++i) {
1650                 var  li = B[i];
1651                 if (li &&
1652                     li[this.FN] == fn &&
1653                     li[this.EL] == el &&
1654                     li[this.TYPE] == AA) {
1655                     return  i;
1656                 }
1657             }
1658
1659             return  -1;
1660         },
1661
1662
1663         elCache: {},
1664
1665
1666         getEl: function(id) {
1667             return  document.getElementById(id);
1668         },
1669
1670
1671         clearCache: function() {
1672         },
1673
1674
1675         _load: function(e) {
1676             A = true;
1677             var  EU = Roo.lib.Event;
1678
1679
1680             if (Roo.isIE) {
1681                 EU.doRemove(window, "load", EU._load);
1682             }
1683         },
1684
1685
1686         _tryPreloadAttach: function() {
1687
1688             if (this.locked) {
1689                 return  false;
1690             }
1691
1692
1693             this.locked = true;
1694
1695
1696             var  AB = !A;
1697             if (!AB) {
1698                 AB = (D > 0);
1699             }
1700
1701
1702             var  AC = [];
1703             for (var  i = 0,s = E.length; i < s; ++i) {
1704                 var  item = E[i];
1705                 if (item) {
1706                     var  el = this.getEl(item.id);
1707
1708                     if (el) {
1709                         if (!item.checkReady ||
1710                             A ||
1711                             el.nextSibling ||
1712                             (document && document.body)) {
1713
1714                             var  scope = el;
1715                             if (item.override) {
1716                                 if (item.override === true) {
1717                                     scope = item.obj;
1718                                 } else  {
1719                                     scope = item.override;
1720                                 }
1721                             }
1722
1723                             item.fn.call(scope, item.obj);
1724                             E[i] = null;
1725                         }
1726                     } else  {
1727                         AC.push(item);
1728                     }
1729                 }
1730             }
1731
1732
1733             D = (AC.length === 0) ? 0 : D - 1;
1734
1735             if (AB) {
1736
1737                 this.startInterval();
1738             } else  {
1739                 clearInterval(this._interval);
1740                 this._interval = null;
1741             }
1742
1743
1744             this.locked = false;
1745
1746             return  true;
1747
1748         },
1749
1750
1751         purgeElement: function(el, AD, AE) {
1752             var  AF = this.getListeners(el, AE);
1753             if (AF) {
1754                 for (var  i = 0,s = AF.length; i < s; ++i) {
1755                     var  l = AF[i];
1756                     this.removeListener(el, l.type, l.fn);
1757                 }
1758             }
1759
1760             if (AD && el && el.childNodes) {
1761                 for (i = 0,s = el.childNodes.length; i < s; ++i) {
1762                     this.purgeElement(el.childNodes[i], AD, AE);
1763                 }
1764             }
1765         },
1766
1767
1768         getListeners: function(el, AG) {
1769             var  AH = [], AI;
1770             if (!AG) {
1771                 AI = [B, C];
1772             } else  if (AG == "unload") {
1773                 AI = [C];
1774             } else  {
1775                 AI = [B];
1776             }
1777
1778             for (var  j = 0; j < AI.length; ++j) {
1779                 var  searchList = AI[j];
1780                 if (searchList && searchList.length > 0) {
1781                     for (var  i = 0,s = searchList.length; i < s; ++i) {
1782                         var  l = searchList[i];
1783                         if (l && l[this.EL] === el &&
1784                             (!AG || AG === l[this.TYPE])) {
1785                             AH.push({
1786                                 type:   l[this.TYPE],
1787                                 fn:     l[this.FN],
1788                                 obj:    l[this.OBJ],
1789                                 adjust: l[this.ADJ_SCOPE],
1790                                 index:  i
1791                             });
1792                         }
1793                     }
1794                 }
1795             }
1796
1797             return  (AH.length) ? AH : null;
1798         },
1799
1800
1801         _unload: function(e) {
1802
1803             var  EU = Roo.lib.Event, i, j, l, AJ, AK;
1804
1805             for (i = 0,AJ = C.length; i < AJ; ++i) {
1806                 l = C[i];
1807                 if (l) {
1808                     var  scope = window;
1809                     if (l[EU.ADJ_SCOPE]) {
1810                         if (l[EU.ADJ_SCOPE] === true) {
1811                             scope = l[EU.OBJ];
1812                         } else  {
1813                             scope = l[EU.ADJ_SCOPE];
1814                         }
1815                     }
1816
1817                     l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]);
1818                     C[i] = null;
1819                     l = null;
1820                     scope = null;
1821                 }
1822             }
1823
1824
1825             C = null;
1826
1827             if (B && B.length > 0) {
1828                 j = B.length;
1829                 while (j) {
1830                     AK = j - 1;
1831                     l = B[AK];
1832                     if (l) {
1833                         EU.removeListener(l[EU.EL], l[EU.TYPE],
1834                                 l[EU.FN], AK);
1835                     }
1836
1837                     j = j - 1;
1838                 }
1839
1840                 l = null;
1841
1842                 EU.clearCache();
1843             }
1844
1845
1846             EU.doRemove(window, "unload", EU._unload);
1847
1848         },
1849
1850
1851         getScroll: function() {
1852             var  dd = document.documentElement, db = document.body;
1853             if (dd && (dd.scrollTop || dd.scrollLeft)) {
1854                 return  [dd.scrollTop, dd.scrollLeft];
1855             } else  if (db) {
1856                 return  [db.scrollTop, db.scrollLeft];
1857             } else  {
1858                 return  [0, 0];
1859             }
1860         },
1861
1862
1863         doAdd: function () {
1864             if (window.addEventListener) {
1865                 return  function(el, AL, fn, AM) {
1866                     el.addEventListener(AL, fn, (AM));
1867                 };
1868             } else  if (window.attachEvent) {
1869                 return  function(el, AL, fn, AM) {
1870                     el.attachEvent("on" + AL, fn);
1871                 };
1872             } else  {
1873                 return  function() {
1874                 };
1875             }
1876         }(),
1877
1878
1879         doRemove: function() {
1880             if (window.removeEventListener) {
1881                 return  function (el, AL, fn, AM) {
1882                     el.removeEventListener(AL, fn, (AM));
1883                 };
1884             } else  if (window.detachEvent) {
1885                 return  function (el, AL, fn) {
1886                     el.detachEvent("on" + AL, fn);
1887                 };
1888             } else  {
1889                 return  function() {
1890                 };
1891             }
1892         }()
1893     };
1894     
1895 }();
1896 (function() {     
1897    
1898     var  E = Roo.lib.Event;
1899     E.on = E.addListener;
1900     E.un = E.removeListener;
1901
1902     if (document && document.body) {
1903         E._load();
1904     } else  {
1905         E.doAdd(window, "load", E._load);
1906     }
1907
1908     E.doAdd(window, "unload", E._unload);
1909     E._tryPreloadAttach();
1910 })();
1911
1912
1913
1914
1915
1916 (function() {
1917     
1918     Roo.lib.Ajax = {
1919         request : function(A, B, cb, C, D) {
1920             if(D){
1921                 var  hs = D.headers;
1922                 if(hs){
1923                     for(var  h  in  hs){
1924                         if(hs.hasOwnProperty(h)){
1925                             this.initHeader(h, hs[h], false);
1926                         }
1927                     }
1928                 }
1929                 if(D.xmlData){
1930                     this.initHeader('Content-Type', 'text/xml', false);
1931                     A = 'POST';
1932                     C = D.xmlData;
1933                 }
1934             }
1935
1936             return  this.asyncRequest(A, B, cb, C);
1937         },
1938
1939         serializeForm : function(E) {
1940             if(typeof  E == 'string') {
1941                 E = (document.getElementById(E) || document.forms[E]);
1942             }
1943
1944             var  el, F, G, H, I = '', J = false;
1945             for (var  i = 0; i < E.elements.length; i++) {
1946                 el = E.elements[i];
1947                 H = E.elements[i].disabled;
1948                 F = E.elements[i].name;
1949                 G = E.elements[i].value;
1950
1951                 if (!H && F){
1952                     switch (el.type)
1953                             {
1954                         case  'select-one':
1955                         case  'select-multiple':
1956                             for (var  j = 0; j < el.options.length; j++) {
1957                                 if (el.options[j].selected) {
1958                                     if (Roo.isIE) {
1959                                         I += encodeURIComponent(F) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
1960                                     }
1961                                     else  {
1962                                         I += encodeURIComponent(F) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
1963                                     }
1964                                 }
1965                             }
1966                             break;
1967                         case  'radio':
1968                         case  'checkbox':
1969                             if (el.checked) {
1970                                 I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1971                             }
1972                             break;
1973                         case  'file':
1974
1975                         case  undefined:
1976
1977                         case  'reset':
1978
1979                         case  'button':
1980
1981                             break;
1982                         case  'submit':
1983                             if(J == false) {
1984                                 I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1985                                 J = true;
1986                             }
1987                             break;
1988                         default:
1989                             I += encodeURIComponent(F) + '=' + encodeURIComponent(G) + '&';
1990                             break;
1991                     }
1992                 }
1993             }
1994
1995             I = I.substr(0, I.length - 1);
1996             return  I;
1997         },
1998
1999         headers:{},
2000
2001         hasHeaders:false,
2002
2003         useDefaultHeader:true,
2004
2005         defaultPostHeader:'application/x-www-form-urlencoded',
2006
2007         useDefaultXhrHeader:true,
2008
2009         defaultXhrHeader:'XMLHttpRequest',
2010
2011         hasDefaultHeaders:true,
2012
2013         defaultHeaders:{},
2014
2015         poll:{},
2016
2017         timeout:{},
2018
2019         pollInterval:50,
2020
2021         transactionId:0,
2022
2023         setProgId:function(id)
2024         {
2025             this.activeX.unshift(id);
2026         },
2027
2028         setDefaultPostHeader:function(b)
2029         {
2030             this.useDefaultHeader = b;
2031         },
2032
2033         setDefaultXhrHeader:function(b)
2034         {
2035             this.useDefaultXhrHeader = b;
2036         },
2037
2038         setPollingInterval:function(i)
2039         {
2040             if (typeof  i == 'number' && isFinite(i)) {
2041                 this.pollInterval = i;
2042             }
2043         },
2044
2045         createXhrObject:function(K)
2046         {
2047             var  L,M;
2048             try
2049             {
2050
2051                 M = new  XMLHttpRequest();
2052
2053                 L = { conn:M, tId:K };
2054             }
2055             catch(e)
2056             {
2057                 for (var  i = 0; i < this.activeX.length; ++i) {
2058                     try
2059                     {
2060
2061                         http = new  ActiveXObject(this.activeX[i]);
2062
2063                         obj = { conn:http, tId:transactionId };
2064                         break;
2065                     }
2066                     catch(e) {
2067                     }
2068                 }
2069             }
2070             finally
2071             {
2072                 return  L;
2073             }
2074         },
2075
2076         getConnectionObject:function()
2077         {
2078             var  o;
2079             var  N = this.transactionId;
2080
2081             try
2082             {
2083                 o = this.createXhrObject(N);
2084                 if (o) {
2085                     this.transactionId++;
2086                 }
2087             }
2088             catch(e) {
2089             }
2090             finally
2091             {
2092                 return  o;
2093             }
2094         },
2095
2096         asyncRequest:function(O, P, Q, R)
2097         {
2098             var  o = this.getConnectionObject();
2099
2100             if (!o) {
2101                 return  null;
2102             }
2103             else  {
2104                 o.conn.open(O, P, true);
2105
2106                 if (this.useDefaultXhrHeader) {
2107                     if (!this.defaultHeaders['X-Requested-With']) {
2108                         this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
2109                     }
2110                 }
2111
2112                 if(R && this.useDefaultHeader){
2113                     this.initHeader('Content-Type', this.defaultPostHeader);
2114                 }
2115
2116                  if (this.hasDefaultHeaders || this.hasHeaders) {
2117                     this.setHeader(o);
2118                 }
2119
2120
2121                 this.handleReadyState(o, Q);
2122                 o.conn.send(R || null);
2123
2124                 return  o;
2125             }
2126         },
2127
2128         handleReadyState:function(o, S)
2129         {
2130             var  T = this;
2131
2132             if (S && S.timeout) {
2133                 this.timeout[o.tId] = window.setTimeout(function() {
2134                     T.abort(o, S, true);
2135                 }, S.timeout);
2136             }
2137
2138
2139             this.poll[o.tId] = window.setInterval(
2140                     function() {
2141                         if (o.conn && o.conn.readyState == 4) {
2142                             window.clearInterval(T.poll[o.tId]);
2143                             delete  T.poll[o.tId];
2144
2145                             if(S && S.timeout) {
2146                                 window.clearTimeout(T.timeout[o.tId]);
2147                                 delete  T.timeout[o.tId];
2148                             }
2149
2150
2151                             T.handleTransactionResponse(o, S);
2152                         }
2153                     }
2154                     , this.pollInterval);
2155         },
2156
2157         handleTransactionResponse:function(o, U, V)
2158         {
2159
2160             if (!U) {
2161                 this.releaseObject(o);
2162                 return;
2163             }
2164
2165             var  W, X;
2166
2167             try
2168             {
2169                 if (o.conn.status !== undefined && o.conn.status != 0) {
2170                     W = o.conn.status;
2171                 }
2172                 else  {
2173                     W = 13030;
2174                 }
2175             }
2176             catch(e) {
2177
2178
2179                 httpStatus = 13030;
2180             }
2181
2182             if (W >= 200 && W < 300) {
2183                 X = this.createResponseObject(o, U.argument);
2184                 if (U.success) {
2185                     if (!U.scope) {
2186                         U.success(X);
2187                     }
2188                     else  {
2189
2190
2191                         U.success.apply(U.scope, [X]);
2192                     }
2193                 }
2194             }
2195             else  {
2196                 switch (W) {
2197
2198                     case  12002:
2199                     case  12029:
2200                     case  12030:
2201                     case  12031:
2202                     case  12152:
2203                     case  13030:
2204                         X = this.createExceptionObject(o.tId, U.argument, (V ? V : false));
2205                         if (U.failure) {
2206                             if (!U.scope) {
2207                                 U.failure(X);
2208                             }
2209                             else  {
2210                                 U.failure.apply(U.scope, [X]);
2211                             }
2212                         }
2213                         break;
2214                     default:
2215                         X = this.createResponseObject(o, U.argument);
2216                         if (U.failure) {
2217                             if (!U.scope) {
2218                                 U.failure(X);
2219                             }
2220                             else  {
2221                                 U.failure.apply(U.scope, [X]);
2222                             }
2223                         }
2224                 }
2225             }
2226
2227
2228             this.releaseObject(o);
2229             X = null;
2230         },
2231
2232         createResponseObject:function(o, Y)
2233         {
2234             var  Z = {};
2235             var  a = {};
2236
2237             try
2238             {
2239                 var  headerStr = o.conn.getAllResponseHeaders();
2240                 var  header = headerStr.split('\n');
2241                 for (var  i = 0; i < header.length; i++) {
2242                     var  delimitPos = header[i].indexOf(':');
2243                     if (delimitPos != -1) {
2244                         a[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
2245                     }
2246                 }
2247             }
2248             catch(e) {
2249             }
2250
2251
2252             Z.tId = o.tId;
2253             Z.status = o.conn.status;
2254             Z.statusText = o.conn.statusText;
2255             Z.getResponseHeader = a;
2256             Z.getAllResponseHeaders = headerStr;
2257             Z.responseText = o.conn.responseText;
2258             Z.responseXML = o.conn.responseXML;
2259
2260             if (typeof  Y !== undefined) {
2261                 Z.argument = Y;
2262             }
2263
2264             return  Z;
2265         },
2266
2267         createExceptionObject:function(c, d, f)
2268         {
2269             var  g = 0;
2270             var  k = 'communication failure';
2271             var  l = -1;
2272             var  m = 'transaction aborted';
2273
2274             var  n = {};
2275
2276             n.tId = c;
2277             if (f) {
2278                 n.status = l;
2279                 n.statusText = m;
2280             }
2281             else  {
2282                 n.status = g;
2283                 n.statusText = k;
2284             }
2285
2286             if (d) {
2287                 n.argument = d;
2288             }
2289
2290             return  n;
2291         },
2292
2293         initHeader:function(p, q, r)
2294         {
2295             var  s = (r) ? this.defaultHeaders : this.headers;
2296
2297             if (s[p] === undefined) {
2298                 s[p] = q;
2299             }
2300             else  {
2301
2302
2303                 s[p] = q + "," + s[p];
2304             }
2305
2306             if (r) {
2307                 this.hasDefaultHeaders = true;
2308             }
2309             else  {
2310                 this.hasHeaders = true;
2311             }
2312         },
2313
2314
2315         setHeader:function(o)
2316         {
2317             if (this.hasDefaultHeaders) {
2318                 for (var  prop  in  this.defaultHeaders) {
2319                     if (this.defaultHeaders.hasOwnProperty(prop)) {
2320                         o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
2321                     }
2322                 }
2323             }
2324
2325             if (this.hasHeaders) {
2326                 for (var  prop  in  this.headers) {
2327                     if (this.headers.hasOwnProperty(prop)) {
2328                         o.conn.setRequestHeader(prop, this.headers[prop]);
2329                     }
2330                 }
2331
2332                 this.headers = {};
2333                 this.hasHeaders = false;
2334             }
2335         },
2336
2337         resetDefaultHeaders:function() {
2338             delete  this.defaultHeaders;
2339             this.defaultHeaders = {};
2340             this.hasDefaultHeaders = false;
2341         },
2342
2343         abort:function(o, t, u)
2344         {
2345             if(this.isCallInProgress(o)) {
2346                 o.conn.abort();
2347                 window.clearInterval(this.poll[o.tId]);
2348                 delete  this.poll[o.tId];
2349                 if (u) {
2350                     delete  this.timeout[o.tId];
2351                 }
2352
2353
2354                 this.handleTransactionResponse(o, t, true);
2355
2356                 return  true;
2357             }
2358             else  {
2359                 return  false;
2360             }
2361         },
2362
2363
2364         isCallInProgress:function(o)
2365         {
2366             if (o && o.conn) {
2367                 return  o.conn.readyState != 4 && o.conn.readyState != 0;
2368             }
2369             else  {
2370
2371                 return  false;
2372             }
2373         },
2374
2375
2376         releaseObject:function(o)
2377         {
2378
2379             o.conn = null;
2380
2381             o = null;
2382         },
2383
2384         activeX:[
2385         'MSXML2.XMLHTTP.3.0',
2386         'MSXML2.XMLHTTP',
2387         'Microsoft.XMLHTTP'
2388         ]
2389
2390
2391     };
2392 })();
2393
2394
2395
2396 Roo.lib.Region = function(t, r, b, l) {
2397     this.top = t;
2398     this[1] = t;
2399     this.right = r;
2400     this.bottom = b;
2401     this.left = l;
2402     this[0] = l;
2403 };
2404
2405
2406 Roo.lib.Region.prototype = {
2407     contains : function(A) {
2408         return  ( A.left >= this.left &&
2409                  A.right <= this.right &&
2410                  A.top >= this.top &&
2411                  A.bottom <= this.bottom    );
2412
2413     },
2414
2415     getArea : function() {
2416         return  ( (this.bottom - this.top) * (this.right - this.left) );
2417     },
2418
2419     intersect : function(B) {
2420         var  t = Math.max(this.top, B.top);
2421         var  r = Math.min(this.right, B.right);
2422         var  b = Math.min(this.bottom, B.bottom);
2423         var  l = Math.max(this.left, B.left);
2424
2425         if (b >= t && r >= l) {
2426             return  new  Roo.lib.Region(t, r, b, l);
2427         } else  {
2428             return  null;
2429         }
2430     },
2431     union : function(C) {
2432         var  t = Math.min(this.top, C.top);
2433         var  r = Math.max(this.right, C.right);
2434         var  b = Math.max(this.bottom, C.bottom);
2435         var  l = Math.min(this.left, C.left);
2436
2437         return  new  Roo.lib.Region(t, r, b, l);
2438     },
2439
2440     adjust : function(t, l, b, r) {
2441         this.top += t;
2442         this.left += l;
2443         this.right += r;
2444         this.bottom += b;
2445         return  this;
2446     }
2447 };
2448
2449 Roo.lib.Region.getRegion = function(el) {
2450     var  p = Roo.lib.Dom.getXY(el);
2451
2452     var  t = p[1];
2453     var  r = p[0] + el.offsetWidth;
2454     var  b = p[1] + el.offsetHeight;
2455     var  l = p[0];
2456
2457     return  new  Roo.lib.Region(t, r, b, l);
2458 };
2459
2460
2461
2462
2463
2464
2465 Roo.lib.Point = function(x, y) {
2466     if (x  instanceof  Array) {
2467         y = x[1];
2468         x = x[0];
2469     }
2470
2471     this.x = this.right = this.left = this[0] = x;
2472     this.y = this.top = this.bottom = this[1] = y;
2473 };
2474
2475 Roo.lib.Point.prototype = new  Roo.lib.Region();
2476
2477
2478
2479  
2480 (function() {   
2481
2482     Roo.lib.Anim = {
2483         scroll : function(el, A, B, C, cb, D) {
2484             this.run(el, A, B, C, cb, D, Roo.lib.Scroll);
2485         },
2486
2487         motion : function(el, E, F, G, cb, H) {
2488             this.run(el, E, F, G, cb, H, Roo.lib.Motion);
2489         },
2490
2491         color : function(el, I, J, K, cb, L) {
2492             this.run(el, I, J, K, cb, L, Roo.lib.ColorAnim);
2493         },
2494
2495         run : function(el, M, N, O, cb, P, Q) {
2496             Q = Q || Roo.lib.AnimBase;
2497             if (typeof  O == "string") {
2498                 O = Roo.lib.Easing[O];
2499             }
2500             var  R = new  Q(el, M, N, O);
2501             R.animateX(function() {
2502                 Roo.callback(cb, P);
2503             });
2504             return  R;
2505         }
2506     };
2507 })();
2508
2509
2510
2511 (function() {    
2512     var  A;
2513     
2514     function  B(el) {
2515         if (!A) {
2516             A = new  Roo.Element.Flyweight();
2517         }
2518
2519         A.dom = el;
2520         return  A;
2521     }
2522
2523
2524     
2525     
2526    
2527     
2528     Roo.lib.AnimBase = function(el, C, D, E) {
2529         if (el) {
2530             this.init(el, C, D, E);
2531         }
2532     };
2533
2534     Roo.lib.AnimBase.fly = B;
2535     
2536     
2537     
2538     Roo.lib.AnimBase.prototype = {
2539
2540         toString: function() {
2541             var  el = this.getEl();
2542             var  id = el.id || el.tagName;
2543             return  ("Anim " + id);
2544         },
2545
2546         patterns: {
2547             noNegatives:        /width|height|opacity|padding/i,
2548             offsetAttribute:  /^((width|height)|(top|left))$/,
2549             defaultUnit:        /width|height|top$|bottom$|left$|right$/i,
2550             offsetUnit:         /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i
2551         },
2552
2553
2554         doMethod: function(C, D, E) {
2555             return  this.method(this.currentFrame, D, E - D, this.totalFrames);
2556         },
2557
2558
2559         setAttribute: function(F, G, H) {
2560             if (this.patterns.noNegatives.test(F)) {
2561                 G = (G > 0) ? G : 0;
2562             }
2563
2564
2565             Roo.fly(this.getEl(), '_anim').setStyle(F, G + H);
2566         },
2567
2568
2569         getAttribute: function(I) {
2570             var  el = this.getEl();
2571             var  J = B(el).getStyle(I);
2572
2573             if (J !== 'auto' && !this.patterns.offsetUnit.test(J)) {
2574                 return  parseFloat(J);
2575             }
2576
2577             var  a = this.patterns.offsetAttribute.exec(I) || [];
2578             var  K = !!( a[3] );
2579             var  L = !!( a[2] );
2580
2581
2582             if (L || (B(el).getStyle('position') == 'absolute' && K)) {
2583                 J = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
2584             } else  {
2585                 J = 0;
2586             }
2587
2588             return  J;
2589         },
2590
2591
2592         getDefaultUnit: function(M) {
2593             if (this.patterns.defaultUnit.test(M)) {
2594                 return  'px';
2595             }
2596
2597             return  '';
2598         },
2599
2600         animateX : function(N, O) {
2601             var  f = function() {
2602                 this.onComplete.removeListener(f);
2603                 if (typeof  N == "function") {
2604                     N.call(O || this, this);
2605                 }
2606             };
2607             this.onComplete.addListener(f, this);
2608             this.animate();
2609         },
2610
2611
2612         setRuntimeAttribute: function(P) {
2613             var  Q;
2614             var  R;
2615             var  S = this.attributes;
2616
2617             this.runtimeAttributes[P] = {};
2618
2619             var  T = function(U) {
2620                 return  (typeof  U !== 'undefined');
2621             };
2622
2623             if (!T(S[P]['to']) && !T(S[P]['by'])) {
2624                 return  false;
2625             }
2626
2627
2628             Q = ( T(S[P]['from']) ) ? S[P]['from'] : this.getAttribute(P);
2629
2630
2631             if (T(S[P]['to'])) {
2632                 R = S[P]['to'];
2633             } else  if (T(S[P]['by'])) {
2634                 if (Q.constructor == Array) {
2635                     R = [];
2636                     for (var  i = 0, len = Q.length; i < len; ++i) {
2637                         R[i] = Q[i] + S[P]['by'][i];
2638                     }
2639                 } else  {
2640                     R = Q + S[P]['by'];
2641                 }
2642             }
2643
2644
2645             this.runtimeAttributes[P].start = Q;
2646             this.runtimeAttributes[P].end = R;
2647
2648
2649             this.runtimeAttributes[P].unit = ( T(S[P].unit) ) ? S[P]['unit'] : this.getDefaultUnit(P);
2650         },
2651
2652
2653         init: function(el, U, V, W) {
2654
2655             var  X = false;
2656
2657
2658             var  Y = null;
2659
2660
2661             var  Z = 0;
2662
2663
2664             el = Roo.getDom(el);
2665
2666
2667             this.attributes = U || {};
2668
2669
2670             this.duration = V || 1;
2671
2672
2673             this.method = W || Roo.lib.Easing.easeNone;
2674
2675
2676             this.useSeconds = true;
2677
2678
2679             this.currentFrame = 0;
2680
2681
2682             this.totalFrames = Roo.lib.AnimMgr.fps;
2683
2684
2685             this.getEl = function() {
2686                 return  el;
2687             };
2688
2689
2690             this.isAnimated = function() {
2691                 return  X;
2692             };
2693
2694
2695             this.getStartTime = function() {
2696                 return  Y;
2697             };
2698
2699             this.runtimeAttributes = {};
2700
2701
2702             this.animate = function() {
2703                 if (this.isAnimated()) {
2704                     return  false;
2705                 }
2706
2707
2708                 this.currentFrame = 0;
2709
2710                 this.totalFrames = ( this.useSeconds ) ? Math.ceil(Roo.lib.AnimMgr.fps * this.duration) : this.duration;
2711
2712                 Roo.lib.AnimMgr.registerElement(this);
2713             };
2714
2715
2716             this.stop = function(e) {
2717                 if (e) {
2718                     this.currentFrame = this.totalFrames;
2719                     this._onTween.fire();
2720                 }
2721
2722                 Roo.lib.AnimMgr.stop(this);
2723             };
2724
2725             var  b = function() {
2726                 this.onStart.fire();
2727
2728                 this.runtimeAttributes = {};
2729                 for (var  P  in  this.attributes) {
2730                     this.setRuntimeAttribute(P);
2731                 }
2732
2733
2734                 X = true;
2735                 Z = 0;
2736                 Y = new  Date();
2737             };
2738
2739
2740             var  c = function() {
2741                 var  e = {
2742                     duration: new  Date() - this.getStartTime(),
2743                     currentFrame: this.currentFrame
2744                 };
2745
2746                 e.toString = function() {
2747                     return  (
2748                             'duration: ' + e.duration +
2749                             ', currentFrame: ' + e.currentFrame
2750                             );
2751                 };
2752
2753                 this.onTween.fire(e);
2754
2755                 var  g = this.runtimeAttributes;
2756
2757                 for (var  P  in  g) {
2758                     this.setAttribute(P, this.doMethod(P, g[P].start, g[P].end), g[P].unit);
2759                 }
2760
2761
2762                 Z += 1;
2763             };
2764
2765             var  d = function() {
2766                 var  e = (new  Date() - Y) / 1000 ;
2767
2768                 var  g = {
2769                     duration: e,
2770                     frames: Z,
2771                     fps: Z / e
2772                 };
2773
2774                 g.toString = function() {
2775                     return  (
2776                             'duration: ' + g.duration +
2777                             ', frames: ' + g.frames +
2778                             ', fps: ' + g.fps
2779                             );
2780                 };
2781
2782                 X = false;
2783                 Z = 0;
2784                 this.onComplete.fire(g);
2785             };
2786
2787
2788             this._onStart = new  Roo.util.Event(this);
2789             this.onStart = new  Roo.util.Event(this);
2790             this.onTween = new  Roo.util.Event(this);
2791             this._onTween = new  Roo.util.Event(this);
2792             this.onComplete = new  Roo.util.Event(this);
2793             this._onComplete = new  Roo.util.Event(this);
2794             this._onStart.addListener(b);
2795             this._onTween.addListener(c);
2796             this._onComplete.addListener(d);
2797         }
2798     };
2799 })();
2800
2801
2802
2803
2804 Roo.lib.AnimMgr = new  function() {
2805
2806         var  A = null;
2807
2808
2809         var  B = [];
2810
2811
2812         var  C = 0;
2813
2814
2815         this.fps = 1000;
2816
2817
2818         this.delay = 1;
2819
2820
2821         this.registerElement = function(F) {
2822             B[B.length] = F;
2823             C += 1;
2824             F._onStart.fire();
2825             this.start();
2826         };
2827
2828
2829         this.unRegister = function(F, G) {
2830             F._onComplete.fire();
2831             G = G || D(F);
2832             if (G != -1) {
2833                 B.splice(G, 1);
2834             }
2835
2836
2837             C -= 1;
2838             if (C <= 0) {
2839                 this.stop();
2840             }
2841         };
2842
2843
2844         this.start = function() {
2845             if (A === null) {
2846                 A = setInterval(this.run, this.delay);
2847             }
2848         };
2849
2850
2851         this.stop = function(F) {
2852             if (!F) {
2853                 clearInterval(A);
2854
2855                 for (var  i = 0, len = B.length; i < len; ++i) {
2856                     if (B[0].isAnimated()) {
2857                         this.unRegister(B[0], 0);
2858                     }
2859                 }
2860
2861
2862                 B = [];
2863                 A = null;
2864                 C = 0;
2865             }
2866             else  {
2867                 this.unRegister(F);
2868             }
2869         };
2870
2871
2872         this.run = function() {
2873             for (var  i = 0, len = B.length; i < len; ++i) {
2874                 var  tween = B[i];
2875                 if (!tween || !tween.isAnimated()) {
2876                     continue;
2877                 }
2878
2879                 if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
2880                 {
2881                     tween.currentFrame += 1;
2882
2883                     if (tween.useSeconds) {
2884                         E(tween);
2885                     }
2886
2887                     tween._onTween.fire();
2888                 }
2889                 else  {
2890                     Roo.lib.AnimMgr.stop(tween, i);
2891                 }
2892             }
2893         };
2894
2895         var  D = function(F) {
2896             for (var  i = 0, len = B.length; i < len; ++i) {
2897                 if (B[i] == F) {
2898                     return  i;
2899                 }
2900             }
2901             return  -1;
2902         };
2903
2904
2905         var  E = function(F) {
2906             var  G = F.totalFrames;
2907             var  H = F.currentFrame;
2908             var  I = (F.currentFrame * F.duration * 1000 / F.totalFrames);
2909             var  J = (new  Date() - F.getStartTime());
2910             var  K = 0;
2911
2912             if (J < F.duration * 1000) {
2913                 K = Math.round((J / I - 1) * F.currentFrame);
2914             } else  {
2915                 K = G - (H + 1);
2916             }
2917             if (K > 0 && isFinite(K)) {
2918                 if (F.currentFrame + K >= G) {
2919                     K = G - (H + 1);
2920                 }
2921
2922
2923                 F.currentFrame += K;
2924             }
2925         };
2926     };
2927
2928
2929 Roo.lib.Bezier = new  function() {
2930
2931         this.getPosition = function(A, t) {
2932             var  n = A.length;
2933             var  B = [];
2934
2935             for (var  i = 0; i < n; ++i) {
2936                 B[i] = [A[i][0], A[i][1]];
2937             }
2938
2939             for (var  j = 1; j < n; ++j) {
2940                 for (i = 0; i < n - j; ++i) {
2941                     B[i][0] = (1 - t) * B[i][0] + t * B[parseInt(i + 1, 10)][0];
2942                     B[i][1] = (1 - t) * B[i][1] + t * B[parseInt(i + 1, 10)][1];
2943                 }
2944             }
2945
2946             return  [ B[0][0], B[0][1] ];
2947
2948         };
2949     };
2950
2951
2952 (function() {
2953
2954     Roo.lib.ColorAnim = function(el, D, E, F) {
2955         Roo.lib.ColorAnim.superclass.constructor.call(this, el, D, E, F);
2956     };
2957
2958     Roo.extend(Roo.lib.ColorAnim, Roo.lib.AnimBase);
2959
2960     var  A = Roo.lib.AnimBase.fly;
2961     var  Y = Roo.lib;
2962     var  B = Y.ColorAnim.superclass;
2963     var  C = Y.ColorAnim.prototype;
2964
2965     C.toString = function() {
2966         var  el = this.getEl();
2967         var  id = el.id || el.tagName;
2968         return  ("ColorAnim " + id);
2969     };
2970
2971     C.patterns.color = /color$/i;
2972     C.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
2973     C.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
2974     C.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
2975     C.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/;
2976
2977
2978     C.parseColor = function(s) {
2979         if (s.length == 3) {
2980             return  s;
2981         }
2982
2983         var  c = this.patterns.hex.exec(s);
2984         if (c && c.length == 4) {
2985             return  [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
2986         }
2987
2988
2989         c = this.patterns.rgb.exec(s);
2990         if (c && c.length == 4) {
2991             return  [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
2992         }
2993
2994
2995         c = this.patterns.hex3.exec(s);
2996         if (c && c.length == 4) {
2997             return  [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
2998         }
2999
3000         return  null;
3001     };
3002     
3003     C.getAttribute = function(D) {
3004         var  el = this.getEl();
3005         if (this.patterns.color.test(D)) {
3006             var  val = A(el).getStyle(D);
3007
3008             if (this.patterns.transparent.test(val)) {
3009                 var  parent = el.parentNode;
3010                 val = A(parent).getStyle(D);
3011
3012                 while (parent && this.patterns.transparent.test(val)) {
3013                     parent = parent.parentNode;
3014                     val = A(parent).getStyle(D);
3015                     if (parent.tagName.toUpperCase() == 'HTML') {
3016                         val = '#fff';
3017                     }
3018                 }
3019             }
3020         } else  {
3021             val = B.getAttribute.call(this, D);
3022         }
3023
3024         return  val;
3025     };
3026     C.getAttribute = function(D) {
3027         var  el = this.getEl();
3028         if (this.patterns.color.test(D)) {
3029             var  val = A(el).getStyle(D);
3030
3031             if (this.patterns.transparent.test(val)) {
3032                 var  parent = el.parentNode;
3033                 val = A(parent).getStyle(D);
3034
3035                 while (parent && this.patterns.transparent.test(val)) {
3036                     parent = parent.parentNode;
3037                     val = A(parent).getStyle(D);
3038                     if (parent.tagName.toUpperCase() == 'HTML') {
3039                         val = '#fff';
3040                     }
3041                 }
3042             }
3043         } else  {
3044             val = B.getAttribute.call(this, D);
3045         }
3046
3047         return  val;
3048     };
3049
3050     C.doMethod = function(D, E, F) {
3051         var  G;
3052
3053         if (this.patterns.color.test(D)) {
3054             G = [];
3055             for (var  i = 0, len = E.length; i < len; ++i) {
3056                 G[i] = B.doMethod.call(this, D, E[i], F[i]);
3057             }
3058
3059
3060             G = 'rgb(' + Math.floor(G[0]) + ',' + Math.floor(G[1]) + ',' + Math.floor(G[2]) + ')';
3061         }
3062         else  {
3063             G = B.doMethod.call(this, D, E, F);
3064         }
3065
3066         return  G;
3067     };
3068
3069     C.setRuntimeAttribute = function(D) {
3070         B.setRuntimeAttribute.call(this, D);
3071
3072         if (this.patterns.color.test(D)) {
3073             var  attributes = this.attributes;
3074             var  start = this.parseColor(this.runtimeAttributes[D].start);
3075             var  end = this.parseColor(this.runtimeAttributes[D].end);
3076
3077             if (typeof  attributes[D]['to'] === 'undefined' && typeof  attributes[D]['by'] !== 'undefined') {
3078                 end = this.parseColor(attributes[D].by);
3079
3080                 for (var  i = 0, len = start.length; i < len; ++i) {
3081                     end[i] = start[i] + end[i];
3082                 }
3083             }
3084
3085
3086             this.runtimeAttributes[D].start = start;
3087             this.runtimeAttributes[D].end = end;
3088         }
3089     };
3090 })();
3091
3092
3093
3094
3095 Roo.lib.Easing = {
3096
3097
3098     easeNone: function (t, b, c, d) {
3099         return  c * t / d + b;
3100     },
3101
3102
3103     easeIn: function (t, b, c, d) {
3104         return  c * (t /= d) * t + b;
3105     },
3106
3107
3108     easeOut: function (t, b, c, d) {
3109         return  -c * (t /= d) * (t - 2) + b;
3110     },
3111
3112
3113     easeBoth: function (t, b, c, d) {
3114         if ((t /= d / 2) < 1) {
3115             return  c / 2 * t * t + b;
3116         }
3117
3118         return  -c / 2 * ((--t) * (t - 2) - 1) + b;
3119     },
3120
3121
3122     easeInStrong: function (t, b, c, d) {
3123         return  c * (t /= d) * t * t * t + b;
3124     },
3125
3126
3127     easeOutStrong: function (t, b, c, d) {
3128         return  -c * ((t = t / d - 1) * t * t * t - 1) + b;
3129     },
3130
3131
3132     easeBothStrong: function (t, b, c, d) {
3133         if ((t /= d / 2) < 1) {
3134             return  c / 2 * t * t * t * t + b;
3135         }
3136
3137         return  -c / 2 * ((t -= 2) * t * t * t - 2) + b;
3138     },
3139
3140
3141
3142     elasticIn: function (t, b, c, d, a, p) {
3143         if (t == 0) {
3144             return  b;
3145         }
3146         if ((t /= d) == 1) {
3147             return  b + c;
3148         }
3149         if (!p) {
3150             p = d * .3;
3151         }
3152
3153         if (!a || a < Math.abs(c)) {
3154             a = c;
3155             var  s = p / 4;
3156         }
3157         else  {
3158             var  s = p / (2 * Math.PI) * Math.asin(c / a);
3159         }
3160
3161         return  -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
3162     },
3163
3164
3165     elasticOut: function (t, b, c, d, a, p) {
3166         if (t == 0) {
3167             return  b;
3168         }
3169         if ((t /= d) == 1) {
3170             return  b + c;
3171         }
3172         if (!p) {
3173             p = d * .3;
3174         }
3175
3176         if (!a || a < Math.abs(c)) {
3177             a = c;
3178             var  s = p / 4;
3179         }
3180         else  {
3181             var  s = p / (2 * Math.PI) * Math.asin(c / a);
3182         }
3183
3184         return  a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
3185     },
3186
3187
3188     elasticBoth: function (t, b, c, d, a, p) {
3189         if (t == 0) {
3190             return  b;
3191         }
3192
3193         if ((t /= d / 2) == 2) {
3194             return  b + c;
3195         }
3196
3197         if (!p) {
3198             p = d * (.3 * 1.5);
3199         }
3200
3201         if (!a || a < Math.abs(c)) {
3202             a = c;
3203             var  s = p / 4;
3204         }
3205         else  {
3206             var  s = p / (2 * Math.PI) * Math.asin(c / a);
3207         }
3208
3209         if (t < 1) {
3210             return  -.5 * (a * Math.pow(2, 10 * (t -= 1)) *
3211                           Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
3212         }
3213         return  a * Math.pow(2, -10 * (t -= 1)) *
3214                Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
3215     },
3216
3217
3218
3219     backIn: function (t, b, c, d, s) {
3220         if (typeof  s == 'undefined') {
3221             s = 1.70158;
3222         }
3223         return  c * (t /= d) * t * ((s + 1) * t - s) + b;
3224     },
3225
3226
3227     backOut: function (t, b, c, d, s) {
3228         if (typeof  s == 'undefined') {
3229             s = 1.70158;
3230         }
3231         return  c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
3232     },
3233
3234
3235     backBoth: function (t, b, c, d, s) {
3236         if (typeof  s == 'undefined') {
3237             s = 1.70158;
3238         }
3239
3240         if ((t /= d / 2 ) < 1) {
3241             return  c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
3242         }
3243         return  c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
3244     },
3245
3246
3247     bounceIn: function (t, b, c, d) {
3248         return  c - Roo.lib.Easing.bounceOut(d - t, 0, c, d) + b;
3249     },
3250
3251
3252     bounceOut: function (t, b, c, d) {
3253         if ((t /= d) < (1 / 2.75)) {
3254             return  c * (7.5625 * t * t) + b;
3255         } else  if (t < (2 / 2.75)) {
3256             return  c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
3257         } else  if (t < (2.5 / 2.75)) {
3258             return  c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
3259         }
3260         return  c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
3261     },
3262
3263
3264     bounceBoth: function (t, b, c, d) {
3265         if (t < d / 2) {
3266             return  Roo.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b;
3267         }
3268         return  Roo.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
3269     }
3270 };
3271
3272
3273     (function() {
3274         Roo.lib.Motion = function(el, E, F, G) {
3275             if (el) {
3276                 Roo.lib.Motion.superclass.constructor.call(this, el, E, F, G);
3277             }
3278         };
3279
3280         Roo.extend(Roo.lib.Motion, Roo.lib.ColorAnim);
3281
3282
3283         var  Y = Roo.lib;
3284         var  A = Y.Motion.superclass;
3285         var  B = Y.Motion.prototype;
3286
3287         B.toString = function() {
3288             var  el = this.getEl();
3289             var  id = el.id || el.tagName;
3290             return  ("Motion " + id);
3291         };
3292
3293         B.patterns.points = /^points$/i;
3294
3295         B.setAttribute = function(E, F, G) {
3296             if (this.patterns.points.test(E)) {
3297                 G = G || 'px';
3298                 A.setAttribute.call(this, 'left', F[0], G);
3299                 A.setAttribute.call(this, 'top', F[1], G);
3300             } else  {
3301                 A.setAttribute.call(this, E, F, G);
3302             }
3303         };
3304
3305         B.getAttribute = function(E) {
3306             if (this.patterns.points.test(E)) {
3307                 var  val = [
3308                         A.getAttribute.call(this, 'left'),
3309                         A.getAttribute.call(this, 'top')
3310                         ];
3311             } else  {
3312                 val = A.getAttribute.call(this, E);
3313             }
3314
3315             return  val;
3316         };
3317
3318         B.doMethod = function(E, F, G) {
3319             var  H = null;
3320
3321             if (this.patterns.points.test(E)) {
3322                 var  t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
3323                 H = Y.Bezier.getPosition(this.runtimeAttributes[E], t);
3324             } else  {
3325                 H = A.doMethod.call(this, E, F, G);
3326             }
3327             return  H;
3328         };
3329
3330         B.setRuntimeAttribute = function(E) {
3331             if (this.patterns.points.test(E)) {
3332                 var  el = this.getEl();
3333                 var  attributes = this.attributes;
3334                 var  start;
3335                 var  control = attributes['points']['control'] || [];
3336                 var  end;
3337                 var  i, len;
3338
3339                 if (control.length > 0 && !(control[0]  instanceof  Array)) {
3340                     control = [control];
3341                 } else  {
3342                     var  tmp = [];
3343                     for (i = 0,len = control.length; i < len; ++i) {
3344                         tmp[i] = control[i];
3345                     }
3346
3347                     control = tmp;
3348                 }
3349
3350
3351                 Roo.fly(el).position();
3352
3353                 if (D(attributes['points']['from'])) {
3354                     Roo.lib.Dom.setXY(el, attributes['points']['from']);
3355                 }
3356                 else  {
3357                     Roo.lib.Dom.setXY(el, Roo.lib.Dom.getXY(el));
3358                 }
3359
3360
3361                 start = this.getAttribute('points');
3362
3363
3364                 if (D(attributes['points']['to'])) {
3365                     end = C.call(this, attributes['points']['to'], start);
3366
3367                     var  pageXY = Roo.lib.Dom.getXY(this.getEl());
3368                     for (i = 0,len = control.length; i < len; ++i) {
3369                         control[i] = C.call(this, control[i], start);
3370                     }
3371
3372
3373                 } else  if (D(attributes['points']['by'])) {
3374                     end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
3375
3376                     for (i = 0,len = control.length; i < len; ++i) {
3377                         control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
3378                     }
3379                 }
3380
3381
3382                 this.runtimeAttributes[E] = [start];
3383
3384                 if (control.length > 0) {
3385                     this.runtimeAttributes[E] = this.runtimeAttributes[E].concat(control);
3386                 }
3387
3388
3389                 this.runtimeAttributes[E][this.runtimeAttributes[E].length] = end;
3390             }
3391             else  {
3392                 A.setRuntimeAttribute.call(this, E);
3393             }
3394         };
3395
3396         var  C = function(E, F) {
3397             var  G = Roo.lib.Dom.getXY(this.getEl());
3398             E = [ E[0] - G[0] + F[0], E[1] - G[1] + F[1] ];
3399
3400             return  E;
3401         };
3402
3403         var  D = function(E) {
3404             return  (typeof  E !== 'undefined');
3405         };
3406     })();
3407
3408
3409
3410     (function() {
3411         Roo.lib.Scroll = function(el, C, D, E) {
3412             if (el) {
3413                 Roo.lib.Scroll.superclass.constructor.call(this, el, C, D, E);
3414             }
3415         };
3416
3417         Roo.extend(Roo.lib.Scroll, Roo.lib.ColorAnim);
3418
3419
3420         var  Y = Roo.lib;
3421         var  A = Y.Scroll.superclass;
3422         var  B = Y.Scroll.prototype;
3423
3424         B.toString = function() {
3425             var  el = this.getEl();
3426             var  id = el.id || el.tagName;
3427             return  ("Scroll " + id);
3428         };
3429
3430         B.doMethod = function(C, D, E) {
3431             var  F = null;
3432
3433             if (C == 'scroll') {
3434                 F = [
3435                         this.method(this.currentFrame, D[0], E[0] - D[0], this.totalFrames),
3436                         this.method(this.currentFrame, D[1], E[1] - D[1], this.totalFrames)
3437                         ];
3438
3439             } else  {
3440                 F = A.doMethod.call(this, C, D, E);
3441             }
3442             return  F;
3443         };
3444
3445         B.getAttribute = function(C) {
3446             var  D = null;
3447             var  el = this.getEl();
3448
3449             if (C == 'scroll') {
3450                 D = [ el.scrollLeft, el.scrollTop ];
3451             } else  {
3452                 D = A.getAttribute.call(this, C);
3453             }
3454
3455             return  D;
3456         };
3457
3458         B.setAttribute = function(C, D, E) {
3459             var  el = this.getEl();
3460
3461             if (C == 'scroll') {
3462                 el.scrollLeft = D[0];
3463                 el.scrollTop = D[1];
3464             } else  {
3465                 A.setAttribute.call(this, C, D, E);
3466             }
3467         };
3468     })();
3469
3470
3471
3472  
3473
3474
3475
3476 Roo.DomHelper = function(){
3477     var  A = null;
3478     var  B = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
3479     var  C = /^table|tbody|tr|td$/i;
3480     var  D = {};
3481     
3482     
3483
3484     var  E = function(o){
3485         if(typeof  o == 'string'){
3486             return  o;
3487         }
3488         var  b = "";
3489         if(!o.tag){
3490             o.tag = "div";
3491         }
3492
3493         b += "<" + o.tag;
3494         for(var  attr  in  o){
3495             if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof  o[attr] == "function") continue;
3496             if(attr == "style"){
3497                 var  s = o["style"];
3498                 if(typeof  s == "function"){
3499                     s = s.call();
3500                 }
3501                 if(typeof  s == "string"){
3502                     b += ' style="' + s + '"';
3503                 }else  if(typeof  s == "object"){
3504                     b += ' style="';
3505                     for(var  key  in  s){
3506                         if(typeof  s[key] != "function"){
3507                             b += key + ":" + s[key] + ";";
3508                         }
3509                     }
3510
3511                     b += '"';
3512                 }
3513             }else {
3514                 if(attr == "cls"){
3515                     b += ' class="' + o["cls"] + '"';
3516                 }else  if(attr == "htmlFor"){
3517                     b += ' for="' + o["htmlFor"] + '"';
3518                 }else {
3519                     b += " " + attr + '="' + o[attr] + '"';
3520                 }
3521             }
3522         }
3523         if(B.test(o.tag)){
3524             b += "/>";
3525         }else {
3526             b += ">";
3527             var  cn = o.children || o.cn;
3528             if(cn){
3529                 
3530                 if((cn  instanceof  Array) || (Roo.isSafari && typeof(cn.join) == "function")){
3531                     for(var  i = 0, len = cn.length; i < len; i++) {
3532                         b += E(cn[i], b);
3533                     }
3534                 }else {
3535                     b += E(cn, b);
3536                 }
3537             }
3538             if(o.html){
3539                 b += o.html;
3540             }
3541
3542             b += "</" + o.tag + ">";
3543         }
3544         return  b;
3545     };
3546
3547     
3548     
3549
3550     var  F = function(o, M){
3551          
3552         
3553         var  ns = false;
3554         if (o.ns && o.ns != 'html') {
3555                
3556             if (o.xmlns && typeof(D[o.ns]) == 'undefined') {
3557                 D[o.ns] = o.xmlns;
3558                 ns = o.xmlns;
3559             }
3560             if (typeof(D[o.ns]) == 'undefined') {
3561                 console.log("Trying to create namespace element " + o.ns + ", however no xmlns was sent to builder previously");
3562             }
3563
3564             ns = D[o.ns];
3565         }
3566         
3567         
3568         if (typeof(o) == 'string') {
3569             return  M.appendChild(document.createTextNode(o));
3570         }
3571
3572         o.tag = o.tag || div;
3573         if (o.ns && Roo.isIE) {
3574             ns = false;
3575             o.tag = o.ns + ':' + o.tag;
3576             
3577         }
3578         var  el = ns ? document.createElementNS( ns, o.tag||'div') :  document.createElement(o.tag||'div');
3579         var  N = el.setAttribute ? true : false; 
3580         for(var  attr  in  o){
3581             
3582             if(attr == "tag" || attr == "ns" ||attr == "xmlns" ||attr == "children" || attr == "cn" || attr == "html" || 
3583                     attr == "style" || typeof  o[attr] == "function") continue;
3584                     
3585             if(attr=="cls" && Roo.isIE){
3586                 el.className = o["cls"];
3587             }else {
3588                 if(N) el.setAttribute(attr=="cls" ? 'class' : attr, o[attr]);
3589                 else  el[attr] = o[attr];
3590             }
3591         }
3592
3593         Roo.DomHelper.applyStyles(el, o.style);
3594         var  cn = o.children || o.cn;
3595         if(cn){
3596             
3597              if((cn  instanceof  Array) || (Roo.isSafari && typeof(cn.join) == "function")){
3598                 for(var  i = 0, len = cn.length; i < len; i++) {
3599                     F(cn[i], el);
3600                 }
3601             }else {
3602                 F(cn, el);
3603             }
3604         }
3605         if(o.html){
3606             el.innerHTML = o.html;
3607         }
3608         if(M){
3609            M.appendChild(el);
3610         }
3611         return  el;
3612     };
3613
3614     var  G = function(M, s, h, e){
3615         A.innerHTML = [s, h, e].join('');
3616         var  i = -1, el = A;
3617         while(++i < M){
3618             el = el.firstChild;
3619         }
3620         return  el;
3621     };
3622
3623     
3624     var  ts = '<table>',
3625         te = '</table>',
3626         H = ts+'<tbody>',
3627         I = '</tbody>'+te,
3628         J = H + '<tr>',
3629         K = '</tr>'+I;
3630
3631     
3632
3633     var  L = function(M, N, el, O){
3634         if(!A){
3635             A = document.createElement('div');
3636         }
3637         var  P;
3638         var  Q = null;
3639         if(M == 'td'){
3640             if(N == 'afterbegin' || N == 'beforeend'){ 
3641                 return;
3642             }
3643             if(N == 'beforebegin'){
3644                 Q = el;
3645                 el = el.parentNode;
3646             } else {
3647                 Q = el.nextSibling;
3648                 el = el.parentNode;
3649             }
3650
3651             P = G(4, J, O, K);
3652         }
3653         else  if(M == 'tr'){
3654             if(N == 'beforebegin'){
3655                 Q = el;
3656                 el = el.parentNode;
3657                 P = G(3, H, O, I);
3658             } else  if(N == 'afterend'){
3659                 Q = el.nextSibling;
3660                 el = el.parentNode;
3661                 P = G(3, H, O, I);
3662             } else { 
3663                 if(N == 'afterbegin'){
3664                     Q = el.firstChild;
3665                 }
3666
3667                 P = G(4, J, O, K);
3668             }
3669         } else  if(M == 'tbody'){
3670             if(N == 'beforebegin'){
3671                 Q = el;
3672                 el = el.parentNode;
3673                 P = G(2, ts, O, te);
3674             } else  if(N == 'afterend'){
3675                 Q = el.nextSibling;
3676                 el = el.parentNode;
3677                 P = G(2, ts, O, te);
3678             } else {
3679                 if(N == 'afterbegin'){
3680                     Q = el.firstChild;
3681                 }
3682
3683                 P = G(3, H, O, I);
3684             }
3685         } else { 
3686             if(N == 'beforebegin' || N == 'afterend'){ 
3687                 return;
3688             }
3689             if(N == 'afterbegin'){
3690                 Q = el.firstChild;
3691             }
3692
3693             P = G(2, ts, O, te);
3694         }
3695
3696         el.insertBefore(P, Q);
3697         return  P;
3698     };
3699
3700     return  {
3701     
3702
3703     useDom : false,
3704
3705     
3706
3707     markup : function(o){
3708         return  E(o);
3709     },
3710
3711     
3712
3713     applyStyles : function(el, c){
3714         if(c){
3715            el = Roo.fly(el);
3716            if(typeof  c == "string"){
3717                var  re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
3718                var  matches;
3719                while ((matches = re.exec(c)) != null){
3720                    el.setStyle(matches[1], matches[2]);
3721                }
3722            }else  if (typeof  c == "object"){
3723                for (var  style  in  c){
3724                   el.setStyle(style, c[style]);
3725                }
3726            }else  if (typeof  c == "function"){
3727                 Roo.DomHelper.applyStyles(el, c.call());
3728            }
3729         }
3730     },
3731
3732     
3733
3734     insertHtml : function(d, el, e){
3735         d = d.toLowerCase();
3736         if(el.insertAdjacentHTML){
3737             if(C.test(el.tagName)){
3738                 var  rs;
3739                 if(rs = L(el.tagName.toLowerCase(), d, el, e)){
3740                     return  rs;
3741                 }
3742             }
3743             switch(d){
3744                 case  "beforebegin":
3745                     el.insertAdjacentHTML('BeforeBegin', e);
3746                     return  el.previousSibling;
3747                 case  "afterbegin":
3748                     el.insertAdjacentHTML('AfterBegin', e);
3749                     return  el.firstChild;
3750                 case  "beforeend":
3751                     el.insertAdjacentHTML('BeforeEnd', e);
3752                     return  el.lastChild;
3753                 case  "afterend":
3754                     el.insertAdjacentHTML('AfterEnd', e);
3755                     return  el.nextSibling;
3756             }
3757             throw  'Illegal insertion point -> "' + d + '"';
3758         }
3759         var  f = el.ownerDocument.createRange();
3760         var  g;
3761         switch(d){
3762              case  "beforebegin":
3763                 f.setStartBefore(el);
3764                 g = f.createContextualFragment(e);
3765                 el.parentNode.insertBefore(g, el);
3766                 return  el.previousSibling;
3767              case  "afterbegin":
3768                 if(el.firstChild){
3769                     f.setStartBefore(el.firstChild);
3770                     g = f.createContextualFragment(e);
3771                     el.insertBefore(g, el.firstChild);
3772                     return  el.firstChild;
3773                 }else {
3774                     el.innerHTML = e;
3775                     return  el.firstChild;
3776                 }
3777             case  "beforeend":
3778                 if(el.lastChild){
3779                     f.setStartAfter(el.lastChild);
3780                     g = f.createContextualFragment(e);
3781                     el.appendChild(g);
3782                     return  el.lastChild;
3783                 }else {
3784                     el.innerHTML = e;
3785                     return  el.lastChild;
3786                 }
3787             case  "afterend":
3788                 f.setStartAfter(el);
3789                 g = f.createContextualFragment(e);
3790                 el.parentNode.insertBefore(g, el.nextSibling);
3791                 return  el.nextSibling;
3792             }
3793             throw  'Illegal insertion point -> "' + d + '"';
3794     },
3795
3796     
3797
3798     insertBefore : function(el, o, h){
3799         return  this.doInsert(el, o, h, "beforeBegin");
3800     },
3801
3802     
3803
3804     insertAfter : function(el, o, j){
3805         return  this.doInsert(el, o, j, "afterEnd", "nextSibling");
3806     },
3807
3808     
3809
3810     insertFirst : function(el, o, k){
3811         return  this.doInsert(el, o, k, "afterBegin");
3812     },
3813
3814     
3815     doInsert : function(el, o, l, m, n){
3816         el = Roo.getDom(el);
3817         var  p;
3818         if(this.useDom || o.ns){
3819             p = F(o, null);
3820             el.parentNode.insertBefore(p, n ? el[n] : el);
3821         }else {
3822             var  e = E(o);
3823             p = this.insertHtml(m, el, e);
3824         }
3825         return  l ? Roo.get(p, true) : p;
3826     },
3827
3828     
3829
3830     append : function(el, o, q){
3831         el = Roo.getDom(el);
3832         var  r;
3833         if(this.useDom || o.ns){
3834             r = F(o, null);
3835             el.appendChild(r);
3836         }else {
3837             var  e = E(o);
3838             r = this.insertHtml("beforeEnd", el, e);
3839         }
3840         return  q ? Roo.get(r, true) : r;
3841     },
3842
3843     
3844
3845     overwrite : function(el, o, t){
3846         el = Roo.getDom(el);
3847         if (o.ns) {
3848           
3849             while (el.childNodes.length) {
3850                 el.removeChild(el.firstChild);
3851             }
3852
3853             F(o, el);
3854         } else  {
3855             el.innerHTML = E(o);   
3856         }
3857         
3858         return  t ? Roo.get(el.firstChild, true) : el.firstChild;
3859     },
3860
3861     
3862
3863     createTemplate : function(o){
3864         var  u = E(o);
3865         return  new  Roo.Template(u);
3866     }
3867     };
3868 }();
3869
3870
3871
3872  
3873
3874
3875 Roo.Template = function(A){
3876     
3877     if(A  instanceof  Array){
3878         A = A.join("");
3879     }else  if(arguments.length > 1){
3880         A = Array.prototype.join.call(arguments, "");
3881     }
3882     
3883     
3884     if (typeof(A) == 'object') {
3885         Roo.apply(this,A)
3886     } else  {
3887         
3888         this.html = A;
3889     }
3890     
3891     
3892 };
3893 Roo.Template.prototype = {
3894     
3895     
3896
3897     html : '',
3898     
3899
3900     applyTemplate : function(values){
3901         try {
3902             
3903             if(this.compiled){
3904                 return  this.compiled(values);
3905             }
3906             var  useF = this.disableFormats !== true;
3907             var  fm = Roo.util.Format, tpl = this;
3908             var  fn = function(m, E, F, G){
3909                 if(F && useF){
3910                     if(F.substr(0, 5) == "this."){
3911                         return  tpl.call(F.substr(5), values[E], values);
3912                     }else {
3913                         if(G){
3914                             
3915                             
3916                             
3917                             var  re = /^\s*['"](.*)["']\s*$/;
3918                             G = G.split(',');
3919                             for(var  i = 0, len = G.length; i < len; i++){
3920                                 G[i] = G[i].replace(re, "$1");
3921                             }
3922
3923                             G = [values[E]].concat(G);
3924                         }else {
3925                             G = [values[E]];
3926                         }
3927                         return  fm[F].apply(fm, G);
3928                     }
3929                 }else {
3930                     return  values[E] !== undefined ? values[E] : "";
3931                 }
3932             };
3933             return  this.html.replace(this.re, fn);
3934         } catch (e) {
3935             Roo.log(e);
3936             throw  e;
3937         }
3938          
3939     },
3940     
3941     
3942
3943     set : function(B, C){
3944         this.html = B;
3945         this.compiled = null;
3946         if(C){
3947             this.compile();
3948         }
3949         return  this;
3950     },
3951     
3952     
3953
3954     disableFormats : false,
3955     
3956     
3957
3958     re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
3959     
3960     
3961
3962     compile : function(){
3963         var  fm = Roo.util.Format;
3964         var  D = this.disableFormats !== true;
3965         var  E = Roo.isGecko ? "+" : ",";
3966         var  fn = function(m, G, H, I){
3967             if(H && D){
3968                 I = I ? ',' + I : "";
3969                 if(H.substr(0, 5) != "this."){
3970                     H = "fm." + H + '(';
3971                 }else {
3972                     H = 'this.call("'+ H.substr(5) + '", ';
3973                     I = ", values";
3974                 }
3975             }else {
3976                 I= ''; H = "(values['" + G + "'] == undefined ? '' : ";
3977             }
3978             return  "'"+ E + H + "values['" + G + "']" + I + ")"+E+"'";
3979         };
3980         var  F;
3981         
3982         if(Roo.isGecko){
3983             F = "this.compiled = function(values){ return '" +
3984                    this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
3985                     "';};";
3986         }else {
3987             F = ["this.compiled = function(values){ return ['"];
3988             F.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
3989             F.push("'].join('');};");
3990             F = F.join('');
3991         }
3992         
3993
3994         eval(F);
3995         return  this;
3996     },
3997     
3998     
3999     call : function(G, H, I){
4000         return  this[G](H, I);
4001     },
4002     
4003     
4004
4005     insertFirst: function(el, J, K){
4006         return  this.doInsert('afterBegin', el, J, K);
4007     },
4008
4009     
4010
4011     insertBefore: function(el, L, M){
4012         return  this.doInsert('beforeBegin', el, L, M);
4013     },
4014
4015     
4016
4017     insertAfter : function(el, N, O){
4018         return  this.doInsert('afterEnd', el, N, O);
4019     },
4020     
4021     
4022
4023     append : function(el, P, Q){
4024         return  this.doInsert('beforeEnd', el, P, Q);
4025     },
4026
4027     doInsert : function(R, el, S, T){
4028         el = Roo.getDom(el);
4029         var  U = Roo.DomHelper.insertHtml(R, el, this.applyTemplate(S));
4030         return  T ? Roo.get(U, true) : U;
4031     },
4032
4033     
4034
4035     overwrite : function(el, V, W){
4036         el = Roo.getDom(el);
4037         el.innerHTML = this.applyTemplate(V);
4038         return  W ? Roo.get(el.firstChild, true) : el.firstChild;
4039     }
4040 };
4041
4042
4043 Roo.Template.prototype.apply = Roo.Template.prototype.applyTemplate;
4044
4045
4046 Roo.DomHelper.Template = Roo.Template;
4047
4048
4049
4050 Roo.Template.from = function(el){
4051     el = Roo.getDom(el);
4052     return  new  Roo.Template(el.value || el.innerHTML);
4053 };
4054
4055
4056  
4057
4058
4059
4060
4061
4062 Roo.DomQuery = function(){
4063     var  A = {}, simpleCache = {}, valueCache = {};
4064     var  B = /\S/;
4065     var  C = /^\s+|\s+$/g;
4066     var  D = /\{(\d+)\}/g;
4067     var  E = /^(\s?[\/>+~]\s?|\s|$)/;
4068     var  F = /^(#)?([\w-\*]+)/;
4069     var  G = /(\d*)n\+?(\d*)/, H = /\D/;
4070
4071     function  I(p, T){
4072         var  i = 0;
4073         var  n = p.firstChild;
4074         while(n){
4075             if(n.nodeType == 1){
4076                if(++i == T){
4077                    return  n;
4078                }
4079             }
4080
4081             n = n.nextSibling;
4082         }
4083         return  null;
4084     };
4085
4086     function  J(n){
4087         while((n = n.nextSibling) && n.nodeType != 1);
4088         return  n;
4089     };
4090
4091     function  K(n){
4092         while((n = n.previousSibling) && n.nodeType != 1);
4093         return  n;
4094     };
4095
4096     function  L(d){
4097         var  n = d.firstChild, ni = -1;
4098             while(n){
4099                 var  nx = n.nextSibling;
4100                 if(n.nodeType == 3 && !B.test(n.nodeValue)){
4101                     d.removeChild(n);
4102                 }else {
4103                     n.nodeIndex = ++ni;
4104                 }
4105
4106                 n = nx;
4107             }
4108             return  this;
4109         };
4110
4111     function  byClassName(c, a, v){
4112         if(!v){
4113             return  c;
4114         }
4115         var  r = [], ri = -1, cn;
4116         for(var  i = 0, ci; ci = c[i]; i++){
4117             if((' '+ci.className+' ').indexOf(v) != -1){
4118                 r[++ri] = ci;
4119             }
4120         }
4121         return  r;
4122     };
4123
4124     function  attrValue(n, T){
4125         if(!n.tagName && typeof  n.length != "undefined"){
4126             n = n[0];
4127         }
4128         if(!n){
4129             return  null;
4130         }
4131         if(T == "for"){
4132             return  n.htmlFor;
4133         }
4134         if(T == "class" || T == "className"){
4135             return  n.className;
4136         }
4137         return  n.getAttribute(T) || n[T];
4138
4139     };
4140
4141     function  getNodes(ns, T, U){
4142         var  V = [], ri = -1, cs;
4143         if(!ns){
4144             return  V;
4145         }
4146
4147         U = U || "*";
4148         if(typeof  ns.getElementsByTagName != "undefined"){
4149             ns = [ns];
4150         }
4151         if(!T){
4152             for(var  i = 0, ni; ni = ns[i]; i++){
4153                 cs = ni.getElementsByTagName(U);
4154                 for(var  j = 0, ci; ci = cs[j]; j++){
4155                     V[++ri] = ci;
4156                 }
4157             }
4158         }else  if(T == "/" || T == ">"){
4159             var  utag = U.toUpperCase();
4160             for(var  i = 0, ni, cn; ni = ns[i]; i++){
4161                 cn = ni.children || ni.childNodes;
4162                 for(var  j = 0, cj; cj = cn[j]; j++){
4163                     if(cj.nodeName == utag || cj.nodeName == U  || U == '*'){
4164                         V[++ri] = cj;
4165                     }
4166                 }
4167             }
4168         }else  if(T == "+"){
4169             var  utag = U.toUpperCase();
4170             for(var  i = 0, n; n = ns[i]; i++){
4171                 while((n = n.nextSibling) && n.nodeType != 1);
4172                 if(n && (n.nodeName == utag || n.nodeName == U || U == '*')){
4173                     V[++ri] = n;
4174                 }
4175             }
4176         }else  if(T == "~"){
4177             for(var  i = 0, n; n = ns[i]; i++){
4178                 while((n = n.nextSibling) && (n.nodeType != 1 || (U == '*' || n.tagName.toLowerCase()!=U)));
4179                 if(n){
4180                     V[++ri] = n;
4181                 }
4182             }
4183         }
4184         return  V;
4185     };
4186
4187     function  M(a, b){
4188         if(b.slice){
4189             return  a.concat(b);
4190         }
4191         for(var  i = 0, l = b.length; i < l; i++){
4192             a[a.length] = b[i];
4193         }
4194         return  a;
4195     }
4196
4197     function  byTag(cs, T){
4198         if(cs.tagName || cs == document){
4199             cs = [cs];
4200         }
4201         if(!T){
4202             return  cs;
4203         }
4204         var  r = [], ri = -1;
4205         T = T.toLowerCase();
4206         for(var  i = 0, ci; ci = cs[i]; i++){
4207             if(ci.nodeType == 1 && ci.tagName.toLowerCase()==T){
4208                 r[++ri] = ci;
4209             }
4210         }
4211         return  r;
4212     };
4213
4214     function  N(cs, T, id){
4215         if(cs.tagName || cs == document){
4216             cs = [cs];
4217         }
4218         if(!id){
4219             return  cs;
4220         }
4221         var  r = [], ri = -1;
4222         for(var  i = 0,ci; ci = cs[i]; i++){
4223             if(ci && ci.id == id){
4224                 r[++ri] = ci;
4225                 return  r;
4226             }
4227         }
4228         return  r;
4229     };
4230
4231     function  byAttribute(cs, T, U, op, V){
4232         var  r = [], ri = -1, st = V=="{";
4233         var  f = Roo.DomQuery.operators[op];
4234         for(var  i = 0, ci; ci = cs[i]; i++){
4235             var  a;
4236             if(st){
4237                 a = Roo.DomQuery.getStyle(ci, T);
4238             }
4239             else  if(T == "class" || T == "className"){
4240                 a = ci.className;
4241             }else  if(T == "for"){
4242                 a = ci.htmlFor;
4243             }else  if(T == "href"){
4244                 a = ci.getAttribute("href", 2);
4245             }else {
4246                 a = ci.getAttribute(T);
4247             }
4248             if((f && f(a, U)) || (!f && a)){
4249                 r[++ri] = ci;
4250             }
4251         }
4252         return  r;
4253     };
4254
4255     function  byPseudo(cs, T, U){
4256         return  Roo.DomQuery.pseudos[T](cs, U);
4257     };
4258
4259     
4260     
4261     
4262     var  O = window.ActiveXObject ? true : false;
4263
4264     
4265     
4266     
4267     
4268
4269     var  batch = 30803; 
4270
4271     var  P = 30803;
4272
4273     function  Q(cs){
4274         var  d = ++P;
4275         cs[0].setAttribute("_nodup", d);
4276         var  r = [cs[0]];
4277         for(var  i = 1, len = cs.length; i < len; i++){
4278             var  c = cs[i];
4279             if(!c.getAttribute("_nodup") != d){
4280                 c.setAttribute("_nodup", d);
4281                 r[r.length] = c;
4282             }
4283         }
4284         for(var  i = 0, len = cs.length; i < len; i++){
4285             cs[i].removeAttribute("_nodup");
4286         }
4287         return  r;
4288     }
4289
4290     function  nodup(cs){
4291         if(!cs){
4292             return  [];
4293         }
4294         var  T = cs.length, c, i, r = cs, cj, ri = -1;
4295         if(!T || typeof  cs.nodeType != "undefined" || T == 1){
4296             return  cs;
4297         }
4298         if(O && typeof  cs[0].selectSingleNode != "undefined"){
4299             return  Q(cs);
4300         }
4301         var  d = ++P;
4302         cs[0]._nodup = d;
4303         for(i = 1; c = cs[i]; i++){
4304             if(c._nodup != d){
4305                 c._nodup = d;
4306             }else {
4307                 r = [];
4308                 for(var  j = 0; j < i; j++){
4309                     r[++ri] = cs[j];
4310                 }
4311                 for(j = i+1; cj = cs[j]; j++){
4312                     if(cj._nodup != d){
4313                         cj._nodup = d;
4314                         r[++ri] = cj;
4315                     }
4316                 }
4317                 return  r;
4318             }
4319         }
4320         return  r;
4321     }
4322
4323     function  R(c1, c2){
4324         var  d = ++P;
4325         for(var  i = 0, len = c1.length; i < len; i++){
4326             c1[i].setAttribute("_qdiff", d);
4327         }
4328         var  r = [];
4329         for(var  i = 0, len = c2.length; i < len; i++){
4330             if(c2[i].getAttribute("_qdiff") != d){
4331                 r[r.length] = c2[i];
4332             }
4333         }
4334         for(var  i = 0, len = c1.length; i < len; i++){
4335            c1[i].removeAttribute("_qdiff");
4336         }
4337         return  r;
4338     }
4339
4340     function  S(c1, c2){
4341         var  T = c1.length;
4342         if(!T){
4343             return  c2;
4344         }
4345         if(O && c1[0].selectSingleNode){
4346             return  R(c1, c2);
4347         }
4348         var  d = ++P;
4349         for(var  i = 0; i < T; i++){
4350             c1[i]._qdiff = d;
4351         }
4352         var  r = [];
4353         for(var  i = 0, len = c2.length; i < len; i++){
4354             if(c2[i]._qdiff != d){
4355                 r[r.length] = c2[i];
4356             }
4357         }
4358         return  r;
4359     }
4360
4361     function  quickId(ns, T, U, id){
4362         if(ns == U){
4363            var  d = U.ownerDocument || U;
4364            return  d.getElementById(id);
4365         }
4366
4367         ns = getNodes(ns, T, "*");
4368         return  N(ns, null, id);
4369     }
4370
4371     return  {
4372         getStyle : function(el, AA){
4373             return  Roo.fly(el).getStyle(AA);
4374         },
4375         
4376
4377         compile : function(AB, AC){
4378             AC = AC || "select";
4379             
4380             var  fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
4381             var  q = AB, mode, lq;
4382             var  tk = Roo.DomQuery.matchers;
4383             var  AD = tk.length;
4384             var  mm;
4385
4386             
4387             var  AE = q.match(E);
4388             if(AE && AE[1]){
4389                 fn[fn.length] = 'mode="'+AE[1].replace(C, "")+'";';
4390                 q = q.replace(AE[1], "");
4391             }
4392             
4393             while(AB.substr(0, 1)=="/"){
4394                 AB = AB.substr(1);
4395             }
4396
4397             while(q && lq != q){
4398                 lq = q;
4399                 var  tm = q.match(F);
4400                 if(AC == "select"){
4401                     if(tm){
4402                         if(tm[1] == "#"){
4403                             fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
4404                         }else {
4405                             fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
4406                         }
4407
4408                         q = q.replace(tm[0], "");
4409                     }else  if(q.substr(0, 1) != '@'){
4410                         fn[fn.length] = 'n = getNodes(n, mode, "*");';
4411                     }
4412                 }else {
4413                     if(tm){
4414                         if(tm[1] == "#"){
4415                             fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
4416                         }else {
4417                             fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
4418                         }
4419
4420                         q = q.replace(tm[0], "");
4421                     }
4422                 }
4423                 while(!(mm = q.match(E))){
4424                     var  matched = false;
4425                     for(var  j = 0; j < AD; j++){
4426                         var  t = tk[j];
4427                         var  m = q.match(t.re);
4428                         if(m){
4429                             fn[fn.length] = t.select.replace(D, function(x, i){
4430                                                     return  m[i];
4431                                                 });
4432                             q = q.replace(m[0], "");
4433                             matched = true;
4434                             break;
4435                         }
4436                     }
4437                     
4438                     if(!matched){
4439                         throw  'Error parsing selector, parsing failed at "' + q + '"';
4440                     }
4441                 }
4442                 if(mm[1]){
4443                     fn[fn.length] = 'mode="'+mm[1].replace(C, "")+'";';
4444                     q = q.replace(mm[1], "");
4445                 }
4446             }
4447
4448             fn[fn.length] = "return nodup(n);\n}";
4449             
4450              
4451  
4452             eval(fn.join(""));
4453             return  f;
4454         },
4455
4456         
4457
4458         select : function(AF, AG, AH){
4459             if(!AG || AG == document){
4460                 AG = document;
4461             }
4462             if(typeof  AG == "string"){
4463                 AG = document.getElementById(AG);
4464             }
4465             var  AI = AF.split(",");
4466             var  AJ = [];
4467             for(var  i = 0, len = AI.length; i < len; i++){
4468                 var  p = AI[i].replace(C, "");
4469                 if(!A[p]){
4470                     A[p] = Roo.DomQuery.compile(p);
4471                     if(!A[p]){
4472                         throw  p + " is not a valid selector";
4473                     }
4474                 }
4475                 var  z = A[p](AG);
4476                 if(z && z != document){
4477                     AJ = AJ.concat(z);
4478                 }
4479             }
4480             if(AI.length > 1){
4481                 return  nodup(AJ);
4482             }
4483             return  AJ;
4484         },
4485
4486         
4487
4488         selectNode : function(AK, AL){
4489             return  Roo.DomQuery.select(AK, AL)[0];
4490         },
4491
4492         
4493
4494         selectValue : function(AM, AN, AO){
4495             AM = AM.replace(C, "");
4496             if(!valueCache[AM]){
4497                 valueCache[AM] = Roo.DomQuery.compile(AM, "select");
4498             }
4499             var  n = valueCache[AM](AN);
4500             n = n[0] ? n[0] : n;
4501             var  v = (n && n.firstChild ? n.firstChild.nodeValue : null);
4502             return  ((v === null||v === undefined||v==='') ? AO : v);
4503         },
4504
4505         
4506
4507         selectNumber : function(AP, AQ, AR){
4508             var  v = Roo.DomQuery.selectValue(AP, AQ, AR || 0);
4509             return  parseFloat(v);
4510         },
4511
4512         
4513
4514         is : function(el, ss){
4515             if(typeof  el == "string"){
4516                 el = document.getElementById(el);
4517             }
4518             var  AS = (el  instanceof  Array);
4519             var  AT = Roo.DomQuery.filter(AS ? el : [el], ss);
4520             return  AS ? (AT.length == el.length) : (AT.length > 0);
4521         },
4522
4523         
4524
4525         filter : function(AU, ss, AV){
4526             ss = ss.replace(C, "");
4527             if(!simpleCache[ss]){
4528                 simpleCache[ss] = Roo.DomQuery.compile(ss, "simple");
4529             }
4530             var  AW = simpleCache[ss](AU);
4531             return  AV ? S(AW, AU) : AW;
4532         },
4533
4534         
4535
4536         matchers : [{
4537                 re: /^\.([\w-]+)/,
4538                 select: 'n = byClassName(n, null, " {1} ");'
4539             }, {
4540                 re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
4541                 select: 'n = byPseudo(n, "{1}", "{2}");'
4542             },{
4543                 re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
4544                 select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
4545             }, {
4546                 re: /^#([\w-]+)/,
4547                 select: 'n = byId(n, null, "{1}");'
4548             },{
4549                 re: /^@([\w-]+)/,
4550                 select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
4551             }
4552         ],
4553
4554         
4555
4556         operators : {
4557             "=" : function(a, v){
4558                 return  a == v;
4559             },
4560             "!=" : function(a, v){
4561                 return  a != v;
4562             },
4563             "^=" : function(a, v){
4564                 return  a && a.substr(0, v.length) == v;
4565             },
4566             "$=" : function(a, v){
4567                 return  a && a.substr(a.length-v.length) == v;
4568             },
4569             "*=" : function(a, v){
4570                 return  a && a.indexOf(v) !== -1;
4571             },
4572             "%=" : function(a, v){
4573                 return  (a % v) == 0;
4574             },
4575             "|=" : function(a, v){
4576                 return  a && (a == v || a.substr(0, v.length+1) == v+'-');
4577             },
4578             "~=" : function(a, v){
4579                 return  a && (' '+a+' ').indexOf(' '+v+' ') != -1;
4580             }
4581         },
4582
4583         
4584
4585         pseudos : {
4586             "first-child" : function(c){
4587                 var  r = [], ri = -1, n;
4588                 for(var  i = 0, ci; ci = n = c[i]; i++){
4589                     while((n = n.previousSibling) && n.nodeType != 1);
4590                     if(!n){
4591                         r[++ri] = ci;
4592                     }
4593                 }
4594                 return  r;
4595             },
4596
4597             "last-child" : function(c){
4598                 var  r = [], ri = -1, n;
4599                 for(var  i = 0, ci; ci = n = c[i]; i++){
4600                     while((n = n.nextSibling) && n.nodeType != 1);
4601                     if(!n){
4602                         r[++ri] = ci;
4603                     }
4604                 }
4605                 return  r;
4606             },
4607
4608             "nth-child" : function(c, a) {
4609                 var  r = [], ri = -1;
4610                 var  m = G.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !H.test(a) && "n+" + a || a);
4611                 var  f = (m[1] || 1) - 0, l = m[2] - 0;
4612                 for(var  i = 0, n; n = c[i]; i++){
4613                     var  pn = n.parentNode;
4614                     if (batch != pn._batch) {
4615                         var  j = 0;
4616                         for(var  cn = pn.firstChild; cn; cn = cn.nextSibling){
4617                             if(cn.nodeType == 1){
4618                                cn.nodeIndex = ++j;
4619                             }
4620                         }
4621
4622                         pn._batch = batch;
4623                     }
4624                     if (f == 1) {
4625                         if (l == 0 || n.nodeIndex == l){
4626                             r[++ri] = n;
4627                         }
4628                     } else  if ((n.nodeIndex + l) % f == 0){
4629                         r[++ri] = n;
4630                     }
4631                 }
4632
4633                 return  r;
4634             },
4635
4636             "only-child" : function(c){
4637                 var  r = [], ri = -1;;
4638                 for(var  i = 0, ci; ci = c[i]; i++){
4639                     if(!K(ci) && !J(ci)){
4640                         r[++ri] = ci;
4641                     }
4642                 }
4643                 return  r;
4644             },
4645
4646             "empty" : function(c){
4647                 var  r = [], ri = -1;
4648                 for(var  i = 0, ci; ci = c[i]; i++){
4649                     var  cns = ci.childNodes, j = 0, cn, empty = true;
4650                     while(cn = cns[j]){
4651                         ++j;
4652                         if(cn.nodeType == 1 || cn.nodeType == 3){
4653                             empty = false;
4654                             break;
4655                         }
4656                     }
4657                     if(empty){
4658                         r[++ri] = ci;
4659                     }
4660                 }
4661                 return  r;
4662             },
4663
4664             "contains" : function(c, v){
4665                 var  r = [], ri = -1;
4666                 for(var  i = 0, ci; ci = c[i]; i++){
4667                     if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
4668                         r[++ri] = ci;
4669                     }
4670                 }
4671                 return  r;
4672             },
4673
4674             "nodeValue" : function(c, v){
4675                 var  r = [], ri = -1;
4676                 for(var  i = 0, ci; ci = c[i]; i++){
4677                     if(ci.firstChild && ci.firstChild.nodeValue == v){
4678                         r[++ri] = ci;
4679                     }
4680                 }
4681                 return  r;
4682             },
4683
4684             "checked" : function(c){
4685                 var  r = [], ri = -1;
4686                 for(var  i = 0, ci; ci = c[i]; i++){
4687                     if(ci.checked == true){
4688                         r[++ri] = ci;
4689                     }
4690                 }
4691                 return  r;
4692             },
4693
4694             "not" : function(c, ss){
4695                 return  Roo.DomQuery.filter(c, ss, true);
4696             },
4697
4698             "odd" : function(c){
4699                 return  this["nth-child"](c, "odd");
4700             },
4701
4702             "even" : function(c){
4703                 return  this["nth-child"](c, "even");
4704             },
4705
4706             "nth" : function(c, a){
4707                 return  c[a-1] || [];
4708             },
4709
4710             "first" : function(c){
4711                 return  c[0] || [];
4712             },
4713
4714             "last" : function(c){
4715                 return  c[c.length-1] || [];
4716             },
4717
4718             "has" : function(c, ss){
4719                 var  s = Roo.DomQuery.select;
4720                 var  r = [], ri = -1;
4721                 for(var  i = 0, ci; ci = c[i]; i++){
4722                     if(s(ss, ci).length > 0){
4723                         r[++ri] = ci;
4724                     }
4725                 }
4726                 return  r;
4727             },
4728
4729             "next" : function(c, ss){
4730                 var  is = Roo.DomQuery.is;
4731                 var  r = [], ri = -1;
4732                 for(var  i = 0, ci; ci = c[i]; i++){
4733                     var  n = J(ci);
4734                     if(n && is(n, ss)){
4735                         r[++ri] = ci;
4736                     }
4737                 }
4738                 return  r;
4739             },
4740
4741             "prev" : function(c, ss){
4742                 var  is = Roo.DomQuery.is;
4743                 var  r = [], ri = -1;
4744                 for(var  i = 0, ci; ci = c[i]; i++){
4745                     var  n = K(ci);
4746                     if(n && is(n, ss)){
4747                         r[++ri] = ci;
4748                     }
4749                 }
4750                 return  r;
4751             }
4752         }
4753     };
4754 }();
4755
4756
4757
4758 Roo.query = Roo.DomQuery.select;
4759
4760
4761
4762
4763
4764
4765
4766 Roo.util.Observable = function(A){
4767     
4768     A = A|| {};
4769     this.addEvents(A.events || {});
4770     if (A.events) {
4771         delete  A.events; 
4772     }
4773
4774      
4775     Roo.apply(this, A);
4776     
4777     if(this.listeners){
4778         this.on(this.listeners);
4779         delete  this.listeners;
4780     }
4781 };
4782 Roo.util.Observable.prototype = {
4783     
4784
4785     
4786     
4787     
4788
4789     fireEvent : function(){
4790         var  ce = this.events[arguments[0].toLowerCase()];
4791         if(typeof  ce == "object"){
4792             return  ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
4793         }else {
4794             return  true;
4795         }
4796     },
4797
4798     
4799     filterOptRe : /^(?:scope|delay|buffer|single)$/,
4800
4801     
4802
4803     addListener : function(B, fn, C, o){
4804         if(typeof  B == "object"){
4805             o = B;
4806             for(var  e  in  o){
4807                 if(this.filterOptRe.test(e)){
4808                     continue;
4809                 }
4810                 if(typeof  o[e] == "function"){
4811                     
4812                     this.addListener(e, o[e], o.scope,  o);
4813                 }else {
4814                     
4815                     this.addListener(e, o[e].fn, o[e].scope, o[e]);
4816                 }
4817             }
4818             return;
4819         }
4820
4821         o = (!o || typeof  o == "boolean") ? {} : o;
4822         B = B.toLowerCase();
4823         var  ce = this.events[B] || true;
4824         if(typeof  ce == "boolean"){
4825             ce = new  Roo.util.Event(this, B);
4826             this.events[B] = ce;
4827         }
4828
4829         ce.addListener(fn, C, o);
4830     },
4831
4832     
4833
4834     removeListener : function(D, fn, E){
4835         var  ce = this.events[D.toLowerCase()];
4836         if(typeof  ce == "object"){
4837             ce.removeListener(fn, E);
4838         }
4839     },
4840
4841     
4842
4843     purgeListeners : function(){
4844         for(var  evt  in  this.events){
4845             if(typeof  this.events[evt] == "object"){
4846                  this.events[evt].clearListeners();
4847             }
4848         }
4849     },
4850
4851     relayEvents : function(o, F){
4852         var  G = function(H){
4853             return  function(){
4854                 return  this.fireEvent.apply(this, Roo.combine(H, Array.prototype.slice.call(arguments, 0)));
4855             };
4856         };
4857         for(var  i = 0, len = F.length; i < len; i++){
4858             var  ename = F[i];
4859             if(!this.events[ename]){ this.events[ename] = true; };
4860             o.on(ename, G(ename), this);
4861         }
4862     },
4863
4864     
4865
4866     addEvents : function(o){
4867         if(!this.events){
4868             this.events = {};
4869         }
4870
4871         Roo.applyIf(this.events, o);
4872     },
4873
4874     
4875
4876     hasListener : function(H){
4877         var  e = this.events[H];
4878         return  typeof  e == "object" && e.listeners.length > 0;
4879     }
4880 };
4881
4882
4883 Roo.util.Observable.prototype.on = Roo.util.Observable.prototype.addListener;
4884
4885
4886 Roo.util.Observable.prototype.un = Roo.util.Observable.prototype.removeListener;
4887
4888
4889
4890 Roo.util.Observable.capture = function(o, fn, I){
4891     o.fireEvent = o.fireEvent.createInterceptor(fn, I);
4892 };
4893
4894
4895
4896 Roo.util.Observable.releaseCapture = function(o){
4897     o.fireEvent = Roo.util.Observable.prototype.fireEvent;
4898 };
4899
4900 (function(){
4901
4902     var  J = function(h, o, M){
4903         var  N = new  Roo.util.DelayedTask();
4904         return  function(){
4905             N.delay(o.buffer, h, M, Array.prototype.slice.call(arguments, 0));
4906         };
4907     };
4908
4909     var  K = function(h, e, fn, M){
4910         return  function(){
4911             e.removeListener(fn, M);
4912             return  h.apply(M, arguments);
4913         };
4914     };
4915
4916     var  L = function(h, o, M){
4917         return  function(){
4918             var  N = Array.prototype.slice.call(arguments, 0);
4919             setTimeout(function(){
4920                 h.apply(M, N);
4921             }, o.delay || 10);
4922         };
4923     };
4924
4925     Roo.util.Event = function(M, N){
4926         this.name = N;
4927         this.obj = M;
4928         this.listeners = [];
4929     };
4930
4931     Roo.util.Event.prototype = {
4932         addListener : function(fn, M, N){
4933             var  o = N || {};
4934             M = M || this.obj;
4935             if(!this.isListening(fn, M)){
4936                 var  l = {fn: fn, scope: M, options: o};
4937                 var  h = fn;
4938                 if(o.delay){
4939                     h = L(h, o, M);
4940                 }
4941                 if(o.single){
4942                     h = K(h, this, fn, M);
4943                 }
4944                 if(o.buffer){
4945                     h = J(h, o, M);
4946                 }
4947
4948                 l.fireFn = h;
4949                 if(!this.firing){ 
4950                     this.listeners.push(l);
4951                 }else {
4952                     this.listeners = this.listeners.slice(0);
4953                     this.listeners.push(l);
4954                 }
4955             }
4956         },
4957
4958         findListener : function(fn, O){
4959             O = O || this.obj;
4960             var  ls = this.listeners;
4961             for(var  i = 0, len = ls.length; i < len; i++){
4962                 var  l = ls[i];
4963                 if(l.fn == fn && l.scope == O){
4964                     return  i;
4965                 }
4966             }
4967             return  -1;
4968         },
4969
4970         isListening : function(fn, P){
4971             return  this.findListener(fn, P) != -1;
4972         },
4973
4974         removeListener : function(fn, Q){
4975             var  R;
4976             if((R = this.findListener(fn, Q)) != -1){
4977                 if(!this.firing){
4978                     this.listeners.splice(R, 1);
4979                 }else {
4980                     this.listeners = this.listeners.slice(0);
4981                     this.listeners.splice(R, 1);
4982                 }
4983                 return  true;
4984             }
4985             return  false;
4986         },
4987
4988         clearListeners : function(){
4989             this.listeners = [];
4990         },
4991
4992         fire : function(){
4993             var  ls = this.listeners, S, T = ls.length;
4994             if(T > 0){
4995                 this.firing = true;
4996                 var  args = Array.prototype.slice.call(arguments, 0);
4997                 for(var  i = 0; i < T; i++){
4998                     var  l = ls[i];
4999                     if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
5000                         this.firing = false;
5001                         return  false;
5002                     }
5003                 }
5004
5005                 this.firing = false;
5006             }
5007             return  true;
5008         }
5009     };
5010 })();
5011
5012
5013
5014
5015
5016 Roo.EventManager = function(){
5017     var  A, B, C = false;
5018     var  F, G, H, I;
5019     var  E = Roo.lib.Event;
5020     var  D = Roo.lib.Dom;
5021
5022
5023     var  J = function(){
5024         if(!C){
5025             C = true;
5026             Roo.isReady = true;
5027             if(B){
5028                 clearInterval(B);
5029             }
5030             if(Roo.isGecko || Roo.isOpera) {
5031                 document.removeEventListener("DOMContentLoaded", J, false);
5032             }
5033             if(Roo.isIE){
5034                 var  defer = document.getElementById("ie-deferred-loader");
5035                 if(defer){
5036                     defer.onreadystatechange = null;
5037                     defer.parentNode.removeChild(defer);
5038                 }
5039             }
5040             if(A){
5041                 A.fire();
5042                 A.clearListeners();
5043             }
5044         }
5045     };
5046     
5047     var  K = function(){
5048         A = new  Roo.util.Event();
5049         if(Roo.isGecko || Roo.isOpera) {
5050             document.addEventListener("DOMContentLoaded", J, false);
5051         }else  if(Roo.isIE){
5052             document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
5053             var  defer = document.getElementById("ie-deferred-loader");
5054             defer.onreadystatechange = function(){
5055                 if(this.readyState == "complete"){
5056                     J();
5057                 }
5058             };
5059         }else  if(Roo.isSafari){ 
5060             B = setInterval(function(){
5061                 var  rs = document.readyState;
5062                 if(rs == "complete") {
5063                     J();     
5064                  }
5065             }, 10);
5066         }
5067
5068         
5069         E.on(window, "load", J);
5070     };
5071
5072     var  L = function(h, o){
5073         var  S = new  Roo.util.DelayedTask(h);
5074         return  function(e){
5075             
5076             e = new  Roo.EventObjectImpl(e);
5077             S.delay(o.buffer, h, null, [e]);
5078         };
5079     };
5080
5081     var  M = function(h, el, S, fn){
5082         return  function(e){
5083             Roo.EventManager.removeListener(el, S, fn);
5084             h(e);
5085         };
5086     };
5087
5088     var  N = function(h, o){
5089         return  function(e){
5090             
5091             e = new  Roo.EventObjectImpl(e);
5092             setTimeout(function(){
5093                 h(e);
5094             }, o.delay || 10);
5095         };
5096     };
5097
5098     var  O = function(S, T, U, fn, V){
5099         var  o = (!U || typeof  U == "boolean") ? {} : U;
5100         fn = fn || o.fn; V = V || o.scope;
5101         var  el = Roo.getDom(S);
5102         if(!el){
5103             throw  "Error listening for \"" + T + '\". Element "' + S + '" doesn\'t exist.';
5104         }
5105         var  h = function(e){
5106             e = Roo.EventObject.setEvent(e);
5107             var  t;
5108             if(o.delegate){
5109                 t = e.getTarget(o.delegate, el);
5110                 if(!t){
5111                     return;
5112                 }
5113             }else {
5114                 t = e.target;
5115             }
5116             if(o.stopEvent === true){
5117                 e.stopEvent();
5118             }
5119             if(o.preventDefault === true){
5120                e.preventDefault();
5121             }
5122             if(o.stopPropagation === true){
5123                 e.stopPropagation();
5124             }
5125
5126             if(o.normalized === false){
5127                 e = e.browserEvent;
5128             }
5129
5130
5131             fn.call(V || el, e, t, o);
5132         };
5133         if(o.delay){
5134             h = N(h, o);
5135         }
5136         if(o.single){
5137             h = M(h, el, T, fn);
5138         }
5139         if(o.buffer){
5140             h = L(h, o);
5141         }
5142
5143         fn._handlers = fn._handlers || [];
5144         fn._handlers.push([Roo.id(el), T, h]);
5145
5146         E.on(el, T, h);
5147         if(T == "mousewheel" && el.addEventListener){ 
5148             el.addEventListener("DOMMouseScroll", h, false);
5149             E.on(window, 'unload', function(){
5150                 el.removeEventListener("DOMMouseScroll", h, false);
5151             });
5152         }
5153         if(T == "mousedown" && el == document){ 
5154             Roo.EventManager.stoppedMouseDownEvent.addListener(h);
5155         }
5156         return  h;
5157     };
5158
5159     var  P = function(el, S, fn){
5160         var  id = Roo.id(el), T = fn._handlers, hd = fn;
5161         if(T){
5162             for(var  i = 0, len = T.length; i < len; i++){
5163                 var  h = T[i];
5164                 if(h[0] == id && h[1] == S){
5165                     hd = h[2];
5166                     T.splice(i, 1);
5167                     break;
5168                 }
5169             }
5170         }
5171
5172         E.un(el, S, hd);
5173         el = Roo.getDom(el);
5174         if(S == "mousewheel" && el.addEventListener){
5175             el.removeEventListener("DOMMouseScroll", hd, false);
5176         }
5177         if(S == "mousedown" && el == document){ 
5178             Roo.EventManager.stoppedMouseDownEvent.removeListener(hd);
5179         }
5180     };
5181
5182     var  Q = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
5183     
5184     var  R = {
5185         
5186         
5187         
5188
5189         
5190         
5191         
5192
5193         wrap : function(fn, S, T){
5194             return  function(e){
5195                 Roo.EventObject.setEvent(e);
5196                 fn.call(T ? S || window : window, Roo.EventObject, S);
5197             };
5198         },
5199         
5200         
5201
5202         addListener : function(U, V, fn, W, X){
5203             if(typeof  V == "object"){
5204                 var  o = V;
5205                 for(var  e  in  o){
5206                     if(Q.test(e)){
5207                         continue;
5208                     }
5209                     if(typeof  o[e] == "function"){
5210                         
5211                         O(U, e, o, o[e], o.scope);
5212                     }else {
5213                         
5214                         O(U, e, o[e]);
5215                     }
5216                 }
5217                 return;
5218             }
5219             return  O(U, V, X, fn, W);
5220         },
5221         
5222         
5223
5224         removeListener : function(Y, Z, fn){
5225             return  P(Y, Z, fn);
5226         },
5227         
5228         
5229
5230         onDocumentReady : function(fn, a, b){
5231             if(C){ 
5232                 A.addListener(fn, a, b);
5233                 A.fire();
5234                 A.clearListeners();
5235                 return;
5236             }
5237             if(!A){
5238                 K();
5239             }
5240
5241             A.addListener(fn, a, b);
5242         },
5243         
5244         
5245
5246         onWindowResize : function(fn, c, d){
5247             if(!F){
5248                 F = new  Roo.util.Event();
5249                 G = new  Roo.util.DelayedTask(function(){
5250                     F.fire(D.getViewWidth(), D.getViewHeight());
5251                 });
5252                 E.on(window, "resize", function(){
5253                     if(Roo.isIE){
5254                         G.delay(50);
5255                     }else {
5256                         F.fire(D.getViewWidth(), D.getViewHeight());
5257                     }
5258                 });
5259             }
5260
5261             F.addListener(fn, c, d);
5262         },
5263
5264         
5265
5266         onTextResize : function(fn, f, g){
5267             if(!H){
5268                 H = new  Roo.util.Event();
5269                 var  textEl = new  Roo.Element(document.createElement('div'));
5270                 textEl.dom.className = 'x-text-resize';
5271                 textEl.dom.innerHTML = 'X';
5272                 textEl.appendTo(document.body);
5273                 I = textEl.dom.offsetHeight;
5274                 setInterval(function(){
5275                     if(textEl.dom.offsetHeight != I){
5276                         H.fire(I, I = textEl.dom.offsetHeight);
5277                     }
5278                 }, this.textResizeInterval);
5279             }
5280
5281             H.addListener(fn, f, g);
5282         },
5283
5284         
5285
5286         removeResizeListener : function(fn, j){
5287             if(F){
5288                 F.removeListener(fn, j);
5289             }
5290         },
5291
5292         
5293         fireResize : function(){
5294             if(F){
5295                 F.fire(D.getViewWidth(), D.getViewHeight());
5296             }   
5297         },
5298         
5299
5300         ieDeferSrc : false,
5301         
5302
5303         textResizeInterval : 50
5304     };
5305     
5306     
5307
5308     
5309      
5310
5311     R.on = R.addListener;
5312     R.un = R.removeListener;
5313
5314     R.stoppedMouseDownEvent = new  Roo.util.Event();
5315     return  R;
5316 }();
5317
5318
5319 Roo.onReady = Roo.EventManager.onDocumentReady;
5320
5321 Roo.onReady(function(){
5322     var  bd = Roo.get(document.body);
5323     if(!bd){ return; }
5324
5325     var  S = [
5326             Roo.isIE ? "roo-ie"
5327             : Roo.isGecko ? "roo-gecko"
5328             : Roo.isOpera ? "roo-opera"
5329             : Roo.isSafari ? "roo-safari" : ""];
5330
5331     if(Roo.isMac){
5332         S.push("roo-mac");
5333     }
5334     if(Roo.isLinux){
5335         S.push("roo-linux");
5336     }
5337     if(Roo.isBorderBox){
5338         S.push('roo-border-box');
5339     }
5340     if(Roo.isStrict){ 
5341         var  p = bd.dom.parentNode;
5342         if(p){
5343             p.className += ' roo-strict';
5344         }
5345     }
5346
5347     bd.addClass(S.join(' '));
5348 });
5349
5350
5351
5352 Roo.EventObject = function(){
5353     
5354     var  E = Roo.lib.Event;
5355     
5356     
5357     var  T = {
5358         63234 : 37, 
5359         63235 : 39, 
5360         63232 : 38, 
5361         63233 : 40, 
5362         63276 : 33, 
5363         63277 : 34, 
5364         63272 : 46, 
5365         63273 : 36, 
5366         63275 : 35  
5367     };
5368
5369     
5370     var  U = Roo.isIE ? {1:0,4:1,2:2} :
5371                 (Roo.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
5372
5373     Roo.EventObjectImpl = function(e){
5374         if(e){
5375             this.setEvent(e.browserEvent || e);
5376         }
5377     };
5378     Roo.EventObjectImpl.prototype = {
5379         
5380
5381             
5382
5383         
5384         
5385         
5386
5387         browserEvent : null,
5388         
5389
5390         button : -1,
5391         
5392
5393         shiftKey : false,
5394         
5395
5396         ctrlKey : false,
5397         
5398
5399         altKey : false,
5400
5401         
5402
5403         BACKSPACE : 8,
5404         
5405
5406         TAB : 9,
5407         
5408
5409         RETURN  : 13,
5410         
5411
5412         ENTER : 13,
5413         
5414
5415         SHIFT : 16,
5416         
5417
5418         CONTROL : 17,
5419         
5420
5421         ESC : 27,
5422         
5423
5424         SPACE : 32,
5425         
5426
5427         PAGEUP : 33,
5428         
5429
5430         PAGEDOWN : 34,
5431         
5432
5433         END : 35,
5434         
5435
5436         HOME : 36,
5437         
5438
5439         LEFT : 37,
5440         
5441
5442         UP : 38,
5443         
5444
5445         RIGHT : 39,
5446         
5447
5448         DOWN : 40,
5449         
5450
5451         DELETE  : 46,
5452         
5453
5454         F5 : 116,
5455
5456            
5457
5458         setEvent : function(e){
5459             if(e == this || (e && e.browserEvent)){ 
5460                 return  e;
5461             }
5462
5463             this.browserEvent = e;
5464             if(e){
5465                 
5466                 this.button = e.button ? U[e.button] : (e.which ? e.which-1 : -1);
5467                 if(e.type == 'click' && this.button == -1){
5468                     this.button = 0;
5469                 }
5470
5471                 this.type = e.type;
5472                 this.shiftKey = e.shiftKey;
5473                 
5474                 this.ctrlKey = e.ctrlKey || e.metaKey;
5475                 this.altKey = e.altKey;
5476                 
5477                 this.keyCode = e.keyCode;
5478                 
5479                 this.charCode = (e.type == 'keyup' || e.type == 'keydown') ? 0 : e.charCode;
5480                 
5481                 this.target = E.getTarget(e);
5482                 
5483                 this.xy = E.getXY(e);
5484             }else {
5485                 this.button = -1;
5486                 this.shiftKey = false;
5487                 this.ctrlKey = false;
5488                 this.altKey = false;
5489                 this.keyCode = 0;
5490                 this.charCode =0;
5491                 this.target = null;
5492                 this.xy = [0, 0];
5493             }
5494             return  this;
5495         },
5496
5497         
5498
5499         stopEvent : function(){
5500             if(this.browserEvent){
5501                 if(this.browserEvent.type == 'mousedown'){
5502                     Roo.EventManager.stoppedMouseDownEvent.fire(this);
5503                 }
5504
5505                 E.stopEvent(this.browserEvent);
5506             }
5507         },
5508
5509         
5510
5511         preventDefault : function(){
5512             if(this.browserEvent){
5513                 E.preventDefault(this.browserEvent);
5514             }
5515         },
5516
5517         
5518
5519         isNavKeyPress : function(){
5520             var  k = this.keyCode;
5521             k = Roo.isSafari ? (T[k] || k) : k;
5522             return  (k >= 33 && k <= 40) || k == this.RETURN  || k == this.TAB || k == this.ESC;
5523         },
5524
5525         isSpecialKey : function(){
5526             var  k = this.keyCode;
5527             return  (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13  || k == 40 || k == 27 ||
5528             (k == 16) || (k == 17) ||
5529             (k >= 18 && k <= 20) ||
5530             (k >= 33 && k <= 35) ||
5531             (k >= 36 && k <= 39) ||
5532             (k >= 44 && k <= 45);
5533         },
5534         
5535
5536         stopPropagation : function(){
5537             if(this.browserEvent){
5538                 if(this.type == 'mousedown'){
5539                     Roo.EventManager.stoppedMouseDownEvent.fire(this);
5540                 }
5541
5542                 E.stopPropagation(this.browserEvent);
5543             }
5544         },
5545
5546         
5547
5548         getCharCode : function(){
5549             return  this.charCode || this.keyCode;
5550         },
5551
5552         
5553
5554         getKey : function(){
5555             var  k = this.keyCode || this.charCode;
5556             return  Roo.isSafari ? (T[k] || k) : k;
5557         },
5558
5559         
5560
5561         getPageX : function(){
5562             return  this.xy[0];
5563         },
5564
5565         
5566
5567         getPageY : function(){
5568             return  this.xy[1];
5569         },
5570
5571         
5572
5573         getTime : function(){
5574             if(this.browserEvent){
5575                 return  E.getTime(this.browserEvent);
5576             }
5577             return  null;
5578         },
5579
5580         
5581
5582         getXY : function(){
5583             return  this.xy;
5584         },
5585
5586         
5587
5588         getTarget : function(V, W, X){
5589             return  V ? Roo.fly(this.target).findParent(V, W, X) : this.target;
5590         },
5591         
5592
5593         getRelatedTarget : function(){
5594             if(this.browserEvent){
5595                 return  E.getRelatedTarget(this.browserEvent);
5596             }
5597             return  null;
5598         },
5599
5600         
5601
5602         getWheelDelta : function(){
5603             var  e = this.browserEvent;
5604             var  Y = 0;
5605             if(e.wheelDelta){ 
5606
5607                 Y = e.wheelDelta/120;
5608             }else  if(e.detail){ 
5609
5610                 Y = -e.detail/3;
5611             }
5612             return  Y;
5613         },
5614
5615         
5616
5617         hasModifier : function(){
5618             return  !!((this.ctrlKey || this.altKey) || this.shiftKey);
5619         },
5620
5621         
5622
5623         within : function(el, Z){
5624             var  t = this[Z ? "getRelatedTarget" : "getTarget"]();
5625             return  t && Roo.fly(el).contains(t);
5626         },
5627
5628         getPoint : function(){
5629             return  new  Roo.lib.Point(this.xy[0], this.xy[1]);
5630         }
5631     };
5632
5633     return  new  Roo.EventObjectImpl();
5634 }();
5635             
5636     
5637
5638
5639
5640  
5641
5642  
5643 (function(){
5644     var  D = Roo.lib.Dom;
5645     var  E = Roo.lib.Event;
5646     var  A = Roo.lib.Anim;
5647
5648     
5649     var  B = {};
5650     var  C = /(-[a-z])/gi;
5651     var  F = function(m, a){ return  a.charAt(1).toUpperCase(); };
5652     var  G = document.defaultView;
5653
5654
5655
5656     Roo.Element = function(J, K){
5657         var  L = typeof  J == "string" ?
5658                 document.getElementById(J) : J;
5659         if(!L){ 
5660             return  null;
5661         }
5662         var  id = L.id;
5663         if(K !== true && id && Roo.Element.cache[id]){ 
5664             return  Roo.Element.cache[id];
5665         }
5666
5667
5668         
5669
5670         this.dom = L;
5671
5672         
5673
5674         this.id = id || Roo.id(L);
5675     };
5676
5677     var  El = Roo.Element;
5678
5679     El.prototype = {
5680         
5681
5682         originalDisplay : "",
5683
5684         visibilityMode : 1,
5685         
5686
5687         defaultUnit : "px",
5688         
5689
5690         setVisibilityMode : function(J){
5691             this.visibilityMode = J;
5692             return  this;
5693         },
5694         
5695
5696         enableDisplayMode : function(K){
5697             this.setVisibilityMode(El.DISPLAY);
5698             if(typeof  K != "undefined") this.originalDisplay = K;
5699             return  this;
5700         },
5701
5702         
5703
5704         findParent : function(L, M, N){
5705             var  p = this.dom, b = document.body, O = 0, dq = Roo.DomQuery, P;
5706             M = M || 50;
5707             if(typeof  M != "number"){
5708                 P = Roo.getDom(M);
5709                 M = 10;
5710             }
5711             while(p && p.nodeType == 1 && O < M && p != b && p != P){
5712                 if(dq.is(p, L)){
5713                     return  N ? Roo.get(p) : p;
5714                 }
5715
5716                 O++;
5717                 p = p.parentNode;
5718             }
5719             return  null;
5720         },
5721
5722
5723         
5724
5725         findParentNode : function(Q, R, S){
5726             var  p = Roo.fly(this.dom.parentNode, '_internal');
5727             return  p ? p.findParent(Q, R, S) : null;
5728         },
5729
5730         
5731
5732         up : function(T, U){
5733             return  this.findParentNode(T, U, true);
5734         },
5735
5736
5737
5738         
5739
5740         is : function(V){
5741             return  Roo.DomQuery.is(this.dom, V);
5742         },
5743
5744         
5745
5746         animate : function(W, X, Y, Z, c){
5747             this.anim(W, {duration: X, callback: Y, easing: Z}, c);
5748             return  this;
5749         },
5750
5751         
5752
5753         anim : function(e, g, h, j, k, cb){
5754             h = h || 'run';
5755             g = g || {};
5756             var  l = Roo.lib.Anim[h](
5757                 this.dom, e,
5758                 (g.duration || j) || .35,
5759                 (g.easing || k) || 'easeOut',
5760                 function(){
5761                     Roo.callback(cb, this);
5762                     Roo.callback(g.callback, g.scope || this, [this, g]);
5763                 },
5764                 this
5765             );
5766             g.anim = l;
5767             return  l;
5768         },
5769
5770         
5771         preanim : function(a, i){
5772             return  !a[i] ? false : (typeof  a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
5773         },
5774
5775         
5776
5777         clean : function(o){
5778             if(this.isCleaned && o !== true){
5779                 return  this;
5780             }
5781             var  ns = /\S/;
5782             var  d = this.dom, n = d.firstChild, ni = -1;
5783             while(n){
5784                 var  nx = n.nextSibling;
5785                 if(n.nodeType == 3 && !ns.test(n.nodeValue)){
5786                     d.removeChild(n);
5787                 }else {
5788                     n.nodeIndex = ++ni;
5789                 }
5790
5791                 n = nx;
5792             }
5793
5794             this.isCleaned = true;
5795             return  this;
5796         },
5797
5798         
5799         calcOffsetsTo : function(el){
5800             el = Roo.get(el);
5801             var  d = el.dom;
5802             var  q = false;
5803             if(el.getStyle('position') == 'static'){
5804                 el.position('relative');
5805                 q = true;
5806             }
5807             var  x = 0, y =0;
5808             var  op = this.dom;
5809             while(op && op != d && op.tagName != 'HTML'){
5810                 x+= op.offsetLeft;
5811                 y+= op.offsetTop;
5812                 op = op.offsetParent;
5813             }
5814             if(q){
5815                 el.position('static');
5816             }
5817             return  [x, y];
5818         },
5819
5820         
5821
5822         scrollIntoView : function(u, v){
5823             var  c = Roo.getDom(u) || document.body;
5824             var  el = this.dom;
5825
5826             var  o = this.calcOffsetsTo(c),
5827                 l = o[0],
5828                 t = o[1],
5829                 b = t+el.offsetHeight,
5830                 r = l+el.offsetWidth;
5831
5832             var  ch = c.clientHeight;
5833             var  ct = parseInt(c.scrollTop, 10);
5834             var  cl = parseInt(c.scrollLeft, 10);
5835             var  cb = ct + ch;
5836             var  cr = cl + c.clientWidth;
5837
5838             if(t < ct){
5839                 c.scrollTop = t;
5840             }else  if(b > cb){
5841                 c.scrollTop = b-ch;
5842             }
5843
5844             if(v !== false){
5845                 if(l < cl){
5846                     c.scrollLeft = l;
5847                 }else  if(r > cr){
5848                     c.scrollLeft = r-c.clientWidth;
5849                 }
5850             }
5851             return  this;
5852         },
5853
5854         
5855         scrollChildIntoView : function(w, z){
5856             Roo.fly(w, '_scrollChildIntoView').scrollIntoView(this, z);
5857         },
5858
5859         
5860
5861         autoHeight : function(AA, AB, AC, AD){
5862             var  AE = this.getHeight();
5863             this.clip();
5864             this.setHeight(1); 
5865             setTimeout(function(){
5866                 var  AG = parseInt(this.dom.scrollHeight, 10); 
5867                 if(!AA){
5868                     this.setHeight(AG);
5869                     this.unclip();
5870                     if(typeof  AC == "function"){
5871                         AC();
5872                     }
5873                 }else {
5874                     this.setHeight(AE); 
5875                     this.setHeight(AG, AA, AB, function(){
5876                         this.unclip();
5877                         if(typeof  AC == "function") AC();
5878                     }.createDelegate(this), AD);
5879                 }
5880             }.createDelegate(this), 0);
5881             return  this;
5882         },
5883
5884         
5885
5886         contains : function(el){
5887             if(!el){return  false;}
5888             return  D.isAncestor(this.dom, el.dom ? el.dom : el);
5889         },
5890
5891         
5892
5893         isVisible : function(AF) {
5894             var  AG = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
5895             if(AF !== true || !AG){
5896                 return  AG;
5897             }
5898             var  p = this.dom.parentNode;
5899             while(p && p.tagName.toLowerCase() != "body"){
5900                 if(!Roo.fly(p, '_isVisible').isVisible()){
5901                     return  false;
5902                 }
5903
5904                 p = p.parentNode;
5905             }
5906             return  true;
5907         },
5908
5909         
5910
5911         select : function(AH, AI){
5912             return  El.select(AH, AI, this.dom);
5913         },
5914
5915         
5916
5917         query : function(AJ, AK){
5918             return  Roo.DomQuery.select(AJ, this.dom);
5919         },
5920
5921         
5922
5923         child : function(AL, AM){
5924             var  n = Roo.DomQuery.selectNode(AL, this.dom);
5925             return  AM ? n : Roo.get(n);
5926         },
5927
5928         
5929
5930         down : function(AN, AO){
5931             var  n = Roo.DomQuery.selectNode(" > " + AN, this.dom);
5932             return  AO ? n : Roo.get(n);
5933         },
5934
5935         
5936
5937         initDD : function(AP, AQ, AR){
5938             var  dd = new  Roo.dd.DD(Roo.id(this.dom), AP, AQ);
5939             return  Roo.apply(dd, AR);
5940         },
5941
5942         
5943
5944         initDDProxy : function(AS, AT, AU){
5945             var  dd = new  Roo.dd.DDProxy(Roo.id(this.dom), AS, AT);
5946             return  Roo.apply(dd, AU);
5947         },
5948
5949         
5950
5951         initDDTarget : function(AV, AW, AX){
5952             var  dd = new  Roo.dd.DDTarget(Roo.id(this.dom), AV, AW);
5953             return  Roo.apply(dd, AX);
5954         },
5955
5956         
5957
5958          setVisible : function(AY, AZ){
5959             if(!AZ || !A){
5960                 if(this.visibilityMode == El.DISPLAY){
5961                     this.setDisplayed(AY);
5962                 }else {
5963                     this.fixDisplay();
5964                     this.dom.style.visibility = AY ? "visible" : "hidden";
5965                 }
5966             }else {
5967                 
5968                 var  dom = this.dom;
5969                 var  J = this.visibilityMode;
5970                 if(AY){
5971                     this.setOpacity(.01);
5972                     this.setVisible(true);
5973                 }
5974
5975                 this.anim({opacity: { to: (AY?1:0) }},
5976                       this.preanim(arguments, 1),
5977                       null, .35, 'easeIn', function(){
5978                          if(!AY){
5979                              if(J == El.DISPLAY){
5980                                  dom.style.display = "none";
5981                              }else {
5982                                  dom.style.visibility = "hidden";
5983                              }
5984
5985                              Roo.get(dom).setOpacity(1);
5986                          }
5987                      });
5988             }
5989             return  this;
5990         },
5991
5992         
5993
5994         isDisplayed : function() {
5995             return  this.getStyle("display") != "none";
5996         },
5997
5998         
5999
6000         toggle : function(Aa){
6001             this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
6002             return  this;
6003         },
6004
6005         
6006
6007         setDisplayed : function(Ab) {
6008             if(typeof  Ab == "boolean"){
6009                Ab = Ab ? this.originalDisplay : "none";
6010             }
6011
6012             this.setStyle("display", Ab);
6013             return  this;
6014         },
6015
6016         
6017
6018         focus : function() {
6019             try{
6020                 this.dom.focus();
6021             }catch(e){}
6022             return  this;
6023         },
6024
6025         
6026
6027         blur : function() {
6028             try{
6029                 this.dom.blur();
6030             }catch(e){}
6031             return  this;
6032         },
6033
6034         
6035
6036         addClass : function(Ac){
6037             if(Ac  instanceof  Array){
6038                 for(var  i = 0, len = Ac.length; i < len; i++) {
6039                     this.addClass(Ac[i]);
6040                 }
6041             }else {
6042                 if(Ac && !this.hasClass(Ac)){
6043                     this.dom.className = this.dom.className + " " + Ac;
6044                 }
6045             }
6046             return  this;
6047         },
6048
6049         
6050
6051         radioClass : function(Ad){
6052             var  Ae = this.dom.parentNode.childNodes;
6053             for(var  i = 0; i < Ae.length; i++) {
6054                 var  s = Ae[i];
6055                 if(s.nodeType == 1){
6056                     Roo.get(s).removeClass(Ad);
6057                 }
6058             }
6059
6060             this.addClass(Ad);
6061             return  this;
6062         },
6063
6064         
6065
6066         removeClass : function(Af){
6067             if(!Af || !this.dom.className){
6068                 return  this;
6069             }
6070             if(Af  instanceof  Array){
6071                 for(var  i = 0, len = Af.length; i < len; i++) {
6072                     this.removeClass(Af[i]);
6073                 }
6074             }else {
6075                 if(this.hasClass(Af)){
6076                     var  re = this.classReCache[Af];
6077                     if (!re) {
6078                        re = new  RegExp('(?:^|\\s+)' + Af + '(?:\\s+|$)', "g");
6079                        this.classReCache[Af] = re;
6080                     }
6081
6082                     this.dom.className =
6083                         this.dom.className.replace(re, " ");
6084                 }
6085             }
6086             return  this;
6087         },
6088
6089         
6090         classReCache: {},
6091
6092         
6093
6094         toggleClass : function(Ag){
6095             if(this.hasClass(Ag)){
6096                 this.removeClass(Ag);
6097             }else {
6098                 this.addClass(Ag);
6099             }
6100             return  this;
6101         },
6102
6103         
6104
6105         hasClass : function(Ah){
6106             return  Ah && (' '+this.dom.className+' ').indexOf(' '+Ah+' ') != -1;
6107         },
6108
6109         
6110
6111         replaceClass : function(Ai, Aj){
6112             this.removeClass(Ai);
6113             this.addClass(Aj);
6114             return  this;
6115         },
6116
6117         
6118
6119         getStyles : function(){
6120             var  a = arguments, Ak = a.length, r = {};
6121             for(var  i = 0; i < Ak; i++){
6122                 r[a[i]] = this.getStyle(a[i]);
6123             }
6124             return  r;
6125         },
6126
6127         
6128
6129         getStyle : function(){
6130             return  G && G.getComputedStyle ?
6131                 function(Al){
6132                     var  el = this.dom, v, cs, Am;
6133                     if(Al == 'float'){
6134                         Al = "cssFloat";
6135                     }
6136                     if(el.style && (v = el.style[Al])){
6137                         return  v;
6138                     }
6139                     if(cs = G.getComputedStyle(el, "")){
6140                         if(!(Am = B[Al])){
6141                             Am = B[Al] = Al.replace(C, F);
6142                         }
6143                         return  cs[Am];
6144                     }
6145                     return  null;
6146                 } :
6147                 function(Al){
6148                     var  el = this.dom, v, cs, Am;
6149                     if(Al == 'opacity'){
6150                         if(typeof  el.style.filter == 'string'){
6151                             var  m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
6152                             if(m){
6153                                 var  fv = parseFloat(m[1]);
6154                                 if(!isNaN(fv)){
6155                                     return  fv ? fv / 100 : 0;
6156                                 }
6157                             }
6158                         }
6159                         return  1;
6160                     }else  if(Al == 'float'){
6161                         Al = "styleFloat";
6162                     }
6163                     if(!(Am = B[Al])){
6164                         Am = B[Al] = Al.replace(C, F);
6165                     }
6166                     if(v = el.style[Am]){
6167                         return  v;
6168                     }
6169                     if(cs = el.currentStyle){
6170                         return  cs[Am];
6171                     }
6172                     return  null;
6173                 };
6174         }(),
6175
6176         
6177
6178         setStyle : function(Al, Am){
6179             if(typeof  Al == "string"){
6180                 
6181                 if (Al == 'float') {
6182                     this.setStyle(Roo.isIE ? 'styleFloat'  : 'cssFloat', Am);
6183                     return  this;
6184                 }
6185                 
6186                 var  camel;
6187                 if(!(camel = B[Al])){
6188                     camel = B[Al] = Al.replace(C, F);
6189                 }
6190                 
6191                 if(camel == 'opacity') {
6192                     this.setOpacity(Am);
6193                 }else {
6194                     this.dom.style[camel] = Am;
6195                 }
6196             }else {
6197                 for(var  style  in  Al){
6198                     if(typeof  Al[style] != "function"){
6199                        this.setStyle(style, Al[style]);
6200                     }
6201                 }
6202             }
6203             return  this;
6204         },
6205
6206         
6207
6208         applyStyles : function(An){
6209             Roo.DomHelper.applyStyles(this.dom, An);
6210             return  this;
6211         },
6212
6213         
6214
6215         getX : function(){
6216             return  D.getX(this.dom);
6217         },
6218
6219         
6220
6221         getY : function(){
6222             return  D.getY(this.dom);
6223         },
6224
6225         
6226
6227         getXY : function(){
6228             return  D.getXY(this.dom);
6229         },
6230
6231         
6232
6233         setX : function(x, Ao){
6234             if(!Ao || !A){
6235                 D.setX(this.dom, x);
6236             }else {
6237                 this.setXY([x, this.getY()], this.preanim(arguments, 1));
6238             }
6239             return  this;
6240         },
6241
6242         
6243
6244         setY : function(y, Ap){
6245             if(!Ap || !A){
6246                 D.setY(this.dom, y);
6247             }else {
6248                 this.setXY([this.getX(), y], this.preanim(arguments, 1));
6249             }
6250             return  this;
6251         },
6252
6253         
6254
6255         setLeft : function(Aq){
6256             this.setStyle("left", this.addUnits(Aq));
6257             return  this;
6258         },
6259
6260         
6261
6262         setTop : function(Ar){
6263             this.setStyle("top", this.addUnits(Ar));
6264             return  this;
6265         },
6266
6267         
6268
6269         setRight : function(As){
6270             this.setStyle("right", this.addUnits(As));
6271             return  this;
6272         },
6273
6274         
6275
6276         setBottom : function(At){
6277             this.setStyle("bottom", this.addUnits(At));
6278             return  this;
6279         },
6280
6281         
6282
6283         setXY : function(Au, Av){
6284             if(!Av || !A){
6285                 D.setXY(this.dom, Au);
6286             }else {
6287                 this.anim({points: {to: Au}}, this.preanim(arguments, 1), 'motion');
6288             }
6289             return  this;
6290         },
6291
6292         
6293
6294         setLocation : function(x, y, Aw){
6295             this.setXY([x, y], this.preanim(arguments, 2));
6296             return  this;
6297         },
6298
6299         
6300
6301         moveTo : function(x, y, Ax){
6302             this.setXY([x, y], this.preanim(arguments, 2));
6303             return  this;
6304         },
6305
6306         
6307
6308         getRegion : function(){
6309             return  D.getRegion(this.dom);
6310         },
6311
6312         
6313
6314         getHeight : function(Ay){
6315             var  h = this.dom.offsetHeight || 0;
6316             return  Ay !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb");
6317         },
6318
6319         
6320
6321         getWidth : function(Az){
6322             var  w = this.dom.offsetWidth || 0;
6323             return  Az !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr");
6324         },
6325
6326         
6327
6328         getComputedHeight : function(){
6329             var  h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
6330             if(!h){
6331                 h = parseInt(this.getStyle('height'), 10) || 0;
6332                 if(!this.isBorderBox()){
6333                     h += this.getFrameWidth('tb');
6334                 }
6335             }
6336             return  h;
6337         },
6338
6339         
6340
6341         getComputedWidth : function(){
6342             var  w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
6343             if(!w){
6344                 w = parseInt(this.getStyle('width'), 10) || 0;
6345                 if(!this.isBorderBox()){
6346                     w += this.getFrameWidth('lr');
6347                 }
6348             }
6349             return  w;
6350         },
6351
6352         
6353
6354         getSize : function(A0){
6355             return  {width: this.getWidth(A0), height: this.getHeight(A0)};
6356         },
6357
6358         
6359
6360         getViewSize : function(){
6361             var  d = this.dom, A1 = document, aw = 0, ah = 0;
6362             if(d == A1 || d == A1.body){
6363                 return  {width : D.getViewWidth(), height: D.getViewHeight()};
6364             }else {
6365                 return  {
6366                     width : d.clientWidth,
6367                     height: d.clientHeight
6368                 };
6369             }
6370         },
6371
6372         
6373
6374         getValue : function(A2){
6375             return  A2 ? parseInt(this.dom.value, 10) : this.dom.value;
6376         },
6377
6378         
6379         adjustWidth : function(A3){
6380             if(typeof  A3 == "number"){
6381                 if(this.autoBoxAdjust && !this.isBorderBox()){
6382                    A3 -= (this.getBorderWidth("lr") + this.getPadding("lr"));
6383                 }
6384                 if(A3 < 0){
6385                     A3 = 0;
6386                 }
6387             }
6388             return  A3;
6389         },
6390
6391         
6392         adjustHeight : function(A4){
6393             if(typeof  A4 == "number"){
6394                if(this.autoBoxAdjust && !this.isBorderBox()){
6395                    A4 -= (this.getBorderWidth("tb") + this.getPadding("tb"));
6396                }
6397                if(A4 < 0){
6398                    A4 = 0;
6399                }
6400             }
6401             return  A4;
6402         },
6403
6404         
6405
6406         setWidth : function(A5, A6){
6407             A5 = this.adjustWidth(A5);
6408             if(!A6 || !A){
6409                 this.dom.style.width = this.addUnits(A5);
6410             }else {
6411                 this.anim({width: {to: A5}}, this.preanim(arguments, 1));
6412             }
6413             return  this;
6414         },
6415
6416         
6417
6418          setHeight : function(A7, A8){
6419             A7 = this.adjustHeight(A7);
6420             if(!A8 || !A){
6421                 this.dom.style.height = this.addUnits(A7);
6422             }else {
6423                 this.anim({height: {to: A7}}, this.preanim(arguments, 1));
6424             }
6425             return  this;
6426         },
6427
6428         
6429
6430          setSize : function(A9, BA, BB){
6431             if(typeof  A9 == "object"){ 
6432                 BA = A9.height; A9 = A9.width;
6433             }
6434
6435             A9 = this.adjustWidth(A9); BA = this.adjustHeight(BA);
6436             if(!BB || !A){
6437                 this.dom.style.width = this.addUnits(A9);
6438                 this.dom.style.height = this.addUnits(BA);
6439             }else {
6440                 this.anim({width: {to: A9}, height: {to: BA}}, this.preanim(arguments, 2));
6441             }
6442             return  this;
6443         },
6444
6445         
6446
6447         setBounds : function(x, y, BC, BD, BE){
6448             if(!BE || !A){
6449                 this.setSize(BC, BD);
6450                 this.setLocation(x, y);
6451             }else {
6452                 BC = this.adjustWidth(BC); BD = this.adjustHeight(BD);
6453                 this.anim({points: {to: [x, y]}, width: {to: BC}, height: {to: BD}},
6454                               this.preanim(arguments, 4), 'motion');
6455             }
6456             return  this;
6457         },
6458
6459         
6460
6461         setRegion : function(BF, BG){
6462             this.setBounds(BF.left, BF.top, BF.right-BF.left, BF.bottom-BF.top, this.preanim(arguments, 1));
6463             return  this;
6464         },
6465
6466         
6467
6468         addListener : function(BH, fn, BI, BJ){
6469             Roo.EventManager.on(this.dom,  BH, fn, BI || this, BJ);
6470         },
6471
6472         
6473
6474         removeListener : function(BK, fn){
6475             Roo.EventManager.removeListener(this.dom,  BK, fn);
6476             return  this;
6477         },
6478
6479         
6480
6481         removeAllListeners : function(){
6482             E.purgeElement(this.dom);
6483             return  this;
6484         },
6485
6486         relayEvent : function(BL, BM){
6487             this.on(BL, function(e){
6488                 BM.fireEvent(BL, e);
6489             });
6490         },
6491
6492         
6493
6494          setOpacity : function(BN, BO){
6495             if(!BO || !A){
6496                 var  s = this.dom.style;
6497                 if(Roo.isIE){
6498                     s.zoom = 1;
6499                     s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
6500                                (BN == 1 ? "" : "alpha(opacity=" + BN * 100 + ")");
6501                 }else {
6502                     s.opacity = BN;
6503                 }
6504             }else {
6505                 this.anim({opacity: {to: BN}}, this.preanim(arguments, 1), null, .35, 'easeIn');
6506             }
6507             return  this;
6508         },
6509
6510         
6511
6512         getLeft : function(BP){
6513             if(!BP){
6514                 return  this.getX();
6515             }else {
6516                 return  parseInt(this.getStyle("left"), 10) || 0;
6517             }
6518         },
6519
6520         
6521
6522         getRight : function(BQ){
6523             if(!BQ){
6524                 return  this.getX() + this.getWidth();
6525             }else {
6526                 return  (this.getLeft(true) + this.getWidth()) || 0;
6527             }
6528         },
6529
6530         
6531
6532         getTop : function(BR) {
6533             if(!BR){
6534                 return  this.getY();
6535             }else {
6536                 return  parseInt(this.getStyle("top"), 10) || 0;
6537             }
6538         },
6539
6540         
6541
6542         getBottom : function(BS){
6543             if(!BS){
6544                 return  this.getY() + this.getHeight();
6545             }else {
6546                 return  (this.getTop(true) + this.getHeight()) || 0;
6547             }
6548         },
6549
6550         
6551
6552         position : function(BT, BU, x, y){
6553             if(!BT){
6554                if(this.getStyle('position') == 'static'){
6555                    this.setStyle('position', 'relative');
6556                }
6557             }else {
6558                 this.setStyle("position", BT);
6559             }
6560             if(BU){
6561                 this.setStyle("z-index", BU);
6562             }
6563             if(x !== undefined && y !== undefined){
6564                 this.setXY([x, y]);
6565             }else  if(x !== undefined){
6566                 this.setX(x);
6567             }else  if(y !== undefined){
6568                 this.setY(y);
6569             }
6570         },
6571
6572         
6573
6574         clearPositioning : function(BV){
6575             BV = BV ||'';
6576             this.setStyle({
6577                 "left": BV,
6578                 "right": BV,
6579                 "top": BV,
6580                 "bottom": BV,
6581                 "z-index": "",
6582                 "position" : "static"
6583             });
6584             return  this;
6585         },
6586
6587         
6588
6589         getPositioning : function(){
6590             var  l = this.getStyle("left");
6591             var  t = this.getStyle("top");
6592             return  {
6593                 "position" : this.getStyle("position"),
6594                 "left" : l,
6595                 "right" : l ? "" : this.getStyle("right"),
6596                 "top" : t,
6597                 "bottom" : t ? "" : this.getStyle("bottom"),
6598                 "z-index" : this.getStyle("z-index")
6599             };
6600         },
6601
6602         
6603
6604         getBorderWidth : function(BW){
6605             return  this.addStyles(BW, El.borders);
6606         },
6607
6608         
6609
6610         getPadding : function(BX){
6611             return  this.addStyles(BX, El.paddings);
6612         },
6613
6614         
6615
6616         setPositioning : function(pc){
6617             this.applyStyles(pc);
6618             if(pc.right == "auto"){
6619                 this.dom.style.right = "";
6620             }
6621             if(pc.bottom == "auto"){
6622                 this.dom.style.bottom = "";
6623             }
6624             return  this;
6625         },
6626
6627         
6628         fixDisplay : function(){
6629             if(this.getStyle("display") == "none"){
6630                 this.setStyle("visibility", "hidden");
6631                 this.setStyle("display", this.originalDisplay); 
6632                 if(this.getStyle("display") == "none"){ 
6633                     this.setStyle("display", "block");
6634                 }
6635             }
6636         },
6637
6638         
6639
6640          setLeftTop : function(BY, BZ){
6641             this.dom.style.left = this.addUnits(BY);
6642             this.dom.style.top = this.addUnits(BZ);
6643             return  this;
6644         },
6645
6646         
6647
6648          move : function(Ba, Bb, Bc){
6649             var  xy = this.getXY();
6650             Ba = Ba.toLowerCase();
6651             switch(Ba){
6652                 case  "l":
6653                 case  "left":
6654                     this.moveTo(xy[0]-Bb, xy[1], this.preanim(arguments, 2));
6655                     break;
6656                case  "r":
6657                case  "right":
6658                     this.moveTo(xy[0]+Bb, xy[1], this.preanim(arguments, 2));
6659                     break;
6660                case  "t":
6661                case  "top":
6662                case  "up":
6663                     this.moveTo(xy[0], xy[1]-Bb, this.preanim(arguments, 2));
6664                     break;
6665                case  "b":
6666                case  "bottom":
6667                case  "down":
6668                     this.moveTo(xy[0], xy[1]+Bb, this.preanim(arguments, 2));
6669                     break;
6670             }
6671             return  this;
6672         },
6673
6674         
6675
6676         clip : function(){
6677             if(!this.isClipped){
6678                this.isClipped = true;
6679                this.originalClip = {
6680                    "o": this.getStyle("overflow"),
6681                    "x": this.getStyle("overflow-x"),
6682                    "y": this.getStyle("overflow-y")
6683                };
6684                this.setStyle("overflow", "hidden");
6685                this.setStyle("overflow-x", "hidden");
6686                this.setStyle("overflow-y", "hidden");
6687             }
6688             return  this;
6689         },
6690
6691         
6692
6693         unclip : function(){
6694             if(this.isClipped){
6695                 this.isClipped = false;
6696                 var  o = this.originalClip;
6697                 if(o.o){this.setStyle("overflow", o.o);}
6698                 if(o.x){this.setStyle("overflow-x", o.x);}
6699                 if(o.y){this.setStyle("overflow-y", o.y);}
6700             }
6701             return  this;
6702         },
6703
6704
6705         
6706
6707         getAnchorXY : function(Bd, Be, s){
6708             
6709             
6710
6711             var  w, h, vp = false;
6712             if(!s){
6713                 var  d = this.dom;
6714                 if(d == document.body || d == document){
6715                     vp = true;
6716                     w = D.getViewWidth(); h = D.getViewHeight();
6717                 }else {
6718                     w = this.getWidth(); h = this.getHeight();
6719                 }
6720             }else {
6721                 w = s.width;  h = s.height;
6722             }
6723             var  x = 0, y = 0, r = Math.round;
6724             switch((Bd || "tl").toLowerCase()){
6725                 case  "c":
6726                     x = r(w*.5);
6727                     y = r(h*.5);
6728                 break;
6729                 case  "t":
6730                     x = r(w*.5);
6731                     y = 0;
6732                 break;
6733                 case  "l":
6734                     x = 0;
6735                     y = r(h*.5);
6736                 break;
6737                 case  "r":
6738                     x = w;
6739                     y = r(h*.5);
6740                 break;
6741                 case  "b":
6742                     x = r(w*.5);
6743                     y = h;
6744                 break;
6745                 case  "tl":
6746                     x = 0;
6747                     y = 0;
6748                 break;
6749                 case  "bl":
6750                     x = 0;
6751                     y = h;
6752                 break;
6753                 case  "br":
6754                     x = w;
6755                     y = h;
6756                 break;
6757                 case  "tr":
6758                     x = w;
6759                     y = 0;
6760                 break;
6761             }
6762             if(Be === true){
6763                 return  [x, y];
6764             }
6765             if(vp){
6766                 var  sc = this.getScroll();
6767                 return  [x + sc.left, y + sc.top];
6768             }
6769             
6770             var  o = this.getXY();
6771             return  [x+o[0], y+o[1]];
6772         },
6773
6774         
6775
6776         getAlignToXY : function(el, p, o){
6777             el = Roo.get(el);
6778             var  d = this.dom;
6779             if(!el.dom){
6780                 throw  "Element.alignTo with an element that doesn't exist";
6781             }
6782             var  c = false; 
6783             var  p1 = "", p2 = "";
6784             o = o || [0,0];
6785
6786             if(!p){
6787                 p = "tl-bl";
6788             }else  if(p == "?"){
6789                 p = "tl-bl?";
6790             }else  if(p.indexOf("-") == -1){
6791                 p = "tl-" + p;
6792             }
6793
6794             p = p.toLowerCase();
6795             var  m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
6796             if(!m){
6797                throw  "Element.alignTo with an invalid alignment " + p;
6798             }
6799
6800             p1 = m[1]; p2 = m[2]; c = !!m[3];
6801
6802             
6803             
6804             var  a1 = this.getAnchorXY(p1, true);
6805             var  a2 = el.getAnchorXY(p2, false);
6806             var  x = a2[0] - a1[0] + o[0];
6807             var  y = a2[1] - a1[1] + o[1];
6808             if(c){
6809                 
6810                 var  w = this.getWidth(), h = this.getHeight(), r = el.getRegion();
6811                 
6812                 var  dw = D.getViewWidth()-5, dh = D.getViewHeight()-5;
6813
6814                 
6815                 
6816                 
6817                 var  p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
6818                var  p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
6819                var  swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
6820                var  swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
6821
6822                var  A1 = document;
6823                var  scrollX = (A1.documentElement.scrollLeft || A1.body.scrollLeft || 0)+5;
6824                var  scrollY = (A1.documentElement.scrollTop || A1.body.scrollTop || 0)+5;
6825
6826                if((x+w) > dw + scrollX){
6827                     x = swapX ? r.left-w : dw+scrollX-w;
6828                 }
6829                if(x < scrollX){
6830                    x = swapX ? r.right : scrollX;
6831                }
6832                if((y+h) > dh + scrollY){
6833                     y = swapY ? r.top-h : dh+scrollY-h;
6834                 }
6835                if (y < scrollY){
6836                    y = swapY ? r.bottom : scrollY;
6837                }
6838             }
6839             return  [x,y];
6840         },
6841
6842         
6843         getConstrainToXY : function(){
6844             var  os = {top:0, left:0, bottom:0, right: 0};
6845
6846             return  function(el, Bf, Bg, Bh){
6847                 el = Roo.get(el);
6848                 Bg = Bg ? Roo.applyIf(Bg, os) : os;
6849
6850                 var  vw, vh, vx = 0, vy = 0;
6851                 if(el.dom == document.body || el.dom == document){
6852                     vw = Roo.lib.Dom.getViewWidth();
6853                     vh = Roo.lib.Dom.getViewHeight();
6854                 }else {
6855                     vw = el.dom.clientWidth;
6856                     vh = el.dom.clientHeight;
6857                     if(!Bf){
6858                         var  vxy = el.getXY();
6859                         vx = vxy[0];
6860                         vy = vxy[1];
6861                     }
6862                 }
6863
6864                 var  s = el.getScroll();
6865
6866                 vx += Bg.left + s.left;
6867                 vy += Bg.top + s.top;
6868
6869                 vw -= Bg.right;
6870                 vh -= Bg.bottom;
6871
6872                 var  vr = vx+vw;
6873                 var  vb = vy+vh;
6874
6875                 var  xy = Bh || (!Bf ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
6876                 var  x = xy[0], y = xy[1];
6877                 var  w = this.dom.offsetWidth, h = this.dom.offsetHeight;
6878
6879                 
6880                 var  Bi = false;
6881
6882                 
6883                 if((x + w) > vr){
6884                     x = vr - w;
6885                     Bi = true;
6886                 }
6887                 if((y + h) > vb){
6888                     y = vb - h;
6889                     Bi = true;
6890                 }
6891                 
6892                 if(x < vx){
6893                     x = vx;
6894                     Bi = true;
6895                 }
6896                 if(y < vy){
6897                     y = vy;
6898                     Bi = true;
6899                 }
6900                 return  Bi ? [x, y] : false;
6901             };
6902         }(),
6903
6904         
6905         adjustForConstraints : function(xy, Bf, Bg){
6906             return  this.getConstrainToXY(Bf || document, false, Bg, xy) ||  xy;
6907         },
6908
6909         
6910
6911         alignTo : function(Bh, Bi, Bj, Bk){
6912             var  xy = this.getAlignToXY(Bh, Bi, Bj);
6913             this.setXY(xy, this.preanim(arguments, 3));
6914             return  this;
6915         },
6916
6917         
6918
6919         anchorTo : function(el, Bl, Bm, Bn, Bo, Bp){
6920             var  Bq = function(){
6921                 this.alignTo(el, Bl, Bm, Bn);
6922                 Roo.callback(Bp, this);
6923             };
6924             Roo.EventManager.onWindowResize(Bq, this);
6925             var  tm = typeof  Bo;
6926             if(tm != 'undefined'){
6927                 Roo.EventManager.on(window, 'scroll', Bq, this,
6928                     {buffer: tm == 'number' ? Bo : 50});
6929             }
6930
6931             Bq.call(this); 
6932             return  this;
6933         },
6934         
6935
6936         clearOpacity : function(){
6937             if (window.ActiveXObject) {
6938                 if(typeof  this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){
6939                     this.dom.style.filter = "";
6940                 }
6941             } else  {
6942                 this.dom.style.opacity = "";
6943                 this.dom.style["-moz-opacity"] = "";
6944                 this.dom.style["-khtml-opacity"] = "";
6945             }
6946             return  this;
6947         },
6948
6949         
6950
6951         hide : function(Br){
6952             this.setVisible(false, this.preanim(arguments, 0));
6953             return  this;
6954         },
6955
6956         
6957
6958         show : function(Bs){
6959             this.setVisible(true, this.preanim(arguments, 0));
6960             return  this;
6961         },
6962
6963         
6964
6965         addUnits : function(Bt){
6966             return  Roo.Element.addUnits(Bt, this.defaultUnit);
6967         },
6968
6969         
6970
6971         beginMeasure : function(){
6972             var  el = this.dom;
6973             if(el.offsetWidth || el.offsetHeight){
6974                 return  this; 
6975             }
6976             var  Bu = [];
6977             var  p = this.dom, b = document.body; 
6978             while((!el.offsetWidth && !el.offsetHeight) && p && p.tagName && p != b){
6979                 var  pe = Roo.get(p);
6980                 if(pe.getStyle('display') == 'none'){
6981                     Bu.push({el: p, visibility: pe.getStyle("visibility")});
6982                     p.style.visibility = "hidden";
6983                     p.style.display = "block";
6984                 }
6985
6986                 p = p.parentNode;
6987             }
6988
6989             this._measureChanged = Bu;
6990             return  this;
6991
6992         },
6993
6994         
6995
6996         endMeasure : function(){
6997             var  Bv = this._measureChanged;
6998             if(Bv){
6999                 for(var  i = 0, Ak = Bv.length; i < Ak; i++) {
7000                     var  r = Bv[i];
7001                     r.el.style.visibility = r.visibility;
7002                     r.el.style.display = "none";
7003                 }
7004
7005                 this._measureChanged = null;
7006             }
7007             return  this;
7008         },
7009
7010         
7011
7012         update : function(Bw, Bx, By){
7013             if(typeof  Bw == "undefined"){
7014                 Bw = "";
7015             }
7016             if(Bx !== true){
7017                 this.dom.innerHTML = Bw;
7018                 if(typeof  By == "function"){
7019                     By();
7020                 }
7021                 return  this;
7022             }
7023             var  id = Roo.id();
7024             var  Bz = this.dom;
7025
7026             Bw += '<span id="' + id + '"></span>';
7027
7028             E.onAvailable(id, function(){
7029                 var  hd = document.getElementsByTagName("head")[0];
7030                 var  re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
7031                 var  B0 = /\ssrc=([\'\"])(.*?)\1/i;
7032                 var  B1 = /\stype=([\'\"])(.*?)\1/i;
7033
7034                 var  B2;
7035                 while(B2 = re.exec(Bw)){
7036                     var  attrs = B2[1];
7037                     var  srcMatch = attrs ? attrs.match(B0) : false;
7038                     if(srcMatch && srcMatch[2]){
7039                        var  s = document.createElement("script");
7040                        s.src = srcMatch[2];
7041                        var  typeMatch = attrs.match(B1);
7042                        if(typeMatch && typeMatch[2]){
7043                            s.type = typeMatch[2];
7044                        }
7045
7046                        hd.appendChild(s);
7047                     }else  if(B2[2] && B2[2].length > 0){
7048                         if(window.execScript) {
7049                            window.execScript(B2[2]);
7050                         } else  {
7051                             
7052
7053                            window.eval(B2[2]);
7054                         }
7055                     }
7056                 }
7057                 var  el = document.getElementById(id);
7058                 if(el){el.parentNode.removeChild(el);}
7059                 if(typeof  By == "function"){
7060                     By();
7061                 }
7062             });
7063             Bz.innerHTML = Bw.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
7064             return  this;
7065         },
7066
7067         
7068
7069         load : function(){
7070             var  um = this.getUpdateManager();
7071             um.update.apply(um, arguments);
7072             return  this;
7073         },
7074
7075         
7076
7077         getUpdateManager : function(){
7078             if(!this.updateManager){
7079                 this.updateManager = new  Roo.UpdateManager(this);
7080             }
7081             return  this.updateManager;
7082         },
7083
7084         
7085
7086         unselectable : function(){
7087             this.dom.unselectable = "on";
7088             this.swallowEvent("selectstart", true);
7089             this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
7090             this.addClass("x-unselectable");
7091             return  this;
7092         },
7093
7094         
7095
7096         getCenterXY : function(){
7097             return  this.getAlignToXY(document, 'c-c');
7098         },
7099
7100         
7101
7102         center : function(B0){
7103             this.alignTo(B0 || document, 'c-c');
7104             return  this;
7105         },
7106
7107         
7108
7109         isBorderBox : function(){
7110             return  I[this.dom.tagName.toLowerCase()] || Roo.isBorderBox;
7111         },
7112
7113         
7114
7115         getBox : function(B1, B2){
7116             var  xy;
7117             if(!B2){
7118                 xy = this.getXY();
7119             }else {
7120                 var  BY = parseInt(this.getStyle("left"), 10) || 0;
7121                 var  BZ = parseInt(this.getStyle("top"), 10) || 0;
7122                 xy = [BY, BZ];
7123             }
7124             var  el = this.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
7125             if(!B1){
7126                 bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
7127             }else {
7128                 var  l = this.getBorderWidth("l")+this.getPadding("l");
7129                 var  r = this.getBorderWidth("r")+this.getPadding("r");
7130                 var  t = this.getBorderWidth("t")+this.getPadding("t");
7131                 var  b = this.getBorderWidth("b")+this.getPadding("b");
7132                 bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
7133             }
7134
7135             bx.right = bx.x + bx.width;
7136             bx.bottom = bx.y + bx.height;
7137             return  bx;
7138         },
7139
7140         
7141
7142         getFrameWidth : function(B3, B4){
7143             return  B4 && Roo.isBorderBox ? 0 : (this.getPadding(B3) + this.getBorderWidth(B3));
7144         },
7145
7146         
7147
7148         setBox : function(B5, B6, B7){
7149             var  w = B5.width, h = B5.height;
7150             if((B6 && !this.autoBoxAdjust) && !this.isBorderBox()){
7151                w -= (this.getBorderWidth("lr") + this.getPadding("lr"));
7152                h -= (this.getBorderWidth("tb") + this.getPadding("tb"));
7153             }
7154
7155             this.setBounds(B5.x, B5.y, w, h, this.preanim(arguments, 2));
7156             return  this;
7157         },
7158
7159         
7160
7161          repaint : function(){
7162             var  B8 = this.dom;
7163             this.addClass("x-repaint");
7164             setTimeout(function(){
7165                 Roo.get(B8).removeClass("x-repaint");
7166             }, 1);
7167             return  this;
7168         },
7169
7170         
7171
7172         getMargins : function(B9){
7173             if(!B9){
7174                 return  {
7175                     top: parseInt(this.getStyle("margin-top"), 10) || 0,
7176                     left: parseInt(this.getStyle("margin-left"), 10) || 0,
7177                     bottom: parseInt(this.getStyle("margin-bottom"), 10) || 0,
7178                     right: parseInt(this.getStyle("margin-right"), 10) || 0
7179                 };
7180             }else {
7181                 return  this.addStyles(B9, El.margins);
7182              }
7183         },
7184
7185         
7186         addStyles : function(CA, CB){
7187             var  CC = 0, v, w;
7188             for(var  i = 0, Ak = CA.length; i < Ak; i++){
7189                 v = this.getStyle(CB[CA.charAt(i)]);
7190                 if(v){
7191                      w = parseInt(v, 10);
7192                      if(w){ CC += w; }
7193                 }
7194             }
7195             return  CC;
7196         },
7197
7198         
7199
7200         createProxy : function(CD, CE, CF){
7201             if(CE){
7202                 CE = Roo.getDom(CE);
7203             }else {
7204                 CE = document.body;
7205             }
7206
7207             CD = typeof  CD == "object" ?
7208                 CD : {tag : "div", cls: CD};
7209             var  CG = Roo.DomHelper.append(CE, CD, true);
7210             if(CF){
7211                CG.setBox(this.getBox());
7212             }
7213             return  CG;
7214         },
7215
7216         
7217
7218         mask : function(CH, CI){
7219             if(this.getStyle("position") == "static"){
7220                 this.setStyle("position", "relative");
7221             }
7222             if(!this._mask){
7223                 this._mask = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask"}, true);
7224             }
7225
7226             this.addClass("x-masked");
7227             this._mask.setDisplayed(true);
7228             if(typeof  CH == 'string'){
7229                 if(!this._maskMsg){
7230                     this._maskMsg = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask-msg", cn:{tag:'div'}}, true);
7231                 }
7232                 var  mm = this._maskMsg;
7233                 mm.dom.className = CI ? "roo-el-mask-msg " + CI : "roo-el-mask-msg";
7234                 mm.dom.firstChild.innerHTML = CH;
7235                 mm.setDisplayed(true);
7236                 mm.center(this);
7237             }
7238             if(Roo.isIE && !(Roo.isIE7 && Roo.isStrict) && this.getStyle('height') == 'auto'){ 
7239                 this._mask.setHeight(this.getHeight());
7240             }
7241             return  this._mask;
7242         },
7243
7244         
7245
7246         unmask : function(CJ){
7247             if(this._mask){
7248                 if(CJ === true){
7249                     this._mask.remove();
7250                     delete  this._mask;
7251                     if(this._maskMsg){
7252                         this._maskMsg.remove();
7253                         delete  this._maskMsg;
7254                     }
7255                 }else {
7256                     this._mask.setDisplayed(false);
7257                     if(this._maskMsg){
7258                         this._maskMsg.setDisplayed(false);
7259                     }
7260                 }
7261             }
7262
7263             this.removeClass("x-masked");
7264         },
7265
7266         
7267
7268         isMasked : function(){
7269             return  this._mask && this._mask.isVisible();
7270         },
7271
7272         
7273
7274         createShim : function(){
7275             var  el = document.createElement('iframe');
7276             el.frameBorder = 'no';
7277             el.className = 'roo-shim';
7278             if(Roo.isIE && Roo.isSecure){
7279                 el.src = Roo.SSL_SECURE_URL;
7280             }
7281             var  CK = Roo.get(this.dom.parentNode.insertBefore(el, this.dom));
7282             CK.autoBoxAdjust = false;
7283             return  CK;
7284         },
7285
7286         
7287
7288         remove : function(){
7289             if(this.dom.parentNode){
7290                 this.dom.parentNode.removeChild(this.dom);
7291             }
7292             delete  El.cache[this.dom.id];
7293         },
7294
7295         
7296
7297         addClassOnOver : function(CL, CM){
7298             this.on("mouseover", function(){
7299                 Roo.fly(this, '_internal').addClass(CL);
7300             }, this.dom);
7301             var  CN = function(e){
7302                 if(CM !== true || !e.within(this, true)){
7303                     Roo.fly(this, '_internal').removeClass(CL);
7304                 }
7305             };
7306             this.on("mouseout", CN, this.dom);
7307             return  this;
7308         },
7309
7310         
7311
7312         addClassOnFocus : function(CO){
7313             this.on("focus", function(){
7314                 Roo.fly(this, '_internal').addClass(CO);
7315             }, this.dom);
7316             this.on("blur", function(){
7317                 Roo.fly(this, '_internal').removeClass(CO);
7318             }, this.dom);
7319             return  this;
7320         },
7321         
7322
7323         addClassOnClick : function(CP){
7324             var  CQ = this.dom;
7325             this.on("mousedown", function(){
7326                 Roo.fly(CQ, '_internal').addClass(CP);
7327                 var  d = Roo.get(document);
7328                 var  fn = function(){
7329                     Roo.fly(CQ, '_internal').removeClass(CP);
7330                     d.removeListener("mouseup", fn);
7331                 };
7332                 d.on("mouseup", fn);
7333             });
7334             return  this;
7335         },
7336
7337         
7338
7339         swallowEvent : function(CR, CS){
7340             var  fn = function(e){
7341                 e.stopPropagation();
7342                 if(CS){
7343                     e.preventDefault();
7344                 }
7345             };
7346             if(CR  instanceof  Array){
7347                 for(var  i = 0, Ak = CR.length; i < Ak; i++){
7348                      this.on(CR[i], fn);
7349                 }
7350                 return  this;
7351             }
7352
7353             this.on(CR, fn);
7354             return  this;
7355         },
7356
7357         
7358
7359       fitToParentDelegate : Roo.emptyFn, 
7360
7361         
7362
7363         fitToParent : function(CT, CU) {
7364           Roo.EventManager.removeResizeListener(this.fitToParentDelegate); 
7365           this.fitToParentDelegate = Roo.emptyFn; 
7366           if (CT === true && !this.dom.parentNode) { 
7367             return;
7368           }
7369           var  p = Roo.get(CU || this.dom.parentNode);
7370           this.setSize(p.getComputedWidth() - p.getFrameWidth('lr'), p.getComputedHeight() - p.getFrameWidth('tb'));
7371           if (CT === true) {
7372             this.fitToParentDelegate = this.fitToParent.createDelegate(this, [true, CU]);
7373             Roo.EventManager.onWindowResize(this.fitToParentDelegate);
7374           }
7375           return  this;
7376         },
7377
7378         
7379
7380         getNextSibling : function(){
7381             var  n = this.dom.nextSibling;
7382             while(n && n.nodeType != 1){
7383                 n = n.nextSibling;
7384             }
7385             return  n;
7386         },
7387
7388         
7389
7390         getPrevSibling : function(){
7391             var  n = this.dom.previousSibling;
7392             while(n && n.nodeType != 1){
7393                 n = n.previousSibling;
7394             }
7395             return  n;
7396         },
7397
7398
7399         
7400
7401         appendChild: function(el){
7402             el = Roo.get(el);
7403             el.appendTo(this);
7404             return  this;
7405         },
7406
7407         
7408
7409         createChild: function(CV, CW, CX){
7410             CV = CV || {tag:'div'};
7411             if(CW){
7412                 return  Roo.DomHelper.insertBefore(CW, CV, CX !== true);
7413             }
7414             return  Roo.DomHelper[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, CV,  CX !== true);
7415         },
7416
7417         
7418
7419         appendTo: function(el){
7420             el = Roo.getDom(el);
7421             el.appendChild(this.dom);
7422             return  this;
7423         },
7424
7425         
7426
7427         insertBefore: function(el){
7428             el = Roo.getDom(el);
7429             el.parentNode.insertBefore(this.dom, el);
7430             return  this;
7431         },
7432
7433         
7434
7435         insertAfter: function(el){
7436             el = Roo.getDom(el);
7437             el.parentNode.insertBefore(this.dom, el.nextSibling);
7438             return  this;
7439         },
7440
7441         
7442
7443         insertFirst: function(el, CY){
7444             el = el || {};
7445             if(typeof  el == 'object' && !el.nodeType){ 
7446                 return  this.createChild(el, this.dom.firstChild, CY);
7447             }else {
7448                 el = Roo.getDom(el);
7449                 this.dom.insertBefore(el, this.dom.firstChild);
7450                 return  !CY ? Roo.get(el) : el;
7451             }
7452         },
7453
7454         
7455
7456         insertSibling: function(el, CZ, Ca){
7457             CZ = CZ ? CZ.toLowerCase() : 'before';
7458             el = el || {};
7459             var  rt, Cb = CZ == 'before' ? this.dom : this.dom.nextSibling;
7460
7461             if(typeof  el == 'object' && !el.nodeType){ 
7462                 if(CZ == 'after' && !this.dom.nextSibling){
7463                     rt = Roo.DomHelper.append(this.dom.parentNode, el, !Ca);
7464                 }else {
7465                     rt = Roo.DomHelper[CZ == 'after' ? 'insertAfter' : 'insertBefore'](this.dom, el, !Ca);
7466                 }
7467
7468             }else {
7469                 rt = this.dom.parentNode.insertBefore(Roo.getDom(el),
7470                             CZ == 'before' ? this.dom : this.dom.nextSibling);
7471                 if(!Ca){
7472                     rt = Roo.get(rt);
7473                 }
7474             }
7475             return  rt;
7476         },
7477
7478         
7479
7480         wrap: function(Cc, Cd){
7481             if(!Cc){
7482                 Cc = {tag: "div"};
7483             }
7484             var  Ce = Roo.DomHelper.insertBefore(this.dom, Cc, !Cd);
7485             Ce.dom ? Ce.dom.appendChild(this.dom) : Ce.appendChild(this.dom);
7486             return  Ce;
7487         },
7488
7489         
7490
7491         replace: function(el){
7492             el = Roo.get(el);
7493             this.insertBefore(el);
7494             el.remove();
7495             return  this;
7496         },
7497
7498         
7499
7500         insertHtml : function(Cf, Cg, Ch){
7501             var  el = Roo.DomHelper.insertHtml(Cf, this.dom, Cg);
7502             return  Ch ? Roo.get(el) : el;
7503         },
7504
7505         
7506
7507         set : function(o, Ci){
7508             var  el = this.dom;
7509             Ci = typeof  Ci == 'undefined' ? (el.setAttribute ? true : false) : Ci;
7510             for(var  attr  in  o){
7511                 if(attr == "style" || typeof  o[attr] == "function") continue;
7512                 if(attr=="cls"){
7513                     el.className = o["cls"];
7514                 }else {
7515                     if(Ci) el.setAttribute(attr, o[attr]);
7516                     else  el[attr] = o[attr];
7517                 }
7518             }
7519             if(o.style){
7520                 Roo.DomHelper.applyStyles(el, o.style);
7521             }
7522             return  this;
7523         },
7524
7525         
7526
7527         addKeyListener : function(Cj, fn, Ck){
7528             var  Cl;
7529             if(typeof  Cj != "object" || Cj  instanceof  Array){
7530                 Cl = {
7531                     key: Cj,
7532                     fn: fn,
7533                     scope: Ck
7534                 };
7535             }else {
7536                 Cl = {
7537                     key : Cj.key,
7538                     shift : Cj.shift,
7539                     ctrl : Cj.ctrl,
7540                     alt : Cj.alt,
7541                     fn: fn,
7542                     scope: Ck
7543                 };
7544             }
7545             return  new  Roo.KeyMap(this, Cl);
7546         },
7547
7548         
7549
7550         addKeyMap : function(Cm){
7551             return  new  Roo.KeyMap(this, Cm);
7552         },
7553
7554         
7555
7556          isScrollable : function(){
7557             var  Cn = this.dom;
7558             return  Cn.scrollHeight > Cn.clientHeight || Cn.scrollWidth > Cn.clientWidth;
7559         },
7560
7561         
7562
7563
7564         scrollTo : function(Co, Cp, Cq){
7565             var  Cr = Co.toLowerCase() == "left" ? "scrollLeft" : "scrollTop";
7566             if(!Cq || !A){
7567                 this.dom[Cr] = Cp;
7568             }else {
7569                 var  to = Cr == "scrollLeft" ? [Cp, this.dom.scrollTop] : [this.dom.scrollLeft, Cp];
7570                 this.anim({scroll: {"to": to}}, this.preanim(arguments, 2), 'scroll');
7571             }
7572             return  this;
7573         },
7574
7575         
7576
7577          scroll : function(Cs, Ct, Cu){
7578              if(!this.isScrollable()){
7579                  return;
7580              }
7581              var  el = this.dom;
7582              var  l = el.scrollLeft, t = el.scrollTop;
7583              var  w = el.scrollWidth, h = el.scrollHeight;
7584              var  cw = el.clientWidth, ch = el.clientHeight;
7585              Cs = Cs.toLowerCase();
7586              var  Cv = false;
7587              var  a = this.preanim(arguments, 2);
7588              switch(Cs){
7589                  case  "l":
7590                  case  "left":
7591                      if(w - l > cw){
7592                          var  v = Math.min(l + Ct, w-cw);
7593                          this.scrollTo("left", v, a);
7594                          Cv = true;
7595                      }
7596                      break;
7597                 case  "r":
7598                 case  "right":
7599                      if(l > 0){
7600                          var  v = Math.max(l - Ct, 0);
7601                          this.scrollTo("left", v, a);
7602                          Cv = true;
7603                      }
7604                      break;
7605                 case  "t":
7606                 case  "top":
7607                 case  "up":
7608                      if(t > 0){
7609                          var  v = Math.max(t - Ct, 0);
7610                          this.scrollTo("top", v, a);
7611                          Cv = true;
7612                      }
7613                      break;
7614                 case  "b":
7615                 case  "bottom":
7616                 case  "down":
7617                      if(h - t > ch){
7618                          var  v = Math.min(t + Ct, h-ch);
7619                          this.scrollTo("top", v, a);
7620                          Cv = true;
7621                      }
7622                      break;
7623              }
7624              return  Cv;
7625         },
7626
7627         
7628
7629         translatePoints : function(x, y){
7630             if(typeof  x == 'object' || x  instanceof  Array){
7631                 y = x[1]; x = x[0];
7632             }
7633             var  p = this.getStyle('position');
7634             var  o = this.getXY();
7635
7636             var  l = parseInt(this.getStyle('left'), 10);
7637             var  t = parseInt(this.getStyle('top'), 10);
7638
7639             if(isNaN(l)){
7640                 l = (p == "relative") ? 0 : this.dom.offsetLeft;
7641             }
7642             if(isNaN(t)){
7643                 t = (p == "relative") ? 0 : this.dom.offsetTop;
7644             }
7645
7646             return  {left: (x - o[0] + l), top: (y - o[1] + t)};
7647         },
7648
7649         
7650
7651         getScroll : function(){
7652             var  d = this.dom, Cw = document;
7653             if(d == Cw || d == Cw.body){
7654                 var  l = window.pageXOffset || Cw.documentElement.scrollLeft || Cw.body.scrollLeft || 0;
7655                 var  t = window.pageYOffset || Cw.documentElement.scrollTop || Cw.body.scrollTop || 0;
7656                 return  {left: l, top: t};
7657             }else {
7658                 return  {left: d.scrollLeft, top: d.scrollTop};
7659             }
7660         },
7661
7662         
7663
7664         getColor : function(Cx, Cy, Cz){
7665             var  v = this.getStyle(Cx);
7666             if(!v || v == "transparent" || v == "inherit") {
7667                 return  Cy;
7668             }
7669             var  C0 = typeof  Cz == "undefined" ? "#" : Cz;
7670             if(v.substr(0, 4) == "rgb("){
7671                 var  rvs = v.slice(4, v.length -1).split(",");
7672                 for(var  i = 0; i < 3; i++){
7673                     var  h = parseInt(rvs[i]).toString(16);
7674                     if(h < 16){
7675                         h = "0" + h;
7676                     }
7677
7678                     C0 += h;
7679                 }
7680             } else  {
7681                 if(v.substr(0, 1) == "#"){
7682                     if(v.length == 4) {
7683                         for(var  i = 1; i < 4; i++){
7684                             var  c = v.charAt(i);
7685                             C0 +=  c + c;
7686                         }
7687                     }else  if(v.length == 7){
7688                         C0 += v.substr(1);
7689                     }
7690                 }
7691             }
7692             return (C0.length > 5 ? C0.toLowerCase() : Cy);
7693         },
7694
7695         
7696
7697         boxWrap : function(C1){
7698             C1 = C1 || 'x-box';
7699             var  el = Roo.get(this.insertHtml('beforeBegin', String.format('<div class="{0}">'+El.boxMarkup+'</div>', C1)));
7700             el.child('.'+C1+'-mc').dom.appendChild(this.dom);
7701             return  el;
7702         },
7703
7704         
7705
7706         getAttributeNS : Roo.isIE ? function(ns, C2){
7707             var  d = this.dom;
7708             var  C3 = typeof  d[ns+":"+C2];
7709             if(C3 != 'undefined' && C3 != 'unknown'){
7710                 return  d[ns+":"+C2];
7711             }
7712             return  d[C2];
7713         } : function(ns, C4){
7714             var  d = this.dom;
7715             return  d.getAttributeNS(ns, C4) || d.getAttribute(ns+":"+C4) || d.getAttribute(C4) || d[C4];
7716         }
7717     };
7718
7719     var  ep = El.prototype;
7720
7721     
7722
7723     ep.on = ep.addListener;
7724         
7725     ep.mon = ep.addListener;
7726
7727     
7728
7729     ep.un = ep.removeListener;
7730
7731     
7732
7733     ep.autoBoxAdjust = true;
7734
7735     
7736     El.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
7737
7738     
7739     El.addUnits = function(v, J){
7740         if(v === "" || v == "auto"){
7741             return  v;
7742         }
7743         if(v === undefined){
7744             return  '';
7745         }
7746         if(typeof  v == "number" || !El.unitPattern.test(v)){
7747             return  v + (J || 'px');
7748         }
7749         return  v;
7750     };
7751
7752     
7753     El.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
7754     
7755
7756     El.VISIBILITY = 1;
7757     
7758
7759     El.DISPLAY = 2;
7760
7761     El.borders = {l: "border-left-width", r: "border-right-width", t: "border-top-width", b: "border-bottom-width"};
7762     El.paddings = {l: "padding-left", r: "padding-right", t: "padding-top", b: "padding-bottom"};
7763     El.margins = {l: "margin-left", r: "margin-right", t: "margin-top", b: "margin-bottom"};
7764
7765
7766
7767     
7768
7769     El.cache = {};
7770
7771     var  H;
7772
7773     
7774
7775     El.get = function(el){
7776         var  ex, J, id;
7777         if(!el){ return  null; }
7778         if(typeof  el == "string"){ 
7779             if(!(J = document.getElementById(el))){
7780                 return  null;
7781             }
7782             if(ex = El.cache[el]){
7783                 ex.dom = J;
7784             }else {
7785                 ex = El.cache[el] = new  El(J);
7786             }
7787             return  ex;
7788         }else  if(el.tagName){ 
7789             if(!(id = el.id)){
7790                 id = Roo.id(el);
7791             }
7792             if(ex = El.cache[id]){
7793                 ex.dom = el;
7794             }else {
7795                 ex = El.cache[id] = new  El(el);
7796             }
7797             return  ex;
7798         }else  if(el  instanceof  El){
7799             if(el != H){
7800                 el.dom = document.getElementById(el.id) || el.dom; 
7801                                                               
7802                 El.cache[el.id] = el; 
7803             }
7804             return  el;
7805         }else  if(el.isComposite){
7806             return  el;
7807         }else  if(el  instanceof  Array){
7808             return  El.select(el);
7809         }else  if(el == document){
7810             
7811             if(!H){
7812                 var  f = function(){};
7813                 f.prototype = El.prototype;
7814                 H = new  f();
7815                 H.dom = document;
7816             }
7817             return  H;
7818         }
7819         return  null;
7820     };
7821
7822     
7823     El.uncache = function(el){
7824         for(var  i = 0, a = arguments, len = a.length; i < len; i++) {
7825             if(a[i]){
7826                 delete  El.cache[a[i].id || a[i]];
7827             }
7828         }
7829     };
7830
7831     
7832     
7833     
7834     El.garbageCollect = function(){
7835         if(!Roo.enableGarbageCollector){
7836             clearInterval(El.collectorThread);
7837             return;
7838         }
7839         for(var  eid  in  El.cache){
7840             var  el = El.cache[eid], d = el.dom;
7841             
7842             
7843             
7844             
7845             
7846             
7847             
7848             
7849             
7850             
7851             
7852             
7853             
7854             
7855             
7856             
7857             
7858             if(!d || !d.parentNode || (!d.offsetParent && !document.getElementById(eid))){
7859                 delete  El.cache[eid];
7860                 if(d && Roo.enableListenerCollection){
7861                     E.purgeElement(d);
7862                 }
7863             }
7864         }
7865     }
7866
7867     El.collectorThreadId = setInterval(El.garbageCollect, 30000);
7868
7869
7870     
7871     El.Flyweight = function(J){
7872         this.dom = J;
7873     };
7874     El.Flyweight.prototype = El.prototype;
7875
7876     El._flyweights = {};
7877     
7878
7879     El.fly = function(el, J){
7880         J = J || '_global';
7881         el = Roo.getDom(el);
7882         if(!el){
7883             return  null;
7884         }
7885         if(!El._flyweights[J]){
7886             El._flyweights[J] = new  El.Flyweight();
7887         }
7888
7889         El._flyweights[J].dom = el;
7890         return  El._flyweights[J];
7891     };
7892
7893     
7894
7895     Roo.get = El.get;
7896     
7897
7898     Roo.fly = El.fly;
7899
7900     
7901     var  I = Roo.isStrict ? {
7902         select:1
7903     } : {
7904         input:1, select:1, textarea:1
7905     };
7906     if(Roo.isIE || Roo.isGecko){
7907         I['button'] = 1;
7908     }
7909
7910
7911
7912     Roo.EventManager.on(window, 'unload', function(){
7913         delete  El.cache;
7914         delete  El._flyweights;
7915     });
7916 })();
7917
7918
7919
7920
7921 if(Roo.DomQuery){
7922     Roo.Element.selectorFunction = Roo.DomQuery.select;
7923 }
7924
7925
7926 Roo.Element.select = function(J, K, L){
7927     var  M;
7928     if(typeof  J == "string"){
7929         M = Roo.Element.selectorFunction(J, L);
7930     }else  if(J.length !== undefined){
7931         M = J;
7932     }else {
7933         throw  "Invalid selector";
7934     }
7935     if(K === true){
7936         return  new  Roo.CompositeElement(M);
7937     }else {
7938         return  new  Roo.CompositeElementLite(M);
7939     }
7940 };
7941
7942
7943 Roo.select = Roo.Element.select;
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965 Roo.enableFx = true;
7966
7967
7968
7969 Roo.Fx = {
7970         
7971
7972     slideIn : function(A, o){
7973         var  el = this.getFxEl();
7974         o = o || {};
7975
7976         el.queueFx(o, function(){
7977
7978             A = A || "t";
7979
7980             
7981             this.fixDisplay();
7982
7983             
7984             var  r = this.getFxRestore();
7985             var  b = this.getBox();
7986             
7987             this.setSize(b);
7988
7989             
7990             var  B = this.fxWrap(r.pos, o, "hidden");
7991
7992             var  st = this.dom.style;
7993             st.visibility = "visible";
7994             st.position = "absolute";
7995
7996             
7997             var  C = function(){
7998                 el.fxUnwrap(B, r.pos, o);
7999                 st.width = r.width;
8000                 st.height = r.height;
8001                 el.afterFx(o);
8002             };
8003             
8004             var  a, pt = {to: [b.x, b.y]}, bw = {to: b.width}, bh = {to: b.height};
8005
8006             switch(A.toLowerCase()){
8007                 case  "t":
8008                     B.setSize(b.width, 0);
8009                     st.left = st.bottom = "0";
8010                     a = {height: bh};
8011                 break;
8012                 case  "l":
8013                     B.setSize(0, b.height);
8014                     st.right = st.top = "0";
8015                     a = {width: bw};
8016                 break;
8017                 case  "r":
8018                     B.setSize(0, b.height);
8019                     B.setX(b.right);
8020                     st.left = st.top = "0";
8021                     a = {width: bw, points: pt};
8022                 break;
8023                 case  "b":
8024                     B.setSize(b.width, 0);
8025                     B.setY(b.bottom);
8026                     st.left = st.top = "0";
8027                     a = {height: bh, points: pt};
8028                 break;
8029                 case  "tl":
8030                     B.setSize(0, 0);
8031                     st.right = st.bottom = "0";
8032                     a = {width: bw, height: bh};
8033                 break;
8034                 case  "bl":
8035                     B.setSize(0, 0);
8036                     B.setY(b.y+b.height);
8037                     st.right = st.top = "0";
8038                     a = {width: bw, height: bh, points: pt};
8039                 break;
8040                 case  "br":
8041                     B.setSize(0, 0);
8042                     B.setXY([b.right, b.bottom]);
8043                     st.left = st.top = "0";
8044                     a = {width: bw, height: bh, points: pt};
8045                 break;
8046                 case  "tr":
8047                     B.setSize(0, 0);
8048                     B.setX(b.x+b.width);
8049                     st.left = st.bottom = "0";
8050                     a = {width: bw, height: bh, points: pt};
8051                 break;
8052             }
8053
8054             this.dom.style.visibility = "visible";
8055             B.show();
8056
8057             arguments.callee.anim = B.fxanim(a,
8058                 o,
8059                 'motion',
8060                 .5,
8061                 'easeOut', C);
8062         });
8063         return  this;
8064     },
8065     
8066         
8067
8068     slideOut : function(B, o){
8069         var  el = this.getFxEl();
8070         o = o || {};
8071
8072         el.queueFx(o, function(){
8073
8074             B = B || "t";
8075
8076             
8077             var  r = this.getFxRestore();
8078             
8079             var  b = this.getBox();
8080             
8081             this.setSize(b);
8082
8083             
8084             var  C = this.fxWrap(r.pos, o, "visible");
8085
8086             var  st = this.dom.style;
8087             st.visibility = "visible";
8088             st.position = "absolute";
8089
8090             C.setSize(b);
8091
8092             var  D = function(){
8093                 if(o.useDisplay){
8094                     el.setDisplayed(false);
8095                 }else {
8096                     el.hide();
8097                 }
8098
8099
8100                 el.fxUnwrap(C, r.pos, o);
8101
8102                 st.width = r.width;
8103                 st.height = r.height;
8104
8105                 el.afterFx(o);
8106             };
8107
8108             var  a, E = {to: 0};
8109             switch(B.toLowerCase()){
8110                 case  "t":
8111                     st.left = st.bottom = "0";
8112                     a = {height: E};
8113                 break;
8114                 case  "l":
8115                     st.right = st.top = "0";
8116                     a = {width: E};
8117                 break;
8118                 case  "r":
8119                     st.left = st.top = "0";
8120                     a = {width: E, points: {to:[b.right, b.y]}};
8121                 break;
8122                 case  "b":
8123                     st.left = st.top = "0";
8124                     a = {height: E, points: {to:[b.x, b.bottom]}};
8125                 break;
8126                 case  "tl":
8127                     st.right = st.bottom = "0";
8128                     a = {width: E, height: E};
8129                 break;
8130                 case  "bl":
8131                     st.right = st.top = "0";
8132                     a = {width: E, height: E, points: {to:[b.x, b.bottom]}};
8133                 break;
8134                 case  "br":
8135                     st.left = st.top = "0";
8136                     a = {width: E, height: E, points: {to:[b.x+b.width, b.bottom]}};
8137                 break;
8138                 case  "tr":
8139                     st.left = st.bottom = "0";
8140                     a = {width: E, height: E, points: {to:[b.right, b.y]}};
8141                 break;
8142             }
8143
8144
8145             arguments.callee.anim = C.fxanim(a,
8146                 o,
8147                 'motion',
8148                 .5,
8149                 "easeOut", D);
8150         });
8151         return  this;
8152     },
8153
8154         
8155
8156     puff : function(o){
8157         var  el = this.getFxEl();
8158         o = o || {};
8159
8160         el.queueFx(o, function(){
8161             this.clearOpacity();
8162             this.show();
8163
8164             
8165             var  r = this.getFxRestore();
8166             var  st = this.dom.style;
8167
8168             var  C = function(){
8169                 if(o.useDisplay){
8170                     el.setDisplayed(false);
8171                 }else {
8172                     el.hide();
8173                 }
8174
8175
8176                 el.clearOpacity();
8177
8178                 el.setPositioning(r.pos);
8179                 st.width = r.width;
8180                 st.height = r.height;
8181                 st.fontSize = '';
8182                 el.afterFx(o);
8183             };
8184
8185             var  D = this.getWidth();
8186             var  E = this.getHeight();
8187
8188             arguments.callee.anim = this.fxanim({
8189                     width : {to: this.adjustWidth(D * 2)},
8190                     height : {to: this.adjustHeight(E * 2)},
8191                     points : {by: [-(D * .5), -(E * .5)]},
8192                     opacity : {to: 0},
8193                     fontSize: {to:200, unit: "%"}
8194                 },
8195                 o,
8196                 'motion',
8197                 .5,
8198                 "easeOut", C);
8199         });
8200         return  this;
8201     },
8202
8203         
8204
8205     switchOff : function(o){
8206         var  el = this.getFxEl();
8207         o = o || {};
8208
8209         el.queueFx(o, function(){
8210             this.clearOpacity();
8211             this.clip();
8212
8213             
8214             var  r = this.getFxRestore();
8215             var  st = this.dom.style;
8216
8217             var  C = function(){
8218                 if(o.useDisplay){
8219                     el.setDisplayed(false);
8220                 }else {
8221                     el.hide();
8222                 }
8223
8224
8225                 el.clearOpacity();
8226                 el.setPositioning(r.pos);
8227                 st.width = r.width;
8228                 st.height = r.height;
8229
8230                 el.afterFx(o);
8231             };
8232
8233             this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
8234                 this.clearOpacity();
8235                 (function(){
8236                     this.fxanim({
8237                         height:{to:1},
8238                         points:{by:[0, this.getHeight() * .5]}
8239                     }, o, 'motion', 0.3, 'easeIn', C);
8240                 }).defer(100, this);
8241             });
8242         });
8243         return  this;
8244     },
8245
8246     
8247         
8248     highlight : function(C, o){
8249         var  el = this.getFxEl();
8250         o = o || {};
8251
8252         el.queueFx(o, function(){
8253             C = C || "ffff9c";
8254             attr = o.attr || "backgroundColor";
8255
8256             this.clearOpacity();
8257             this.show();
8258
8259             var  D = this.getColor(attr);
8260             var  E = this.dom.style[attr];
8261             endColor = (o.endColor || D) || "ffffff";
8262
8263             var  F = function(){
8264                 el.dom.style[attr] = E;
8265                 el.afterFx(o);
8266             };
8267
8268             var  a = {};
8269             a[attr] = {from: C, to: endColor};
8270             arguments.callee.anim = this.fxanim(a,
8271                 o,
8272                 'color',
8273                 1,
8274                 'easeIn', F);
8275         });
8276         return  this;
8277     },
8278
8279    
8280
8281     frame : function(D, E, o){
8282         var  el = this.getFxEl();
8283         o = o || {};
8284
8285         el.queueFx(o, function(){
8286             D = D || "#C3DAF9";
8287             if(D.length == 6){
8288                 D = "#" + D;
8289             }
8290
8291             E = E || 1;
8292             duration = o.duration || 1;
8293             this.show();
8294
8295             var  b = this.getBox();
8296             var  F = function(){
8297                 var  G = this.createProxy({
8298
8299                      style:{
8300                         visbility:"hidden",
8301                         position:"absolute",
8302                         "z-index":"35000", 
8303                         border:"0px solid " + D
8304                      }
8305                   });
8306                 var  H = Roo.isBorderBox ? 2 : 1;
8307                 G.animate({
8308                     top:{from:b.y, to:b.y - 20},
8309                     left:{from:b.x, to:b.x - 20},
8310                     borderWidth:{from:0, to:10},
8311                     opacity:{from:1, to:0},
8312                     height:{from:b.height, to:(b.height + (20*H))},
8313                     width:{from:b.width, to:(b.width + (20*H))}
8314                 }, duration, function(){
8315                     G.remove();
8316                 });
8317                 if(--E > 0){
8318                      F.defer((duration/2)*1000, this);
8319                 }else {
8320                     el.afterFx(o);
8321                 }
8322             };
8323             F.call(this);
8324         });
8325         return  this;
8326     },
8327
8328    
8329
8330     pause : function(F){
8331         var  el = this.getFxEl();
8332         var  o = {};
8333
8334         el.queueFx(o, function(){
8335             setTimeout(function(){
8336                 el.afterFx(o);
8337             }, F * 1000);
8338         });
8339         return  this;
8340     },
8341
8342    
8343
8344     fadeIn : function(o){
8345         var  el = this.getFxEl();
8346         o = o || {};
8347         el.queueFx(o, function(){
8348             this.setOpacity(0);
8349             this.fixDisplay();
8350             this.dom.style.visibility = 'visible';
8351             var  to = o.endOpacity || 1;
8352             arguments.callee.anim = this.fxanim({opacity:{to:to}},
8353                 o, null, .5, "easeOut", function(){
8354                 if(to == 1){
8355                     this.clearOpacity();
8356                 }
8357
8358                 el.afterFx(o);
8359             });
8360         });
8361         return  this;
8362     },
8363
8364    
8365
8366     fadeOut : function(o){
8367         var  el = this.getFxEl();
8368         o = o || {};
8369         el.queueFx(o, function(){
8370             arguments.callee.anim = this.fxanim({opacity:{to:o.endOpacity || 0}},
8371                 o, null, .5, "easeOut", function(){
8372                 if(this.visibilityMode == Roo.Element.DISPLAY || o.useDisplay){
8373                      this.dom.style.display = "none";
8374                 }else {
8375                      this.dom.style.visibility = "hidden";
8376                 }
8377
8378                 this.clearOpacity();
8379                 el.afterFx(o);
8380             });
8381         });
8382         return  this;
8383     },
8384
8385    
8386
8387     scale : function(w, h, o){
8388         this.shift(Roo.apply({}, o, {
8389             width: w,
8390             height: h
8391         }));
8392         return  this;
8393     },
8394
8395    
8396
8397     shift : function(o){
8398         var  el = this.getFxEl();
8399         o = o || {};
8400         el.queueFx(o, function(){
8401             var  a = {}, w = o.width, h = o.height, x = o.x, y = o.y,  op = o.opacity;
8402             if(w !== undefined){
8403                 a.width = {to: this.adjustWidth(w)};
8404             }
8405             if(h !== undefined){
8406                 a.height = {to: this.adjustHeight(h)};
8407             }
8408             if(x !== undefined || y !== undefined){
8409                 a.points = {to: [
8410                     x !== undefined ? x : this.getX(),
8411                     y !== undefined ? y : this.getY()
8412                 ]};
8413             }
8414             if(op !== undefined){
8415                 a.opacity = {to: op};
8416             }
8417             if(o.xy !== undefined){
8418                 a.points = {to: o.xy};
8419             }
8420
8421             arguments.callee.anim = this.fxanim(a,
8422                 o, 'motion', .35, "easeOut", function(){
8423                 el.afterFx(o);
8424             });
8425         });
8426         return  this;
8427     },
8428
8429         
8430
8431     ghost : function(G, o){
8432         var  el = this.getFxEl();
8433         o = o || {};
8434
8435         el.queueFx(o, function(){
8436             G = G || "b";
8437
8438             
8439             var  r = this.getFxRestore();
8440             var  w = this.getWidth(),
8441                 h = this.getHeight();
8442
8443             var  st = this.dom.style;
8444
8445             var  H = function(){
8446                 if(o.useDisplay){
8447                     el.setDisplayed(false);
8448                 }else {
8449                     el.hide();
8450                 }
8451
8452
8453                 el.clearOpacity();
8454                 el.setPositioning(r.pos);
8455                 st.width = r.width;
8456                 st.height = r.height;
8457
8458                 el.afterFx(o);
8459             };
8460
8461             var  a = {opacity: {to: 0}, points: {}}, pt = a.points;
8462             switch(G.toLowerCase()){
8463                 case  "t":
8464                     pt.by = [0, -h];
8465                 break;
8466                 case  "l":
8467                     pt.by = [-w, 0];
8468                 break;
8469                 case  "r":
8470                     pt.by = [w, 0];
8471                 break;
8472                 case  "b":
8473                     pt.by = [0, h];
8474                 break;
8475                 case  "tl":
8476                     pt.by = [-w, -h];
8477                 break;
8478                 case  "bl":
8479                     pt.by = [-w, h];
8480                 break;
8481                 case  "br":
8482                     pt.by = [w, h];
8483                 break;
8484                 case  "tr":
8485                     pt.by = [w, -h];
8486                 break;
8487             }
8488
8489
8490             arguments.callee.anim = this.fxanim(a,
8491                 o,
8492                 'motion',
8493                 .5,
8494                 "easeOut", H);
8495         });
8496         return  this;
8497     },
8498
8499         
8500
8501     syncFx : function(){
8502         this.fxDefaults = Roo.apply(this.fxDefaults || {}, {
8503             block : false,
8504             concurrent : true,
8505             stopFx : false
8506         });
8507         return  this;
8508     },
8509
8510         
8511
8512     sequenceFx : function(){
8513         this.fxDefaults = Roo.apply(this.fxDefaults || {}, {
8514             block : false,
8515             concurrent : false,
8516             stopFx : false
8517         });
8518         return  this;
8519     },
8520
8521         
8522
8523     nextFx : function(){
8524         var  ef = this.fxQueue[0];
8525         if(ef){
8526             ef.call(this);
8527         }
8528     },
8529
8530         
8531
8532     hasActiveFx : function(){
8533         return  this.fxQueue && this.fxQueue[0];
8534     },
8535
8536         
8537
8538     stopFx : function(){
8539         if(this.hasActiveFx()){
8540             var  cur = this.fxQueue[0];
8541             if(cur && cur.anim && cur.anim.isAnimated()){
8542                 this.fxQueue = [cur]; 
8543                 cur.anim.stop(true);
8544             }
8545         }
8546         return  this;
8547     },
8548
8549         
8550
8551     beforeFx : function(o){
8552         if(this.hasActiveFx() && !o.concurrent){
8553            if(o.stopFx){
8554                this.stopFx();
8555                return  true;
8556            }
8557            return  false;
8558         }
8559         return  true;
8560     },
8561
8562         
8563
8564     hasFxBlock : function(){
8565         var  q = this.fxQueue;
8566         return  q && q[0] && q[0].block;
8567     },
8568
8569         
8570
8571     queueFx : function(o, fn){
8572         if(!this.fxQueue){
8573             this.fxQueue = [];
8574         }
8575         if(!this.hasFxBlock()){
8576             Roo.applyIf(o, this.fxDefaults);
8577             if(!o.concurrent){
8578                 var  run = this.beforeFx(o);
8579                 fn.block = o.block;
8580                 this.fxQueue.push(fn);
8581                 if(run){
8582                     this.nextFx();
8583                 }
8584             }else {
8585                 fn.call(this);
8586             }
8587         }
8588         return  this;
8589     },
8590
8591         
8592
8593     fxWrap : function(H, o, I){
8594         var  J;
8595         if(!o.wrap || !(J = Roo.get(o.wrap))){
8596             var  wrapXY;
8597             if(o.fixPosition){
8598                 wrapXY = this.getXY();
8599             }
8600             var  div = document.createElement("div");
8601             div.style.visibility = I;
8602             J = Roo.get(this.dom.parentNode.insertBefore(div, this.dom));
8603             J.setPositioning(H);
8604             if(J.getStyle("position") == "static"){
8605                 J.position("relative");
8606             }
8607
8608             this.clearPositioning('auto');
8609             J.clip();
8610             J.dom.appendChild(this.dom);
8611             if(wrapXY){
8612                 J.setXY(wrapXY);
8613             }
8614         }
8615         return  J;
8616     },
8617
8618         
8619
8620     fxUnwrap : function(K, L, o){
8621         this.clearPositioning();
8622         this.setPositioning(L);
8623         if(!o.wrap){
8624             K.dom.parentNode.insertBefore(this.dom, K.dom);
8625             K.remove();
8626         }
8627     },
8628
8629         
8630
8631     getFxRestore : function(){
8632         var  st = this.dom.style;
8633         return  {pos: this.getPositioning(), width: st.width, height : st.height};
8634     },
8635
8636         
8637
8638     afterFx : function(o){
8639         if(o.afterStyle){
8640             this.applyStyles(o.afterStyle);
8641         }
8642         if(o.afterCls){
8643             this.addClass(o.afterCls);
8644         }
8645         if(o.remove === true){
8646             this.remove();
8647         }
8648
8649         Roo.callback(o.callback, o.scope, [this]);
8650         if(!o.concurrent){
8651             this.fxQueue.shift();
8652             this.nextFx();
8653         }
8654     },
8655
8656         
8657
8658     getFxEl : function(){ 
8659         return  Roo.get(this.dom);
8660     },
8661
8662         
8663
8664     fxanim : function(M, N, O, P, Q, cb){
8665         O = O || 'run';
8666         N = N || {};
8667         var  R = Roo.lib.Anim[O](
8668             this.dom, M,
8669             (N.duration || P) || .35,
8670             (N.easing || Q) || 'easeOut',
8671             function(){
8672                 Roo.callback(cb, this);
8673             },
8674             this
8675         );
8676         N.anim = R;
8677         return  R;
8678     }
8679 };
8680
8681
8682 Roo.Fx.resize = Roo.Fx.scale;
8683
8684
8685
8686 Roo.apply(Roo.Element.prototype, Roo.Fx);
8687
8688
8689
8690
8691
8692
8693 Roo.CompositeElement = function(A){
8694     this.elements = [];
8695     this.addElements(A);
8696 };
8697 Roo.CompositeElement.prototype = {
8698     isComposite: true,
8699     addElements : function(B){
8700         if(!B) return  this;
8701         if(typeof  B == "string"){
8702             B = Roo.Element.selectorFunction(B);
8703         }
8704         var  C = this.elements;
8705         var  D = C.length-1;
8706         for(var  i = 0, len = B.length; i < len; i++) {
8707                 C[++D] = Roo.get(B[i]);
8708         }
8709         return  this;
8710     },
8711
8712     
8713
8714     fill : function(E){
8715         this.elements = [];
8716         this.add(E);
8717         return  this;
8718     },
8719
8720     
8721
8722     filter : function(F){
8723         var  G = [];
8724         this.each(function(el){
8725             if(el.is(F)){
8726                 G[G.length] = el.dom;
8727             }
8728         });
8729         this.fill(G);
8730         return  this;
8731     },
8732
8733     invoke : function(fn, H){
8734         var  I = this.elements;
8735         for(var  i = 0, len = I.length; i < len; i++) {
8736                 Roo.Element.prototype[fn].apply(I[i], H);
8737         }
8738         return  this;
8739     },
8740     
8741
8742     add : function(J){
8743         if(typeof  J == "string"){
8744             this.addElements(Roo.Element.selectorFunction(J));
8745         }else  if(J.length !== undefined){
8746             this.addElements(J);
8747         }else {
8748             this.addElements([J]);
8749         }
8750         return  this;
8751     },
8752     
8753
8754     each : function(fn, K){
8755         var  L = this.elements;
8756         for(var  i = 0, len = L.length; i < len; i++){
8757             if(fn.call(K || L[i], L[i], this, i) === false) {
8758                 break;
8759             }
8760         }
8761         return  this;
8762     },
8763
8764     
8765
8766     item : function(M){
8767         return  this.elements[M] || null;
8768     },
8769
8770     
8771
8772     first : function(){
8773         return  this.item(0);
8774     },
8775
8776     
8777
8778     last : function(){
8779         return  this.item(this.elements.length-1);
8780     },
8781
8782     
8783
8784     getCount : function(){
8785         return  this.elements.length;
8786     },
8787
8788     
8789
8790     contains : function(el){
8791         return  this.indexOf(el) !== -1;
8792     },
8793
8794     
8795
8796     indexOf : function(el){
8797         return  this.elements.indexOf(Roo.get(el));
8798     },
8799
8800
8801     
8802
8803     removeElement : function(el, N){
8804         if(el  instanceof  Array){
8805             for(var  i = 0, len = el.length; i < len; i++){
8806                 this.removeElement(el[i]);
8807             }
8808             return  this;
8809         }
8810         var  O = typeof  el == 'number' ? el : this.indexOf(el);
8811         if(O !== -1){
8812             if(N){
8813                 var  d = this.elements[O];
8814                 if(d.dom){
8815                     d.remove();
8816                 }else {
8817                     d.parentNode.removeChild(d);
8818                 }
8819             }
8820
8821             this.elements.splice(O, 1);
8822         }
8823         return  this;
8824     },
8825
8826     
8827
8828     replaceElement : function(el, P, Q){
8829         var  R = typeof  el == 'number' ? el : this.indexOf(el);
8830         if(R !== -1){
8831             if(Q){
8832                 this.elements[R].replaceWith(P);
8833             }else {
8834                 this.elements.splice(R, 1, Roo.get(P))
8835             }
8836         }
8837         return  this;
8838     },
8839
8840     
8841
8842     clear : function(){
8843         this.elements = [];
8844     }
8845 };
8846 (function(){
8847     Roo.CompositeElement.createCall = function(S, T){
8848         if(!S[T]){
8849             S[T] = function(){
8850                 return  this.invoke(T, arguments);
8851             };
8852         }
8853     };
8854     for(var  fnName  in  Roo.Element.prototype){
8855         if(typeof  Roo.Element.prototype[fnName] == "function"){
8856             Roo.CompositeElement.createCall(Roo.CompositeElement.prototype, fnName);
8857         }
8858     };
8859 })();
8860
8861
8862
8863
8864
8865
8866 Roo.CompositeElementLite = function(A){
8867     Roo.CompositeElementLite.superclass.constructor.call(this, A);
8868     this.el = new  Roo.Element.Flyweight();
8869 };
8870 Roo.extend(Roo.CompositeElementLite, Roo.CompositeElement, {
8871     addElements : function(B){
8872         if(B){
8873             if(B  instanceof  Array){
8874                 this.elements = this.elements.concat(B);
8875             }else {
8876                 var  yels = this.elements;
8877                 var  index = yels.length-1;
8878                 for(var  i = 0, len = B.length; i < len; i++) {
8879                     yels[++index] = B[i];
8880                 }
8881             }
8882         }
8883         return  this;
8884     },
8885     invoke : function(fn, C){
8886         var  D = this.elements;
8887         var  el = this.el;
8888         for(var  i = 0, len = D.length; i < len; i++) {
8889             el.dom = D[i];
8890                 Roo.Element.prototype[fn].apply(el, C);
8891         }
8892         return  this;
8893     },
8894     
8895
8896     item : function(E){
8897         if(!this.elements[E]){
8898             return  null;
8899         }
8900
8901         this.el.dom = this.elements[E];
8902         return  this.el;
8903     },
8904
8905     
8906     addListener : function(F, G, H, I){
8907         var  J = this.elements;
8908         for(var  i = 0, len = J.length; i < len; i++) {
8909             Roo.EventManager.on(J[i], F, G, H || J[i], I);
8910         }
8911         return  this;
8912     },
8913
8914     
8915
8916     each : function(fn, K){
8917         var  L = this.elements;
8918         var  el = this.el;
8919         for(var  i = 0, len = L.length; i < len; i++){
8920             el.dom = L[i];
8921                 if(fn.call(K || el, el, this, i) === false){
8922                 break;
8923             }
8924         }
8925         return  this;
8926     },
8927
8928     indexOf : function(el){
8929         return  this.elements.indexOf(Roo.getDom(el));
8930     },
8931
8932     replaceElement : function(el, M, N){
8933         var  O = typeof  el == 'number' ? el : this.indexOf(el);
8934         if(O !== -1){
8935             M = Roo.getDom(M);
8936             if(N){
8937                 var  d = this.elements[O];
8938                 d.parentNode.insertBefore(M, d);
8939                 d.parentNode.removeChild(d);
8940             }
8941
8942             this.elements.splice(O, 1, M);
8943         }
8944         return  this;
8945     }
8946 });
8947 Roo.CompositeElementLite.prototype.on = Roo.CompositeElementLite.prototype.addListener;
8948
8949
8950
8951
8952
8953  
8954
8955
8956
8957 Roo.data.Connection = function(A){
8958     Roo.apply(this, A);
8959     this.addEvents({
8960         
8961
8962         "beforerequest" : true,
8963         
8964
8965         "requestcomplete" : true,
8966         
8967
8968         "requestexception" : true
8969     });
8970     Roo.data.Connection.superclass.constructor.call(this);
8971 };
8972
8973 Roo.extend(Roo.data.Connection, Roo.util.Observable, {
8974     
8975
8976     
8977
8978     
8979
8980     
8981
8982     
8983
8984     timeout : 30000,
8985     
8986
8987     autoAbort:false,
8988
8989     
8990
8991     disableCaching: true,
8992
8993     
8994
8995     request : function(o){
8996         if(this.fireEvent("beforerequest", this, o) !== false){
8997             var  p = o.params;
8998
8999             if(typeof  p == "function"){
9000                 p = p.call(o.scope||window, o);
9001             }
9002             if(typeof  p == "object"){
9003                 p = Roo.urlEncode(o.params);
9004             }
9005             if(this.extraParams){
9006                 var  extras = Roo.urlEncode(this.extraParams);
9007                 p = p ? (p + '&' + extras) : extras;
9008             }
9009
9010             var  url = o.url || this.url;
9011             if(typeof  url == 'function'){
9012                 url = url.call(o.scope||window, o);
9013             }
9014
9015             if(o.form){
9016                 var  form = Roo.getDom(o.form);
9017                 url = url || form.action;
9018
9019                 var  enctype = form.getAttribute("enctype");
9020                 if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
9021                     return  this.doFormUpload(o, p, url);
9022                 }
9023                 var  f = Roo.lib.Ajax.serializeForm(form);
9024                 p = p ? (p + '&' + f) : f;
9025             }
9026
9027             var  hs = o.headers;
9028             if(this.defaultHeaders){
9029                 hs = Roo.apply(hs || {}, this.defaultHeaders);
9030                 if(!o.headers){
9031                     o.headers = hs;
9032                 }
9033             }
9034
9035             var  cb = {
9036                 success: this.handleResponse,
9037                 failure: this.handleFailure,
9038                 scope: this,
9039                 argument: {options: o},
9040                 timeout : this.timeout
9041             };
9042
9043             var  method = o.method||this.method||(p ? "POST" : "GET");
9044
9045             if(method == 'GET' && (this.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
9046                 url += (url.indexOf('?') != -1 ? '&' : '?') + '_dc=' + (new  Date().getTime());
9047             }
9048
9049             if(typeof  o.autoAbort == 'boolean'){ 
9050                 if(o.autoAbort){
9051                     this.abort();
9052                 }
9053             }else  if(this.autoAbort !== false){
9054                 this.abort();
9055             }
9056
9057             if((method == 'GET' && p) || o.xmlData){
9058                 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
9059                 p = '';
9060             }
9061
9062             this.transId = Roo.lib.Ajax.request(method, url, cb, p, o);
9063             return  this.transId;
9064         }else {
9065             Roo.callback(o.callback, o.scope, [o, null, null]);
9066             return  null;
9067         }
9068     },
9069
9070     
9071
9072     isLoading : function(B){
9073         if(B){
9074             return  Roo.lib.Ajax.isCallInProgress(B);
9075         }else {
9076             return  this.transId ? true : false;
9077         }
9078     },
9079
9080     
9081
9082     abort : function(C){
9083         if(C || this.isLoading()){
9084             Roo.lib.Ajax.abort(C || this.transId);
9085         }
9086     },
9087
9088     
9089     handleResponse : function(D){
9090         this.transId = false;
9091         var  E = D.argument.options;
9092         D.argument = E ? E.argument : null;
9093         this.fireEvent("requestcomplete", this, D, E);
9094         Roo.callback(E.success, E.scope, [D, E]);
9095         Roo.callback(E.callback, E.scope, [E, true, D]);
9096     },
9097
9098     
9099     handleFailure : function(F, e){
9100         this.transId = false;
9101         var  G = F.argument.options;
9102         F.argument = G ? G.argument : null;
9103         this.fireEvent("requestexception", this, F, G, e);
9104         Roo.callback(G.failure, G.scope, [F, G]);
9105         Roo.callback(G.callback, G.scope, [G, false, F]);
9106     },
9107
9108     
9109     doFormUpload : function(o, ps, H){
9110         var  id = Roo.id();
9111         var  I = document.createElement('iframe');
9112         I.id = id;
9113         I.name = id;
9114         I.className = 'x-hidden';
9115         if(Roo.isIE){
9116             I.src = Roo.SSL_SECURE_URL;
9117         }
9118
9119         document.body.appendChild(I);
9120
9121         if(Roo.isIE){
9122            document.frames[id].name = id;
9123         }
9124
9125         var  J = Roo.getDom(o.form);
9126         J.target = id;
9127         J.method = 'POST';
9128         J.enctype = J.encoding = 'multipart/form-data';
9129         if(H){
9130             J.action = H;
9131         }
9132
9133         var  K, hd;
9134         if(ps){ 
9135             K = [];
9136             ps = Roo.urlDecode(ps, false);
9137             for(var  k  in  ps){
9138                 if(ps.hasOwnProperty(k)){
9139                     hd = document.createElement('input');
9140                     hd.type = 'hidden';
9141                     hd.name = k;
9142                     hd.value = ps[k];
9143                     J.appendChild(hd);
9144                     K.push(hd);
9145                 }
9146             }
9147         }
9148
9149         function  cb(){
9150             var  r = {  
9151                 responseText : '',
9152                 responseXML : null
9153             };
9154
9155             r.argument = o ? o.argument : null;
9156
9157             try { 
9158                 var  doc;
9159                 if(Roo.isIE){
9160                     doc = I.contentWindow.document;
9161                 }else  {
9162                     doc = (I.contentDocument || window.frames[id].document);
9163                 }
9164                 if(doc && doc.body){
9165                     r.responseText = doc.body.innerHTML;
9166                 }
9167                 if(doc && doc.XMLDocument){
9168                     r.responseXML = doc.XMLDocument;
9169                 }else  {
9170                     r.responseXML = doc;
9171                 }
9172             }
9173             catch(e) {
9174                 
9175             }
9176
9177
9178             Roo.EventManager.removeListener(I, 'load', cb, this);
9179
9180             this.fireEvent("requestcomplete", this, r, o);
9181             Roo.callback(o.success, o.scope, [r, o]);
9182             Roo.callback(o.callback, o.scope, [o, true, r]);
9183
9184             setTimeout(function(){document.body.removeChild(I);}, 100);
9185         }
9186
9187
9188         Roo.EventManager.on(I, 'load', cb, this);
9189         J.submit();
9190
9191         if(K){ 
9192             for(var  i = 0, len = K.length; i < len; i++){
9193                 J.removeChild(K[i]);
9194             }
9195         }
9196     }
9197 });
9198
9199
9200
9201 Roo.Ajax = new  Roo.data.Connection({
9202     
9203    
9204
9205     
9206
9207     
9208
9209     
9210
9211     
9212
9213     
9214
9215
9216     
9217
9218
9219     
9220
9221     
9222
9223     
9224
9225     
9226
9227     
9228
9229     
9230
9231
9232     
9233
9234     autoAbort : false,
9235
9236     
9237
9238     serializeForm : function(L){
9239         return  Roo.lib.Ajax.serializeForm(L);
9240     }
9241 });
9242
9243
9244  
9245
9246
9247 Roo.Ajax = new  Roo.data.Connection({
9248     
9249     
9250     
9251
9252     
9253    
9254
9255     
9256
9257     
9258
9259     
9260
9261     
9262
9263     
9264
9265
9266     
9267
9268
9269     
9270
9271     
9272
9273     
9274
9275     
9276
9277     
9278
9279     
9280
9281
9282     
9283
9284     autoAbort : false,
9285
9286     
9287
9288     serializeForm : function(A){
9289         return  Roo.lib.Ajax.serializeForm(A);
9290     }
9291 });
9292
9293
9294
9295  
9296
9297
9298 Roo.UpdateManager = function(el, A){
9299     el = Roo.get(el);
9300     if(!A && el.updateManager){
9301         return  el.updateManager;
9302     }
9303
9304     
9305
9306     this.el = el;
9307     
9308
9309     this.defaultUrl = null;
9310
9311     this.addEvents({
9312         
9313
9314         "beforeupdate": true,
9315         
9316
9317         "update": true,
9318         
9319
9320         "failure": true
9321     });
9322     var  d = Roo.UpdateManager.defaults;
9323     
9324
9325     this.sslBlankUrl = d.sslBlankUrl;
9326     
9327
9328     this.disableCaching = d.disableCaching;
9329     
9330
9331     this.indicatorText = d.indicatorText;
9332     
9333
9334     this.showLoadIndicator = d.showLoadIndicator;
9335     
9336
9337     this.timeout = d.timeout;
9338
9339     
9340
9341     this.loadScripts = d.loadScripts;
9342
9343     
9344
9345     this.transaction = null;
9346
9347     
9348
9349     this.autoRefreshProcId = null;
9350     
9351
9352     this.refreshDelegate = this.refresh.createDelegate(this);
9353     
9354
9355     this.updateDelegate = this.update.createDelegate(this);
9356     
9357
9358     this.formUpdateDelegate = this.formUpdate.createDelegate(this);
9359     
9360
9361     this.successDelegate = this.processSuccess.createDelegate(this);
9362     
9363
9364     this.failureDelegate = this.processFailure.createDelegate(this);
9365
9366     if(!this.renderer){
9367      
9368
9369     this.renderer = new  Roo.UpdateManager.BasicRenderer();
9370     }
9371
9372     
9373     Roo.UpdateManager.superclass.constructor.call(this);
9374 };
9375
9376 Roo.extend(Roo.UpdateManager, Roo.util.Observable, {
9377     
9378
9379     getEl : function(){
9380         return  this.el;
9381     },
9382     
9383
9384     update : function(B, C, D, E){
9385         if(this.fireEvent("beforeupdate", this.el, B, C) !== false){
9386             var  method = this.method, cfg;
9387             if(typeof  B == "object"){ 
9388                 cfg = B;
9389                 B = cfg.url;
9390                 C = C || cfg.params;
9391                 D = D || cfg.callback;
9392                 E = E || cfg.discardUrl;
9393                 if(D && cfg.scope){
9394                     D = D.createDelegate(cfg.scope);
9395                 }
9396                 if(typeof  cfg.method != "undefined"){method = cfg.method;};
9397                 if(typeof  cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
9398                 if(typeof  cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
9399                 if(typeof  cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
9400                 if(typeof  cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
9401             }
9402
9403             this.showLoading();
9404             if(!E){
9405                 this.defaultUrl = B;
9406             }
9407             if(typeof  B == "function"){
9408                 B = B.call(this);
9409             }
9410
9411
9412             method = method || (C ? "POST" : "GET");
9413             if(method == "GET"){
9414                 B = this.prepareUrl(B);
9415             }
9416
9417             var  o = Roo.apply(cfg ||{}, {
9418                 url : B,
9419                 params: C,
9420                 success: this.successDelegate,
9421                 failure: this.failureDelegate,
9422                 callback: undefined,
9423                 timeout: (this.timeout*1000),
9424                 argument: {"url": B, "form": null, "callback": D, "params": C}
9425             });
9426
9427             this.transaction = Roo.Ajax.request(o);
9428         }
9429     },
9430
9431     
9432
9433     formUpdate : function(F, G, H, I){
9434         if(this.fireEvent("beforeupdate", this.el, F, G) !== false){
9435             if(typeof  G == "function"){
9436                 G = G.call(this);
9437             }
9438
9439             F = Roo.getDom(F);
9440             this.transaction = Roo.Ajax.request({
9441                 form: F,
9442                 url:G,
9443                 success: this.successDelegate,
9444                 failure: this.failureDelegate,
9445                 timeout: (this.timeout*1000),
9446                 argument: {"url": G, "form": F, "callback": I, "reset": H}
9447             });
9448             this.showLoading.defer(1, this);
9449         }
9450     },
9451
9452     
9453
9454     refresh : function(J){
9455         if(this.defaultUrl == null){
9456             return;
9457         }
9458
9459         this.update(this.defaultUrl, null, J, true);
9460     },
9461
9462     
9463
9464     startAutoRefresh : function(K, L, M, N, O){
9465         if(O){
9466             this.update(L || this.defaultUrl, M, N, true);
9467         }
9468         if(this.autoRefreshProcId){
9469             clearInterval(this.autoRefreshProcId);
9470         }
9471
9472         this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [L || this.defaultUrl, M, N, true]), K*1000);
9473     },
9474
9475     
9476
9477      stopAutoRefresh : function(){
9478         if(this.autoRefreshProcId){
9479             clearInterval(this.autoRefreshProcId);
9480             delete  this.autoRefreshProcId;
9481         }
9482     },
9483
9484     isAutoRefreshing : function(){
9485        return  this.autoRefreshProcId ? true : false;
9486     },
9487     
9488
9489     showLoading : function(){
9490         if(this.showLoadIndicator){
9491             this.el.update(this.indicatorText);
9492         }
9493     },
9494
9495     
9496
9497     prepareUrl : function(P){
9498         if(this.disableCaching){
9499             var  append = "_dc=" + (new  Date().getTime());
9500             if(P.indexOf("?") !== -1){
9501                 P += "&" + append;
9502             }else {
9503                 P += "?" + append;
9504             }
9505         }
9506         return  P;
9507     },
9508
9509     
9510
9511     processSuccess : function(Q){
9512         this.transaction = null;
9513         if(Q.argument.form && Q.argument.reset){
9514             try{ 
9515                 Q.argument.form.reset();
9516             }catch(e){}
9517         }
9518         if(this.loadScripts){
9519             this.renderer.render(this.el, Q, this,
9520                 this.updateComplete.createDelegate(this, [Q]));
9521         }else {
9522             this.renderer.render(this.el, Q, this);
9523             this.updateComplete(Q);
9524         }
9525     },
9526
9527     updateComplete : function(R){
9528         this.fireEvent("update", this.el, R);
9529         if(typeof  R.argument.callback == "function"){
9530             R.argument.callback(this.el, true, R);
9531         }
9532     },
9533
9534     
9535
9536     processFailure : function(S){
9537         this.transaction = null;
9538         this.fireEvent("failure", this.el, S);
9539         if(typeof  S.argument.callback == "function"){
9540             S.argument.callback(this.el, false, S);
9541         }
9542     },
9543
9544     
9545
9546     setRenderer : function(T){
9547         this.renderer = T;
9548     },
9549
9550     getRenderer : function(){
9551        return  this.renderer;
9552     },
9553
9554     
9555
9556     setDefaultUrl : function(U){
9557         this.defaultUrl = U;
9558     },
9559
9560     
9561
9562     abort : function(){
9563         if(this.transaction){
9564             Roo.Ajax.abort(this.transaction);
9565         }
9566     },
9567
9568     
9569
9570     isUpdating : function(){
9571         if(this.transaction){
9572             return  Roo.Ajax.isLoading(this.transaction);
9573         }
9574         return  false;
9575     }
9576 });
9577
9578
9579
9580    Roo.UpdateManager.defaults = {
9581        
9582
9583          timeout : 30,
9584
9585          
9586
9587         loadScripts : false,
9588
9589         
9590
9591         sslBlankUrl : (Roo.SSL_SECURE_URL || "javascript:false"),
9592         
9593
9594         disableCaching : false,
9595         
9596
9597         showLoadIndicator : true,
9598         
9599
9600         indicatorText : '<div class="loading-indicator">Loading...</div>'
9601    };
9602
9603
9604
9605 Roo.UpdateManager.updateElement = function(el, V, W, X){
9606     var  um = Roo.get(el, true).getUpdateManager();
9607     Roo.apply(um, X);
9608     um.update(V, W, X ? X.callback : null);
9609 };
9610
9611 Roo.UpdateManager.update = Roo.UpdateManager.updateElement;
9612
9613
9614 Roo.UpdateManager.BasicRenderer = function(){};
9615
9616 Roo.UpdateManager.BasicRenderer.prototype = {
9617     
9618
9619      render : function(el, Y, Z, a){
9620         el.update(Y.responseText, Z.loadScripts, a);
9621     }
9622 };
9623
9624
9625
9626
9627
9628
9629 Roo.util.DelayedTask = function(fn, A, B){
9630     var  id = null, d, t;
9631
9632     var  C = function(){
9633         var  D = new  Date().getTime();
9634         if(D - t >= d){
9635             clearInterval(id);
9636             id = null;
9637             fn.apply(A, B || []);
9638         }
9639     };
9640     
9641
9642     this.delay = function(D, E, F, G){
9643         if(id && D != d){
9644             this.cancel();
9645         }
9646
9647         d = D;
9648         t = new  Date().getTime();
9649         fn = E || fn;
9650         A = F || A;
9651         B = G || B;
9652         if(!id){
9653             id = setInterval(C, d);
9654         }
9655     };
9656
9657     
9658
9659     this.cancel = function(){
9660         if(id){
9661             clearInterval(id);
9662             id = null;
9663         }
9664     };
9665 };
9666
9667
9668  
9669  
9670 Roo.util.TaskRunner = function(A){
9671     A = A || 10;
9672     var  B = [], C = [];
9673     var  id = 0;
9674     var  D = false;
9675
9676     var  E = function(){
9677         D = false;
9678         clearInterval(id);
9679         id = 0;
9680     };
9681
9682     var  F = function(){
9683         if(!D){
9684             D = true;
9685             id = setInterval(H, A);
9686         }
9687     };
9688
9689     var  G = function(I){
9690         C.push(I);
9691         if(I.onStop){
9692             I.onStop();
9693         }
9694     };
9695
9696     var  H = function(){
9697         if(C.length > 0){
9698             for(var  i = 0, len = C.length; i < len; i++){
9699                 B.remove(C[i]);
9700             }
9701
9702             C = [];
9703             if(B.length < 1){
9704                 E();
9705                 return;
9706             }
9707         }
9708         var  I = new  Date().getTime();
9709         for(var  i = 0, len = B.length; i < len; ++i){
9710             var  t = B[i];
9711             var  itime = I - t.taskRunTime;
9712             if(t.interval <= itime){
9713                 var  rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
9714                 t.taskRunTime = I;
9715                 if(rt === false || t.taskRunCount === t.repeat){
9716                     G(t);
9717                     return;
9718                 }
9719             }
9720             if(t.duration && t.duration <= (I - t.taskStartTime)){
9721                 G(t);
9722             }
9723         }
9724     };
9725
9726     
9727
9728     this.start = function(I){
9729         B.push(I);
9730         I.taskStartTime = new  Date().getTime();
9731         I.taskRunTime = 0;
9732         I.taskRunCount = 0;
9733         F();
9734         return  I;
9735     };
9736
9737     this.stop = function(I){
9738         G(I);
9739         return  I;
9740     };
9741
9742     this.stopAll = function(){
9743         E();
9744         for(var  i = 0, len = B.length; i < len; i++){
9745             if(B[i].onStop){
9746                 B[i].onStop();
9747             }
9748         }
9749
9750         B = [];
9751         C = [];
9752     };
9753 };
9754
9755 Roo.TaskMgr = new  Roo.util.TaskRunner();
9756
9757
9758
9759  
9760
9761
9762 Roo.util.MixedCollection = function(A, B){
9763     this.items = [];
9764     this.map = {};
9765     this.keys = [];
9766     this.length = 0;
9767     this.addEvents({
9768         
9769
9770         "clear" : true,
9771         
9772
9773         "add" : true,
9774         
9775
9776         "replace" : true,
9777         
9778
9779         "remove" : true,
9780         "sort" : true
9781     });
9782     this.allowFunctions = A === true;
9783     if(B){
9784         this.getKey = B;
9785     }
9786
9787     Roo.util.MixedCollection.superclass.constructor.call(this);
9788 };
9789
9790 Roo.extend(Roo.util.MixedCollection, Roo.util.Observable, {
9791     allowFunctions : false,
9792     
9793
9794
9795     add : function(C, o){
9796         if(arguments.length == 1){
9797             o = arguments[0];
9798             C = this.getKey(o);
9799         }
9800         if(typeof  C == "undefined" || C === null){
9801             this.length++;
9802             this.items.push(o);
9803             this.keys.push(null);
9804         }else {
9805             var  old = this.map[C];
9806             if(old){
9807                 return  this.replace(C, o);
9808             }
9809
9810             this.length++;
9811             this.items.push(o);
9812             this.map[C] = o;
9813             this.keys.push(C);
9814         }
9815
9816         this.fireEvent("add", this.length-1, o, C);
9817         return  o;
9818     },
9819    
9820
9821
9822     getKey : function(o){
9823          return  o.id; 
9824     },
9825    
9826
9827
9828     replace : function(D, o){
9829         if(arguments.length == 1){
9830             o = arguments[0];
9831             D = this.getKey(o);
9832         }
9833         var  E = this.item(D);
9834         if(typeof  D == "undefined" || D === null || typeof  E == "undefined"){
9835              return  this.add(D, o);
9836         }
9837         var  F = this.indexOfKey(D);
9838         this.items[F] = o;
9839         this.map[D] = o;
9840         this.fireEvent("replace", D, E, o);
9841         return  o;
9842     },
9843    
9844
9845
9846     addAll : function(G){
9847         if(arguments.length > 1 || G  instanceof  Array){
9848             var  args = arguments.length > 1 ? arguments : G;
9849             for(var  i = 0, len = args.length; i < len; i++){
9850                 this.add(args[i]);
9851             }
9852         }else {
9853             for(var  D  in  G){
9854                 if(this.allowFunctions || typeof  G[D] != "function"){
9855                     this.add(D, G[D]);
9856                 }
9857             }
9858         }
9859     },
9860    
9861
9862
9863     each : function(fn, H){
9864         var  I = [].concat(this.items); 
9865         for(var  i = 0, len = I.length; i < len; i++){
9866             if(fn.call(H || I[i], I[i], i, len) === false){
9867                 break;
9868             }
9869         }
9870     },
9871    
9872
9873
9874     eachKey : function(fn, J){
9875         for(var  i = 0, len = this.keys.length; i < len; i++){
9876             fn.call(J || window, this.keys[i], this.items[i], i, len);
9877         }
9878     },
9879    
9880
9881
9882     find : function(fn, K){
9883         for(var  i = 0, len = this.items.length; i < len; i++){
9884             if(fn.call(K || window, this.items[i], this.keys[i])){
9885                 return  this.items[i];
9886             }
9887         }
9888         return  null;
9889     },
9890    
9891
9892
9893     insert : function(L, M, o){
9894         if(arguments.length == 2){
9895             o = arguments[1];
9896             M = this.getKey(o);
9897         }
9898         if(L >= this.length){
9899             return  this.add(M, o);
9900         }
9901
9902         this.length++;
9903         this.items.splice(L, 0, o);
9904         if(typeof  M != "undefined" && M != null){
9905             this.map[M] = o;
9906         }
9907
9908         this.keys.splice(L, 0, M);
9909         this.fireEvent("add", L, o, M);
9910         return  o;
9911     },
9912    
9913
9914
9915     remove : function(o){
9916         return  this.removeAt(this.indexOf(o));
9917     },
9918    
9919
9920
9921     removeAt : function(N){
9922         if(N < this.length && N >= 0){
9923             this.length--;
9924             var  o = this.items[N];
9925             this.items.splice(N, 1);
9926             var  M = this.keys[N];
9927             if(typeof  M != "undefined"){
9928                 delete  this.map[M];
9929             }
9930
9931             this.keys.splice(N, 1);
9932             this.fireEvent("remove", o, M);
9933         }
9934     },
9935    
9936
9937
9938     removeKey : function(O){
9939         return  this.removeAt(this.indexOfKey(O));
9940     },
9941    
9942
9943
9944     getCount : function(){
9945         return  this.length; 
9946     },
9947    
9948
9949
9950     indexOf : function(o){
9951         if(!this.items.indexOf){
9952             for(var  i = 0, len = this.items.length; i < len; i++){
9953                 if(this.items[i] == o) return  i;
9954             }
9955             return  -1;
9956         }else {
9957             return  this.items.indexOf(o);
9958         }
9959     },
9960    
9961
9962
9963     indexOfKey : function(P){
9964         if(!this.keys.indexOf){
9965             for(var  i = 0, len = this.keys.length; i < len; i++){
9966                 if(this.keys[i] == P) return  i;
9967             }
9968             return  -1;
9969         }else {
9970             return  this.keys.indexOf(P);
9971         }
9972     },
9973    
9974
9975
9976     item : function(Q){
9977         var  R = typeof  this.map[Q] != "undefined" ? this.map[Q] : this.items[Q];
9978         return  typeof  R != 'function' || this.allowFunctions ? R : null; 
9979     },
9980     
9981
9982
9983     itemAt : function(S){
9984         return  this.items[S];
9985     },
9986     
9987
9988
9989     key : function(T){
9990         return  this.map[T];
9991     },
9992    
9993
9994
9995     contains : function(o){
9996         return  this.indexOf(o) != -1;
9997     },
9998    
9999
10000
10001     containsKey : function(U){
10002         return  typeof  this.map[U] != "undefined";
10003     },
10004    
10005
10006
10007     clear : function(){
10008         this.length = 0;
10009         this.items = [];
10010         this.keys = [];
10011         this.map = {};
10012         this.fireEvent("clear");
10013     },
10014    
10015
10016
10017     first : function(){
10018         return  this.items[0]; 
10019     },
10020    
10021
10022
10023     last : function(){
10024         return  this.items[this.length-1];   
10025     },
10026     
10027     _sort : function(V, W, fn){
10028         var  X = String(W).toUpperCase() == "DESC" ? -1 : 1;
10029         fn = fn || function(a, b){
10030             return  a-b;
10031         };
10032         var  c = [], k = this.keys, Y = this.items;
10033         for(var  i = 0, len = Y.length; i < len; i++){
10034             c[c.length] = {key: k[i], value: Y[i], index: i};
10035         }
10036
10037         c.sort(function(a, b){
10038             var  v = fn(a[V], b[V]) * X;
10039             if(v == 0){
10040                 v = (a.index < b.index ? -1 : 1);
10041             }
10042             return  v;
10043         });
10044         for(var  i = 0, len = c.length; i < len; i++){
10045             Y[i] = c[i].value;
10046             k[i] = c[i].key;
10047         }
10048
10049         this.fireEvent("sort", this);
10050     },
10051     
10052     
10053
10054     sort : function(Z, fn){
10055         this._sort("value", Z, fn);
10056     },
10057     
10058     
10059
10060     keySort : function(a, fn){
10061         this._sort("key", a, fn || function(a, b){
10062             return  String(a).toUpperCase()-String(b).toUpperCase();
10063         });
10064     },
10065     
10066     
10067
10068     getRange : function(b, d){
10069         var  e = this.items;
10070         if(e.length < 1){
10071             return  [];
10072         }
10073
10074         b = b || 0;
10075         d = Math.min(typeof  d == "undefined" ? this.length-1 : d, this.length-1);
10076         var  r = [];
10077         if(b <= d){
10078             for(var  i = b; i <= d; i++) {
10079                     r[r.length] = e[i];
10080             }
10081         }else {
10082             for(var  i = b; i >= d; i--) {
10083                     r[r.length] = e[i];
10084             }
10085         }
10086         return  r;
10087     },
10088         
10089     
10090
10091     filter : function(f, g){
10092         if(!g.exec){ 
10093             g = String(g);
10094             if(g.length == 0){
10095                 return  this.clone();
10096             }
10097
10098             g = new  RegExp("^" + Roo.escapeRe(g), "i");
10099         }
10100         return  this.filterBy(function(o){
10101             return  o && g.test(o[f]);
10102         });
10103         },
10104     
10105     
10106
10107     filterBy : function(fn, h){
10108         var  r = new  Roo.util.MixedCollection();
10109         r.getKey = this.getKey;
10110         var  k = this.keys, it = this.items;
10111         for(var  i = 0, len = it.length; i < len; i++){
10112             if(fn.call(h||this, it[i], k[i])){
10113                                 r.add(k[i], it[i]);
10114                         }
10115         }
10116         return  r;
10117     },
10118     
10119     
10120
10121     clone : function(){
10122         var  r = new  Roo.util.MixedCollection();
10123         var  k = this.keys, it = this.items;
10124         for(var  i = 0, len = it.length; i < len; i++){
10125             r.add(k[i], it[i]);
10126         }
10127
10128         r.getKey = this.getKey;
10129         return  r;
10130     }
10131 });
10132
10133
10134 Roo.util.MixedCollection.prototype.get = Roo.util.MixedCollection.prototype.item;
10135
10136
10137
10138
10139 Roo.util.JSON = new  (function(){
10140     var  useHasOwn = {}.hasOwnProperty ? true : false;
10141     
10142     
10143     
10144     
10145     var  pad = function(n) {
10146         return  n < 10 ? "0" + n : n;
10147     };
10148     
10149     var  m = {
10150         "\b": '\\b',
10151         "\t": '\\t',
10152         "\n": '\\n',
10153         "\f": '\\f',
10154         "\r": '\\r',
10155         '"' : '\\"',
10156         "\\": '\\\\'
10157     };
10158
10159     var  encodeString = function(s){
10160         if (/["\\\x00-\x1f]/.test(s)) {
10161             return  '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
10162                 var  c = m[b];
10163                 if(c){
10164                     return  c;
10165                 }
10166
10167                 c = b.charCodeAt();
10168                 return  "\\u00" +
10169                     Math.floor(c / 16).toString(16) +
10170                     (c % 16).toString(16);
10171             }) + '"';
10172         }
10173         return  '"' + s + '"';
10174     };
10175     
10176     var  encodeArray = function(o){
10177         var  a = ["["], b, i, l = o.length, v;
10178             for (i = 0; i < l; i += 1) {
10179                 v = o[i];
10180                 switch (typeof  v) {
10181                     case  "undefined":
10182                     case  "function":
10183                     case  "unknown":
10184                         break;
10185                     default:
10186                         if (b) {
10187                             a.push(',');
10188                         }
10189
10190                         a.push(v === null ? "null" : Roo.util.JSON.encode(v));
10191                         b = true;
10192                 }
10193             }
10194
10195             a.push("]");
10196             return  a.join("");
10197     };
10198     
10199     var  encodeDate = function(o){
10200         return  '"' + o.getFullYear() + "-" +
10201                 pad(o.getMonth() + 1) + "-" +
10202                 pad(o.getDate()) + "T" +
10203                 pad(o.getHours()) + ":" +
10204                 pad(o.getMinutes()) + ":" +
10205                 pad(o.getSeconds()) + '"';
10206     };
10207     
10208     
10209
10210     this.encode = function(o){
10211         if(typeof  o == "undefined" || o === null){
10212             return  "null";
10213         }else  if(o  instanceof  Array){
10214             return  encodeArray(o);
10215         }else  if(o  instanceof  Date){
10216             return  encodeDate(o);
10217         }else  if(typeof  o == "string"){
10218             return  encodeString(o);
10219         }else  if(typeof  o == "number"){
10220             return  isFinite(o) ? String(o) : "null";
10221         }else  if(typeof  o == "boolean"){
10222             return  String(o);
10223         }else  {
10224             var  a = ["{"], b, i, v;
10225             for (i  in  o) {
10226                 if(!useHasOwn || o.hasOwnProperty(i)) {
10227                     v = o[i];
10228                     switch (typeof  v) {
10229                     case  "undefined":
10230                     case  "function":
10231                     case  "unknown":
10232                         break;
10233                     default:
10234                         if(b){
10235                             a.push(',');
10236                         }
10237
10238                         a.push(this.encode(i), ":",
10239                                 v === null ? "null" : this.encode(v));
10240                         b = true;
10241                     }
10242                 }
10243             }
10244
10245             a.push("}");
10246             return  a.join("");
10247         }
10248     };
10249     
10250     
10251
10252     this.decode = function(json){
10253         
10254
10255         return  eval("(" + json + ')');
10256     };
10257 })();
10258
10259
10260 Roo.encode = Roo.util.JSON.encode;
10261
10262
10263 Roo.decode = Roo.util.JSON.decode;
10264
10265
10266
10267  
10268
10269
10270 Roo.util.Format = function(){
10271     var  A = /^\s+|\s+$/g;
10272     return  {
10273         
10274
10275         ellipsis : function(R, S){
10276             if(R && R.length > S){
10277                 return  R.substr(0, S-3)+"...";
10278             }
10279             return  R;
10280         },
10281
10282         
10283
10284         undef : function(T){
10285             return  typeof  T != "undefined" ? T : "";
10286         },
10287
10288         
10289
10290         htmlEncode : function(U){
10291             return  !U ? U : String(U).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
10292         },
10293
10294         
10295
10296         htmlDecode : function(V){
10297             return  !V ? V : String(V).replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"');
10298         },
10299
10300         
10301
10302         trim : function(W){
10303             return  String(W).replace(A, "");
10304         },
10305
10306         
10307
10308         substr : function(X, Y, Z){
10309             return  String(X).substr(Y, Z);
10310         },
10311
10312         
10313
10314         lowercase : function(a){
10315             return  String(a).toLowerCase();
10316         },
10317
10318         
10319
10320         uppercase : function(b){
10321             return  String(b).toUpperCase();
10322         },
10323
10324         
10325
10326         capitalize : function(c){
10327             return  !c ? c : c.charAt(0).toUpperCase() + c.substr(1).toLowerCase();
10328         },
10329
10330         
10331         call : function(value, fn){
10332             if(arguments.length > 2){
10333                 var  args = Array.prototype.slice.call(arguments, 2);
10334                 args.unshift(value);
10335                  
10336                 return  
10337   eval(fn).apply(window, args);
10338             }else {
10339                 
10340
10341                 return  
10342  eval(fn).call(window, value);
10343             }
10344         },
10345
10346         
10347
10348         usMoney : function(v){
10349             v = (Math.round((v-0)*100))/100;
10350             v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
10351             v = String(v);
10352             var  ps = v.split('.');
10353             var  d = ps[0];
10354             var  e = ps[1] ? '.'+ ps[1] : '.00';
10355             var  r = /(\d+)(\d{3})/;
10356             while (r.test(d)) {
10357                 d = d.replace(r, '$1' + ',' + '$2');
10358             }
10359             return  "$" + d + e ;
10360         },
10361
10362         
10363
10364         date : function(v, f){
10365             if(!v){
10366                 return  "";
10367             }
10368             if(!(v  instanceof  Date)){
10369                 v = new  Date(Date.parse(v));
10370             }
10371             return  v.dateFormat(f || "m/d/Y");
10372         },
10373
10374         
10375
10376         dateRenderer : function(g){
10377             return  function(v){
10378                 return  Roo.util.Format.date(v, g);  
10379             };
10380         },
10381
10382         
10383         stripTagsRE : /<\/?[^>]+>/gi,
10384         
10385         
10386
10387         stripTags : function(v){
10388             return  !v ? v : String(v).replace(this.stripTagsRE, "");
10389         }
10390     };
10391 }();
10392
10393
10394
10395
10396  
10397
10398
10399
10400 Roo.MasterTemplate = function(){
10401     Roo.MasterTemplate.superclass.constructor.apply(this, arguments);
10402     this.originalHtml = this.html;
10403     var  st = {};
10404     var  m, re = this.subTemplateRe;
10405     re.lastIndex = 0;
10406     var  A = 0;
10407     while(m = re.exec(this.html)){
10408         var  name = m[1], content = m[2];
10409         st[A] = {
10410             name: name,
10411             index: A,
10412             buffer: [],
10413             tpl : new  Roo.Template(content)
10414         };
10415         if(name){
10416             st[name] = st[A];
10417         }
10418
10419         st[A].tpl.compile();
10420         st[A].tpl.call = this.call.createDelegate(this);
10421         A++;
10422     }
10423
10424     this.subCount = A;
10425     this.subs = st;
10426 };
10427 Roo.extend(Roo.MasterTemplate, Roo.Template, {
10428     
10429
10430     subTemplateRe : /<tpl(?:\sname="([\w-]+)")?>((?:.|\n)*?)<\/tpl>/gi,
10431
10432     
10433
10434      add : function(B, C){
10435         if(arguments.length == 1){
10436             C = arguments[0];
10437             B = 0;
10438         }
10439         var  s = this.subs[B];
10440         s.buffer[s.buffer.length] = s.tpl.apply(C);
10441         return  this;
10442     },
10443
10444     
10445
10446     fill : function(D, E, F){
10447         var  a = arguments;
10448         if(a.length == 1 || (a.length == 2 && typeof  a[1] == "boolean")){
10449             E = a[0];
10450             D = 0;
10451             F = a[1];
10452         }
10453         if(F){
10454             this.reset();
10455         }
10456         for(var  i = 0, len = E.length; i < len; i++){
10457             this.add(D, E[i]);
10458         }
10459         return  this;
10460     },
10461
10462     
10463
10464      reset : function(){
10465         var  s = this.subs;
10466         for(var  i = 0; i < this.subCount; i++){
10467             s[i].buffer = [];
10468         }
10469         return  this;
10470     },
10471
10472     applyTemplate : function(G){
10473         var  s = this.subs;
10474         var  H = -1;
10475         this.html = this.originalHtml.replace(this.subTemplateRe, function(m, I){
10476             return  s[++H].buffer.join("");
10477         });
10478         return  Roo.MasterTemplate.superclass.applyTemplate.call(this, G);
10479     },
10480
10481     apply : function(){
10482         return  this.applyTemplate.apply(this, arguments);
10483     },
10484
10485     compile : function(){return  this;}
10486 });
10487
10488
10489
10490 Roo.MasterTemplate.prototype.addAll = Roo.MasterTemplate.prototype.fill;
10491  
10492
10493 Roo.MasterTemplate.from = function(el, I){
10494     el = Roo.getDom(el);
10495     return  new  Roo.MasterTemplate(el.value || el.innerHTML, I || '');
10496 };
10497
10498
10499
10500  
10501
10502
10503 Roo.util.CSS = function(){
10504         var  A = null;
10505         var  B = document;
10506
10507     var  C = /(-[a-z])/gi;
10508     var  D = function(m, a){ return  a.charAt(1).toUpperCase(); };
10509
10510    return  {
10511    
10512
10513    createStyleSheet : function(P, id){
10514        var  ss;
10515        var  Q = B.getElementsByTagName("head")[0];
10516        var  R = B.createElement("style");
10517        R.setAttribute("type", "text/css");
10518        if(id){
10519            R.setAttribute("id", id);
10520        }
10521        if(Roo.isIE){
10522            Q.appendChild(R);
10523            ss = R.styleSheet;
10524            ss.cssText = P;
10525        }else {
10526            try{
10527                 R.appendChild(B.createTextNode(P));
10528            }catch(e){
10529                R.cssText = P; 
10530            }
10531
10532            Q.appendChild(R);
10533            ss = R.styleSheet ? R.styleSheet : (R.sheet || B.styleSheets[B.styleSheets.length-1]);
10534        }
10535
10536        this.cacheStyleSheet(ss);
10537        return  ss;
10538    },
10539
10540    
10541
10542    removeStyleSheet : function(id){
10543        var  S = B.getElementById(id);
10544        if(S){
10545            S.parentNode.removeChild(S);
10546        }
10547    },
10548
10549    
10550
10551    swapStyleSheet : function(id, T){
10552        this.removeStyleSheet(id);
10553        var  ss = B.createElement("link");
10554        ss.setAttribute("rel", "stylesheet");
10555        ss.setAttribute("type", "text/css");
10556        ss.setAttribute("id", id);
10557        ss.setAttribute("href", T);
10558        B.getElementsByTagName("head")[0].appendChild(ss);
10559    },
10560    
10561    
10562
10563    refreshCache : function(){
10564        return  this.getRules(true);
10565    },
10566
10567    
10568    cacheStyleSheet : function(ss){
10569        if(!R){
10570            R = {};
10571        }
10572        try{
10573            var  ssRules = ss.cssRules || ss.rules;
10574            for(var  j = ssRules.length-1; j >= 0; --j){
10575                R[ssRules[j].selectorText] = ssRules[j];
10576            }
10577        }catch(e){}
10578    },
10579    
10580    
10581
10582    getRules : function(U){
10583                 if(R == null || U){
10584                         R = {};
10585                         var  ds = B.styleSheets;
10586                         for(var  i =0, len = ds.length; i < len; i++){
10587                             try{
10588                         this.cacheStyleSheet(ds[i]);
10589                     }catch(e){} 
10590                 }
10591                 }
10592                 return  R;
10593         },
10594         
10595         
10596
10597    getRule : function(V, W){
10598                 var  rs = this.getRules(W);
10599                 if(!(V  instanceof  Array)){
10600                     return  rs[V];
10601                 }
10602                 for(var  i = 0; i < V.length; i++){
10603                         if(rs[V[i]]){
10604                                 return  rs[V[i]];
10605                         }
10606                 }
10607                 return  null;
10608         },
10609         
10610         
10611         
10612
10613    updateRule : function(X, Y, Z){
10614                 if(!(X  instanceof  Array)){
10615                         var  rule = this.getRule(X);
10616                         if(rule){
10617                                 rule.style[Y.replace(C, D)] = Z;
10618                                 return  true;
10619                         }
10620                 }else {
10621                         for(var  i = 0; i < X.length; i++){
10622                                 if(this.updateRule(X[i], Y, Z)){
10623                                         return  true;
10624                                 }
10625                         }
10626                 }
10627                 return  false;
10628         }
10629    };   
10630 }();
10631
10632
10633
10634  
10635
10636
10637
10638 Roo.util.ClickRepeater = function(el, A)
10639 {
10640     this.el = Roo.get(el);
10641     this.el.unselectable();
10642
10643     Roo.apply(this, A);
10644
10645     this.addEvents({
10646     
10647
10648         "mousedown" : true,
10649     
10650
10651         "click" : true,
10652     
10653
10654         "mouseup" : true
10655     });
10656
10657     this.el.on("mousedown", this.handleMouseDown, this);
10658     if(this.preventDefault || this.stopDefault){
10659         this.el.on("click", function(e){
10660             if(this.preventDefault){
10661                 e.preventDefault();
10662             }
10663             if(this.stopDefault){
10664                 e.stopEvent();
10665             }
10666         }, this);
10667     }
10668
10669     
10670     if(this.handler){
10671         this.on("click", this.handler,  this.scope || this);
10672     }
10673
10674
10675     Roo.util.ClickRepeater.superclass.constructor.call(this);
10676 };
10677
10678 Roo.extend(Roo.util.ClickRepeater, Roo.util.Observable, {
10679     interval : 20,
10680     delay: 250,
10681     preventDefault : true,
10682     stopDefault : false,
10683     timer : 0,
10684
10685     
10686     handleMouseDown : function(){
10687         clearTimeout(this.timer);
10688         this.el.blur();
10689         if(this.pressClass){
10690             this.el.addClass(this.pressClass);
10691         }
10692
10693         this.mousedownTime = new  Date();
10694
10695         Roo.get(document).on("mouseup", this.handleMouseUp, this);
10696         this.el.on("mouseout", this.handleMouseOut, this);
10697
10698         this.fireEvent("mousedown", this);
10699         this.fireEvent("click", this);
10700         
10701         this.timer = this.click.defer(this.delay || this.interval, this);
10702     },
10703
10704     
10705     click : function(){
10706         this.fireEvent("click", this);
10707         this.timer = this.click.defer(this.getInterval(), this);
10708     },
10709
10710     
10711     getInterval: function(){
10712         if(!this.accelerate){
10713             return  this.interval;
10714         }
10715         var  B = this.mousedownTime.getElapsed();
10716         if(B < 500){
10717             return  400;
10718         }else  if(B < 1700){
10719             return  320;
10720         }else  if(B < 2600){
10721             return  250;
10722         }else  if(B < 3500){
10723             return  180;
10724         }else  if(B < 4400){
10725             return  140;
10726         }else  if(B < 5300){
10727             return  80;
10728         }else  if(B < 6200){
10729             return  50;
10730         }else {
10731             return  10;
10732         }
10733     },
10734
10735     
10736     handleMouseOut : function(){
10737         clearTimeout(this.timer);
10738         if(this.pressClass){
10739             this.el.removeClass(this.pressClass);
10740         }
10741
10742         this.el.on("mouseover", this.handleMouseReturn, this);
10743     },
10744
10745     
10746     handleMouseReturn : function(){
10747         this.el.un("mouseover", this.handleMouseReturn);
10748         if(this.pressClass){
10749             this.el.addClass(this.pressClass);
10750         }
10751
10752         this.click();
10753     },
10754
10755     
10756     handleMouseUp : function(){
10757         clearTimeout(this.timer);
10758         this.el.un("mouseover", this.handleMouseReturn);
10759         this.el.un("mouseout", this.handleMouseOut);
10760         Roo.get(document).un("mouseup", this.handleMouseUp);
10761         this.el.removeClass(this.pressClass);
10762         this.fireEvent("mouseup", this);
10763     }
10764 });
10765
10766
10767
10768  
10769
10770
10771 Roo.KeyNav = function(el, A){
10772     this.el = Roo.get(el);
10773     Roo.apply(this, A);
10774     if(!this.disabled){
10775         this.disabled = true;
10776         this.enable();
10777     }
10778 };
10779
10780 Roo.KeyNav.prototype = {
10781     
10782
10783     disabled : false,
10784     
10785
10786     defaultEventAction: "stopEvent",
10787     
10788
10789     forceKeyDown : false,
10790
10791     
10792     prepareEvent : function(e){
10793         var  k = e.getKey();
10794         var  h = this.keyToHandler[k];
10795         
10796         
10797         
10798         if(Roo.isSafari && h && k >= 37 && k <= 40){
10799             e.stopEvent();
10800         }
10801     },
10802
10803     
10804     relay : function(e){
10805         var  k = e.getKey();
10806         var  h = this.keyToHandler[k];
10807         if(h && this[h]){
10808             if(this.doRelay(e, this[h], h) !== true){
10809                 e[this.defaultEventAction]();
10810             }
10811         }
10812     },
10813
10814     
10815     doRelay : function(e, h, B){
10816         return  h.call(this.scope || this, e);
10817     },
10818
10819     
10820     enter : false,
10821     left : false,
10822     right : false,
10823     up : false,
10824     down : false,
10825     tab : false,
10826     esc : false,
10827     pageUp : false,
10828     pageDown : false,
10829     del : false,
10830     home : false,
10831     end : false,
10832
10833     
10834     keyToHandler : {
10835         37 : "left",
10836         39 : "right",
10837         38 : "up",
10838         40 : "down",
10839         33 : "pageUp",
10840         34 : "pageDown",
10841         46 : "del",
10842         36 : "home",
10843         35 : "end",
10844         13 : "enter",
10845         27 : "esc",
10846         9  : "tab"
10847     },
10848
10849         
10850
10851         enable: function(){
10852                 if(this.disabled){
10853             
10854             
10855             if(this.forceKeyDown || Roo.isIE || Roo.isAir){
10856                 this.el.on("keydown", this.relay,  this);
10857             }else {
10858                 this.el.on("keydown", this.prepareEvent,  this);
10859                 this.el.on("keypress", this.relay,  this);
10860             }
10861
10862                     this.disabled = false;
10863                 }
10864         },
10865
10866         
10867
10868         disable: function(){
10869                 if(!this.disabled){
10870                     if(this.forceKeyDown || Roo.isIE || Roo.isAir){
10871                 this.el.un("keydown", this.relay);
10872             }else {
10873                 this.el.un("keydown", this.prepareEvent);
10874                 this.el.un("keypress", this.relay);
10875             }
10876
10877                     this.disabled = true;
10878                 }
10879         }
10880 };
10881
10882
10883
10884  
10885
10886
10887 Roo.KeyMap = function(el, A, B){
10888     this.el  = Roo.get(el);
10889     this.eventName = B || "keydown";
10890     this.bindings = [];
10891     if(A){
10892         this.addBinding(A);
10893     }
10894
10895     this.enable();
10896 };
10897
10898 Roo.KeyMap.prototype = {
10899     
10900
10901     stopEvent : false,
10902
10903     
10904
10905         addBinding : function(C){
10906         if(C  instanceof  Array){
10907             for(var  i = 0, len = C.length; i < len; i++){
10908                 this.addBinding(C[i]);
10909             }
10910             return;
10911         }
10912         var  D = C.key,
10913             E = C.shift, 
10914             F = C.ctrl, 
10915             G = C.alt,
10916             fn = C.fn,
10917             H = C.scope;
10918         if(typeof  D == "string"){
10919             var  ks = [];
10920             var  keyString = D.toUpperCase();
10921             for(var  j = 0, len = keyString.length; j < len; j++){
10922                 ks.push(keyString.charCodeAt(j));
10923             }
10924
10925             D = ks;
10926         }
10927         var  I = D  instanceof  Array;
10928         var  J = function(e){
10929             if((!E || e.shiftKey) && (!F || e.ctrlKey) &&  (!G || e.altKey)){
10930                 var  k = e.getKey();
10931                 if(I){
10932                     for(var  i = 0, len = D.length; i < len; i++){
10933                         if(D[i] == k){
10934                           if(this.stopEvent){
10935                               e.stopEvent();
10936                           }
10937
10938                           fn.call(H || window, k, e);
10939                           return;
10940                         }
10941                     }
10942                 }else {
10943                     if(k == D){
10944                         if(this.stopEvent){
10945                            e.stopEvent();
10946                         }
10947
10948                         fn.call(H || window, k, e);
10949                     }
10950                 }
10951             }
10952         };
10953         this.bindings.push(J);  
10954         },
10955
10956     
10957
10958     on : function(K, fn, L){
10959         var  M, N, O, P;
10960         if(typeof  K == "object" && !(K  instanceof  Array)){
10961             M = K.key;
10962             N = K.shift;
10963             O = K.ctrl;
10964             P = K.alt;
10965         }else {
10966             M = K;
10967         }
10968
10969         this.addBinding({
10970             key: M,
10971             shift: N,
10972             ctrl: O,
10973             alt: P,
10974             fn: fn,
10975             scope: L
10976         })
10977     },
10978
10979     
10980     handleKeyDown : function(e){
10981             if(this.enabled){ 
10982             var  b = this.bindings;
10983             for(var  i = 0, len = b.length; i < len; i++){
10984                 b[i].call(this, e);
10985             }
10986             }
10987         },
10988         
10989         
10990
10991         isEnabled : function(){
10992             return  this.enabled;  
10993         },
10994         
10995         
10996
10997         enable: function(){
10998                 if(!this.enabled){
10999                     this.el.on(this.eventName, this.handleKeyDown, this);
11000                     this.enabled = true;
11001                 }
11002         },
11003
11004         
11005
11006         disable: function(){
11007                 if(this.enabled){
11008                     this.el.removeListener(this.eventName, this.handleKeyDown, this);
11009                     this.enabled = false;
11010                 }
11011         }
11012 };
11013
11014
11015
11016  
11017
11018
11019 Roo.util.TextMetrics = function(){
11020     var  A;
11021     return  {
11022         
11023
11024         measure : function(el, E, F){
11025             if(!A){
11026                 A = Roo.util.TextMetrics.Instance(el, F);
11027             }
11028
11029             A.bind(el);
11030             A.setFixedWidth(F || 'auto');
11031             return  A.getSize(E);
11032         },
11033
11034         
11035
11036         createInstance : function(el, G){
11037             return  Roo.util.TextMetrics.Instance(el, G);
11038         }
11039     };
11040 }();
11041
11042  
11043
11044 Roo.util.TextMetrics.Instance = function(B, C){
11045     var  ml = new  Roo.Element(document.createElement('div'));
11046     document.body.appendChild(ml.dom);
11047     ml.position('absolute');
11048     ml.setLeftTop(-1000, -1000);
11049     ml.hide();
11050
11051     if(C){
11052         ml.setWidth(C);
11053     }
11054      
11055     var  D = {
11056         
11057
11058         getSize : function(E){
11059             ml.update(E);
11060             var  s = ml.getSize();
11061             ml.update('');
11062             return  s;
11063         },
11064
11065         
11066
11067         bind : function(el){
11068             ml.setStyle(
11069                 Roo.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height')
11070             );
11071         },
11072
11073         
11074
11075         setFixedWidth : function(F){
11076             ml.setWidth(F);
11077         },
11078
11079         
11080
11081         getWidth : function(G){
11082             ml.dom.style.width = 'auto';
11083             return  this.getSize(G).width;
11084         },
11085
11086         
11087
11088         getHeight : function(H){
11089             return  this.getSize(H).height;
11090         }
11091     };
11092
11093     D.bind(B);
11094
11095     return  D;
11096 };
11097
11098
11099 Roo.Element.measureText = Roo.util.TextMetrics.measure;
11100
11101
11102
11103
11104
11105 Roo.state.Provider = function(){
11106     
11107
11108     this.addEvents({
11109         "statechange": true
11110     });
11111     this.state = {};
11112     Roo.state.Provider.superclass.constructor.call(this);
11113 };
11114 Roo.extend(Roo.state.Provider, Roo.util.Observable, {
11115     
11116
11117     get : function(A, B){
11118         return  typeof  this.state[A] == "undefined" ?
11119             B : this.state[A];
11120     },
11121     
11122     
11123
11124     clear : function(C){
11125         delete  this.state[C];
11126         this.fireEvent("statechange", this, C, null);
11127     },
11128     
11129     
11130
11131     set : function(D, E){
11132         this.state[D] = E;
11133         this.fireEvent("statechange", this, D, E);
11134     },
11135     
11136     
11137
11138     decodeValue : function(F){
11139         var  re = /^(a|n|d|b|s|o)\:(.*)$/;
11140         var  G = re.exec(unescape(F));
11141         if(!G || !G[1]) return; 
11142         var  H = G[1];
11143         var  v = G[2];
11144         switch(H){
11145             case  "n":
11146                 return  parseFloat(v);
11147             case  "d":
11148                 return  new  Date(Date.parse(v));
11149             case  "b":
11150                 return  (v == "1");
11151             case  "a":
11152                 var  all = [];
11153                 var  values = v.split("^");
11154                 for(var  i = 0, len = values.length; i < len; i++){
11155                     all.push(this.decodeValue(values[i]));
11156                 }
11157                 return  all;
11158            case  "o":
11159                 var  all = {};
11160                 var  values = v.split("^");
11161                 for(var  i = 0, len = values.length; i < len; i++){
11162                     var  kv = values[i].split("=");
11163                     all[kv[0]] = this.decodeValue(kv[1]);
11164                 }
11165                 return  all;
11166            default:
11167                 return  v;
11168         }
11169     },
11170     
11171     
11172
11173     encodeValue : function(v){
11174         var  I;
11175         if(typeof  v == "number"){
11176             I = "n:" + v;
11177         }else  if(typeof  v == "boolean"){
11178             I = "b:" + (v ? "1" : "0");
11179         }else  if(v  instanceof  Date){
11180             I = "d:" + v.toGMTString();
11181         }else  if(v  instanceof  Array){
11182             var  flat = "";
11183             for(var  i = 0, len = v.length; i < len; i++){
11184                 flat += this.encodeValue(v[i]);
11185                 if(i != len-1) flat += "^";
11186             }
11187
11188             I = "a:" + flat;
11189         }else  if(typeof  v == "object"){
11190             var  flat = "";
11191             for(var  key  in  v){
11192                 if(typeof  v[key] != "function"){
11193                     flat += key + "=" + this.encodeValue(v[key]) + "^";
11194                 }
11195             }
11196
11197             I = "o:" + flat.substring(0, flat.length-1);
11198         }else {
11199             I = "s:" + v;
11200         }
11201         return  escape(I);        
11202     }
11203 });
11204
11205
11206
11207
11208
11209
11210 Roo.state.Manager = function(){
11211     var  A = new  Roo.state.Provider();
11212     
11213     return  {
11214         
11215
11216         setProvider : function(H){
11217             A = H;
11218         },
11219         
11220         
11221
11222         get : function(I, J){
11223             return  A.get(I, J);
11224         },
11225         
11226         
11227
11228          set : function(K, L){
11229             A.set(K, L);
11230         },
11231         
11232         
11233
11234         clear : function(M){
11235             A.clear(M);
11236         },
11237         
11238         
11239
11240         getProvider : function(){
11241             return  A;
11242         }
11243     };
11244 }();
11245
11246
11247
11248
11249
11250 Roo.state.CookieProvider = function(A){
11251     Roo.state.CookieProvider.superclass.constructor.call(this);
11252     this.path = "/";
11253     this.expires = new  Date(new  Date().getTime()+(1000*60*60*24*7)); 
11254     this.domain = null;
11255     this.secure = false;
11256     Roo.apply(this, A);
11257     this.state = this.readCookies();
11258 };
11259
11260 Roo.extend(Roo.state.CookieProvider, Roo.state.Provider, {
11261     
11262     set : function(B, C){
11263         if(typeof  C == "undefined" || C === null){
11264             this.clear(B);
11265             return;
11266         }
11267
11268         this.setCookie(B, C);
11269         Roo.state.CookieProvider.superclass.set.call(this, B, C);
11270     },
11271
11272     
11273     clear : function(D){
11274         this.clearCookie(D);
11275         Roo.state.CookieProvider.superclass.clear.call(this, D);
11276     },
11277
11278     
11279     readCookies : function(){
11280         var  E = {};
11281         var  c = document.cookie + ";";
11282         var  re = /\s?(.*?)=(.*?);/g;
11283         var  F;
11284         while((F = re.exec(c)) != null){
11285             var  D = F[1];
11286             var  C = F[2];
11287             if(D && D.substring(0,3) == "ys-"){
11288                 E[D.substr(3)] = this.decodeValue(C);
11289             }
11290         }
11291         return  E;
11292     },
11293
11294     
11295     setCookie : function(G, H){
11296         document.cookie = "ys-"+ G + "=" + this.encodeValue(H) +
11297            ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
11298            ((this.path == null) ? "" : ("; path=" + this.path)) +
11299            ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
11300            ((this.secure == true) ? "; secure" : "");
11301     },
11302
11303     
11304     clearCookie : function(I){
11305         document.cookie = "ys-" + I + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
11306            ((this.path == null) ? "" : ("; path=" + this.path)) +
11307            ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
11308            ((this.secure == true) ? "; secure" : "");
11309     }
11310 });