remove dependence on MochiKit.Signal
[dygraphs.git] / dygraph-combined.js
1 /***
2
3 MochiKit.MochiKit 1.4 : PACKED VERSION
4
5 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6 diff against the source tree, not this file.
7
8 See <http://mochikit.com/> for documentation, downloads, license, etc.
9
10 (c) 2005 Bob Ippolito. All rights Reserved.
11
12 ***/
13
14 if(typeof (dojo)!="undefined"){
15 dojo.provide("MochiKit.Base");
16 }
17 if(typeof (MochiKit)=="undefined"){
18 MochiKit={};
19 }
20 if(typeof (MochiKit.Base)=="undefined"){
21 MochiKit.Base={};
22 }
23 if(typeof (MochiKit.__export__)=="undefined"){
24 MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined"));
25 }
26 MochiKit.Base.VERSION="1.4";
27 MochiKit.Base.NAME="MochiKit.Base";
28 MochiKit.Base.update=function(_1,_2){
29 if(_1===null){
30 _1={};
31 }
32 for(var i=1;i<arguments.length;i++){
33 var o=arguments[i];
34 if(typeof (o)!="undefined"&&o!==null){
35 for(var k in o){
36 _1[k]=o[k];
37 }
38 }
39 }
40 return _1;
41 };
42 MochiKit.Base.update(MochiKit.Base,{__repr__:function(){
43 return "["+this.NAME+" "+this.VERSION+"]";
44 },toString:function(){
45 return this.__repr__();
46 },camelize:function(_6){
47 var _7=_6.split("-");
48 var cc=_7[0];
49 for(var i=1;i<_7.length;i++){
50 cc+=_7[i].charAt(0).toUpperCase()+_7[i].substring(1);
51 }
52 return cc;
53 },counter:function(n){
54 if(arguments.length===0){
55 n=1;
56 }
57 return function(){
58 return n++;
59 };
60 },clone:function(_b){
61 var me=arguments.callee;
62 if(arguments.length==1){
63 me.prototype=_b;
64 return new me();
65 }
66 },_flattenArray:function(_d,_e){
67 for(var i=0;i<_e.length;i++){
68 var o=_e[i];
69 if(o instanceof Array){
70 arguments.callee(_d,o);
71 }else{
72 _d.push(o);
73 }
74 }
75 return _d;
76 },flattenArray:function(lst){
77 return MochiKit.Base._flattenArray([],lst);
78 },flattenArguments:function(lst){
79 var res=[];
80 var m=MochiKit.Base;
81 var _15=m.extend(null,arguments);
82 while(_15.length){
83 var o=_15.shift();
84 if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
85 for(var i=o.length-1;i>=0;i--){
86 _15.unshift(o[i]);
87 }
88 }else{
89 res.push(o);
90 }
91 }
92 return res;
93 },extend:function(_18,obj,_1a){
94 if(!_1a){
95 _1a=0;
96 }
97 if(obj){
98 var l=obj.length;
99 if(typeof (l)!="number"){
100 if(typeof (MochiKit.Iter)!="undefined"){
101 obj=MochiKit.Iter.list(obj);
102 l=obj.length;
103 }else{
104 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
105 }
106 }
107 if(!_18){
108 _18=[];
109 }
110 for(var i=_1a;i<l;i++){
111 _18.push(obj[i]);
112 }
113 }
114 return _18;
115 },updatetree:function(_1d,obj){
116 if(_1d===null){
117 _1d={};
118 }
119 for(var i=1;i<arguments.length;i++){
120 var o=arguments[i];
121 if(typeof (o)!="undefined"&&o!==null){
122 for(var k in o){
123 var v=o[k];
124 if(typeof (_1d[k])=="object"&&typeof (v)=="object"){
125 arguments.callee(_1d[k],v);
126 }else{
127 _1d[k]=v;
128 }
129 }
130 }
131 }
132 return _1d;
133 },setdefault:function(_23,obj){
134 if(_23===null){
135 _23={};
136 }
137 for(var i=1;i<arguments.length;i++){
138 var o=arguments[i];
139 for(var k in o){
140 if(!(k in _23)){
141 _23[k]=o[k];
142 }
143 }
144 }
145 return _23;
146 },keys:function(obj){
147 var _29=[];
148 for(var _2a in obj){
149 _29.push(_2a);
150 }
151 return _29;
152 },values:function(obj){
153 var _2c=[];
154 for(var _2d in obj){
155 _2c.push(obj[_2d]);
156 }
157 return _2c;
158 },items:function(obj){
159 var _2f=[];
160 var e;
161 for(var _31 in obj){
162 var v;
163 try{
164 v=obj[_31];
165 }
166 catch(e){
167 continue;
168 }
169 _2f.push([_31,v]);
170 }
171 return _2f;
172 },_newNamedError:function(_33,_34,_35){
173 _35.prototype=new MochiKit.Base.NamedError(_33.NAME+"."+_34);
174 _33[_34]=_35;
175 },operator:{truth:function(a){
176 return !!a;
177 },lognot:function(a){
178 return !a;
179 },identity:function(a){
180 return a;
181 },not:function(a){
182 return ~a;
183 },neg:function(a){
184 return -a;
185 },add:function(a,b){
186 return a+b;
187 },sub:function(a,b){
188 return a-b;
189 },div:function(a,b){
190 return a/b;
191 },mod:function(a,b){
192 return a%b;
193 },mul:function(a,b){
194 return a*b;
195 },and:function(a,b){
196 return a&b;
197 },or:function(a,b){
198 return a|b;
199 },xor:function(a,b){
200 return a^b;
201 },lshift:function(a,b){
202 return a<<b;
203 },rshift:function(a,b){
204 return a>>b;
205 },zrshift:function(a,b){
206 return a>>>b;
207 },eq:function(a,b){
208 return a==b;
209 },ne:function(a,b){
210 return a!=b;
211 },gt:function(a,b){
212 return a>b;
213 },ge:function(a,b){
214 return a>=b;
215 },lt:function(a,b){
216 return a<b;
217 },le:function(a,b){
218 return a<=b;
219 },seq:function(a,b){
220 return a===b;
221 },sne:function(a,b){
222 return a!==b;
223 },ceq:function(a,b){
224 return MochiKit.Base.compare(a,b)===0;
225 },cne:function(a,b){
226 return MochiKit.Base.compare(a,b)!==0;
227 },cgt:function(a,b){
228 return MochiKit.Base.compare(a,b)==1;
229 },cge:function(a,b){
230 return MochiKit.Base.compare(a,b)!=-1;
231 },clt:function(a,b){
232 return MochiKit.Base.compare(a,b)==-1;
233 },cle:function(a,b){
234 return MochiKit.Base.compare(a,b)!=1;
235 },logand:function(a,b){
236 return a&&b;
237 },logor:function(a,b){
238 return a||b;
239 },contains:function(a,b){
240 return b in a;
241 }},forwardCall:function(_73){
242 return function(){
243 return this[_73].apply(this,arguments);
244 };
245 },itemgetter:function(_74){
246 return function(arg){
247 return arg[_74];
248 };
249 },typeMatcher:function(){
250 var _76={};
251 for(var i=0;i<arguments.length;i++){
252 var typ=arguments[i];
253 _76[typ]=typ;
254 }
255 return function(){
256 for(var i=0;i<arguments.length;i++){
257 if(!(typeof (arguments[i]) in _76)){
258 return false;
259 }
260 }
261 return true;
262 };
263 },isNull:function(){
264 for(var i=0;i<arguments.length;i++){
265 if(arguments[i]!==null){
266 return false;
267 }
268 }
269 return true;
270 },isUndefinedOrNull:function(){
271 for(var i=0;i<arguments.length;i++){
272 var o=arguments[i];
273 if(!(typeof (o)=="undefined"||o===null)){
274 return false;
275 }
276 }
277 return true;
278 },isEmpty:function(obj){
279 return !MochiKit.Base.isNotEmpty.apply(this,arguments);
280 },isNotEmpty:function(obj){
281 for(var i=0;i<arguments.length;i++){
282 var o=arguments[i];
283 if(!(o&&o.length)){
284 return false;
285 }
286 }
287 return true;
288 },isArrayLike:function(){
289 for(var i=0;i<arguments.length;i++){
290 var o=arguments[i];
291 var typ=typeof (o);
292 if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"||o.nodeType===3){
293 return false;
294 }
295 }
296 return true;
297 },isDateLike:function(){
298 for(var i=0;i<arguments.length;i++){
299 var o=arguments[i];
300 if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){
301 return false;
302 }
303 }
304 return true;
305 },xmap:function(fn){
306 if(fn===null){
307 return MochiKit.Base.extend(null,arguments,1);
308 }
309 var _87=[];
310 for(var i=1;i<arguments.length;i++){
311 _87.push(fn(arguments[i]));
312 }
313 return _87;
314 },map:function(fn,lst){
315 var m=MochiKit.Base;
316 var itr=MochiKit.Iter;
317 var _8d=m.isArrayLike;
318 if(arguments.length<=2){
319 if(!_8d(lst)){
320 if(itr){
321 lst=itr.list(lst);
322 if(fn===null){
323 return lst;
324 }
325 }else{
326 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
327 }
328 }
329 if(fn===null){
330 return m.extend(null,lst);
331 }
332 var _8e=[];
333 for(var i=0;i<lst.length;i++){
334 _8e.push(fn(lst[i]));
335 }
336 return _8e;
337 }else{
338 if(fn===null){
339 fn=Array;
340 }
341 var _90=null;
342 for(i=1;i<arguments.length;i++){
343 if(!_8d(arguments[i])){
344 if(itr){
345 return itr.list(itr.imap.apply(null,arguments));
346 }else{
347 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
348 }
349 }
350 var l=arguments[i].length;
351 if(_90===null||_90>l){
352 _90=l;
353 }
354 }
355 _8e=[];
356 for(i=0;i<_90;i++){
357 var _92=[];
358 for(var j=1;j<arguments.length;j++){
359 _92.push(arguments[j][i]);
360 }
361 _8e.push(fn.apply(this,_92));
362 }
363 return _8e;
364 }
365 },xfilter:function(fn){
366 var _95=[];
367 if(fn===null){
368 fn=MochiKit.Base.operator.truth;
369 }
370 for(var i=1;i<arguments.length;i++){
371 var o=arguments[i];
372 if(fn(o)){
373 _95.push(o);
374 }
375 }
376 return _95;
377 },filter:function(fn,lst,_9a){
378 var _9b=[];
379 var m=MochiKit.Base;
380 if(!m.isArrayLike(lst)){
381 if(MochiKit.Iter){
382 lst=MochiKit.Iter.list(lst);
383 }else{
384 throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
385 }
386 }
387 if(fn===null){
388 fn=m.operator.truth;
389 }
390 if(typeof (Array.prototype.filter)=="function"){
391 return Array.prototype.filter.call(lst,fn,_9a);
392 }else{
393 if(typeof (_9a)=="undefined"||_9a===null){
394 for(var i=0;i<lst.length;i++){
395 var o=lst[i];
396 if(fn(o)){
397 _9b.push(o);
398 }
399 }
400 }else{
401 for(i=0;i<lst.length;i++){
402 o=lst[i];
403 if(fn.call(_9a,o)){
404 _9b.push(o);
405 }
406 }
407 }
408 }
409 return _9b;
410 },_wrapDumbFunction:function(_9f){
411 return function(){
412 switch(arguments.length){
413 case 0:
414 return _9f();
415 case 1:
416 return _9f(arguments[0]);
417 case 2:
418 return _9f(arguments[0],arguments[1]);
419 case 3:
420 return _9f(arguments[0],arguments[1],arguments[2]);
421 }
422 var _a0=[];
423 for(var i=0;i<arguments.length;i++){
424 _a0.push("arguments["+i+"]");
425 }
426 return eval("(func("+_a0.join(",")+"))");
427 };
428 },methodcaller:function(_a2){
429 var _a3=MochiKit.Base.extend(null,arguments,1);
430 if(typeof (_a2)=="function"){
431 return function(obj){
432 return _a2.apply(obj,_a3);
433 };
434 }else{
435 return function(obj){
436 return obj[_a2].apply(obj,_a3);
437 };
438 }
439 },method:function(_a6,_a7){
440 var m=MochiKit.Base;
441 return m.bind.apply(this,m.extend([_a7,_a6],arguments,2));
442 },compose:function(f1,f2){
443 var _ab=[];
444 var m=MochiKit.Base;
445 if(arguments.length===0){
446 throw new TypeError("compose() requires at least one argument");
447 }
448 for(var i=0;i<arguments.length;i++){
449 var fn=arguments[i];
450 if(typeof (fn)!="function"){
451 throw new TypeError(m.repr(fn)+" is not a function");
452 }
453 _ab.push(fn);
454 }
455 return function(){
456 var _af=arguments;
457 for(var i=_ab.length-1;i>=0;i--){
458 _af=[_ab[i].apply(this,_af)];
459 }
460 return _af[0];
461 };
462 },bind:function(_b1,_b2){
463 if(typeof (_b1)=="string"){
464 _b1=_b2[_b1];
465 }
466 var _b3=_b1.im_func;
467 var _b4=_b1.im_preargs;
468 var _b5=_b1.im_self;
469 var m=MochiKit.Base;
470 if(typeof (_b1)=="function"&&typeof (_b1.apply)=="undefined"){
471 _b1=m._wrapDumbFunction(_b1);
472 }
473 if(typeof (_b3)!="function"){
474 _b3=_b1;
475 }
476 if(typeof (_b2)!="undefined"){
477 _b5=_b2;
478 }
479 if(typeof (_b4)=="undefined"){
480 _b4=[];
481 }else{
482 _b4=_b4.slice();
483 }
484 m.extend(_b4,arguments,2);
485 var _b7=function(){
486 var _b8=arguments;
487 var me=arguments.callee;
488 if(me.im_preargs.length>0){
489 _b8=m.concat(me.im_preargs,_b8);
490 }
491 var _ba=me.im_self;
492 if(!_ba){
493 _ba=this;
494 }
495 return me.im_func.apply(_ba,_b8);
496 };
497 _b7.im_self=_b5;
498 _b7.im_func=_b3;
499 _b7.im_preargs=_b4;
500 return _b7;
501 },bindMethods:function(_bb){
502 var _bc=MochiKit.Base.bind;
503 for(var k in _bb){
504 var _be=_bb[k];
505 if(typeof (_be)=="function"){
506 _bb[k]=_bc(_be,_bb);
507 }
508 }
509 },registerComparator:function(_bf,_c0,_c1,_c2){
510 MochiKit.Base.comparatorRegistry.register(_bf,_c0,_c1,_c2);
511 },_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){
512 if(a==b){
513 return 0;
514 }
515 var _c5=(typeof (a)=="undefined"||a===null);
516 var _c6=(typeof (b)=="undefined"||b===null);
517 if(_c5&&_c6){
518 return 0;
519 }else{
520 if(_c5){
521 return -1;
522 }else{
523 if(_c6){
524 return 1;
525 }
526 }
527 }
528 var m=MochiKit.Base;
529 var _c8=m._primitives;
530 if(!(typeof (a) in _c8&&typeof (b) in _c8)){
531 try{
532 return m.comparatorRegistry.match(a,b);
533 }
534 catch(e){
535 if(e!=m.NotFound){
536 throw e;
537 }
538 }
539 }
540 if(a<b){
541 return -1;
542 }else{
543 if(a>b){
544 return 1;
545 }
546 }
547 var _c9=m.repr;
548 throw new TypeError(_c9(a)+" and "+_c9(b)+" can not be compared");
549 },compareDateLike:function(a,b){
550 return MochiKit.Base.compare(a.getTime(),b.getTime());
551 },compareArrayLike:function(a,b){
552 var _ce=MochiKit.Base.compare;
553 var _cf=a.length;
554 var _d0=0;
555 if(_cf>b.length){
556 _d0=1;
557 _cf=b.length;
558 }else{
559 if(_cf<b.length){
560 _d0=-1;
561 }
562 }
563 for(var i=0;i<_cf;i++){
564 var cmp=_ce(a[i],b[i]);
565 if(cmp){
566 return cmp;
567 }
568 }
569 return _d0;
570 },registerRepr:function(_d3,_d4,_d5,_d6){
571 MochiKit.Base.reprRegistry.register(_d3,_d4,_d5,_d6);
572 },repr:function(o){
573 if(typeof (o)=="undefined"){
574 return "undefined";
575 }else{
576 if(o===null){
577 return "null";
578 }
579 }
580 try{
581 if(typeof (o.__repr__)=="function"){
582 return o.__repr__();
583 }else{
584 if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){
585 return o.repr();
586 }
587 }
588 return MochiKit.Base.reprRegistry.match(o);
589 }
590 catch(e){
591 if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){
592 return o.NAME;
593 }
594 }
595 try{
596 var _d8=(o+"");
597 }
598 catch(e){
599 return "["+typeof (o)+"]";
600 }
601 if(typeof (o)=="function"){
602 o=_d8.replace(/^\s+/,"");
603 var idx=o.indexOf("{");
604 if(idx!=-1){
605 o=o.substr(0,idx)+"{...}";
606 }
607 }
608 return _d8;
609 },reprArrayLike:function(o){
610 var m=MochiKit.Base;
611 return "["+m.map(m.repr,o).join(", ")+"]";
612 },reprString:function(o){
613 return ("\""+o.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
614 },reprNumber:function(o){
615 return o+"";
616 },registerJSON:function(_de,_df,_e0,_e1){
617 MochiKit.Base.jsonRegistry.register(_de,_df,_e0,_e1);
618 },evalJSON:function(){
619 return eval("("+arguments[0]+")");
620 },serializeJSON:function(o){
621 var _e3=typeof (o);
622 if(_e3=="number"||_e3=="boolean"){
623 return o+"";
624 }else{
625 if(o===null){
626 return "null";
627 }
628 }
629 var m=MochiKit.Base;
630 var _e5=m.reprString;
631 if(_e3=="string"){
632 return _e5(o);
633 }
634 var me=arguments.callee;
635 var _e7;
636 if(typeof (o.__json__)=="function"){
637 _e7=o.__json__();
638 if(o!==_e7){
639 return me(_e7);
640 }
641 }
642 if(typeof (o.json)=="function"){
643 _e7=o.json();
644 if(o!==_e7){
645 return me(_e7);
646 }
647 }
648 if(_e3!="function"&&typeof (o.length)=="number"){
649 var res=[];
650 for(var i=0;i<o.length;i++){
651 var val=me(o[i]);
652 if(typeof (val)!="string"){
653 val="undefined";
654 }
655 res.push(val);
656 }
657 return "["+res.join(", ")+"]";
658 }
659 try{
660 _e7=m.jsonRegistry.match(o);
661 if(o!==_e7){
662 return me(_e7);
663 }
664 }
665 catch(e){
666 if(e!=m.NotFound){
667 throw e;
668 }
669 }
670 if(_e3=="undefined"){
671 throw new TypeError("undefined can not be serialized as JSON");
672 }
673 if(_e3=="function"){
674 return null;
675 }
676 res=[];
677 for(var k in o){
678 var _ec;
679 if(typeof (k)=="number"){
680 _ec="\""+k+"\"";
681 }else{
682 if(typeof (k)=="string"){
683 _ec=_e5(k);
684 }else{
685 continue;
686 }
687 }
688 val=me(o[k]);
689 if(typeof (val)!="string"){
690 continue;
691 }
692 res.push(_ec+":"+val);
693 }
694 return "{"+res.join(", ")+"}";
695 },objEqual:function(a,b){
696 return (MochiKit.Base.compare(a,b)===0);
697 },arrayEqual:function(_ef,arr){
698 if(_ef.length!=arr.length){
699 return false;
700 }
701 return (MochiKit.Base.compare(_ef,arr)===0);
702 },concat:function(){
703 var _f1=[];
704 var _f2=MochiKit.Base.extend;
705 for(var i=0;i<arguments.length;i++){
706 _f2(_f1,arguments[i]);
707 }
708 return _f1;
709 },keyComparator:function(key){
710 var m=MochiKit.Base;
711 var _f6=m.compare;
712 if(arguments.length==1){
713 return function(a,b){
714 return _f6(a[key],b[key]);
715 };
716 }
717 var _f9=m.extend(null,arguments);
718 return function(a,b){
719 var _fc=0;
720 for(var i=0;(_fc===0)&&(i<_f9.length);i++){
721 var key=_f9[i];
722 _fc=_f6(a[key],b[key]);
723 }
724 return _fc;
725 };
726 },reverseKeyComparator:function(key){
727 var _100=MochiKit.Base.keyComparator.apply(this,arguments);
728 return function(a,b){
729 return _100(b,a);
730 };
731 },partial:function(func){
732 var m=MochiKit.Base;
733 return m.bind.apply(this,m.extend([func,undefined],arguments,1));
734 },listMinMax:function(_105,lst){
735 if(lst.length===0){
736 return null;
737 }
738 var cur=lst[0];
739 var _108=MochiKit.Base.compare;
740 for(var i=1;i<lst.length;i++){
741 var o=lst[i];
742 if(_108(o,cur)==_105){
743 cur=o;
744 }
745 }
746 return cur;
747 },objMax:function(){
748 return MochiKit.Base.listMinMax(1,arguments);
749 },objMin:function(){
750 return MochiKit.Base.listMinMax(-1,arguments);
751 },findIdentical:function(lst,_10c,_10d,end){
752 if(typeof (end)=="undefined"||end===null){
753 end=lst.length;
754 }
755 if(typeof (_10d)=="undefined"||_10d===null){
756 _10d=0;
757 }
758 for(var i=_10d;i<end;i++){
759 if(lst[i]===_10c){
760 return i;
761 }
762 }
763 return -1;
764 },mean:function(){
765 var sum=0;
766 var m=MochiKit.Base;
767 var args=m.extend(null,arguments);
768 var _113=args.length;
769 while(args.length){
770 var o=args.shift();
771 if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
772 _113+=o.length-1;
773 for(var i=o.length-1;i>=0;i--){
774 sum+=o[i];
775 }
776 }else{
777 sum+=o;
778 }
779 }
780 if(_113<=0){
781 throw new TypeError("mean() requires at least one argument");
782 }
783 return sum/_113;
784 },median:function(){
785 var data=MochiKit.Base.flattenArguments(arguments);
786 if(data.length===0){
787 throw new TypeError("median() requires at least one argument");
788 }
789 data.sort(compare);
790 if(data.length%2==0){
791 var _117=data.length/2;
792 return (data[_117]+data[_117-1])/2;
793 }else{
794 return data[(data.length-1)/2];
795 }
796 },findValue:function(lst,_119,_11a,end){
797 if(typeof (end)=="undefined"||end===null){
798 end=lst.length;
799 }
800 if(typeof (_11a)=="undefined"||_11a===null){
801 _11a=0;
802 }
803 var cmp=MochiKit.Base.compare;
804 for(var i=_11a;i<end;i++){
805 if(cmp(lst[i],_119)===0){
806 return i;
807 }
808 }
809 return -1;
810 },nodeWalk:function(node,_11f){
811 var _120=[node];
812 var _121=MochiKit.Base.extend;
813 while(_120.length){
814 var res=_11f(_120.shift());
815 if(res){
816 _121(_120,res);
817 }
818 }
819 },nameFunctions:function(_123){
820 var base=_123.NAME;
821 if(typeof (base)=="undefined"){
822 base="";
823 }else{
824 base=base+".";
825 }
826 for(var name in _123){
827 var o=_123[name];
828 if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
829 try{
830 o.NAME=base+name;
831 }
832 catch(e){
833 }
834 }
835 }
836 },queryString:function(_127,_128){
837 if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_127)=="string"||(typeof (_127.nodeType)!="undefined"&&_127.nodeType>0))){
838 var kv=MochiKit.DOM.formContents(_127);
839 _127=kv[0];
840 _128=kv[1];
841 }else{
842 if(arguments.length==1){
843 if(typeof (_127.length)=="number"&&_127.length==2){
844 return arguments.callee(_127[0],_127[1]);
845 }
846 var o=_127;
847 _127=[];
848 _128=[];
849 for(var k in o){
850 var v=o[k];
851 if(typeof (v)=="function"){
852 continue;
853 }else{
854 if(typeof (v)!="string"&&typeof (v.length)=="number"){
855 for(var i=0;i<v.length;i++){
856 _127.push(k);
857 _128.push(v[i]);
858 }
859 }else{
860 _127.push(k);
861 _128.push(v);
862 }
863 }
864 }
865 }
866 }
867 var rval=[];
868 var len=Math.min(_127.length,_128.length);
869 var _130=MochiKit.Base.urlEncode;
870 for(var i=0;i<len;i++){
871 v=_128[i];
872 if(typeof (v)!="undefined"&&v!==null){
873 rval.push(_130(_127[i])+"="+_130(v));
874 }
875 }
876 return rval.join("&");
877 },parseQueryString:function(_131,_132){
878 var qstr=(_131.charAt(0)=="?")?_131.substring(1):_131;
879 var _134=qstr.replace(/\+/g,"%20").split(/(\&amp\;|\&\#38\;|\&#x26;|\&)/);
880 var o={};
881 var _136;
882 if(typeof (decodeURIComponent)!="undefined"){
883 _136=decodeURIComponent;
884 }else{
885 _136=unescape;
886 }
887 if(_132){
888 for(var i=0;i<_134.length;i++){
889 var pair=_134[i].split("=");
890 var name=_136(pair.shift());
891 if(!name){
892 continue;
893 }
894 var arr=o[name];
895 if(!(arr instanceof Array)){
896 arr=[];
897 o[name]=arr;
898 }
899 arr.push(_136(pair.join("=")));
900 }
901 }else{
902 for(i=0;i<_134.length;i++){
903 pair=_134[i].split("=");
904 var name=pair.shift();
905 if(!name){
906 continue;
907 }
908 o[_136(name)]=_136(pair.join("="));
909 }
910 }
911 return o;
912 }});
913 MochiKit.Base.AdapterRegistry=function(){
914 this.pairs=[];
915 };
916 MochiKit.Base.AdapterRegistry.prototype={register:function(name,_13c,wrap,_13e){
917 if(_13e){
918 this.pairs.unshift([name,_13c,wrap]);
919 }else{
920 this.pairs.push([name,_13c,wrap]);
921 }
922 },match:function(){
923 for(var i=0;i<this.pairs.length;i++){
924 var pair=this.pairs[i];
925 if(pair[1].apply(this,arguments)){
926 return pair[2].apply(this,arguments);
927 }
928 }
929 throw MochiKit.Base.NotFound;
930 },unregister:function(name){
931 for(var i=0;i<this.pairs.length;i++){
932 var pair=this.pairs[i];
933 if(pair[0]==name){
934 this.pairs.splice(i,1);
935 return true;
936 }
937 }
938 return false;
939 }};
940 MochiKit.Base.EXPORT=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
941 MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
942 MochiKit.Base._exportSymbols=function(_144,_145){
943 if(!MochiKit.__export__){
944 return;
945 }
946 var all=_145.EXPORT_TAGS[":all"];
947 for(var i=0;i<all.length;i++){
948 _144[all[i]]=_145[all[i]];
949 }
950 };
951 MochiKit.Base.__new__=function(){
952 var m=this;
953 m.noop=m.operator.identity;
954 m.forward=m.forwardCall;
955 m.find=m.findValue;
956 if(typeof (encodeURIComponent)!="undefined"){
957 m.urlEncode=function(_149){
958 return encodeURIComponent(_149).replace(/\'/g,"%27");
959 };
960 }else{
961 m.urlEncode=function(_14a){
962 return escape(_14a).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27");
963 };
964 }
965 m.NamedError=function(name){
966 this.message=name;
967 this.name=name;
968 };
969 m.NamedError.prototype=new Error();
970 m.update(m.NamedError.prototype,{repr:function(){
971 if(this.message&&this.message!=this.name){
972 return this.name+"("+m.repr(this.message)+")";
973 }else{
974 return this.name+"()";
975 }
976 },toString:m.forwardCall("repr")});
977 m.NotFound=new m.NamedError("MochiKit.Base.NotFound");
978 m.listMax=m.partial(m.listMinMax,1);
979 m.listMin=m.partial(m.listMinMax,-1);
980 m.isCallable=m.typeMatcher("function");
981 m.isUndefined=m.typeMatcher("undefined");
982 m.merge=m.partial(m.update,null);
983 m.zip=m.partial(m.map,null);
984 m.average=m.mean;
985 m.comparatorRegistry=new m.AdapterRegistry();
986 m.registerComparator("dateLike",m.isDateLike,m.compareDateLike);
987 m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike);
988 m.reprRegistry=new m.AdapterRegistry();
989 m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike);
990 m.registerRepr("string",m.typeMatcher("string"),m.reprString);
991 m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber);
992 m.jsonRegistry=new m.AdapterRegistry();
993 var all=m.concat(m.EXPORT,m.EXPORT_OK);
994 m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all};
995 m.nameFunctions(this);
996 };
997 MochiKit.Base.__new__();
998 if(MochiKit.__export__){
999 compare=MochiKit.Base.compare;
1000 compose=MochiKit.Base.compose;
1001 serializeJSON=MochiKit.Base.serializeJSON;
1002 }
1003 MochiKit.Base._exportSymbols(this,MochiKit.Base);
1004 if(typeof (dojo)!="undefined"){
1005 dojo.provide("MochiKit.Color");
1006 dojo.require("MochiKit.Base");
1007 }
1008 if(typeof (JSAN)!="undefined"){
1009 JSAN.use("MochiKit.Base",[]);
1010 }
1011 try{
1012 if(typeof (MochiKit.Base)=="undefined"){
1013 throw "";
1014 }
1015 }
1016 catch(e){
1017 throw "MochiKit.Color depends on MochiKit.Base";
1018 }
1019 if(typeof (MochiKit.Color)=="undefined"){
1020 MochiKit.Color={};
1021 }
1022 MochiKit.Color.NAME="MochiKit.Color";
1023 MochiKit.Color.VERSION="1.4";
1024 MochiKit.Color.__repr__=function(){
1025 return "["+this.NAME+" "+this.VERSION+"]";
1026 };
1027 MochiKit.Color.toString=function(){
1028 return this.__repr__();
1029 };
1030 MochiKit.Color.Color=function(red,_14e,blue,_150){
1031 if(typeof (_150)=="undefined"||_150===null){
1032 _150=1;
1033 }
1034 this.rgb={r:red,g:_14e,b:blue,a:_150};
1035 };
1036 MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_151){
1037 var rgb=this.rgb;
1038 var m=MochiKit.Color;
1039 return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_151);
1040 },colorWithHue:function(hue){
1041 var hsl=this.asHSL();
1042 hsl.h=hue;
1043 var m=MochiKit.Color;
1044 return m.Color.fromHSL(hsl);
1045 },colorWithSaturation:function(_157){
1046 var hsl=this.asHSL();
1047 hsl.s=_157;
1048 var m=MochiKit.Color;
1049 return m.Color.fromHSL(hsl);
1050 },colorWithLightness:function(_15a){
1051 var hsl=this.asHSL();
1052 hsl.l=_15a;
1053 var m=MochiKit.Color;
1054 return m.Color.fromHSL(hsl);
1055 },darkerColorWithLevel:function(_15d){
1056 var hsl=this.asHSL();
1057 hsl.l=Math.max(hsl.l-_15d,0);
1058 var m=MochiKit.Color;
1059 return m.Color.fromHSL(hsl);
1060 },lighterColorWithLevel:function(_160){
1061 var hsl=this.asHSL();
1062 hsl.l=Math.min(hsl.l+_160,1);
1063 var m=MochiKit.Color;
1064 return m.Color.fromHSL(hsl);
1065 },blendedColor:function(_163,_164){
1066 if(typeof (_164)=="undefined"||_164===null){
1067 _164=0.5;
1068 }
1069 var sf=1-_164;
1070 var s=this.rgb;
1071 var d=_163.rgb;
1072 var df=_164;
1073 return MochiKit.Color.Color.fromRGB((s.r*sf)+(d.r*df),(s.g*sf)+(d.g*df),(s.b*sf)+(d.b*df),(s.a*sf)+(d.a*df));
1074 },compareRGB:function(_169){
1075 var a=this.asRGB();
1076 var b=_169.asRGB();
1077 return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]);
1078 },isLight:function(){
1079 return this.asHSL().b>0.5;
1080 },isDark:function(){
1081 return (!this.isLight());
1082 },toHSLString:function(){
1083 var c=this.asHSL();
1084 var ccc=MochiKit.Color.clampColorComponent;
1085 var rval=this._hslString;
1086 if(!rval){
1087 var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%");
1088 var a=c.a;
1089 if(a>=1){
1090 a=1;
1091 rval="hsl("+mid+")";
1092 }else{
1093 if(a<=0){
1094 a=0;
1095 }
1096 rval="hsla("+mid+","+a+")";
1097 }
1098 this._hslString=rval;
1099 }
1100 return rval;
1101 },toRGBString:function(){
1102 var c=this.rgb;
1103 var ccc=MochiKit.Color.clampColorComponent;
1104 var rval=this._rgbString;
1105 if(!rval){
1106 var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0));
1107 if(c.a!=1){
1108 rval="rgba("+mid+","+c.a+")";
1109 }else{
1110 rval="rgb("+mid+")";
1111 }
1112 this._rgbString=rval;
1113 }
1114 return rval;
1115 },asRGB:function(){
1116 return MochiKit.Base.clone(this.rgb);
1117 },toHexString:function(){
1118 var m=MochiKit.Color;
1119 var c=this.rgb;
1120 var ccc=MochiKit.Color.clampColorComponent;
1121 var rval=this._hexString;
1122 if(!rval){
1123 rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255)));
1124 this._hexString=rval;
1125 }
1126 return rval;
1127 },asHSV:function(){
1128 var hsv=this.hsv;
1129 var c=this.rgb;
1130 if(typeof (hsv)=="undefined"||hsv===null){
1131 hsv=MochiKit.Color.rgbToHSV(this.rgb);
1132 this.hsv=hsv;
1133 }
1134 return MochiKit.Base.clone(hsv);
1135 },asHSL:function(){
1136 var hsl=this.hsl;
1137 var c=this.rgb;
1138 if(typeof (hsl)=="undefined"||hsl===null){
1139 hsl=MochiKit.Color.rgbToHSL(this.rgb);
1140 this.hsl=hsl;
1141 }
1142 return MochiKit.Base.clone(hsl);
1143 },toString:function(){
1144 return this.toRGBString();
1145 },repr:function(){
1146 var c=this.rgb;
1147 var col=[c.r,c.g,c.b,c.a];
1148 return this.__class__.NAME+"("+col.join(", ")+")";
1149 }};
1150 MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_180,blue,_182){
1151 var _183=MochiKit.Color.Color;
1152 if(arguments.length==1){
1153 var rgb=red;
1154 red=rgb.r;
1155 _180=rgb.g;
1156 blue=rgb.b;
1157 if(typeof (rgb.a)=="undefined"){
1158 _182=undefined;
1159 }else{
1160 _182=rgb.a;
1161 }
1162 }
1163 return new _183(red,_180,blue,_182);
1164 },fromHSL:function(hue,_186,_187,_188){
1165 var m=MochiKit.Color;
1166 return m.Color.fromRGB(m.hslToRGB.apply(m,arguments));
1167 },fromHSV:function(hue,_18b,_18c,_18d){
1168 var m=MochiKit.Color;
1169 return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments));
1170 },fromName:function(name){
1171 var _190=MochiKit.Color.Color;
1172 if(name.charAt(0)=="\""){
1173 name=name.substr(1,name.length-2);
1174 }
1175 var _191=_190._namedColors[name.toLowerCase()];
1176 if(typeof (_191)=="string"){
1177 return _190.fromHexString(_191);
1178 }else{
1179 if(name=="transparent"){
1180 return _190.transparentColor();
1181 }
1182 }
1183 return null;
1184 },fromString:function(_192){
1185 var self=MochiKit.Color.Color;
1186 var _194=_192.substr(0,3);
1187 if(_194=="rgb"){
1188 return self.fromRGBString(_192);
1189 }else{
1190 if(_194=="hsl"){
1191 return self.fromHSLString(_192);
1192 }else{
1193 if(_192.charAt(0)=="#"){
1194 return self.fromHexString(_192);
1195 }
1196 }
1197 }
1198 return self.fromName(_192);
1199 },fromHexString:function(_195){
1200 if(_195.charAt(0)=="#"){
1201 _195=_195.substring(1);
1202 }
1203 var _196=[];
1204 var i,hex;
1205 if(_195.length==3){
1206 for(i=0;i<3;i++){
1207 hex=_195.substr(i,1);
1208 _196.push(parseInt(hex+hex,16)/255);
1209 }
1210 }else{
1211 for(i=0;i<6;i+=2){
1212 hex=_195.substr(i,2);
1213 _196.push(parseInt(hex,16)/255);
1214 }
1215 }
1216 var _199=MochiKit.Color.Color;
1217 return _199.fromRGB.apply(_199,_196);
1218 },_fromColorString:function(pre,_19b,_19c,_19d){
1219 if(_19d.indexOf(pre)===0){
1220 _19d=_19d.substring(_19d.indexOf("(",3)+1,_19d.length-1);
1221 }
1222 var _19e=_19d.split(/\s*,\s*/);
1223 var _19f=[];
1224 for(var i=0;i<_19e.length;i++){
1225 var c=_19e[i];
1226 var val;
1227 var _1a3=c.substring(c.length-3);
1228 if(c.charAt(c.length-1)=="%"){
1229 val=0.01*parseFloat(c.substring(0,c.length-1));
1230 }else{
1231 if(_1a3=="deg"){
1232 val=parseFloat(c)/360;
1233 }else{
1234 if(_1a3=="rad"){
1235 val=parseFloat(c)/(Math.PI*2);
1236 }else{
1237 val=_19c[i]*parseFloat(c);
1238 }
1239 }
1240 }
1241 _19f.push(val);
1242 }
1243 return this[_19b].apply(this,_19f);
1244 },fromBackground:function(elem){
1245 var cls=MochiKit.Color.Color;
1246 return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor();
1247 },fromText:function(elem){
1248 var cls=MochiKit.Color.Color;
1249 return cls.fromComputedStyle(elem,"color","color")||cls.blackColor();
1250 },namedColors:function(){
1251 return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
1252 }});
1253 MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_1a9){
1254 v*=_1a9;
1255 if(v<0){
1256 return 0;
1257 }else{
1258 if(v>_1a9){
1259 return _1a9;
1260 }else{
1261 return v;
1262 }
1263 }
1264 },_hslValue:function(n1,n2,hue){
1265 if(hue>6){
1266 hue-=6;
1267 }else{
1268 if(hue<0){
1269 hue+=6;
1270 }
1271 }
1272 var val;
1273 if(hue<1){
1274 val=n1+(n2-n1)*hue;
1275 }else{
1276 if(hue<3){
1277 val=n2;
1278 }else{
1279 if(hue<4){
1280 val=n1+(n2-n1)*(4-hue);
1281 }else{
1282 val=n1;
1283 }
1284 }
1285 }
1286 return val;
1287 },hsvToRGB:function(hue,_1af,_1b0,_1b1){
1288 if(arguments.length==1){
1289 var hsv=hue;
1290 hue=hsv.h;
1291 _1af=hsv.s;
1292 _1b0=hsv.v;
1293 _1b1=hsv.a;
1294 }
1295 var red;
1296 var _1b4;
1297 var blue;
1298 if(_1af===0){
1299 red=_1b0;
1300 _1b4=_1b0;
1301 blue=_1b0;
1302 }else{
1303 var i=Math.floor(hue*6);
1304 var f=(hue*6)-i;
1305 var p=_1b0*(1-_1af);
1306 var q=_1b0*(1-(_1af*f));
1307 var t=_1b0*(1-(_1af*(1-f)));
1308 switch(i){
1309 case 1:
1310 red=q;
1311 _1b4=_1b0;
1312 blue=p;
1313 break;
1314 case 2:
1315 red=p;
1316 _1b4=_1b0;
1317 blue=t;
1318 break;
1319 case 3:
1320 red=p;
1321 _1b4=q;
1322 blue=_1b0;
1323 break;
1324 case 4:
1325 red=t;
1326 _1b4=p;
1327 blue=_1b0;
1328 break;
1329 case 5:
1330 red=_1b0;
1331 _1b4=p;
1332 blue=q;
1333 break;
1334 case 6:
1335 case 0:
1336 red=_1b0;
1337 _1b4=t;
1338 blue=p;
1339 break;
1340 }
1341 }
1342 return {r:red,g:_1b4,b:blue,a:_1b1};
1343 },hslToRGB:function(hue,_1bc,_1bd,_1be){
1344 if(arguments.length==1){
1345 var hsl=hue;
1346 hue=hsl.h;
1347 _1bc=hsl.s;
1348 _1bd=hsl.l;
1349 _1be=hsl.a;
1350 }
1351 var red;
1352 var _1c1;
1353 var blue;
1354 if(_1bc===0){
1355 red=_1bd;
1356 _1c1=_1bd;
1357 blue=_1bd;
1358 }else{
1359 var m2;
1360 if(_1bd<=0.5){
1361 m2=_1bd*(1+_1bc);
1362 }else{
1363 m2=_1bd+_1bc-(_1bd*_1bc);
1364 }
1365 var m1=(2*_1bd)-m2;
1366 var f=MochiKit.Color._hslValue;
1367 var h6=hue*6;
1368 red=f(m1,m2,h6+2);
1369 _1c1=f(m1,m2,h6);
1370 blue=f(m1,m2,h6-2);
1371 }
1372 return {r:red,g:_1c1,b:blue,a:_1be};
1373 },rgbToHSV:function(red,_1c8,blue,_1ca){
1374 if(arguments.length==1){
1375 var rgb=red;
1376 red=rgb.r;
1377 _1c8=rgb.g;
1378 blue=rgb.b;
1379 _1ca=rgb.a;
1380 }
1381 var max=Math.max(Math.max(red,_1c8),blue);
1382 var min=Math.min(Math.min(red,_1c8),blue);
1383 var hue;
1384 var _1cf;
1385 var _1d0=max;
1386 if(min==max){
1387 hue=0;
1388 _1cf=0;
1389 }else{
1390 var _1d1=(max-min);
1391 _1cf=_1d1/max;
1392 if(red==max){
1393 hue=(_1c8-blue)/_1d1;
1394 }else{
1395 if(_1c8==max){
1396 hue=2+((blue-red)/_1d1);
1397 }else{
1398 hue=4+((red-_1c8)/_1d1);
1399 }
1400 }
1401 hue/=6;
1402 if(hue<0){
1403 hue+=1;
1404 }
1405 if(hue>1){
1406 hue-=1;
1407 }
1408 }
1409 return {h:hue,s:_1cf,v:_1d0,a:_1ca};
1410 },rgbToHSL:function(red,_1d3,blue,_1d5){
1411 if(arguments.length==1){
1412 var rgb=red;
1413 red=rgb.r;
1414 _1d3=rgb.g;
1415 blue=rgb.b;
1416 _1d5=rgb.a;
1417 }
1418 var max=Math.max(red,Math.max(_1d3,blue));
1419 var min=Math.min(red,Math.min(_1d3,blue));
1420 var hue;
1421 var _1da;
1422 var _1db=(max+min)/2;
1423 var _1dc=max-min;
1424 if(_1dc===0){
1425 hue=0;
1426 _1da=0;
1427 }else{
1428 if(_1db<=0.5){
1429 _1da=_1dc/(max+min);
1430 }else{
1431 _1da=_1dc/(2-max-min);
1432 }
1433 if(red==max){
1434 hue=(_1d3-blue)/_1dc;
1435 }else{
1436 if(_1d3==max){
1437 hue=2+((blue-red)/_1dc);
1438 }else{
1439 hue=4+((red-_1d3)/_1dc);
1440 }
1441 }
1442 hue/=6;
1443 if(hue<0){
1444 hue+=1;
1445 }
1446 if(hue>1){
1447 hue-=1;
1448 }
1449 }
1450 return {h:hue,s:_1da,l:_1db,a:_1d5};
1451 },toColorPart:function(num){
1452 num=Math.round(num);
1453 var _1de=num.toString(16);
1454 if(num<16){
1455 return "0"+_1de;
1456 }
1457 return _1de;
1458 },__new__:function(){
1459 var m=MochiKit.Base;
1460 this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]);
1461 this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]);
1462 var _1e0=1/3;
1463 var _1e1={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_1e0,_1e0,_1e0],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_1e0,2*_1e0,2*_1e0],magenta:[1,0,1],orange:[1,0.5,0],purple:[0.5,0,0.5],red:[1,0,0],transparent:[0,0,0,0],white:[1,1,1],yellow:[1,1,0]};
1464 var _1e2=function(name,r,g,b,a){
1465 var rval=this.fromRGB(r,g,b,a);
1466 this[name]=function(){
1467 return rval;
1468 };
1469 return rval;
1470 };
1471 for(var k in _1e1){
1472 var name=k+"Color";
1473 var _1eb=m.concat([_1e2,this.Color,name],_1e1[k]);
1474 this.Color[name]=m.bind.apply(null,_1eb);
1475 }
1476 var _1ec=function(){
1477 for(var i=0;i<arguments.length;i++){
1478 if(!(arguments[i] instanceof Color)){
1479 return false;
1480 }
1481 }
1482 return true;
1483 };
1484 var _1ee=function(a,b){
1485 return a.compareRGB(b);
1486 };
1487 m.nameFunctions(this);
1488 m.registerComparator(this.Color.NAME,_1ec,_1ee);
1489 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
1490 }});
1491 MochiKit.Color.EXPORT=["Color"];
1492 MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
1493 MochiKit.Color.__new__();
1494 MochiKit.Base._exportSymbols(this,MochiKit.Color);
1495 MochiKit.Color.Color._namedColors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};
1496 if(typeof (dojo)!="undefined"){
1497 dojo.provide("MochiKit.DOM");
1498 dojo.require("MochiKit.Base");
1499 }
1500 if(typeof (JSAN)!="undefined"){
1501 JSAN.use("MochiKit.Base",[]);
1502 }
1503 try{
1504 if(typeof (MochiKit.Base)=="undefined"){
1505 throw "";
1506 }
1507 }
1508 catch(e){
1509 throw "MochiKit.DOM depends on MochiKit.Base!";
1510 }
1511 if(typeof (MochiKit.DOM)=="undefined"){
1512 MochiKit.DOM={};
1513 }
1514 MochiKit.DOM.NAME="MochiKit.DOM";
1515 MochiKit.DOM.VERSION="1.4";
1516 MochiKit.DOM.__repr__=function(){
1517 return "["+this.NAME+" "+this.VERSION+"]";
1518 };
1519 MochiKit.DOM.toString=function(){
1520 return this.__repr__();
1521 };
1522 MochiKit.DOM.EXPORT=["removeEmptyTextNodes","formContents","currentWindow","currentDocument","withWindow","withDocument","registerDOMConverter","coerceToDOM","createDOM","createDOMFunc","isChildNode","getNodeAttribute","removeNodeAttribute","setNodeAttribute","updateNodeAttributes","appendChildNodes","insertSiblingNodesAfter","insertSiblingNodesBefore","replaceChildNodes","removeElement","swapDOM","BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","TD","TR","THEAD","TBODY","TFOOT","TABLE","TH","INPUT","SPAN","A","DIV","IMG","getElement","$","getElementsByTagAndClassName","addToCallStack","addLoadEvent","focusOnLoad","setElementClass","toggleElementClass","addElementClass","removeElementClass","swapElementClass","hasElementClass","escapeHTML","toHTML","emitHTML","scrapeText","isParent","getFirstParentByTagAndClassName","makeClipping","undoClipping","makePositioned","undoPositioned","getFirstElementByTagAndClassName"];
1523 MochiKit.DOM.EXPORT_OK=["domConverters"];
1524 MochiKit.DOM.DEPRECATED=[["computedStyle","MochiKit.Style.getStyle","1.4"],["elementDimensions","MochiKit.Style.getElementDimensions","1.4"],["elementPosition","MochiKit.Style.getElementPosition","1.4"],["hideElement","MochiKit.Style.hideElement","1.4"],["setElementDimensions","MochiKit.Style.setElementDimensions","1.4"],["setElementPosition","MochiKit.Style.setElementPosition","1.4"],["setDisplayForElement","MochiKit.Style.setDisplayForElement","1.4"],["setOpacity","MochiKit.Style.setOpacity","1.4"],["showElement","MochiKit.Style.showElement","1.4"],["Coordinates","MochiKit.Style.Coordinates","1.4"],["Dimensions","MochiKit.Style.Dimensions","1.4"]];
1525 MochiKit.DOM.getViewportDimensions=new Function(""+"if (!MochiKit[\"Style\"]) {"+" throw new Error(\"This function has been deprecated and depends on MochiKit.Style.\");"+"}"+"return MochiKit.Style.getViewportDimensions.apply(this, arguments);");
1526 MochiKit.Base.update(MochiKit.DOM,{currentWindow:function(){
1527 return MochiKit.DOM._window;
1528 },currentDocument:function(){
1529 return MochiKit.DOM._document;
1530 },withWindow:function(win,func){
1531 var self=MochiKit.DOM;
1532 var _1f4=self._document;
1533 var _1f5=self._window;
1534 var rval;
1535 try{
1536 self._window=win;
1537 self._document=win.document;
1538 rval=func();
1539 }
1540 catch(e){
1541 self._window=_1f5;
1542 self._document=_1f4;
1543 throw e;
1544 }
1545 self._window=_1f5;
1546 self._document=_1f4;
1547 return rval;
1548 },formContents:function(elem){
1549 var _1f8=[];
1550 var _1f9=[];
1551 var m=MochiKit.Base;
1552 var self=MochiKit.DOM;
1553 if(typeof (elem)=="undefined"||elem===null){
1554 elem=self._document.body;
1555 }else{
1556 elem=self.getElement(elem);
1557 }
1558 m.nodeWalk(elem,function(elem){
1559 var name=elem.name;
1560 if(m.isNotEmpty(name)){
1561 var _1fe=elem.tagName.toUpperCase();
1562 if(_1fe==="INPUT"&&(elem.type=="radio"||elem.type=="checkbox")&&!elem.checked){
1563 return null;
1564 }
1565 if(_1fe==="SELECT"){
1566 if(elem.type=="select-one"){
1567 if(elem.selectedIndex>=0){
1568 var opt=elem.options[elem.selectedIndex];
1569 var v=opt.value;
1570 if(!v){
1571 var h=opt.outerHTML;
1572 if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
1573 v=opt.text;
1574 }
1575 }
1576 _1f8.push(name);
1577 _1f9.push(v);
1578 return null;
1579 }
1580 _1f8.push(name);
1581 _1f9.push("");
1582 return null;
1583 }else{
1584 var opts=elem.options;
1585 if(!opts.length){
1586 _1f8.push(name);
1587 _1f9.push("");
1588 return null;
1589 }
1590 for(var i=0;i<opts.length;i++){
1591 var opt=opts[i];
1592 if(!opt.selected){
1593 continue;
1594 }
1595 var v=opt.value;
1596 if(!v){
1597 var h=opt.outerHTML;
1598 if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
1599 v=opt.text;
1600 }
1601 }
1602 _1f8.push(name);
1603 _1f9.push(v);
1604 }
1605 return null;
1606 }
1607 }
1608 if(_1fe==="FORM"||_1fe==="P"||_1fe==="SPAN"||_1fe==="DIV"){
1609 return elem.childNodes;
1610 }
1611 _1f8.push(name);
1612 _1f9.push(elem.value||"");
1613 return null;
1614 }
1615 return elem.childNodes;
1616 });
1617 return [_1f8,_1f9];
1618 },withDocument:function(doc,func){
1619 var self=MochiKit.DOM;
1620 var _207=self._document;
1621 var rval;
1622 try{
1623 self._document=doc;
1624 rval=func();
1625 }
1626 catch(e){
1627 self._document=_207;
1628 throw e;
1629 }
1630 self._document=_207;
1631 return rval;
1632 },registerDOMConverter:function(name,_20a,wrap,_20c){
1633 MochiKit.DOM.domConverters.register(name,_20a,wrap,_20c);
1634 },coerceToDOM:function(node,ctx){
1635 var m=MochiKit.Base;
1636 var im=MochiKit.Iter;
1637 var self=MochiKit.DOM;
1638 if(im){
1639 var iter=im.iter;
1640 var _213=im.repeat;
1641 var map=m.map;
1642 }
1643 var _215=self.domConverters;
1644 var _216=arguments.callee;
1645 var _217=m.NotFound;
1646 while(true){
1647 if(typeof (node)=="undefined"||node===null){
1648 return null;
1649 }
1650 if(typeof (node)=="function"&&typeof (node.length)=="number"&&!(node instanceof Function)){
1651 node=im.list(node);
1652 }
1653 if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){
1654 return node;
1655 }
1656 if(typeof (node)=="number"||typeof (node)=="boolean"){
1657 node=node.toString();
1658 }
1659 if(typeof (node)=="string"){
1660 return self._document.createTextNode(node);
1661 }
1662 if(typeof (node.__dom__)=="function"){
1663 node=node.__dom__(ctx);
1664 continue;
1665 }
1666 if(typeof (node.dom)=="function"){
1667 node=node.dom(ctx);
1668 continue;
1669 }
1670 if(typeof (node)=="function"){
1671 node=node.apply(ctx,[ctx]);
1672 continue;
1673 }
1674 if(im){
1675 var _218=null;
1676 try{
1677 _218=iter(node);
1678 }
1679 catch(e){
1680 }
1681 if(_218){
1682 return map(_216,_218,_213(ctx));
1683 }
1684 }
1685 try{
1686 node=_215.match(node,ctx);
1687 continue;
1688 }
1689 catch(e){
1690 if(e!=_217){
1691 throw e;
1692 }
1693 }
1694 return self._document.createTextNode(node.toString());
1695 }
1696 return undefined;
1697 },isChildNode:function(node,_21a){
1698 var self=MochiKit.DOM;
1699 if(typeof (node)=="string"){
1700 node=self.getElement(node);
1701 }
1702 if(typeof (_21a)=="string"){
1703 _21a=self.getElement(_21a);
1704 }
1705 if(node===_21a){
1706 return true;
1707 }
1708 while(node&&node.tagName.toUpperCase()!="BODY"){
1709 node=node.parentNode;
1710 if(node===_21a){
1711 return true;
1712 }
1713 }
1714 return false;
1715 },setNodeAttribute:function(node,attr,_21e){
1716 var o={};
1717 o[attr]=_21e;
1718 try{
1719 return MochiKit.DOM.updateNodeAttributes(node,o);
1720 }
1721 catch(e){
1722 }
1723 return null;
1724 },getNodeAttribute:function(node,attr){
1725 var self=MochiKit.DOM;
1726 var _223=self.attributeArray.renames[attr];
1727 node=self.getElement(node);
1728 try{
1729 if(_223){
1730 return node[_223];
1731 }
1732 return node.getAttribute(attr);
1733 }
1734 catch(e){
1735 }
1736 return null;
1737 },removeNodeAttribute:function(node,attr){
1738 var self=MochiKit.DOM;
1739 var _227=self.attributeArray.renames[attr];
1740 node=self.getElement(node);
1741 try{
1742 if(_227){
1743 return node[_227];
1744 }
1745 return node.removeAttribute(attr);
1746 }
1747 catch(e){
1748 }
1749 return null;
1750 },updateNodeAttributes:function(node,_229){
1751 var elem=node;
1752 var self=MochiKit.DOM;
1753 if(typeof (node)=="string"){
1754 elem=self.getElement(node);
1755 }
1756 if(_229){
1757 var _22c=MochiKit.Base.updatetree;
1758 if(self.attributeArray.compliant){
1759 for(var k in _229){
1760 var v=_229[k];
1761 if(typeof (v)=="object"&&typeof (elem[k])=="object"){
1762 if(k=="style"&&MochiKit.Style){
1763 MochiKit.Style.setStyle(elem,v);
1764 }else{
1765 _22c(elem[k],v);
1766 }
1767 }else{
1768 if(k.substring(0,2)=="on"){
1769 if(typeof (v)=="string"){
1770 v=new Function(v);
1771 }
1772 elem[k]=v;
1773 }else{
1774 elem.setAttribute(k,v);
1775 }
1776 }
1777 }
1778 }else{
1779 var _22f=self.attributeArray.renames;
1780 for(var k in _229){
1781 v=_229[k];
1782 var _230=_22f[k];
1783 if(k=="style"&&typeof (v)=="string"){
1784 elem.style.cssText=v;
1785 }else{
1786 if(typeof (_230)=="string"){
1787 elem[_230]=v;
1788 }else{
1789 if(typeof (elem[k])=="object"&&typeof (v)=="object"){
1790 if(k=="style"&&MochiKit.Style){
1791 MochiKit.Style.setStyle(elem,v);
1792 }else{
1793 _22c(elem[k],v);
1794 }
1795 }else{
1796 if(k.substring(0,2)=="on"){
1797 if(typeof (v)=="string"){
1798 v=new Function(v);
1799 }
1800 elem[k]=v;
1801 }else{
1802 elem.setAttribute(k,v);
1803 }
1804 }
1805 }
1806 }
1807 }
1808 }
1809 }
1810 return elem;
1811 },appendChildNodes:function(node){
1812 var elem=node;
1813 var self=MochiKit.DOM;
1814 if(typeof (node)=="string"){
1815 elem=self.getElement(node);
1816 }
1817 var _234=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
1818 var _235=MochiKit.Base.concat;
1819 while(_234.length){
1820 var n=_234.shift();
1821 if(typeof (n)=="undefined"||n===null){
1822 }else{
1823 if(typeof (n.nodeType)=="number"){
1824 elem.appendChild(n);
1825 }else{
1826 _234=_235(n,_234);
1827 }
1828 }
1829 }
1830 return elem;
1831 },insertSiblingNodesBefore:function(node){
1832 var elem=node;
1833 var self=MochiKit.DOM;
1834 if(typeof (node)=="string"){
1835 elem=self.getElement(node);
1836 }
1837 var _23a=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
1838 var _23b=elem.parentNode;
1839 var _23c=MochiKit.Base.concat;
1840 while(_23a.length){
1841 var n=_23a.shift();
1842 if(typeof (n)=="undefined"||n===null){
1843 }else{
1844 if(typeof (n.nodeType)=="number"){
1845 _23b.insertBefore(n,elem);
1846 }else{
1847 _23a=_23c(n,_23a);
1848 }
1849 }
1850 }
1851 return _23b;
1852 },insertSiblingNodesAfter:function(node){
1853 var elem=node;
1854 var self=MochiKit.DOM;
1855 if(typeof (node)=="string"){
1856 elem=self.getElement(node);
1857 }
1858 var _241=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
1859 if(elem.nextSibling){
1860 return self.insertSiblingNodesBefore(elem.nextSibling,_241);
1861 }else{
1862 return self.appendChildNodes(elem.parentNode,_241);
1863 }
1864 },replaceChildNodes:function(node){
1865 var elem=node;
1866 var self=MochiKit.DOM;
1867 if(typeof (node)=="string"){
1868 elem=self.getElement(node);
1869 arguments[0]=elem;
1870 }
1871 var _245;
1872 while((_245=elem.firstChild)){
1873 elem.removeChild(_245);
1874 }
1875 if(arguments.length<2){
1876 return elem;
1877 }else{
1878 return self.appendChildNodes.apply(this,arguments);
1879 }
1880 },createDOM:function(name,_247){
1881 var elem;
1882 var self=MochiKit.DOM;
1883 var m=MochiKit.Base;
1884 if(typeof (_247)=="string"||typeof (_247)=="number"){
1885 var args=m.extend([name,null],arguments,1);
1886 return arguments.callee.apply(this,args);
1887 }
1888 if(typeof (name)=="string"){
1889 var _24c=self._xhtml;
1890 if(_247&&!self.attributeArray.compliant){
1891 var _24d="";
1892 if("name" in _247){
1893 _24d+=" name=\""+self.escapeHTML(_247.name)+"\"";
1894 }
1895 if(name=="input"&&"type" in _247){
1896 _24d+=" type=\""+self.escapeHTML(_247.type)+"\"";
1897 }
1898 if(_24d){
1899 name="<"+name+_24d+">";
1900 _24c=false;
1901 }
1902 }
1903 var d=self._document;
1904 if(_24c&&d===document){
1905 elem=d.createElementNS("http://www.w3.org/1999/xhtml",name);
1906 }else{
1907 elem=d.createElement(name);
1908 }
1909 }else{
1910 elem=name;
1911 }
1912 if(_247){
1913 self.updateNodeAttributes(elem,_247);
1914 }
1915 if(arguments.length<=2){
1916 return elem;
1917 }else{
1918 var args=m.extend([elem],arguments,2);
1919 return self.appendChildNodes.apply(this,args);
1920 }
1921 },createDOMFunc:function(){
1922 var m=MochiKit.Base;
1923 return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments));
1924 },removeElement:function(elem){
1925 var e=MochiKit.DOM.getElement(elem);
1926 e.parentNode.removeChild(e);
1927 return e;
1928 },swapDOM:function(dest,src){
1929 var self=MochiKit.DOM;
1930 dest=self.getElement(dest);
1931 var _255=dest.parentNode;
1932 if(src){
1933 src=self.getElement(src);
1934 _255.replaceChild(src,dest);
1935 }else{
1936 _255.removeChild(dest);
1937 }
1938 return src;
1939 },getElement:function(id){
1940 var self=MochiKit.DOM;
1941 if(arguments.length==1){
1942 return ((typeof (id)=="string")?self._document.getElementById(id):id);
1943 }else{
1944 return MochiKit.Base.map(self.getElement,arguments);
1945 }
1946 },getElementsByTagAndClassName:function(_258,_259,_25a){
1947 var self=MochiKit.DOM;
1948 if(typeof (_258)=="undefined"||_258===null){
1949 _258="*";
1950 }
1951 if(typeof (_25a)=="undefined"||_25a===null){
1952 _25a=self._document;
1953 }
1954 _25a=self.getElement(_25a);
1955 var _25c=(_25a.getElementsByTagName(_258)||self._document.all);
1956 if(typeof (_259)=="undefined"||_259===null){
1957 return MochiKit.Base.extend(null,_25c);
1958 }
1959 var _25d=[];
1960 for(var i=0;i<_25c.length;i++){
1961 var _25f=_25c[i];
1962 var cls=_25f.className;
1963 if(!cls){
1964 continue;
1965 }
1966 var _261=cls.split(" ");
1967 for(var j=0;j<_261.length;j++){
1968 if(_261[j]==_259){
1969 _25d.push(_25f);
1970 break;
1971 }
1972 }
1973 }
1974 return _25d;
1975 },_newCallStack:function(path,once){
1976 var rval=function(){
1977 var _266=arguments.callee.callStack;
1978 for(var i=0;i<_266.length;i++){
1979 if(_266[i].apply(this,arguments)===false){
1980 break;
1981 }
1982 }
1983 if(once){
1984 try{
1985 this[path]=null;
1986 }
1987 catch(e){
1988 }
1989 }
1990 };
1991 rval.callStack=[];
1992 return rval;
1993 },addToCallStack:function(_268,path,func,once){
1994 var self=MochiKit.DOM;
1995 var _26d=_268[path];
1996 var _26e=_26d;
1997 if(!(typeof (_26d)=="function"&&typeof (_26d.callStack)=="object"&&_26d.callStack!==null)){
1998 _26e=self._newCallStack(path,once);
1999 if(typeof (_26d)=="function"){
2000 _26e.callStack.push(_26d);
2001 }
2002 _268[path]=_26e;
2003 }
2004 _26e.callStack.push(func);
2005 },addLoadEvent:function(func){
2006 var self=MochiKit.DOM;
2007 self.addToCallStack(self._window,"onload",func,true);
2008 },focusOnLoad:function(_271){
2009 var self=MochiKit.DOM;
2010 self.addLoadEvent(function(){
2011 _271=self.getElement(_271);
2012 if(_271){
2013 _271.focus();
2014 }
2015 });
2016 },setElementClass:function(_273,_274){
2017 var self=MochiKit.DOM;
2018 var obj=self.getElement(_273);
2019 if(self.attributeArray.compliant){
2020 obj.setAttribute("class",_274);
2021 }else{
2022 obj.setAttribute("className",_274);
2023 }
2024 },toggleElementClass:function(_277){
2025 var self=MochiKit.DOM;
2026 for(var i=1;i<arguments.length;i++){
2027 var obj=self.getElement(arguments[i]);
2028 if(!self.addElementClass(obj,_277)){
2029 self.removeElementClass(obj,_277);
2030 }
2031 }
2032 },addElementClass:function(_27b,_27c){
2033 var self=MochiKit.DOM;
2034 var obj=self.getElement(_27b);
2035 var cls=obj.className;
2036 if(cls==undefined||cls.length===0){
2037 self.setElementClass(obj,_27c);
2038 return true;
2039 }
2040 if(cls==_27c){
2041 return false;
2042 }
2043 var _280=cls.split(" ");
2044 for(var i=0;i<_280.length;i++){
2045 if(_280[i]==_27c){
2046 return false;
2047 }
2048 }
2049 self.setElementClass(obj,cls+" "+_27c);
2050 return true;
2051 },removeElementClass:function(_282,_283){
2052 var self=MochiKit.DOM;
2053 var obj=self.getElement(_282);
2054 var cls=obj.className;
2055 if(cls==undefined||cls.length===0){
2056 return false;
2057 }
2058 if(cls==_283){
2059 self.setElementClass(obj,"");
2060 return true;
2061 }
2062 var _287=cls.split(" ");
2063 for(var i=0;i<_287.length;i++){
2064 if(_287[i]==_283){
2065 _287.splice(i,1);
2066 self.setElementClass(obj,_287.join(" "));
2067 return true;
2068 }
2069 }
2070 return false;
2071 },swapElementClass:function(_289,_28a,_28b){
2072 var obj=MochiKit.DOM.getElement(_289);
2073 var res=MochiKit.DOM.removeElementClass(obj,_28a);
2074 if(res){
2075 MochiKit.DOM.addElementClass(obj,_28b);
2076 }
2077 return res;
2078 },hasElementClass:function(_28e,_28f){
2079 var obj=MochiKit.DOM.getElement(_28e);
2080 var cls=obj.className;
2081 if(!cls){
2082 return false;
2083 }
2084 var _292=cls.split(" ");
2085 for(var i=1;i<arguments.length;i++){
2086 var good=false;
2087 for(var j=0;j<_292.length;j++){
2088 if(_292[j]==arguments[i]){
2089 good=true;
2090 break;
2091 }
2092 }
2093 if(!good){
2094 return false;
2095 }
2096 }
2097 return true;
2098 },escapeHTML:function(s){
2099 return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
2100 },toHTML:function(dom){
2101 return MochiKit.DOM.emitHTML(dom).join("");
2102 },emitHTML:function(dom,lst){
2103 if(typeof (lst)=="undefined"||lst===null){
2104 lst=[];
2105 }
2106 var _29a=[dom];
2107 var self=MochiKit.DOM;
2108 var _29c=self.escapeHTML;
2109 var _29d=self.attributeArray;
2110 while(_29a.length){
2111 dom=_29a.pop();
2112 if(typeof (dom)=="string"){
2113 lst.push(dom);
2114 }else{
2115 if(dom.nodeType==1){
2116 lst.push("<"+dom.tagName.toLowerCase());
2117 var _29e=[];
2118 var _29f=_29d(dom);
2119 for(var i=0;i<_29f.length;i++){
2120 var a=_29f[i];
2121 _29e.push([" ",a.name,"=\"",_29c(a.value),"\""]);
2122 }
2123 _29e.sort();
2124 for(i=0;i<_29e.length;i++){
2125 var _2a2=_29e[i];
2126 for(var j=0;j<_2a2.length;j++){
2127 lst.push(_2a2[j]);
2128 }
2129 }
2130 if(dom.hasChildNodes()){
2131 lst.push(">");
2132 _29a.push("</"+dom.tagName.toLowerCase()+">");
2133 var _2a4=dom.childNodes;
2134 for(i=_2a4.length-1;i>=0;i--){
2135 _29a.push(_2a4[i]);
2136 }
2137 }else{
2138 lst.push("/>");
2139 }
2140 }else{
2141 if(dom.nodeType==3){
2142 lst.push(_29c(dom.nodeValue));
2143 }
2144 }
2145 }
2146 }
2147 return lst;
2148 },scrapeText:function(node,_2a6){
2149 var rval=[];
2150 (function(node){
2151 var cn=node.childNodes;
2152 if(cn){
2153 for(var i=0;i<cn.length;i++){
2154 arguments.callee.call(this,cn[i]);
2155 }
2156 }
2157 var _2ab=node.nodeValue;
2158 if(typeof (_2ab)=="string"){
2159 rval.push(_2ab);
2160 }
2161 })(MochiKit.DOM.getElement(node));
2162 if(_2a6){
2163 return rval;
2164 }else{
2165 return rval.join("");
2166 }
2167 },removeEmptyTextNodes:function(_2ac){
2168 _2ac=MochiKit.DOM.getElement(_2ac);
2169 for(var i=0;i<_2ac.childNodes.length;i++){
2170 var node=_2ac.childNodes[i];
2171 if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
2172 node.parentNode.removeChild(node);
2173 }
2174 }
2175 },makeClipping:function(_2af){
2176 _2af=MochiKit.DOM.getElement(_2af);
2177 var _2b0=_2af.style.overflow;
2178 if((MochiKit.Style.getStyle(_2af,"overflow")||"visible")!="hidden"){
2179 _2af.style.overflow="hidden";
2180 }
2181 return _2b0;
2182 },undoClipping:function(_2b1,_2b2){
2183 _2b1=MochiKit.DOM.getElement(_2b1);
2184 if(!_2b2){
2185 return;
2186 }
2187 _2b1.style.overflow=_2b2;
2188 },makePositioned:function(_2b3){
2189 _2b3=MochiKit.DOM.getElement(_2b3);
2190 var pos=MochiKit.Style.getStyle(_2b3,"position");
2191 if(pos=="static"||!pos){
2192 _2b3.style.position="relative";
2193 if(/Opera/.test(navigator.userAgent)){
2194 _2b3.style.top=0;
2195 _2b3.style.left=0;
2196 }
2197 }
2198 },undoPositioned:function(_2b5){
2199 _2b5=MochiKit.DOM.getElement(_2b5);
2200 if(_2b5.style.position=="relative"){
2201 _2b5.style.position=_2b5.style.top=_2b5.style.left=_2b5.style.bottom=_2b5.style.right="";
2202 }
2203 },getFirstElementByTagAndClassName:function(_2b6,_2b7,_2b8){
2204 var self=MochiKit.DOM;
2205 if(typeof (_2b6)=="undefined"||_2b6===null){
2206 _2b6="*";
2207 }
2208 if(typeof (_2b8)=="undefined"||_2b8===null){
2209 _2b8=self._document;
2210 }
2211 _2b8=self.getElement(_2b8);
2212 var _2ba=(_2b8.getElementsByTagName(_2b6)||self._document.all);
2213 if(typeof (_2b7)=="undefined"||_2b7===null){
2214 return _2ba[0];
2215 }
2216 for(var i=0;i<_2ba.length;i++){
2217 var _2bc=_2ba[i];
2218 var _2bd=_2bc.className.split(" ");
2219 for(var j=0;j<_2bd.length;j++){
2220 if(_2bd[j]==_2b7){
2221 return _2bc;
2222 }
2223 }
2224 }
2225 },getFirstParentByTagAndClassName:function(elem,_2c0,_2c1){
2226 var self=MochiKit.DOM;
2227 elem=self.getElement(elem);
2228 if(typeof (_2c0)=="undefined"||_2c0===null){
2229 _2c0="*";
2230 }else{
2231 _2c0=_2c0.toUpperCase();
2232 }
2233 if(typeof (_2c1)=="undefined"||_2c1===null){
2234 _2c1=null;
2235 }
2236 var _2c3="";
2237 var _2c4="";
2238 while(elem&&elem.tagName){
2239 elem=elem.parentNode;
2240 if(_2c0=="*"&&_2c1===null){
2241 return elem;
2242 }
2243 _2c3=elem.className.split(" ");
2244 _2c4=elem.tagName.toUpperCase();
2245 if(_2c1===null&&_2c0==_2c4){
2246 return elem;
2247 }else{
2248 if(_2c1!==null){
2249 for(var i=0;i<_2c3.length;i++){
2250 if(_2c0=="*"&&_2c3[i]==_2c1){
2251 return elem;
2252 }else{
2253 if(_2c0==_2c4&&_2c3[i]==_2c1){
2254 return elem;
2255 }
2256 }
2257 }
2258 }
2259 }
2260 }
2261 return elem;
2262 },isParent:function(_2c6,_2c7){
2263 if(!_2c6.parentNode||_2c6==_2c7){
2264 return false;
2265 }
2266 if(_2c6.parentNode==_2c7){
2267 return true;
2268 }
2269 return MochiKit.DOM.isParent(_2c6.parentNode,_2c7);
2270 },__new__:function(win){
2271 var m=MochiKit.Base;
2272 if(typeof (document)!="undefined"){
2273 this._document=document;
2274 var _2ca="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
2275 this._xhtml=(document.documentElement&&document.createElementNS&&document.documentElement.namespaceURI===_2ca);
2276 }else{
2277 if(MochiKit.MockDOM){
2278 this._document=MochiKit.MockDOM.document;
2279 }
2280 }
2281 this._window=win;
2282 this.domConverters=new m.AdapterRegistry();
2283 var _2cb=this._document.createElement("span");
2284 var _2cc;
2285 if(_2cb&&_2cb.attributes&&_2cb.attributes.length>0){
2286 var _2cd=m.filter;
2287 _2cc=function(node){
2288 return _2cd(_2cc.ignoreAttrFilter,node.attributes);
2289 };
2290 _2cc.ignoreAttr={};
2291 var _2cf=_2cb.attributes;
2292 var _2d0=_2cc.ignoreAttr;
2293 for(var i=0;i<_2cf.length;i++){
2294 var a=_2cf[i];
2295 _2d0[a.name]=a.value;
2296 }
2297 _2cc.ignoreAttrFilter=function(a){
2298 return (_2cc.ignoreAttr[a.name]!=a.value);
2299 };
2300 _2cc.compliant=false;
2301 _2cc.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
2302 }else{
2303 _2cc=function(node){
2304 return node.attributes;
2305 };
2306 _2cc.compliant=true;
2307 _2cc.renames={};
2308 }
2309 this.attributeArray=_2cc;
2310 var _2d5=function(_2d6,arr){
2311 var _2d8=arr[1].split(".");
2312 var str="";
2313 var obj={};
2314 str+="if (!MochiKit."+_2d8[1]+") { throw new Error(\"";
2315 str+="This function has been deprecated and depends on MochiKit.";
2316 str+=_2d8[1]+".\");}";
2317 str+="return MochiKit."+_2d8[1]+"."+arr[0];
2318 str+=".apply(this, arguments);";
2319 obj[_2d8[2]]=new Function(str);
2320 MochiKit.Base.update(MochiKit[_2d6],obj);
2321 };
2322 for(var i;i<MochiKit.DOM.DEPRECATED.length;i++){
2323 _2d5("DOM",MochiKit.DOM.DEPRECATED[i]);
2324 }
2325 var _2db=this.createDOMFunc;
2326 this.UL=_2db("ul");
2327 this.OL=_2db("ol");
2328 this.LI=_2db("li");
2329 this.TD=_2db("td");
2330 this.TR=_2db("tr");
2331 this.TBODY=_2db("tbody");
2332 this.THEAD=_2db("thead");
2333 this.TFOOT=_2db("tfoot");
2334 this.TABLE=_2db("table");
2335 this.TH=_2db("th");
2336 this.INPUT=_2db("input");
2337 this.SPAN=_2db("span");
2338 this.A=_2db("a");
2339 this.DIV=_2db("div");
2340 this.IMG=_2db("img");
2341 this.BUTTON=_2db("button");
2342 this.TT=_2db("tt");
2343 this.PRE=_2db("pre");
2344 this.H1=_2db("h1");
2345 this.H2=_2db("h2");
2346 this.H3=_2db("h3");
2347 this.BR=_2db("br");
2348 this.HR=_2db("hr");
2349 this.LABEL=_2db("label");
2350 this.TEXTAREA=_2db("textarea");
2351 this.FORM=_2db("form");
2352 this.P=_2db("p");
2353 this.SELECT=_2db("select");
2354 this.OPTION=_2db("option");
2355 this.OPTGROUP=_2db("optgroup");
2356 this.LEGEND=_2db("legend");
2357 this.FIELDSET=_2db("fieldset");
2358 this.STRONG=_2db("strong");
2359 this.CANVAS=_2db("canvas");
2360 this.$=this.getElement;
2361 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
2362 m.nameFunctions(this);
2363 }});
2364 MochiKit.DOM.__new__(((typeof (window)=="undefined")?this:window));
2365 if(MochiKit.__export__){
2366 withWindow=MochiKit.DOM.withWindow;
2367 withDocument=MochiKit.DOM.withDocument;
2368 }
2369 MochiKit.Base._exportSymbols(this,MochiKit.DOM);
2370 if(typeof (dojo)!="undefined"){
2371 dojo.provide("MochiKit.Style");
2372 dojo.require("MochiKit.Base");
2373 dojo.require("MochiKit.DOM");
2374 }
2375 if(typeof (JSAN)!="undefined"){
2376 JSAN.use("MochiKit.Base",[]);
2377 JSAN.use("MochiKit.DOM",[]);
2378 }
2379 try{
2380 if(typeof (MochiKit.Base)=="undefined"){
2381 throw "";
2382 }
2383 }
2384 catch(e){
2385 throw "MochiKit.Style depends on MochiKit.Base!";
2386 }
2387 try{
2388 if(typeof (MochiKit.DOM)=="undefined"){
2389 throw "";
2390 }
2391 }
2392 catch(e){
2393 throw "MochiKit.Style depends on MochiKit.DOM!";
2394 }
2395 if(typeof (MochiKit.Style)=="undefined"){
2396 MochiKit.Style={};
2397 }
2398 MochiKit.Style.NAME="MochiKit.Style";
2399 MochiKit.Style.VERSION="1.4";
2400 MochiKit.Style.__repr__=function(){
2401 return "["+this.NAME+" "+this.VERSION+"]";
2402 };
2403 MochiKit.Style.toString=function(){
2404 return this.__repr__();
2405 };
2406 MochiKit.Style.EXPORT_OK=[];
2407 MochiKit.Style.EXPORT=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
2408 MochiKit.Style.Dimensions=function(w,h){
2409 this.w=w;
2410 this.h=h;
2411 };
2412 MochiKit.Style.Dimensions.prototype.__repr__=function(){
2413 var repr=MochiKit.Base.repr;
2414 return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}";
2415 };
2416 MochiKit.Style.Dimensions.prototype.toString=function(){
2417 return this.__repr__();
2418 };
2419 MochiKit.Style.Coordinates=function(x,y){
2420 this.x=x;
2421 this.y=y;
2422 };
2423 MochiKit.Style.Coordinates.prototype.__repr__=function(){
2424 var repr=MochiKit.Base.repr;
2425 return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}";
2426 };
2427 MochiKit.Style.Coordinates.prototype.toString=function(){
2428 return this.__repr__();
2429 };
2430 MochiKit.Base.update(MochiKit.Style,{getStyle:function(elem,_2e3){
2431 var dom=MochiKit.DOM;
2432 var d=dom._document;
2433 elem=dom.getElement(elem);
2434 _2e3=MochiKit.Base.camelize(_2e3);
2435 if(!elem||elem==d){
2436 return undefined;
2437 }
2438 if(_2e3=="opacity"&&elem.filters){
2439 var _2e6=(MochiKit.Style.getStyle(elem,"filter")||"").match(/alpha\(opacity=(.*)\)/);
2440 if(_2e6&&_2e6[1]){
2441 return parseFloat(_2e6[1])/100;
2442 }
2443 return 1;
2444 }
2445 var _2e7=elem.style?elem.style[_2e3]:null;
2446 if(!_2e7){
2447 if(d.defaultView&&d.defaultView.getComputedStyle){
2448 var css=d.defaultView.getComputedStyle(elem,null);
2449 _2e3=_2e3.replace(/([A-Z])/g,"-$1").toLowerCase();
2450 _2e7=css?css.getPropertyValue(_2e3):null;
2451 }else{
2452 if(elem.currentStyle){
2453 _2e7=elem.currentStyle[_2e3];
2454 }
2455 }
2456 }
2457 if(_2e3=="opacity"){
2458 _2e7=parseFloat(_2e7);
2459 }
2460 if(/Opera/.test(navigator.userAgent)&&(MochiKit.Base.find(["left","top","right","bottom"],_2e3)!=-1)){
2461 if(MochiKit.Style.getStyle(elem,"position")=="static"){
2462 _2e7="auto";
2463 }
2464 }
2465 return _2e7=="auto"?null:_2e7;
2466 },setStyle:function(elem,_2ea){
2467 elem=MochiKit.DOM.getElement(elem);
2468 for(var name in _2ea){
2469 if(name=="opacity"){
2470 MochiKit.Style.setOpacity(elem,_2ea[name]);
2471 }else{
2472 elem.style[MochiKit.Base.camelize(name)]=_2ea[name];
2473 }
2474 }
2475 },setOpacity:function(elem,o){
2476 elem=MochiKit.DOM.getElement(elem);
2477 var self=MochiKit.Style;
2478 if(o==1){
2479 var _2ef=/Gecko/.test(navigator.userAgent)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent));
2480 elem.style["opacity"]=_2ef?0.999999:1;
2481 if(/MSIE/.test(navigator.userAgent)){
2482 elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"");
2483 }
2484 }else{
2485 if(o<0.00001){
2486 o=0;
2487 }
2488 elem.style["opacity"]=o;
2489 if(/MSIE/.test(navigator.userAgent)){
2490 elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o*100+")";
2491 }
2492 }
2493 },getElementPosition:function(elem,_2f1){
2494 var self=MochiKit.Style;
2495 var dom=MochiKit.DOM;
2496 elem=dom.getElement(elem);
2497 if(!elem||(!(elem.x&&elem.y)&&(!elem.parentNode===null||self.getStyle(elem,"display")=="none"))){
2498 return undefined;
2499 }
2500 var c=new self.Coordinates(0,0);
2501 var box=null;
2502 var _2f6=null;
2503 var d=MochiKit.DOM._document;
2504 var de=d.documentElement;
2505 var b=d.body;
2506 if(!elem.parentNode&&elem.x&&elem.y){
2507 c.x+=elem.x||0;
2508 c.y+=elem.y||0;
2509 }else{
2510 if(elem.getBoundingClientRect){
2511 box=elem.getBoundingClientRect();
2512 c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
2513 c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
2514 }else{
2515 if(elem.offsetParent){
2516 c.x+=elem.offsetLeft;
2517 c.y+=elem.offsetTop;
2518 _2f6=elem.offsetParent;
2519 if(_2f6!=elem){
2520 while(_2f6){
2521 c.x+=_2f6.offsetLeft;
2522 c.y+=_2f6.offsetTop;
2523 _2f6=_2f6.offsetParent;
2524 }
2525 }
2526 var ua=navigator.userAgent.toLowerCase();
2527 if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("AppleWebKit")!=-1&&self.getStyle(elem,"position")=="absolute")){
2528 c.x-=b.offsetLeft;
2529 c.y-=b.offsetTop;
2530 }
2531 }
2532 }
2533 }
2534 if(typeof (_2f1)!="undefined"){
2535 _2f1=arguments.callee(_2f1);
2536 if(_2f1){
2537 c.x-=(_2f1.x||0);
2538 c.y-=(_2f1.y||0);
2539 }
2540 }
2541 if(elem.parentNode){
2542 _2f6=elem.parentNode;
2543 }else{
2544 _2f6=null;
2545 }
2546 while(_2f6){
2547 var _2fb=_2f6.tagName.toUpperCase();
2548 if(_2fb==="BODY"||_2fb==="HTML"){
2549 break;
2550 }
2551 var disp=self.getStyle(_2f6,"display");
2552 if(disp!="inline"&&disp!="table-row"){
2553 c.x-=_2f6.scrollLeft;
2554 c.y-=_2f6.scrollTop;
2555 }
2556 if(_2f6.parentNode){
2557 _2f6=_2f6.parentNode;
2558 }else{
2559 _2f6=null;
2560 }
2561 }
2562 return c;
2563 },setElementPosition:function(elem,_2fe,_2ff){
2564 elem=MochiKit.DOM.getElement(elem);
2565 if(typeof (_2ff)=="undefined"){
2566 _2ff="px";
2567 }
2568 var _300={};
2569 var _301=MochiKit.Base.isUndefinedOrNull;
2570 if(!_301(_2fe.x)){
2571 _300["left"]=_2fe.x+_2ff;
2572 }
2573 if(!_301(_2fe.y)){
2574 _300["top"]=_2fe.y+_2ff;
2575 }
2576 MochiKit.DOM.updateNodeAttributes(elem,{"style":_300});
2577 },getElementDimensions:function(elem){
2578 var self=MochiKit.Style;
2579 var dom=MochiKit.DOM;
2580 if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){
2581 return new self.Dimensions(elem.w||0,elem.h||0);
2582 }
2583 elem=dom.getElement(elem);
2584 if(!elem){
2585 return undefined;
2586 }
2587 var disp=self.getStyle(elem,"display");
2588 if(disp!="none"&&disp!==""&&typeof (disp)!="undefined"){
2589 return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0);
2590 }
2591 var s=elem.style;
2592 var _307=s.visibility;
2593 var _308=s.position;
2594 s.visibility="hidden";
2595 s.position="absolute";
2596 s.display="";
2597 var _309=elem.offsetWidth;
2598 var _30a=elem.offsetHeight;
2599 s.display="none";
2600 s.position=_308;
2601 s.visibility=_307;
2602 return new self.Dimensions(_309,_30a);
2603 },setElementDimensions:function(elem,_30c,_30d){
2604 elem=MochiKit.DOM.getElement(elem);
2605 if(typeof (_30d)=="undefined"){
2606 _30d="px";
2607 }
2608 var _30e={};
2609 var _30f=MochiKit.Base.isUndefinedOrNull;
2610 if(!_30f(_30c.w)){
2611 _30e["width"]=_30c.w+_30d;
2612 }
2613 if(!_30f(_30c.h)){
2614 _30e["height"]=_30c.h+_30d;
2615 }
2616 MochiKit.DOM.updateNodeAttributes(elem,{"style":_30e});
2617 },setDisplayForElement:function(_310,_311){
2618 var _312=MochiKit.Base.extend(null,arguments,1);
2619 var _313=MochiKit.DOM.getElement;
2620 for(var i=0;i<_312.length;i++){
2621 _311=_313(_312[i]);
2622 if(_311){
2623 _311.style.display=_310;
2624 }
2625 }
2626 },getViewportDimensions:function(){
2627 var d=new MochiKit.Style.Dimensions();
2628 var w=MochiKit.DOM._window;
2629 var b=MochiKit.DOM._document.body;
2630 if(w.innerWidth){
2631 d.w=w.innerWidth;
2632 d.h=w.innerHeight;
2633 }else{
2634 if(b.parentElement.clientWidth){
2635 d.w=b.parentElement.clientWidth;
2636 d.h=b.parentElement.clientHeight;
2637 }else{
2638 if(b&&b.clientWidth){
2639 d.w=b.clientWidth;
2640 d.h=b.clientHeight;
2641 }
2642 }
2643 }
2644 return d;
2645 },getViewportPosition:function(){
2646 var c=new MochiKit.Style.Coordinates(0,0);
2647 var d=MochiKit.DOM._document;
2648 var de=d.documentElement;
2649 var db=d.body;
2650 if(de&&(de.scrollTop||de.scrollLeft)){
2651 c.x=de.scrollLeft;
2652 c.y=de.scrollTop;
2653 }else{
2654 if(db){
2655 c.x=db.scrollLeft;
2656 c.y=db.scrollTop;
2657 }
2658 }
2659 return c;
2660 },__new__:function(){
2661 var m=MochiKit.Base;
2662 this.elementPosition=this.getElementPosition;
2663 this.elementDimensions=this.getElementDimensions;
2664 this.hideElement=m.partial(this.setDisplayForElement,"none");
2665 this.showElement=m.partial(this.setDisplayForElement,"block");
2666 this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
2667 m.nameFunctions(this);
2668 }});
2669 MochiKit.Style.__new__();
2670 MochiKit.Base._exportSymbols(this,MochiKit.Style);
2671
2672
2673 Date.ext={};Date.ext.util={};Date.ext.util.xPad=function(x,pad,r){if(typeof (r)=="undefined"){r=10}for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(d){return Date.ext.util.xPad(parseInt(Date.ext.util.G(d)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date.ext.util.xPad(doy,0,100)},m:function(d){return Date.ext.util.xPad(d.getMonth()+1,0)},M:["getMinutes","0"],p:function(d){return Date.ext.locales[d.locale].p[d.getHours()>=12?1:0]},P:function(d){return Date.ext.locales[d.locale].P[d.getHours()>=12?1:0]},S:["getSeconds","0"],u:function(d){var dow=d.getDay();return dow===0?7:dow},U:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0,10)},y:function(d){return Date.ext.util.xPad(d.getFullYear()%100,0)},Y:"getFullYear",z:function(d){var o=d.getTimezoneOffset();var H=Date.ext.util.xPad(parseInt(Math.abs(o/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a-zA-Z]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a-zA-Z]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY%])/g,function(m0,m1){var f=Date.ext.formats[m1];if(typeof (f)=="string"){return d[f]()}else{if(typeof (f)=="function"){return f.call(d,d)}else{if(typeof (f)=="object"&&typeof (f[0])=="string"){return Date.ext.util.xPad(d[f[0]](),f[1])}else{return m1}}}});d=null;return str};
2674 DygraphLayout=function(_1,_2){
2675 this.dygraph_=_1;
2676 this.options={};
2677 MochiKit.Base.update(this.options,_2?_2:{});
2678 this.datasets=new Array();
2679 };
2680 DygraphLayout.prototype.attr_=function(_3){
2681 return this.dygraph_.attr_(_3);
2682 };
2683 DygraphLayout.prototype.addDataset=function(_4,_5){
2684 this.datasets[_4]=_5;
2685 };
2686 DygraphLayout.prototype.evaluate=function(){
2687 this._evaluateLimits();
2688 this._evaluateLineCharts();
2689 this._evaluateLineTicks();
2690 };
2691 DygraphLayout.prototype._evaluateLimits=function(){
2692 this.minxval=this.maxxval=null;
2693 for(var _6 in this.datasets){
2694 var _7=this.datasets[_6];
2695 var x1=_7[0][0];
2696 if(!this.minxval||x1<this.minxval){
2697 this.minxval=x1;
2698 }
2699 var x2=_7[_7.length-1][0];
2700 if(!this.maxxval||x2>this.maxxval){
2701 this.maxxval=x2;
2702 }
2703 }
2704 this.xrange=this.maxxval-this.minxval;
2705 this.xscale=(this.xrange!=0?1/this.xrange:1);
2706 this.minyval=this.options.yAxis[0];
2707 this.maxyval=this.options.yAxis[1];
2708 this.yrange=this.maxyval-this.minyval;
2709 this.yscale=(this.yrange!=0?1/this.yrange:1);
2710 };
2711 DygraphLayout.prototype._evaluateLineCharts=function(){
2712 this.points=new Array();
2713 for(var _10 in this.datasets){
2714 var _11=this.datasets[_10];
2715 for(var j=0;j<_11.length;j++){
2716 var _13=_11[j];
2717 var _14={x:((parseFloat(_13[0])-this.minxval)*this.xscale),y:1-((parseFloat(_13[1])-this.minyval)*this.yscale),xval:parseFloat(_13[0]),yval:parseFloat(_13[1]),name:_10};
2718 if(_14.y<=0){
2719 _14.y=0;
2720 }
2721 if(_14.y>=1){
2722 _14.y=1;
2723 }
2724 if((_14.x>=0)&&(_14.x<=1)){
2725 this.points.push(_14);
2726 }
2727 }
2728 }
2729 };
2730 DygraphLayout.prototype._evaluateLineTicks=function(){
2731 this.xticks=new Array();
2732 for(var i=0;i<this.options.xTicks.length;i++){
2733 var _16=this.options.xTicks[i];
2734 var _17=_16.label;
2735 var pos=this.xscale*(_16.v-this.minxval);
2736 if((pos>=0)&&(pos<=1)){
2737 this.xticks.push([pos,_17]);
2738 }
2739 }
2740 this.yticks=new Array();
2741 for(var i=0;i<this.options.yTicks.length;i++){
2742 var _16=this.options.yTicks[i];
2743 var _17=_16.label;
2744 var pos=1-(this.yscale*(_16.v-this.minyval));
2745 if((pos>=0)&&(pos<=1)){
2746 this.yticks.push([pos,_17]);
2747 }
2748 }
2749 };
2750 DygraphLayout.prototype.evaluateWithError=function(){
2751 this.evaluate();
2752 if(!this.options.errorBars){
2753 return;
2754 }
2755 var i=0;
2756 for(var _19 in this.datasets){
2757 var j=0;
2758 var _20=this.datasets[_19];
2759 for(var j=0;j<_20.length;j++,i++){
2760 var _21=_20[j];
2761 var xv=parseFloat(_21[0]);
2762 var yv=parseFloat(_21[1]);
2763 if(xv==this.points[i].xval&&yv==this.points[i].yval){
2764 this.points[i].errorMinus=parseFloat(_21[2]);
2765 this.points[i].errorPlus=parseFloat(_21[3]);
2766 }
2767 }
2768 }
2769 };
2770 DygraphLayout.prototype.removeAllDatasets=function(){
2771 delete this.datasets;
2772 this.datasets=new Array();
2773 };
2774 DygraphLayout.prototype.updateOptions=function(_24){
2775 MochiKit.Base.update(this.options,_24?_24:{});
2776 };
2777 DygraphCanvasRenderer=function(_25,_26,_27,_28){
2778 this.dygraph_=_25;
2779 this.options={"strokeWidth":0.5,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"drawYGrid":true,"drawXGrid":true,"gridLineColor":MochiKit.Color.Color.grayColor()};
2780 MochiKit.Base.update(this.options,_28);
2781 this.layout=_27;
2782 this.element=_26;
2783 this.container=this.element.parentNode;
2784 this.isIE=(/MSIE/.test(navigator.userAgent)&&!window.opera);
2785 if(this.isIE&&!isNil(G_vmlCanvasManager)){
2786 this.IEDelay=0.5;
2787 this.maxTries=5;
2788 this.renderDelay=null;
2789 this.clearDelay=null;
2790 this.element=G_vmlCanvasManager.initElement(this.element);
2791 }
2792 this.height=this.element.height;
2793 this.width=this.element.width;
2794 if(!this.isIE&&!(DygraphCanvasRenderer.isSupported(this.element))){
2795 throw "Canvas is not supported.";
2796 }
2797 this.xlabels=new Array();
2798 this.ylabels=new Array();
2799 this.area={x:this.options.yAxisLabelWidth+2*this.options.axisTickSize,y:0};
2800 this.area.w=this.width-this.area.x-this.options.rightGap;
2801 this.area.h=this.height-this.options.axisLabelFontSize-2*this.options.axisTickSize;
2802 this.container.style.position="relative";
2803 this.container.style.width=this.width+"px";
2804 };
2805 DygraphCanvasRenderer.prototype.clear=function(){
2806 if(this.isIE){
2807 try{
2808 if(this.clearDelay){
2809 this.clearDelay.cancel();
2810 this.clearDelay=null;
2811 }
2812 var _29=this.element.getContext("2d");
2813 }
2814 catch(e){
2815 this.clearDelay=MochiKit.Async.wait(this.IEDelay);
2816 this.clearDelay.addCallback(bind(this.clear,this));
2817 return;
2818 }
2819 }
2820 var _29=this.element.getContext("2d");
2821 _29.clearRect(0,0,this.width,this.height);
2822 for(var i=0;i<this.xlabels.length;i++){
2823 var el=this.xlabels[i];
2824 el.parentNode.removeChild(el);
2825 }
2826 for(var i=0;i<this.ylabels.length;i++){
2827 var el=this.ylabels[i];
2828 el.parentNode.removeChild(el);
2829 }
2830 this.xlabels=new Array();
2831 this.ylabels=new Array();
2832 };
2833 DygraphCanvasRenderer.isSupported=function(_31){
2834 var _32=null;
2835 try{
2836 if(MochiKit.Base.isUndefinedOrNull(_31)){
2837 _32=document.createElement("canvas");
2838 }else{
2839 _32=_31;
2840 }
2841 var _33=_32.getContext("2d");
2842 }
2843 catch(e){
2844 var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
2845 var _35=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
2846 if((!ie)||(ie[1]<6)||(_35)){
2847 return false;
2848 }
2849 return true;
2850 }
2851 return true;
2852 };
2853 DygraphCanvasRenderer.prototype.render=function(){
2854 var ctx=this.element.getContext("2d");
2855 if(this.options.drawYGrid){
2856 var _37=this.layout.yticks;
2857 ctx.save();
2858 ctx.strokeStyle=this.options.gridLineColor.toRGBString();
2859 ctx.lineWidth=this.options.axisLineWidth;
2860 for(var i=0;i<_37.length;i++){
2861 var x=this.area.x;
2862 var y=this.area.y+_37[i][0]*this.area.h;
2863 ctx.beginPath();
2864 ctx.moveTo(x,y);
2865 ctx.lineTo(x+this.area.w,y);
2866 ctx.closePath();
2867 ctx.stroke();
2868 }
2869 }
2870 if(this.options.drawXGrid){
2871 var _37=this.layout.xticks;
2872 ctx.save();
2873 ctx.strokeStyle=this.options.gridLineColor.toRGBString();
2874 ctx.lineWidth=this.options.axisLineWidth;
2875 for(var i=0;i<_37.length;i++){
2876 var x=this.area.x+_37[i][0]*this.area.w;
2877 var y=this.area.y+this.area.h;
2878 ctx.beginPath();
2879 ctx.moveTo(x,y);
2880 ctx.lineTo(x,this.area.y);
2881 ctx.closePath();
2882 ctx.stroke();
2883 }
2884 }
2885 this._renderLineChart();
2886 this._renderAxis();
2887 };
2888 DygraphCanvasRenderer.prototype._renderAxis=function(){
2889 if(!this.options.drawXAxis&&!this.options.drawYAxis){
2890 return;
2891 }
2892 var _40=this.element.getContext("2d");
2893 var _41={"style":{"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
2894 _40.save();
2895 _40.strokeStyle=this.options.axisLineColor.toRGBString();
2896 _40.lineWidth=this.options.axisLineWidth;
2897 if(this.options.drawYAxis){
2898 if(this.layout.yticks){
2899 for(var i=0;i<this.layout.yticks.length;i++){
2900 var _42=this.layout.yticks[i];
2901 if(typeof (_42)=="function"){
2902 return;
2903 }
2904 var x=this.area.x;
2905 var y=this.area.y+_42[0]*this.area.h;
2906 _40.beginPath();
2907 _40.moveTo(x,y);
2908 _40.lineTo(x-this.options.axisTickSize,y);
2909 _40.closePath();
2910 _40.stroke();
2911 var _43=DIV(_41,_42[1]);
2912 var top=(y-this.options.axisLabelFontSize/2);
2913 if(top<0){
2914 top=0;
2915 }
2916 if(top+this.options.axisLabelFontSize+3>this.height){
2917 _43.style.bottom="0px";
2918 }else{
2919 _43.style.top=top+"px";
2920 }
2921 _43.style.left="0px";
2922 _43.style.textAlign="right";
2923 _43.style.width=this.options.yAxisLabelWidth+"px";
2924 this.container.appendChild(_43);
2925 this.ylabels.push(_43);
2926 }
2927 var _45=this.ylabels[0];
2928 var _46=this.options.axisLabelFontSize;
2929 var _47=parseInt(_45.style.top)+_46;
2930 if(_47>this.height-_46){
2931 _45.style.top=(parseInt(_45.style.top)-_46/2)+"px";
2932 }
2933 }
2934 _40.beginPath();
2935 _40.moveTo(this.area.x,this.area.y);
2936 _40.lineTo(this.area.x,this.area.y+this.area.h);
2937 _40.closePath();
2938 _40.stroke();
2939 }
2940 if(this.options.drawXAxis){
2941 if(this.layout.xticks){
2942 for(var i=0;i<this.layout.xticks.length;i++){
2943 var _42=this.layout.xticks[i];
2944 if(typeof (dataset)=="function"){
2945 return;
2946 }
2947 var x=this.area.x+_42[0]*this.area.w;
2948 var y=this.area.y+this.area.h;
2949 _40.beginPath();
2950 _40.moveTo(x,y);
2951 _40.lineTo(x,y+this.options.axisTickSize);
2952 _40.closePath();
2953 _40.stroke();
2954 var _43=DIV(_41,_42[1]);
2955 _43.style.textAlign="center";
2956 _43.style.bottom="0px";
2957 var _48=(x-this.options.axisLabelWidth/2);
2958 if(_48+this.options.axisLabelWidth>this.width){
2959 _48=this.width-this.options.xAxisLabelWidth;
2960 _43.style.textAlign="right";
2961 }
2962 if(_48<0){
2963 _48=0;
2964 _43.style.textAlign="left";
2965 }
2966 _43.style.left=_48+"px";
2967 _43.style.width=this.options.xAxisLabelWidth+"px";
2968 this.container.appendChild(_43);
2969 this.xlabels.push(_43);
2970 }
2971 }
2972 _40.beginPath();
2973 _40.moveTo(this.area.x,this.area.y+this.area.h);
2974 _40.lineTo(this.area.x+this.area.w,this.area.y+this.area.h);
2975 _40.closePath();
2976 _40.stroke();
2977 }
2978 _40.restore();
2979 };
2980 DygraphCanvasRenderer.prototype._renderLineChart=function(){
2981 var _49=this.element.getContext("2d");
2982 var _50=this.options.colorScheme.length;
2983 var _51=this.options.colorScheme;
2984 var _52=MochiKit.Base.keys(this.layout.datasets);
2985 var _53=this.layout.options.errorBars;
2986 var _54=_52.length;
2987 var _55=MochiKit.Base.bind;
2988 var _56=MochiKit.Base.partial;
2989 for(var i=0;i<this.layout.points.length;i++){
2990 var _57=this.layout.points[i];
2991 _57.canvasx=this.area.w*_57.x+this.area.x;
2992 _57.canvasy=this.area.h*_57.y+this.area.y;
2993 }
2994 var _58=function(x){
2995 return x&&!isNaN(x);
2996 };
2997 var _59=function(ctx){
2998 for(var i=0;i<_54;i++){
2999 var _60=_52[i];
3000 var _61=_51[i%_50];
3001 var _62=this.options.strokeColorTransform;
3002 _49.save();
3003 _49.strokeStyle=_61.toRGBString();
3004 _49.lineWidth=this.options.strokeWidth;
3005 var _57=this.layout.points[0];
3006 var _63=this.dygraph_.attr_("pointSize");
3007 var _64=null,prevY=null;
3008 var _65=this.dygraph_.attr_("drawPoints");
3009 var _66=this.layout.points;
3010 for(var j=0;j<_66.length;j++){
3011 var _57=_66[j];
3012 if(_57.name==_60){
3013 if(!_58(_57.canvasy)){
3014 _64=prevY=null;
3015 }else{
3016 var _67=(!_64&&(j==_66.length-1||!_58(_66[j+1].canvasy)));
3017 if(!_64){
3018 _64=_57.canvasx;
3019 prevY=_57.canvasy;
3020 }else{
3021 ctx.beginPath();
3022 ctx.moveTo(_64,prevY);
3023 _64=_57.canvasx;
3024 prevY=_57.canvasy;
3025 ctx.lineTo(_64,prevY);
3026 ctx.stroke();
3027 }
3028 if(_65||_67){
3029 ctx.beginPath();
3030 ctx.fillStyle=_61.toRGBString();
3031 ctx.arc(_57.canvasx,_57.canvasy,_63,0,360,false);
3032 ctx.fill();
3033 }
3034 }
3035 }
3036 }
3037 }
3038 };
3039 var _68=function(ctx){
3040 for(var i=0;i<_54;i++){
3041 var _69=_52[i];
3042 var _70=_51[i%_50];
3043 var _71=this.options.strokeColorTransform;
3044 _49.save();
3045 _49.strokeStyle=_70.toRGBString();
3046 _49.lineWidth=this.options.strokeWidth;
3047 var _72=-1;
3048 var _73=[-1,-1];
3049 var _74=0;
3050 var _75=this.layout.yscale;
3051 var _76=_70.colorWithAlpha(0.15);
3052 ctx.fillStyle=_76.toRGBString();
3053 ctx.beginPath();
3054 for(var j=0;j<this.layout.points.length;j++){
3055 var _77=this.layout.points[j];
3056 _74++;
3057 if(_77.name==_69){
3058 if(!_77.y||isNaN(_77.y)){
3059 _72=-1;
3060 return;
3061 }
3062 var _78=[_77.y-_77.errorPlus*_75,_77.y+_77.errorMinus*_75];
3063 _78[0]=this.area.h*_78[0]+this.area.y;
3064 _78[1]=this.area.h*_78[1]+this.area.y;
3065 if(_72>=0){
3066 ctx.moveTo(_72,_73[0]);
3067 ctx.lineTo(_77.canvasx,_78[0]);
3068 ctx.lineTo(_77.canvasx,_78[1]);
3069 ctx.lineTo(_72,_73[1]);
3070 ctx.closePath();
3071 }
3072 _73[0]=_78[0];
3073 _73[1]=_78[1];
3074 _72=_77.canvasx;
3075 }
3076 }
3077 ctx.fill();
3078 }
3079 };
3080 if(_53){
3081 _55(_68,this)(_49);
3082 }
3083 _55(_59,this)(_49);
3084 _49.restore();
3085 };
3086 Dygraph=function(div,_80,_81){
3087 if(arguments.length>0){
3088 if(arguments.length==4){
3089 this.warn("Using deprecated four-argument dygraph constructor");
3090 this.__old_init__(div,_80,arguments[2],arguments[3]);
3091 }else{
3092 this.__init__(div,_80,_81);
3093 }
3094 }
3095 };
3096 Dygraph.NAME="Dygraph";
3097 Dygraph.VERSION="1.2";
3098 Dygraph.__repr__=function(){
3099 return "["+this.NAME+" "+this.VERSION+"]";
3100 };
3101 Dygraph.toString=function(){
3102 return this.__repr__();
3103 };
3104 Dygraph.DEFAULT_ROLL_PERIOD=1;
3105 Dygraph.DEFAULT_WIDTH=480;
3106 Dygraph.DEFAULT_HEIGHT=320;
3107 Dygraph.AXIS_LINE_WIDTH=0.3;
3108 Dygraph.DEFAULT_ATTRS={highlightCircleSize:3,pixelsPerXLabel:60,pixelsPerYLabel:30,labelsDivWidth:250,labelsDivStyles:{},labelsSeparateLines:false,labelsKMB:false,strokeWidth:1,axisTickSize:3,axisLabelFontSize:14,xAxisLabelWidth:50,yAxisLabelWidth:50,rightGap:5,showRoller:false,xValueFormatter:Dygraph.dateString_,xValueParser:Dygraph.dateParser,xTicker:Dygraph.dateTicker,sigma:2,errorBars:false,fractions:false,wilsonInterval:true,customBars:false};
3109 Dygraph.DEBUG=1;
3110 Dygraph.INFO=2;
3111 Dygraph.WARNING=3;
3112 Dygraph.ERROR=3;
3113 Dygraph.prototype.__old_init__=function(div,_82,_83,_84){
3114 if(_83!=null){
3115 var _85=["Date"];
3116 for(var i=0;i<_83.length;i++){
3117 _85.push(_83[i]);
3118 }
3119 MochiKit.Base.update(_84,{"labels":_85});
3120 }
3121 this.__init__(div,_82,_84);
3122 };
3123 Dygraph.prototype.__init__=function(div,_86,_87){
3124 if(_87==null){
3125 _87={};
3126 }
3127 this.maindiv_=div;
3128 this.file_=_86;
3129 this.rollPeriod_=_87.rollPeriod||Dygraph.DEFAULT_ROLL_PERIOD;
3130 this.previousVerticalX_=-1;
3131 this.fractions_=_87.fractions||false;
3132 this.dateWindow_=_87.dateWindow||null;
3133 this.valueRange_=_87.valueRange||null;
3134 this.wilsonInterval_=_87.wilsonInterval||true;
3135 div.innerHTML="";
3136 if(div.style.width==""){
3137 div.style.width=Dygraph.DEFAULT_WIDTH+"px";
3138 }
3139 if(div.style.height==""){
3140 div.style.height=Dygraph.DEFAULT_HEIGHT+"px";
3141 }
3142 this.width_=parseInt(div.style.width,10);
3143 this.height_=parseInt(div.style.height,10);
3144 this.user_attrs_={};
3145 MochiKit.Base.update(this.user_attrs_,_87);
3146 this.attrs_={};
3147 MochiKit.Base.update(this.attrs_,Dygraph.DEFAULT_ATTRS);
3148 this.labelsFromCSV_=(this.attr_("labels")==null);
3149 this.createInterface_();
3150 this.layoutOptions_={"errorBars":(this.attr_("errorBars")||this.attr_("customBars")),"xOriginIsZero":false};
3151 MochiKit.Base.update(this.layoutOptions_,this.attrs_);
3152 MochiKit.Base.update(this.layoutOptions_,this.user_attrs_);
3153 this.layout_=new DygraphLayout(this,this.layoutOptions_);
3154 this.renderOptions_={colorScheme:this.colors_,strokeColor:null,axisLineWidth:Dygraph.AXIS_LINE_WIDTH};
3155 MochiKit.Base.update(this.renderOptions_,this.attrs_);
3156 MochiKit.Base.update(this.renderOptions_,this.user_attrs_);
3157 this.plotter_=new DygraphCanvasRenderer(this,this.hidden_,this.layout_,this.renderOptions_);
3158 this.createStatusMessage_();
3159 this.createRollInterface_();
3160 this.createDragInterface_();
3161 this.start_();
3162 };
3163 Dygraph.prototype.attr_=function(_88){
3164 if(typeof (this.user_attrs_[_88])!="undefined"){
3165 return this.user_attrs_[_88];
3166 }else{
3167 if(typeof (this.attrs_[_88])!="undefined"){
3168 return this.attrs_[_88];
3169 }else{
3170 return null;
3171 }
3172 }
3173 };
3174 Dygraph.prototype.log=function(_89,_90){
3175 if(typeof (console)!="undefined"){
3176 switch(_89){
3177 case Dygraph.DEBUG:
3178 console.debug("dygraphs: "+_90);
3179 break;
3180 case Dygraph.INFO:
3181 console.info("dygraphs: "+_90);
3182 break;
3183 case Dygraph.WARNING:
3184 console.warn("dygraphs: "+_90);
3185 break;
3186 case Dygraph.ERROR:
3187 console.error("dygraphs: "+_90);
3188 break;
3189 }
3190 }
3191 };
3192 Dygraph.prototype.info=function(_91){
3193 this.log(Dygraph.INFO,_91);
3194 };
3195 Dygraph.prototype.warn=function(_92){
3196 this.log(Dygraph.WARNING,_92);
3197 };
3198 Dygraph.prototype.error=function(_93){
3199 this.log(Dygraph.ERROR,_93);
3200 };
3201 Dygraph.prototype.rollPeriod=function(){
3202 return this.rollPeriod_;
3203 };
3204 Dygraph.addEvent=function(el,evt,fn){
3205 var _96=function(e){
3206 if(!e){
3207 var e=window.event;
3208 }
3209 fn(e);
3210 };
3211 if(window.addEventListener){
3212 el.addEventListener(evt,_96,false);
3213 }else{
3214 el.attachEvent("on"+evt,_96);
3215 }
3216 };
3217 Dygraph.prototype.createInterface_=function(){
3218 var _98=this.maindiv_;
3219 this.graphDiv=document.createElement("div");
3220 this.graphDiv.style.width=this.width_+"px";
3221 this.graphDiv.style.height=this.height_+"px";
3222 _98.appendChild(this.graphDiv);
3223 this.canvas_=document.createElement("canvas");
3224 this.canvas_.style.position="absolute";
3225 this.canvas_.width=this.width_;
3226 this.canvas_.height=this.height_;
3227 this.graphDiv.appendChild(this.canvas_);
3228 this.hidden_=this.createPlotKitCanvas_(this.canvas_);
3229 var _99=this;
3230 Dygraph.addEvent(this.hidden_,"mousemove",function(e){
3231 _99.mouseMove_(e);
3232 });
3233 Dygraph.addEvent(this.hidden_,"mouseout",function(e){
3234 _99.mouseOut_(e);
3235 });
3236 };
3237 Dygraph.prototype.createPlotKitCanvas_=function(_100){
3238 var h=document.createElement("canvas");
3239 h.style.position="absolute";
3240 h.style.top=_100.style.top;
3241 h.style.left=_100.style.left;
3242 h.width=this.width_;
3243 h.height=this.height_;
3244 this.graphDiv.appendChild(h);
3245 return h;
3246 };
3247 Dygraph.prototype.setColors_=function(){
3248 var num=this.attr_("labels").length-1;
3249 this.colors_=[];
3250 var _103=this.attr_("colors");
3251 if(!_103){
3252 var sat=this.attr_("colorSaturation")||1;
3253 var val=this.attr_("colorValue")||0.5;
3254 for(var i=1;i<=num;i++){
3255 var hue=(1*i/(1+num));
3256 this.colors_.push(MochiKit.Color.Color.fromHSV(hue,sat,val));
3257 }
3258 }else{
3259 for(var i=0;i<num;i++){
3260 var _107=_103[i%_103.length];
3261 this.colors_.push(MochiKit.Color.Color.fromString(_107));
3262 }
3263 }
3264 this.renderOptions_.colorScheme=this.colors_;
3265 MochiKit.Base.update(this.plotter_.options,this.renderOptions_);
3266 MochiKit.Base.update(this.layoutOptions_,this.user_attrs_);
3267 MochiKit.Base.update(this.layoutOptions_,this.attrs_);
3268 };
3269 Dygraph.findPosX=function(obj){
3270 var _109=0;
3271 if(obj.offsetParent){
3272 while(obj.offsetParent){
3273 _109+=obj.offsetLeft;
3274 obj=obj.offsetParent;
3275 }
3276 }else{
3277 if(obj.x){
3278 _109+=obj.x;
3279 }
3280 }
3281 return _109;
3282 };
3283 Dygraph.findPosY=function(obj){
3284 var _110=0;
3285 if(obj.offsetParent){
3286 while(obj.offsetParent){
3287 _110+=obj.offsetTop;
3288 obj=obj.offsetParent;
3289 }
3290 }else{
3291 if(obj.y){
3292 _110+=obj.y;
3293 }
3294 }
3295 return _110;
3296 };
3297 Dygraph.prototype.createStatusMessage_=function(){
3298 if(!this.attr_("labelsDiv")){
3299 var _111=this.attr_("labelsDivWidth");
3300 var _112={"position":"absolute","fontSize":"14px","zIndex":10,"width":_111+"px","top":"0px","left":(this.width_-_111-2)+"px","background":"white","textAlign":"left","overflow":"hidden"};
3301 MochiKit.Base.update(_112,this.attr_("labelsDivStyles"));
3302 var div=document.createElement("div");
3303 for(var name in _112){
3304 div.style[name]=_112[name];
3305 }
3306 this.graphDiv.appendChild(div);
3307 this.attrs_.labelsDiv=div;
3308 }
3309 };
3310 Dygraph.prototype.createRollInterface_=function(){
3311 var _114=this.attr_("showRoller")?"block":"none";
3312 var _115={"position":"absolute","zIndex":10,"top":(this.plotter_.area.h-25)+"px","left":(this.plotter_.area.x+1)+"px","display":_114};
3313 var _116=document.createElement("input");
3314 _116.type="text";
3315 _116.size="2";
3316 _116.value=this.rollPeriod_;
3317 for(var name in _115){
3318 _116.style[name]=_115[name];
3319 }
3320 var pa=this.graphDiv;
3321 pa.appendChild(_116);
3322 var _118=this;
3323 _116.onchange=function(){
3324 _118.adjustRoll(_116.value);
3325 };
3326 return _116;
3327 };
3328 Dygraph.pageX=function(e){
3329 if(e.pageX){
3330 return (!e.pageX||e.pageX<0)?0:e.pageX;
3331 }else{
3332 var de=document;
3333 var b=document.body;
3334 return e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
3335 }
3336 };
3337 Dygraph.pageY=function(e){
3338 if(e.pageY){
3339 return (!e.pageY||e.pageY<0)?0:e.pageY;
3340 }else{
3341 var de=document;
3342 var b=document.body;
3343 return e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
3344 }
3345 };
3346 Dygraph.prototype.createDragInterface_=function(){
3347 var self=this;
3348 var _122=false;
3349 var _123=null;
3350 var _124=null;
3351 var _125=null;
3352 var _126=null;
3353 var _127=null;
3354 var px=0;
3355 var py=0;
3356 var getX=function(e){
3357 return Dygraph.pageX(e)-px;
3358 };
3359 var getY=function(e){
3360 return Dygraph.pageX(e)-py;
3361 };
3362 Dygraph.addEvent(this.hidden_,"mousemove",function(_132){
3363 if(_122){
3364 _125=getX(_132);
3365 _126=getY(_132);
3366 self.drawZoomRect_(_123,_125,_127);
3367 _127=_125;
3368 }
3369 });
3370 Dygraph.addEvent(this.hidden_,"mousedown",function(_133){
3371 _122=true;
3372 px=Dygraph.findPosX(self.canvas_);
3373 py=Dygraph.findPosY(self.canvas_);
3374 _123=getX(_133);
3375 _124=getY(_133);
3376 });
3377 Dygraph.addEvent(document,"mouseup",function(_134){
3378 if(_122){
3379 _122=false;
3380 _123=null;
3381 _124=null;
3382 }
3383 });
3384 Dygraph.addEvent(this.hidden_,"mouseout",function(_135){
3385 if(_122){
3386 _125=null;
3387 _126=null;
3388 }
3389 });
3390 Dygraph.addEvent(this.hidden_,"mouseup",function(_136){
3391 if(_122){
3392 _122=false;
3393 _125=getX(_136);
3394 _126=getY(_136);
3395 var _137=Math.abs(_125-_123);
3396 var _138=Math.abs(_126-_124);
3397 if(_137<2&&_138<2&&self.attr_("clickCallback")!=null&&self.lastx_!=undefined){
3398 self.attr_("clickCallback")(_136,new Date(self.lastx_));
3399 }
3400 if(_137>=10){
3401 self.doZoom_(Math.min(_123,_125),Math.max(_123,_125));
3402 }else{
3403 self.canvas_.getContext("2d").clearRect(0,0,self.canvas_.width,self.canvas_.height);
3404 }
3405 _123=null;
3406 _124=null;
3407 }
3408 });
3409 Dygraph.addEvent(this.hidden_,"dblclick",function(_139){
3410 self.dateWindow_=null;
3411 self.drawGraph_(self.rawData_);
3412 var _140=self.rawData_[0][0];
3413 var _141=self.rawData_[self.rawData_.length-1][0];
3414 if(self.attr_("zoomCallback")){
3415 self.attr_("zoomCallback")(_140,_141);
3416 }
3417 });
3418 };
3419 Dygraph.prototype.drawZoomRect_=function(_142,endX,_144){
3420 var ctx=this.canvas_.getContext("2d");
3421 if(_144){
3422 ctx.clearRect(Math.min(_142,_144),0,Math.abs(_142-_144),this.height_);
3423 }
3424 if(endX&&_142){
3425 ctx.fillStyle="rgba(128,128,128,0.33)";
3426 ctx.fillRect(Math.min(_142,endX),0,Math.abs(endX-_142),this.height_);
3427 }
3428 };
3429 Dygraph.prototype.doZoom_=function(lowX,_146){
3430 var _147=this.layout_.points;
3431 var _148=null;
3432 var _149=null;
3433 for(var i=0;i<_147.length;i++){
3434 var cx=_147[i].canvasx;
3435 var x=_147[i].xval;
3436 if(cx<lowX&&(_148==null||x>_148)){
3437 _148=x;
3438 }
3439 if(cx>_146&&(_149==null||x<_149)){
3440 _149=x;
3441 }
3442 }
3443 if(_148==null){
3444 _148=_147[0].xval;
3445 }
3446 if(_149==null){
3447 _149=_147[_147.length-1].xval;
3448 }
3449 this.dateWindow_=[_148,_149];
3450 this.drawGraph_(this.rawData_);
3451 if(this.attr_("zoomCallback")){
3452 this.attr_("zoomCallback")(_148,_149);
3453 }
3454 };
3455 Dygraph.prototype.mouseMove_=function(_151){
3456 var _152=Dygraph.pageX(_151)-Dygraph.findPosX(this.hidden_);
3457 var _153=this.layout_.points;
3458 var _154=-1;
3459 var _155=-1;
3460 var _156=1e+100;
3461 var idx=-1;
3462 for(var i=0;i<_153.length;i++){
3463 var dist=Math.abs(_153[i].canvasx-_152);
3464 if(dist>_156){
3465 break;
3466 }
3467 _156=dist;
3468 idx=i;
3469 }
3470 if(idx>=0){
3471 _154=_153[idx].xval;
3472 }
3473 if(_152>_153[_153.length-1].canvasx){
3474 _154=_153[_153.length-1].xval;
3475 }
3476 var _159=[];
3477 for(var i=0;i<_153.length;i++){
3478 if(_153[i].xval==_154){
3479 _159.push(_153[i]);
3480 }
3481 }
3482 var _160=this.attr_("highlightCircleSize");
3483 var ctx=this.canvas_.getContext("2d");
3484 if(this.previousVerticalX_>=0){
3485 var px=this.previousVerticalX_;
3486 ctx.clearRect(px-_160-1,0,2*_160+2,this.height_);
3487 }
3488 var isOK=function(x){
3489 return x&&!isNaN(x);
3490 };
3491 if(_159.length>0){
3492 var _152=_159[0].canvasx;
3493 var _162=this.attr_("xValueFormatter")(_154,this)+":";
3494 var clen=this.colors_.length;
3495 for(var i=0;i<_159.length;i++){
3496 if(!isOK(_159[i].canvasy)){
3497 continue;
3498 }
3499 if(this.attr_("labelsSeparateLines")){
3500 _162+="<br/>";
3501 }
3502 var _164=_159[i];
3503 _162+=" <b><font color='"+this.colors_[i%clen].toHexString()+"'>"+_164.name+"</font></b>:"+this.round_(_164.yval,2);
3504 }
3505 this.attr_("labelsDiv").innerHTML=_162;
3506 this.lastx_=_154;
3507 ctx.save();
3508 for(var i=0;i<_159.length;i++){
3509 if(!isOK(_159[i%clen].canvasy)){
3510 continue;
3511 }
3512 ctx.beginPath();
3513 ctx.fillStyle=this.colors_[i%clen].toRGBString();
3514 ctx.arc(_152,_159[i%clen].canvasy,_160,0,360,false);
3515 ctx.fill();
3516 }
3517 ctx.restore();
3518 this.previousVerticalX_=_152;
3519 }
3520 };
3521 Dygraph.prototype.mouseOut_=function(_165){
3522 var ctx=this.canvas_.getContext("2d");
3523 ctx.clearRect(0,0,this.width_,this.height_);
3524 this.attr_("labelsDiv").innerHTML="";
3525 };
3526 Dygraph.zeropad=function(x){
3527 if(x<10){
3528 return "0"+x;
3529 }else{
3530 return ""+x;
3531 }
3532 };
3533 Dygraph.prototype.hmsString_=function(date){
3534 var _167=Dygraph.zeropad;
3535 var d=new Date(date);
3536 if(d.getSeconds()){
3537 return _167(d.getHours())+":"+_167(d.getMinutes())+":"+_167(d.getSeconds());
3538 }else{
3539 if(d.getMinutes()){
3540 return _167(d.getHours())+":"+_167(d.getMinutes());
3541 }else{
3542 return _167(d.getHours());
3543 }
3544 }
3545 };
3546 Dygraph.dateString_=function(date,self){
3547 var _169=Dygraph.zeropad;
3548 var d=new Date(date);
3549 var year=""+d.getFullYear();
3550 var _171=_169(d.getMonth()+1);
3551 var day=_169(d.getDate());
3552 var ret="";
3553 var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
3554 if(frac){
3555 ret=" "+self.hmsString_(date);
3556 }
3557 return year+"/"+_171+"/"+day+ret;
3558 };
3559 Dygraph.prototype.round_=function(num,_175){
3560 var _176=Math.pow(10,_175);
3561 return Math.round(num*_176)/_176;
3562 };
3563 Dygraph.prototype.loadedEvent_=function(data){
3564 this.rawData_=this.parseCSV_(data);
3565 this.drawGraph_(this.rawData_);
3566 };
3567 Dygraph.prototype.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
3568 Dygraph.prototype.quarters=["Jan","Apr","Jul","Oct"];
3569 Dygraph.prototype.addXTicks_=function(){
3570 var _178,endDate;
3571 if(this.dateWindow_){
3572 _178=this.dateWindow_[0];
3573 endDate=this.dateWindow_[1];
3574 }else{
3575 _178=this.rawData_[0][0];
3576 endDate=this.rawData_[this.rawData_.length-1][0];
3577 }
3578 var _179=this.attr_("xTicker")(_178,endDate,this);
3579 this.layout_.updateOptions({xTicks:_179});
3580 };
3581 Dygraph.SECONDLY=0;
3582 Dygraph.TEN_SECONDLY=1;
3583 Dygraph.THIRTY_SECONDLY=2;
3584 Dygraph.MINUTELY=3;
3585 Dygraph.TEN_MINUTELY=4;
3586 Dygraph.THIRTY_MINUTELY=5;
3587 Dygraph.HOURLY=6;
3588 Dygraph.SIX_HOURLY=7;
3589 Dygraph.DAILY=8;
3590 Dygraph.WEEKLY=9;
3591 Dygraph.MONTHLY=10;
3592 Dygraph.QUARTERLY=11;
3593 Dygraph.BIANNUAL=12;
3594 Dygraph.ANNUAL=13;
3595 Dygraph.DECADAL=14;
3596 Dygraph.NUM_GRANULARITIES=15;
3597 Dygraph.SHORT_SPACINGS=[];
3598 Dygraph.SHORT_SPACINGS[Dygraph.SECONDLY]=1000*1;
3599 Dygraph.SHORT_SPACINGS[Dygraph.TEN_SECONDLY]=1000*10;
3600 Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_SECONDLY]=1000*30;
3601 Dygraph.SHORT_SPACINGS[Dygraph.MINUTELY]=1000*60;
3602 Dygraph.SHORT_SPACINGS[Dygraph.TEN_MINUTELY]=1000*60*10;
3603 Dygraph.SHORT_SPACINGS[Dygraph.THIRTY_MINUTELY]=1000*60*30;
3604 Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600;
3605 Dygraph.SHORT_SPACINGS[Dygraph.HOURLY]=1000*3600*6;
3606 Dygraph.SHORT_SPACINGS[Dygraph.DAILY]=1000*86400;
3607 Dygraph.SHORT_SPACINGS[Dygraph.WEEKLY]=1000*604800;
3608 Dygraph.prototype.NumXTicks=function(_180,_181,_182){
3609 if(_182<Dygraph.MONTHLY){
3610 var _183=Dygraph.SHORT_SPACINGS[_182];
3611 return Math.floor(0.5+1*(_181-_180)/_183);
3612 }else{
3613 var _184=1;
3614 var _185=12;
3615 if(_182==Dygraph.QUARTERLY){
3616 _185=3;
3617 }
3618 if(_182==Dygraph.BIANNUAL){
3619 _185=2;
3620 }
3621 if(_182==Dygraph.ANNUAL){
3622 _185=1;
3623 }
3624 if(_182==Dygraph.DECADAL){
3625 _185=1;
3626 _184=10;
3627 }
3628 var _186=365.2524*24*3600*1000;
3629 var _187=1*(_181-_180)/_186;
3630 return Math.floor(0.5+1*_187*_185/_184);
3631 }
3632 };
3633 Dygraph.prototype.GetXAxis=function(_188,_189,_190){
3634 var _191=[];
3635 if(_190<Dygraph.MONTHLY){
3636 var _192=Dygraph.SHORT_SPACINGS[_190];
3637 var _193="%d%b";
3638 if(_190<Dygraph.HOURLY){
3639 _188=_192*Math.floor(0.5+_188/_192);
3640 }
3641 for(var t=_188;t<=_189;t+=_192){
3642 var d=new Date(t);
3643 var frac=d.getHours()*3600+d.getMinutes()*60+d.getSeconds();
3644 if(frac==0||_190>=Dygraph.DAILY){
3645 _191.push({v:t,label:new Date(t+3600*1000).strftime(_193)});
3646 }else{
3647 _191.push({v:t,label:this.hmsString_(t)});
3648 }
3649 }
3650 }else{
3651 var _195;
3652 var _196=1;
3653 if(_190==Dygraph.MONTHLY){
3654 _195=[0,1,2,3,4,5,6,7,8,9,10,11,12];
3655 }else{
3656 if(_190==Dygraph.QUARTERLY){
3657 _195=[0,3,6,9];
3658 }else{
3659 if(_190==Dygraph.BIANNUAL){
3660 _195=[0,6];
3661 }else{
3662 if(_190==Dygraph.ANNUAL){
3663 _195=[0];
3664 }else{
3665 if(_190==Dygraph.DECADAL){
3666 _195=[0];
3667 _196=10;
3668 }
3669 }
3670 }
3671 }
3672 }
3673 var _197=new Date(_188).getFullYear();
3674 var _198=new Date(_189).getFullYear();
3675 var _199=Dygraph.zeropad;
3676 for(var i=_197;i<=_198;i++){
3677 if(i%_196!=0){
3678 continue;
3679 }
3680 for(var j=0;j<_195.length;j++){
3681 var _200=i+"/"+_199(1+_195[j])+"/01";
3682 var t=Date.parse(_200);
3683 if(t<_188||t>_189){
3684 continue;
3685 }
3686 _191.push({v:t,label:new Date(t).strftime("%b %y")});
3687 }
3688 }
3689 }
3690 return _191;
3691 };
3692 Dygraph.dateTicker=function(_201,_202,self){
3693 var _203=-1;
3694 for(var i=0;i<Dygraph.NUM_GRANULARITIES;i++){
3695 var _204=self.NumXTicks(_201,_202,i);
3696 if(self.width_/_204>=self.attr_("pixelsPerXLabel")){
3697 _203=i;
3698 break;
3699 }
3700 }
3701 if(_203>=0){
3702 return self.GetXAxis(_201,_202,_203);
3703 }else{
3704 }
3705 };
3706 Dygraph.numericTicks=function(minV,maxV,self){
3707 var _207=[1,2,5];
3708 var _208,low_val,high_val,nTicks;
3709 var _209=self.attr_("pixelsPerYLabel");
3710 for(var i=-10;i<50;i++){
3711 var _210=Math.pow(10,i);
3712 for(var j=0;j<_207.length;j++){
3713 _208=_210*_207[j];
3714 low_val=Math.floor(minV/_208)*_208;
3715 high_val=Math.ceil(maxV/_208)*_208;
3716 nTicks=(high_val-low_val)/_208;
3717 var _211=self.height_/nTicks;
3718 if(_211>_209){
3719 break;
3720 }
3721 }
3722 if(_211>_209){
3723 break;
3724 }
3725 }
3726 var _212=[];
3727 for(var i=0;i<nTicks;i++){
3728 var _213=low_val+i*_208;
3729 var _214=self.round_(_213,2);
3730 if(self.attr_("labelsKMB")){
3731 var k=1000;
3732 if(_213>=k*k*k){
3733 _214=self.round_(_213/(k*k*k),1)+"B";
3734 }else{
3735 if(_213>=k*k){
3736 _214=self.round_(_213/(k*k),1)+"M";
3737 }else{
3738 if(_213>=k){
3739 _214=self.round_(_213/k,1)+"K";
3740 }
3741 }
3742 }
3743 }
3744 _212.push({label:_214,v:_213});
3745 }
3746 return _212;
3747 };
3748 Dygraph.prototype.addYTicks_=function(minY,maxY){
3749 var _218=Dygraph.numericTicks(minY,maxY,this);
3750 this.layout_.updateOptions({yAxis:[minY,maxY],yTicks:_218});
3751 };
3752 Dygraph.prototype.extremeValues_=function(_219){
3753 var minY=null,maxY=null;
3754 var bars=this.attr_("errorBars")||this.attr_("customBars");
3755 if(bars){
3756 for(var j=0;j<_219.length;j++){
3757 var y=_219[j][1][0];
3758 if(!y){
3759 continue;
3760 }
3761 var low=y-_219[j][1][1];
3762 var high=y+_219[j][1][2];
3763 if(low>y){
3764 low=y;
3765 }
3766 if(high<y){
3767 high=y;
3768 }
3769 if(maxY==null||high>maxY){
3770 maxY=high;
3771 }
3772 if(minY==null||low<minY){
3773 minY=low;
3774 }
3775 }
3776 }else{
3777 for(var j=0;j<_219.length;j++){
3778 var y=_219[j][1];
3779 if(!y){
3780 continue;
3781 }
3782 if(maxY==null||y>maxY){
3783 maxY=y;
3784 }
3785 if(minY==null||y<minY){
3786 minY=y;
3787 }
3788 }
3789 }
3790 return [minY,maxY];
3791 };
3792 Dygraph.prototype.drawGraph_=function(data){
3793 var minY=null,maxY=null;
3794 this.layout_.removeAllDatasets();
3795 this.setColors_();
3796 this.attrs_["pointSize"]=0.5*this.attr_("highlightCircleSize");
3797 for(var i=1;i<data[0].length;i++){
3798 var _223=[];
3799 for(var j=0;j<data.length;j++){
3800 var date=data[j][0];
3801 _223[j]=[date,data[j][i]];
3802 }
3803 _223=this.rollingAverage(_223,this.rollPeriod_);
3804 var bars=this.attr_("errorBars")||this.attr_("customBars");
3805 if(this.dateWindow_){
3806 var low=this.dateWindow_[0];
3807 var high=this.dateWindow_[1];
3808 var _224=[];
3809 for(var k=0;k<_223.length;k++){
3810 if(_223[k][0]>=low&&_223[k][0]<=high){
3811 _224.push(_223[k]);
3812 }
3813 }
3814 _223=_224;
3815 }
3816 var _225=this.extremeValues_(_223);
3817 var _226=_225[0];
3818 var _227=_225[1];
3819 if(!minY||_226<minY){
3820 minY=_226;
3821 }
3822 if(!maxY||_227>maxY){
3823 maxY=_227;
3824 }
3825 if(bars){
3826 var vals=[];
3827 for(var j=0;j<_223.length;j++){
3828 vals[j]=[_223[j][0],_223[j][1][0],_223[j][1][1],_223[j][1][2]];
3829 }
3830 this.layout_.addDataset(this.attr_("labels")[i],vals);
3831 }else{
3832 this.layout_.addDataset(this.attr_("labels")[i],_223);
3833 }
3834 }
3835 if(this.valueRange_!=null){
3836 this.addYTicks_(this.valueRange_[0],this.valueRange_[1]);
3837 }else{
3838 var span=maxY-minY;
3839 var _230=maxY+0.1*span;
3840 var _231=minY-0.1*span;
3841 if(_231<0&&minY>=0){
3842 _231=0;
3843 }
3844 if(_230>0&&maxY<=0){
3845 _230=0;
3846 }
3847 if(this.attr_("includeZero")){
3848 if(maxY<0){
3849 _230=0;
3850 }
3851 if(minY>0){
3852 _231=0;
3853 }
3854 }
3855 this.addYTicks_(_231,_230);
3856 }
3857 this.addXTicks_();
3858 this.layout_.evaluateWithError();
3859 this.plotter_.clear();
3860 this.plotter_.render();
3861 this.canvas_.getContext("2d").clearRect(0,0,this.canvas_.width,this.canvas_.height);
3862 };
3863 Dygraph.prototype.rollingAverage=function(_232,_233){
3864 if(_232.length<2){
3865 return _232;
3866 }
3867 var _233=Math.min(_233,_232.length-1);
3868 var _234=[];
3869 var _235=this.attr_("sigma");
3870 if(this.fractions_){
3871 var num=0;
3872 var den=0;
3873 var mult=100;
3874 for(var i=0;i<_232.length;i++){
3875 num+=_232[i][1][0];
3876 den+=_232[i][1][1];
3877 if(i-_233>=0){
3878 num-=_232[i-_233][1][0];
3879 den-=_232[i-_233][1][1];
3880 }
3881 var date=_232[i][0];
3882 var _238=den?num/den:0;
3883 if(this.attr_("errorBars")){
3884 if(this.wilsonInterval_){
3885 if(den){
3886 var p=_238<0?0:_238,n=den;
3887 var pm=_235*Math.sqrt(p*(1-p)/n+_235*_235/(4*n*n));
3888 var _241=1+_235*_235/den;
3889 var low=(p+_235*_235/(2*den)-pm)/_241;
3890 var high=(p+_235*_235/(2*den)+pm)/_241;
3891 _234[i]=[date,[p*mult,(p-low)*mult,(high-p)*mult]];
3892 }else{
3893 _234[i]=[date,[0,0,0]];
3894 }
3895 }else{
3896 var _242=den?_235*Math.sqrt(_238*(1-_238)/den):1;
3897 _234[i]=[date,[mult*_238,mult*_242,mult*_242]];
3898 }
3899 }else{
3900 _234[i]=[date,mult*_238];
3901 }
3902 }
3903 }else{
3904 if(this.attr_("customBars")){
3905 var low=0;
3906 var mid=0;
3907 var high=0;
3908 var _244=0;
3909 for(var i=0;i<_232.length;i++){
3910 var data=_232[i][1];
3911 var y=data[1];
3912 _234[i]=[_232[i][0],[y,y-data[0],data[2]-y]];
3913 low+=data[0];
3914 mid+=y;
3915 high+=data[2];
3916 _244+=1;
3917 if(i-_233>=0){
3918 var prev=_232[i-_233];
3919 low-=prev[1][0];
3920 mid-=prev[1][1];
3921 high-=prev[1][2];
3922 _244-=1;
3923 }
3924 _234[i]=[_232[i][0],[1*mid/_244,1*(mid-low)/_244,1*(high-mid)/_244]];
3925 }
3926 }else{
3927 var _246=Math.min(_233-1,_232.length-2);
3928 if(!this.attr_("errorBars")){
3929 if(_233==1){
3930 return _232;
3931 }
3932 for(var i=0;i<_232.length;i++){
3933 var sum=0;
3934 var _248=0;
3935 for(var j=Math.max(0,i-_233+1);j<i+1;j++){
3936 var y=_232[j][1];
3937 if(!y||isNaN(y)){
3938 continue;
3939 }
3940 _248++;
3941 sum+=_232[j][1];
3942 }
3943 if(_248){
3944 _234[i]=[_232[i][0],sum/_248];
3945 }else{
3946 _234[i]=[_232[i][0],null];
3947 }
3948 }
3949 }else{
3950 for(var i=0;i<_232.length;i++){
3951 var sum=0;
3952 var _249=0;
3953 var _248=0;
3954 for(var j=Math.max(0,i-_233+1);j<i+1;j++){
3955 var y=_232[j][1][0];
3956 if(!y||isNaN(y)){
3957 continue;
3958 }
3959 _248++;
3960 sum+=_232[j][1][0];
3961 _249+=Math.pow(_232[j][1][1],2);
3962 }
3963 if(_248){
3964 var _242=Math.sqrt(_249)/_248;
3965 _234[i]=[_232[i][0],[sum/_248,_235*_242,_235*_242]];
3966 }else{
3967 _234[i]=[_232[i][0],[null,null,null]];
3968 }
3969 }
3970 }
3971 }
3972 }
3973 return _234;
3974 };
3975 Dygraph.dateParser=function(_250,self){
3976 var _251;
3977 var d;
3978 if(_250.length==10&&_250.search("-")!=-1){
3979 _251=_250.replace("-","/","g");
3980 while(_251.search("-")!=-1){
3981 _251=_251.replace("-","/");
3982 }
3983 d=Date.parse(_251);
3984 }else{
3985 if(_250.length==8){
3986 _251=_250.substr(0,4)+"/"+_250.substr(4,2)+"/"+_250.substr(6,2);
3987 d=Date.parse(_251);
3988 }else{
3989 d=Date.parse(_250);
3990 }
3991 }
3992 if(!d||isNaN(d)){
3993 self.error("Couldn't parse "+_250+" as a date");
3994 }
3995 return d;
3996 };
3997 Dygraph.prototype.detectTypeFromString_=function(str){
3998 var _253=false;
3999 if(str.indexOf("-")>=0||str.indexOf("/")>=0||isNaN(parseFloat(str))){
4000 _253=true;
4001 }else{
4002 if(str.length==8&&str>"19700101"&&str<"20371231"){
4003 _253=true;
4004 }
4005 }
4006 if(_253){
4007 this.attrs_.xValueFormatter=Dygraph.dateString_;
4008 this.attrs_.xValueParser=Dygraph.dateParser;
4009 this.attrs_.xTicker=Dygraph.dateTicker;
4010 }else{
4011 this.attrs_.xValueFormatter=function(x){
4012 return x;
4013 };
4014 this.attrs_.xValueParser=function(x){
4015 return parseFloat(x);
4016 };
4017 this.attrs_.xTicker=Dygraph.numericTicks;
4018 }
4019 };
4020 Dygraph.prototype.parseCSV_=function(data){
4021 var ret=[];
4022 var _254=data.split("\n");
4023 var _255=0;
4024 if(this.labelsFromCSV_){
4025 _255=1;
4026 this.attrs_.labels=_254[0].split(",");
4027 }
4028 var _256;
4029 var _257=false;
4030 var _258=this.attr_("labels").length;
4031 for(var i=_255;i<_254.length;i++){
4032 var line=_254[i];
4033 if(line.length==0){
4034 continue;
4035 }
4036 var _260=line.split(",");
4037 if(_260.length<2){
4038 continue;
4039 }
4040 var _261=[];
4041 if(!_257){
4042 this.detectTypeFromString_(_260[0]);
4043 _256=this.attr_("xValueParser");
4044 _257=true;
4045 }
4046 _261[0]=_256(_260[0],this);
4047 if(this.fractions_){
4048 for(var j=1;j<_260.length;j++){
4049 var vals=_260[j].split("/");
4050 _261[j]=[parseFloat(vals[0]),parseFloat(vals[1])];
4051 }
4052 }else{
4053 if(this.attr_("errorBars")){
4054 for(var j=1;j<_260.length;j+=2){
4055 _261[(j+1)/2]=[parseFloat(_260[j]),parseFloat(_260[j+1])];
4056 }
4057 }else{
4058 if(this.attr_("customBars")){
4059 for(var j=1;j<_260.length;j++){
4060 var vals=_260[j].split(";");
4061 _261[j]=[parseFloat(vals[0]),parseFloat(vals[1]),parseFloat(vals[2])];
4062 }
4063 }else{
4064 for(var j=1;j<_260.length;j++){
4065 _261[j]=parseFloat(_260[j]);
4066 }
4067 }
4068 }
4069 }
4070 ret.push(_261);
4071 if(_261.length!=_258){
4072 this.error("Number of columns in line "+i+" ("+_261.length+") does not agree with number of labels ("+_258+") "+line);
4073 }
4074 }
4075 return ret;
4076 };
4077 Dygraph.prototype.parseArray_=function(data){
4078 if(data.length==0){
4079 this.error("Can't plot empty data set");
4080 return null;
4081 }
4082 if(data[0].length==0){
4083 this.error("Data set cannot contain an empty row");
4084 return null;
4085 }
4086 if(this.attr_("labels")==null){
4087 this.warn("Using default labels. Set labels explicitly via 'labels' "+"in the options parameter");
4088 this.attrs_.labels=["X"];
4089 for(var i=1;i<data[0].length;i++){
4090 this.attrs_.labels.push("Y"+i);
4091 }
4092 }
4093 if(MochiKit.Base.isDateLike(data[0][0])){
4094 this.attrs_.xValueFormatter=Dygraph.dateString_;
4095 this.attrs_.xTicker=Dygraph.dateTicker;
4096 var _262=MochiKit.Base.clone(data);
4097 for(var i=0;i<data.length;i++){
4098 if(_262[i].length==0){
4099 this.error("Row "<<(1+i)<<" of data is empty");
4100 return null;
4101 }
4102 if(_262[i][0]==null||typeof (_262[i][0].getTime)!="function"){
4103 this.error("x value in row "<<(1+i)<<" is not a Date");
4104 return null;
4105 }
4106 _262[i][0]=_262[i][0].getTime();
4107 }
4108 return _262;
4109 }else{
4110 this.attrs_.xValueFormatter=function(x){
4111 return x;
4112 };
4113 this.attrs_.xTicker=Dygraph.numericTicks;
4114 return data;
4115 }
4116 };
4117 Dygraph.prototype.parseDataTable_=function(data){
4118 var cols=data.getNumberOfColumns();
4119 var rows=data.getNumberOfRows();
4120 var _265=[];
4121 for(var i=0;i<cols;i++){
4122 _265.push(data.getColumnLabel(i));
4123 }
4124 this.attrs_.labels=_265;
4125 var _266=data.getColumnType(0);
4126 if(_266=="date"){
4127 this.attrs_.xValueFormatter=Dygraph.dateString_;
4128 this.attrs_.xValueParser=Dygraph.dateParser;
4129 this.attrs_.xTicker=Dygraph.dateTicker;
4130 }else{
4131 if(_266=="number"){
4132 this.attrs_.xValueFormatter=function(x){
4133 return x;
4134 };
4135 this.attrs_.xValueParser=function(x){
4136 return parseFloat(x);
4137 };
4138 this.attrs_.xTicker=Dygraph.numericTicks;
4139 }else{
4140 this.error("only 'date' and 'number' types are supported for column 1 "+"of DataTable input (Got '"+_266+"')");
4141 return null;
4142 }
4143 }
4144 var ret=[];
4145 for(var i=0;i<rows;i++){
4146 var row=[];
4147 if(!data.getValue(i,0)){
4148 continue;
4149 }
4150 if(_266=="date"){
4151 row.push(data.getValue(i,0).getTime());
4152 }else{
4153 row.push(data.getValue(i,0));
4154 }
4155 for(var j=1;j<cols;j++){
4156 row.push(data.getValue(i,j));
4157 }
4158 ret.push(row);
4159 }
4160 return ret;
4161 };
4162 Dygraph.prototype.start_=function(){
4163 if(typeof this.file_=="function"){
4164 this.loadedEvent_(this.file_());
4165 }else{
4166 if(MochiKit.Base.isArrayLike(this.file_)){
4167 this.rawData_=this.parseArray_(this.file_);
4168 this.drawGraph_(this.rawData_);
4169 }else{
4170 if(typeof this.file_=="object"&&typeof this.file_.getColumnRange=="function"){
4171 this.rawData_=this.parseDataTable_(this.file_);
4172 this.drawGraph_(this.rawData_);
4173 }else{
4174 if(typeof this.file_=="string"){
4175 if(this.file_.indexOf("\n")>=0){
4176 this.loadedEvent_(this.file_);
4177 }else{
4178 var req=new XMLHttpRequest();
4179 var _269=this;
4180 req.onreadystatechange=function(){
4181 if(req.readyState==4){
4182 if(req.status==200){
4183 _269.loadedEvent_(req.responseText);
4184 }
4185 }
4186 };
4187 req.open("GET",this.file_,true);
4188 req.send(null);
4189 }
4190 }else{
4191 this.error("Unknown data format: "+(typeof this.file_));
4192 }
4193 }
4194 }
4195 }
4196 };
4197 Dygraph.prototype.updateOptions=function(_270){
4198 if(_270.rollPeriod){
4199 this.rollPeriod_=_270.rollPeriod;
4200 }
4201 if(_270.dateWindow){
4202 this.dateWindow_=_270.dateWindow;
4203 }
4204 if(_270.valueRange){
4205 this.valueRange_=_270.valueRange;
4206 }
4207 MochiKit.Base.update(this.user_attrs_,_270);
4208 this.labelsFromCSV_=(this.attr_("labels")==null);
4209 this.layout_.updateOptions({"errorBars":this.attr_("errorBars")});
4210 if(_270["file"]&&_270["file"]!=this.file_){
4211 this.file_=_270["file"];
4212 this.start_();
4213 }else{
4214 this.drawGraph_(this.rawData_);
4215 }
4216 };
4217 Dygraph.prototype.adjustRoll=function(_271){
4218 this.rollPeriod_=_271;
4219 this.drawGraph_(this.rawData_);
4220 };
4221 Dygraph.GVizChart=function(_272){
4222 this.container=_272;
4223 };
4224 Dygraph.GVizChart.prototype.draw=function(data,_273){
4225 this.container.innerHTML="";
4226 this.date_graph=new Dygraph(this.container,data,_273);
4227 };
4228 DateGraph=Dygraph;
4229