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