more useful instructions
[dygraphs.git] / docs / dygraph-combined.js
CommitLineData
078d1d29
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"){
1005dojo.provide("MochiKit.Iter");
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){
1017throw "MochiKit.Iter depends on MochiKit.Base!";
1018}
1019if(typeof (MochiKit.Iter)=="undefined"){
1020MochiKit.Iter={};
1021}
1022MochiKit.Iter.NAME="MochiKit.Iter";
1023MochiKit.Iter.VERSION="1.4";
1024MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){
1025return "["+this.NAME+" "+this.VERSION+"]";
1026},toString:function(){
1027return this.__repr__();
1028},registerIteratorFactory:function(name,_14e,_14f,_150){
1029MochiKit.Iter.iteratorRegistry.register(name,_14e,_14f,_150);
1030},iter:function(_151,_152){
1031var self=MochiKit.Iter;
1032if(arguments.length==2){
1033return self.takewhile(function(a){
1034return a!=_152;
1035},_151);
1036}
1037if(typeof (_151.next)=="function"){
1038return _151;
1039}else{
1040if(typeof (_151.iter)=="function"){
1041return _151.iter();
1042}
1043}
1044try{
1045return self.iteratorRegistry.match(_151);
1046}
1047catch(e){
1048var m=MochiKit.Base;
1049if(e==m.NotFound){
1050e=new TypeError(typeof (_151)+": "+m.repr(_151)+" is not iterable");
1051}
1052throw e;
1053}
1054},count:function(n){
1055if(!n){
1056n=0;
1057}
1058var m=MochiKit.Base;
1059return {repr:function(){
1060return "count("+n+")";
1061},toString:m.forwardCall("repr"),next:m.counter(n)};
1062},cycle:function(p){
1063var self=MochiKit.Iter;
1064var m=MochiKit.Base;
1065var lst=[];
1066var _15c=self.iter(p);
1067return {repr:function(){
1068return "cycle(...)";
1069},toString:m.forwardCall("repr"),next:function(){
1070try{
1071var rval=_15c.next();
1072lst.push(rval);
1073return rval;
1074}
1075catch(e){
1076if(e!=self.StopIteration){
1077throw e;
1078}
1079if(lst.length===0){
1080this.next=function(){
1081throw self.StopIteration;
1082};
1083}else{
1084var i=-1;
1085this.next=function(){
1086i=(i+1)%lst.length;
1087return lst[i];
1088};
1089}
1090return this.next();
1091}
1092}};
1093},repeat:function(elem,n){
1094var m=MochiKit.Base;
1095if(typeof (n)=="undefined"){
1096return {repr:function(){
1097return "repeat("+m.repr(elem)+")";
1098},toString:m.forwardCall("repr"),next:function(){
1099return elem;
1100}};
1101}
1102return {repr:function(){
1103return "repeat("+m.repr(elem)+", "+n+")";
1104},toString:m.forwardCall("repr"),next:function(){
1105if(n<=0){
1106throw MochiKit.Iter.StopIteration;
1107}
1108n-=1;
1109return elem;
1110}};
1111},next:function(_162){
1112return _162.next();
1113},izip:function(p,q){
1114var m=MochiKit.Base;
1115var self=MochiKit.Iter;
1116var next=self.next;
1117var _168=m.map(self.iter,arguments);
1118return {repr:function(){
1119return "izip(...)";
1120},toString:m.forwardCall("repr"),next:function(){
1121return m.map(next,_168);
1122}};
1123},ifilter:function(pred,seq){
1124var m=MochiKit.Base;
1125seq=MochiKit.Iter.iter(seq);
1126if(pred===null){
1127pred=m.operator.truth;
1128}
1129return {repr:function(){
1130return "ifilter(...)";
1131},toString:m.forwardCall("repr"),next:function(){
1132while(true){
1133var rval=seq.next();
1134if(pred(rval)){
1135return rval;
1136}
1137}
1138return undefined;
1139}};
1140},ifilterfalse:function(pred,seq){
1141var m=MochiKit.Base;
1142seq=MochiKit.Iter.iter(seq);
1143if(pred===null){
1144pred=m.operator.truth;
1145}
1146return {repr:function(){
1147return "ifilterfalse(...)";
1148},toString:m.forwardCall("repr"),next:function(){
1149while(true){
1150var rval=seq.next();
1151if(!pred(rval)){
1152return rval;
1153}
1154}
1155return undefined;
1156}};
1157},islice:function(seq){
1158var self=MochiKit.Iter;
1159var m=MochiKit.Base;
1160seq=self.iter(seq);
1161var _174=0;
1162var stop=0;
1163var step=1;
1164var i=-1;
1165if(arguments.length==2){
1166stop=arguments[1];
1167}else{
1168if(arguments.length==3){
1169_174=arguments[1];
1170stop=arguments[2];
1171}else{
1172_174=arguments[1];
1173stop=arguments[2];
1174step=arguments[3];
1175}
1176}
1177return {repr:function(){
1178return "islice("+["...",_174,stop,step].join(", ")+")";
1179},toString:m.forwardCall("repr"),next:function(){
1180var rval;
1181while(i<_174){
1182rval=seq.next();
1183i++;
1184}
1185if(_174>=stop){
1186throw self.StopIteration;
1187}
1188_174+=step;
1189return rval;
1190}};
1191},imap:function(fun,p,q){
1192var m=MochiKit.Base;
1193var self=MochiKit.Iter;
1194var _17e=m.map(self.iter,m.extend(null,arguments,1));
1195var map=m.map;
1196var next=self.next;
1197return {repr:function(){
1198return "imap(...)";
1199},toString:m.forwardCall("repr"),next:function(){
1200return fun.apply(this,map(next,_17e));
1201}};
1202},applymap:function(fun,seq,self){
1203seq=MochiKit.Iter.iter(seq);
1204var m=MochiKit.Base;
1205return {repr:function(){
1206return "applymap(...)";
1207},toString:m.forwardCall("repr"),next:function(){
1208return fun.apply(self,seq.next());
1209}};
1210},chain:function(p,q){
1211var self=MochiKit.Iter;
1212var m=MochiKit.Base;
1213if(arguments.length==1){
1214return self.iter(arguments[0]);
1215}
1216var _189=m.map(self.iter,arguments);
1217return {repr:function(){
1218return "chain(...)";
1219},toString:m.forwardCall("repr"),next:function(){
1220while(_189.length>1){
1221try{
1222return _189[0].next();
1223}
1224catch(e){
1225if(e!=self.StopIteration){
1226throw e;
1227}
1228_189.shift();
1229}
1230}
1231if(_189.length==1){
1232var arg=_189.shift();
1233this.next=m.bind("next",arg);
1234return this.next();
1235}
1236throw self.StopIteration;
1237}};
1238},takewhile:function(pred,seq){
1239var self=MochiKit.Iter;
1240seq=self.iter(seq);
1241return {repr:function(){
1242return "takewhile(...)";
1243},toString:MochiKit.Base.forwardCall("repr"),next:function(){
1244var rval=seq.next();
1245if(!pred(rval)){
1246this.next=function(){
1247throw self.StopIteration;
1248};
1249this.next();
1250}
1251return rval;
1252}};
1253},dropwhile:function(pred,seq){
1254seq=MochiKit.Iter.iter(seq);
1255var m=MochiKit.Base;
1256var bind=m.bind;
1257return {"repr":function(){
1258return "dropwhile(...)";
1259},"toString":m.forwardCall("repr"),"next":function(){
1260while(true){
1261var rval=seq.next();
1262if(!pred(rval)){
1263break;
1264}
1265}
1266this.next=bind("next",seq);
1267return rval;
1268}};
1269},_tee:function(_194,sync,_196){
1270sync.pos[_194]=-1;
1271var m=MochiKit.Base;
1272var _198=m.listMin;
1273return {repr:function(){
1274return "tee("+_194+", ...)";
1275},toString:m.forwardCall("repr"),next:function(){
1276var rval;
1277var i=sync.pos[_194];
1278if(i==sync.max){
1279rval=_196.next();
1280sync.deque.push(rval);
1281sync.max+=1;
1282sync.pos[_194]+=1;
1283}else{
1284rval=sync.deque[i-sync.min];
1285sync.pos[_194]+=1;
1286if(i==sync.min&&_198(sync.pos)!=sync.min){
1287sync.min+=1;
1288sync.deque.shift();
1289}
1290}
1291return rval;
1292}};
1293},tee:function(_19b,n){
1294var rval=[];
1295var sync={"pos":[],"deque":[],"max":-1,"min":-1};
1296if(arguments.length==1||typeof (n)=="undefined"||n===null){
1297n=2;
1298}
1299var self=MochiKit.Iter;
1300_19b=self.iter(_19b);
1301var _tee=self._tee;
1302for(var i=0;i<n;i++){
1303rval.push(_tee(i,sync,_19b));
1304}
1305return rval;
1306},list:function(_1a2){
1307var rval;
1308if(_1a2 instanceof Array){
1309return _1a2.slice();
1310}
1311if(typeof (_1a2)=="function"&&!(_1a2 instanceof Function)&&typeof (_1a2.length)=="number"){
1312rval=[];
1313for(var i=0;i<_1a2.length;i++){
1314rval.push(_1a2[i]);
1315}
1316return rval;
1317}
1318var self=MochiKit.Iter;
1319_1a2=self.iter(_1a2);
1320var rval=[];
1321try{
1322while(true){
1323rval.push(_1a2.next());
1324}
1325}
1326catch(e){
1327if(e!=self.StopIteration){
1328throw e;
1329}
1330return rval;
1331}
1332return undefined;
1333},reduce:function(fn,_1a7,_1a8){
1334var i=0;
1335var x=_1a8;
1336var self=MochiKit.Iter;
1337_1a7=self.iter(_1a7);
1338if(arguments.length<3){
1339try{
1340x=_1a7.next();
1341}
1342catch(e){
1343if(e==self.StopIteration){
1344e=new TypeError("reduce() of empty sequence with no initial value");
1345}
1346throw e;
1347}
1348i++;
1349}
1350try{
1351while(true){
1352x=fn(x,_1a7.next());
1353}
1354}
1355catch(e){
1356if(e!=self.StopIteration){
1357throw e;
1358}
1359}
1360return x;
1361},range:function(){
1362var _1ac=0;
1363var stop=0;
1364var step=1;
1365if(arguments.length==1){
1366stop=arguments[0];
1367}else{
1368if(arguments.length==2){
1369_1ac=arguments[0];
1370stop=arguments[1];
1371}else{
1372if(arguments.length==3){
1373_1ac=arguments[0];
1374stop=arguments[1];
1375step=arguments[2];
1376}else{
1377throw new TypeError("range() takes 1, 2, or 3 arguments!");
1378}
1379}
1380}
1381if(step===0){
1382throw new TypeError("range() step must not be 0");
1383}
1384return {next:function(){
1385if((step>0&&_1ac>=stop)||(step<0&&_1ac<=stop)){
1386throw MochiKit.Iter.StopIteration;
1387}
1388var rval=_1ac;
1389_1ac+=step;
1390return rval;
1391},repr:function(){
1392return "range("+[_1ac,stop,step].join(", ")+")";
1393},toString:MochiKit.Base.forwardCall("repr")};
1394},sum:function(_1b0,_1b1){
1395if(typeof (_1b1)=="undefined"||_1b1===null){
1396_1b1=0;
1397}
1398var x=_1b1;
1399var self=MochiKit.Iter;
1400_1b0=self.iter(_1b0);
1401try{
1402while(true){
1403x+=_1b0.next();
1404}
1405}
1406catch(e){
1407if(e!=self.StopIteration){
1408throw e;
1409}
1410}
1411return x;
1412},exhaust:function(_1b4){
1413var self=MochiKit.Iter;
1414_1b4=self.iter(_1b4);
1415try{
1416while(true){
1417_1b4.next();
1418}
1419}
1420catch(e){
1421if(e!=self.StopIteration){
1422throw e;
1423}
1424}
1425},forEach:function(_1b6,func,self){
1426var m=MochiKit.Base;
1427if(arguments.length>2){
1428func=m.bind(func,self);
1429}
1430if(m.isArrayLike(_1b6)){
1431try{
1432for(var i=0;i<_1b6.length;i++){
1433func(_1b6[i]);
1434}
1435}
1436catch(e){
1437if(e!=MochiKit.Iter.StopIteration){
1438throw e;
1439}
1440}
1441}else{
1442self=MochiKit.Iter;
1443self.exhaust(self.imap(func,_1b6));
1444}
1445},every:function(_1bb,func){
1446var self=MochiKit.Iter;
1447try{
1448self.ifilterfalse(func,_1bb).next();
1449return false;
1450}
1451catch(e){
1452if(e!=self.StopIteration){
1453throw e;
1454}
1455return true;
1456}
1457},sorted:function(_1be,cmp){
1458var rval=MochiKit.Iter.list(_1be);
1459if(arguments.length==1){
1460cmp=MochiKit.Base.compare;
1461}
1462rval.sort(cmp);
1463return rval;
1464},reversed:function(_1c1){
1465var rval=MochiKit.Iter.list(_1c1);
1466rval.reverse();
1467return rval;
1468},some:function(_1c3,func){
1469var self=MochiKit.Iter;
1470try{
1471self.ifilter(func,_1c3).next();
1472return true;
1473}
1474catch(e){
1475if(e!=self.StopIteration){
1476throw e;
1477}
1478return false;
1479}
1480},iextend:function(lst,_1c7){
1481if(MochiKit.Base.isArrayLike(_1c7)){
1482for(var i=0;i<_1c7.length;i++){
1483lst.push(_1c7[i]);
1484}
1485}else{
1486var self=MochiKit.Iter;
1487_1c7=self.iter(_1c7);
1488try{
1489while(true){
1490lst.push(_1c7.next());
1491}
1492}
1493catch(e){
1494if(e!=self.StopIteration){
1495throw e;
1496}
1497}
1498}
1499return lst;
1500},groupby:function(_1ca,_1cb){
1501var m=MochiKit.Base;
1502var self=MochiKit.Iter;
1503if(arguments.length<2){
1504_1cb=m.operator.identity;
1505}
1506_1ca=self.iter(_1ca);
1507var pk=undefined;
1508var k=undefined;
1509var v;
1510function fetch(){
1511v=_1ca.next();
1512k=_1cb(v);
1513}
1514function eat(){
1515var ret=v;
1516v=undefined;
1517return ret;
1518}
1519var _1d2=true;
1520var _1d3=m.compare;
1521return {repr:function(){
1522return "groupby(...)";
1523},next:function(){
1524while(_1d3(k,pk)===0){
1525fetch();
1526if(_1d2){
1527_1d2=false;
1528break;
1529}
1530}
1531pk=k;
1532return [k,{next:function(){
1533if(v==undefined){
1534fetch();
1535}
1536if(_1d3(k,pk)!==0){
1537throw self.StopIteration;
1538}
1539return eat();
1540}}];
1541}};
1542},groupby_as_array:function(_1d4,_1d5){
1543var m=MochiKit.Base;
1544var self=MochiKit.Iter;
1545if(arguments.length<2){
1546_1d5=m.operator.identity;
1547}
1548_1d4=self.iter(_1d4);
1549var _1d8=[];
1550var _1d9=true;
1551var _1da;
1552var _1db=m.compare;
1553while(true){
1554try{
1555var _1dc=_1d4.next();
1556var key=_1d5(_1dc);
1557}
1558catch(e){
1559if(e==self.StopIteration){
1560break;
1561}
1562throw e;
1563}
1564if(_1d9||_1db(key,_1da)!==0){
1565var _1de=[];
1566_1d8.push([key,_1de]);
1567}
1568_1de.push(_1dc);
1569_1d9=false;
1570_1da=key;
1571}
1572return _1d8;
1573},arrayLikeIter:function(_1df){
1574var i=0;
1575return {repr:function(){
1576return "arrayLikeIter(...)";
1577},toString:MochiKit.Base.forwardCall("repr"),next:function(){
1578if(i>=_1df.length){
1579throw MochiKit.Iter.StopIteration;
1580}
1581return _1df[i++];
1582}};
1583},hasIterateNext:function(_1e1){
1584return (_1e1&&typeof (_1e1.iterateNext)=="function");
1585},iterateNextIter:function(_1e2){
1586return {repr:function(){
1587return "iterateNextIter(...)";
1588},toString:MochiKit.Base.forwardCall("repr"),next:function(){
1589var rval=_1e2.iterateNext();
1590if(rval===null||rval===undefined){
1591throw MochiKit.Iter.StopIteration;
1592}
1593return rval;
1594}};
1595}});
1596MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter",];
1597MochiKit.Iter.EXPORT=["StopIteration","registerIteratorFactory","iter","count","cycle","repeat","next","izip","ifilter","ifilterfalse","islice","imap","applymap","chain","takewhile","dropwhile","tee","list","reduce","range","sum","exhaust","forEach","every","sorted","reversed","some","iextend","groupby","groupby_as_array"];
1598MochiKit.Iter.__new__=function(){
1599var m=MochiKit.Base;
1600if(typeof (StopIteration)!="undefined"){
1601this.StopIteration=StopIteration;
1602}else{
1603this.StopIteration=new m.NamedError("StopIteration");
1604}
1605this.iteratorRegistry=new m.AdapterRegistry();
1606this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter);
1607this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter);
1608this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
1609m.nameFunctions(this);
1610};
1611MochiKit.Iter.__new__();
1612if(MochiKit.__export__){
1613reduce=MochiKit.Iter.reduce;
1614}
1615MochiKit.Base._exportSymbols(this,MochiKit.Iter);
1616if(typeof (dojo)!="undefined"){
1617dojo.provide("MochiKit.Logging");
1618dojo.require("MochiKit.Base");
1619}
1620if(typeof (JSAN)!="undefined"){
1621JSAN.use("MochiKit.Base",[]);
1622}
1623try{
1624if(typeof (MochiKit.Base)=="undefined"){
1625throw "";
1626}
1627}
1628catch(e){
1629throw "MochiKit.Logging depends on MochiKit.Base!";
1630}
1631if(typeof (MochiKit.Logging)=="undefined"){
1632MochiKit.Logging={};
1633}
1634MochiKit.Logging.NAME="MochiKit.Logging";
1635MochiKit.Logging.VERSION="1.4";
1636MochiKit.Logging.__repr__=function(){
1637return "["+this.NAME+" "+this.VERSION+"]";
1638};
1639MochiKit.Logging.toString=function(){
1640return this.__repr__();
1641};
1642MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];
1643MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"];
1644MochiKit.Logging.LogMessage=function(num,_1e6,info){
1645this.num=num;
1646this.level=_1e6;
1647this.info=info;
1648this.timestamp=new Date();
1649};
1650MochiKit.Logging.LogMessage.prototype={repr:function(){
1651var m=MochiKit.Base;
1652return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")";
1653},toString:MochiKit.Base.forwardCall("repr")};
1654MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1e9){
1655var self=MochiKit.Logging;
1656if(typeof (_1e9)=="string"){
1657_1e9=self.LogLevel[_1e9];
1658}
1659return function(msg){
1660var _1ec=msg.level;
1661if(typeof (_1ec)=="string"){
1662_1ec=self.LogLevel[_1ec];
1663}
1664return _1ec>=_1e9;
1665};
1666},isLogMessage:function(){
1667var _1ed=MochiKit.Logging.LogMessage;
1668for(var i=0;i<arguments.length;i++){
1669if(!(arguments[i] instanceof _1ed)){
1670return false;
1671}
1672}
1673return true;
1674},compareLogMessage:function(a,b){
1675return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]);
1676},alertListener:function(msg){
1677alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" "));
1678}});
1679MochiKit.Logging.Logger=function(_1f2){
1680this.counter=0;
1681if(typeof (_1f2)=="undefined"||_1f2===null){
1682_1f2=-1;
1683}
1684this.maxSize=_1f2;
1685this._messages=[];
1686this.listeners={};
1687this.useNativeConsole=false;
1688};
1689MochiKit.Logging.Logger.prototype={clear:function(){
1690this._messages.splice(0,this._messages.length);
1691},logToConsole:function(msg){
1692if(typeof (window)!="undefined"&&window.console&&window.console.log){
1693window.console.log(msg.replace(/%/g,"\uff05"));
1694}else{
1695if(typeof (opera)!="undefined"&&opera.postError){
1696opera.postError(msg);
1697}else{
1698if(typeof (printfire)=="function"){
1699printfire(msg);
1700}else{
1701if(typeof (Debug)!="undefined"&&Debug.writeln){
1702Debug.writeln(msg);
1703}else{
1704if(typeof (debug)!="undefined"&&debug.trace){
1705debug.trace(msg);
1706}
1707}
1708}
1709}
1710}
1711},dispatchListeners:function(msg){
1712for(var k in this.listeners){
1713var pair=this.listeners[k];
1714if(pair.ident!=k||(pair[0]&&!pair[0](msg))){
1715continue;
1716}
1717pair[1](msg);
1718}
1719},addListener:function(_1f7,_1f8,_1f9){
1720if(typeof (_1f8)=="string"){
1721_1f8=MochiKit.Logging.logLevelAtLeast(_1f8);
1722}
1723var _1fa=[_1f8,_1f9];
1724_1fa.ident=_1f7;
1725this.listeners[_1f7]=_1fa;
1726},removeListener:function(_1fb){
1727delete this.listeners[_1fb];
1728},baseLog:function(_1fc,_1fd){
1729var msg=new MochiKit.Logging.LogMessage(this.counter,_1fc,MochiKit.Base.extend(null,arguments,1));
1730this._messages.push(msg);
1731this.dispatchListeners(msg);
1732if(this.useNativeConsole){
1733this.logToConsole(msg.level+": "+msg.info.join(" "));
1734}
1735this.counter+=1;
1736while(this.maxSize>=0&&this._messages.length>this.maxSize){
1737this._messages.shift();
1738}
1739},getMessages:function(_1ff){
1740var _200=0;
1741if(!(typeof (_1ff)=="undefined"||_1ff===null)){
1742_200=Math.max(0,this._messages.length-_1ff);
1743}
1744return this._messages.slice(_200);
1745},getMessageText:function(_201){
1746if(typeof (_201)=="undefined"||_201===null){
1747_201=30;
1748}
1749var _202=this.getMessages(_201);
1750if(_202.length){
1751var lst=map(function(m){
1752return "\n ["+m.num+"] "+m.level+": "+m.info.join(" ");
1753},_202);
1754lst.unshift("LAST "+_202.length+" MESSAGES:");
1755return lst.join("");
1756}
1757return "";
1758},debuggingBookmarklet:function(_205){
1759if(typeof (MochiKit.LoggingPane)=="undefined"){
1760alert(this.getMessageText());
1761}else{
1762MochiKit.LoggingPane.createLoggingPane(_205||false);
1763}
1764}};
1765MochiKit.Logging.__new__=function(){
1766this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10};
1767var m=MochiKit.Base;
1768m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage);
1769var _207=m.partial;
1770var _208=this.Logger;
1771var _209=_208.prototype.baseLog;
1772m.update(this.Logger.prototype,{debug:_207(_209,"DEBUG"),log:_207(_209,"INFO"),error:_207(_209,"ERROR"),fatal:_207(_209,"FATAL"),warning:_207(_209,"WARNING")});
1773var self=this;
1774var _20b=function(name){
1775return function(){
1776self.logger[name].apply(self.logger,arguments);
1777};
1778};
1779this.log=_20b("log");
1780this.logError=_20b("error");
1781this.logDebug=_20b("debug");
1782this.logFatal=_20b("fatal");
1783this.logWarning=_20b("warning");
1784this.logger=new _208();
1785this.logger.useNativeConsole=true;
1786this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
1787m.nameFunctions(this);
1788};
1789if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){
1790printfire=function(){
1791printfire.args=arguments;
1792var ev=document.createEvent("Events");
1793ev.initEvent("printfire",false,true);
1794dispatchEvent(ev);
1795};
1796}
1797MochiKit.Logging.__new__();
1798MochiKit.Base._exportSymbols(this,MochiKit.Logging);
1799if(typeof (dojo)!="undefined"){
1800dojo.provide("MochiKit.DateTime");
1801}
1802if(typeof (MochiKit)=="undefined"){
1803MochiKit={};
1804}
1805if(typeof (MochiKit.DateTime)=="undefined"){
1806MochiKit.DateTime={};
1807}
1808MochiKit.DateTime.NAME="MochiKit.DateTime";
1809MochiKit.DateTime.VERSION="1.4";
1810MochiKit.DateTime.__repr__=function(){
1811return "["+this.NAME+" "+this.VERSION+"]";
1812};
1813MochiKit.DateTime.toString=function(){
1814return this.__repr__();
1815};
1816MochiKit.DateTime.isoDate=function(str){
1817str=str+"";
1818if(typeof (str)!="string"||str.length===0){
1819return null;
1820}
1821var iso=str.split("-");
1822if(iso.length===0){
1823return null;
1824}
1825return new Date(iso[0],iso[1]-1,iso[2]);
1826};
1827MochiKit.DateTime._isoRegexp=/(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;
1828MochiKit.DateTime.isoTimestamp=function(str){
1829str=str+"";
1830if(typeof (str)!="string"||str.length===0){
1831return null;
1832}
1833var res=str.match(MochiKit.DateTime._isoRegexp);
1834if(typeof (res)=="undefined"||res===null){
1835return null;
1836}
1837var year,_213,day,hour,min,sec,msec;
1838year=parseInt(res[1],10);
1839if(typeof (res[2])=="undefined"||res[2]===""){
1840return new Date(year);
1841}
1842_213=parseInt(res[2],10)-1;
1843day=parseInt(res[3],10);
1844if(typeof (res[4])=="undefined"||res[4]===""){
1845return new Date(year,_213,day);
1846}
1847hour=parseInt(res[4],10);
1848min=parseInt(res[5],10);
1849sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0;
1850if(typeof (res[7])!="undefined"&&res[7]!==""){
1851msec=Math.round(1000*parseFloat("0."+res[7]));
1852}else{
1853msec=0;
1854}
1855if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){
1856return new Date(year,_213,day,hour,min,sec,msec);
1857}
1858var ofs;
1859if(typeof (res[9])!="undefined"&&res[9]!==""){
1860ofs=parseInt(res[10],10)*3600000;
1861if(typeof (res[11])!="undefined"&&res[11]!==""){
1862ofs+=parseInt(res[11],10)*60000;
1863}
1864if(res[9]=="-"){
1865ofs=-ofs;
1866}
1867}else{
1868ofs=0;
1869}
1870return new Date(Date.UTC(year,_213,day,hour,min,sec,msec)-ofs);
1871};
1872MochiKit.DateTime.toISOTime=function(date,_21b){
1873if(typeof (date)=="undefined"||date===null){
1874return null;
1875}
1876var hh=date.getHours();
1877var mm=date.getMinutes();
1878var ss=date.getSeconds();
1879var lst=[((_21b&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)];
1880return lst.join(":");
1881};
1882MochiKit.DateTime.toISOTimestamp=function(date,_221){
1883if(typeof (date)=="undefined"||date===null){
1884return null;
1885}
1886var sep=_221?"T":" ";
1887var foot=_221?"Z":"";
1888if(_221){
1889date=new Date(date.getTime()+(date.getTimezoneOffset()*60000));
1890}
1891return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_221)+foot;
1892};
1893MochiKit.DateTime.toISODate=function(date){
1894if(typeof (date)=="undefined"||date===null){
1895return null;
1896}
1897var _225=MochiKit.DateTime._padTwo;
1898return [date.getFullYear(),_225(date.getMonth()+1),_225(date.getDate())].join("-");
1899};
1900MochiKit.DateTime.americanDate=function(d){
1901d=d+"";
1902if(typeof (d)!="string"||d.length===0){
1903return null;
1904}
1905var a=d.split("/");
1906return new Date(a[2],a[0]-1,a[1]);
1907};
1908MochiKit.DateTime._padTwo=function(n){
1909return (n>9)?n:"0"+n;
1910};
1911MochiKit.DateTime.toPaddedAmericanDate=function(d){
1912if(typeof (d)=="undefined"||d===null){
1913return null;
1914}
1915var _22a=MochiKit.DateTime._padTwo;
1916return [_22a(d.getMonth()+1),_22a(d.getDate()),d.getFullYear()].join("/");
1917};
1918MochiKit.DateTime.toAmericanDate=function(d){
1919if(typeof (d)=="undefined"||d===null){
1920return null;
1921}
1922return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/");
1923};
1924MochiKit.DateTime.EXPORT=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"];
1925MochiKit.DateTime.EXPORT_OK=[];
1926MochiKit.DateTime.EXPORT_TAGS={":common":MochiKit.DateTime.EXPORT,":all":MochiKit.DateTime.EXPORT};
1927MochiKit.DateTime.__new__=function(){
1928var base=this.NAME+".";
1929for(var k in this){
1930var o=this[k];
1931if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
1932try{
1933o.NAME=base+k;
1934}
1935catch(e){
1936}
1937}
1938}
1939};
1940MochiKit.DateTime.__new__();
1941if(typeof (MochiKit.Base)!="undefined"){
1942MochiKit.Base._exportSymbols(this,MochiKit.DateTime);
1943}else{
1944(function(_22f,_230){
1945if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
1946var all=_230.EXPORT_TAGS[":all"];
1947for(var i=0;i<all.length;i++){
1948_22f[all[i]]=_230[all[i]];
1949}
1950}
1951})(this,MochiKit.DateTime);
1952}
1953if(typeof (dojo)!="undefined"){
1954dojo.provide("MochiKit.Format");
1955}
1956if(typeof (MochiKit)=="undefined"){
1957MochiKit={};
1958}
1959if(typeof (MochiKit.Format)=="undefined"){
1960MochiKit.Format={};
1961}
1962MochiKit.Format.NAME="MochiKit.Format";
1963MochiKit.Format.VERSION="1.4";
1964MochiKit.Format.__repr__=function(){
1965return "["+this.NAME+" "+this.VERSION+"]";
1966};
1967MochiKit.Format.toString=function(){
1968return this.__repr__();
1969};
1970MochiKit.Format._numberFormatter=function(_233,_234,_235,_236,_237,_238,_239,_23a,_23b){
1971return function(num){
1972num=parseFloat(num);
1973if(typeof (num)=="undefined"||num===null||isNaN(num)){
1974return _233;
1975}
1976var _23d=_234;
1977var _23e=_235;
1978if(num<0){
1979num=-num;
1980}else{
1981_23d=_23d.replace(/-/,"");
1982}
1983var me=arguments.callee;
1984var fmt=MochiKit.Format.formatLocale(_236);
1985if(_237){
1986num=num*100;
1987_23e=fmt.percent+_23e;
1988}
1989num=MochiKit.Format.roundToFixed(num,_238);
1990var _241=num.split(/\./);
1991var _242=_241[0];
1992var frac=(_241.length==1)?"":_241[1];
1993var res="";
1994while(_242.length<_239){
1995_242="0"+_242;
1996}
1997if(_23a){
1998while(_242.length>_23a){
1999var i=_242.length-_23a;
2000res=fmt.separator+_242.substring(i,_242.length)+res;
2001_242=_242.substring(0,i);
2002}
2003}
2004res=_242+res;
2005if(_238>0){
2006while(frac.length<_23b){
2007frac=frac+"0";
2008}
2009res=res+fmt.decimal+frac;
2010}
2011return _23d+res+_23e;
2012};
2013};
2014MochiKit.Format.numberFormatter=function(_246,_247,_248){
2015if(typeof (_247)=="undefined"){
2016_247="";
2017}
2018var _249=_246.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
2019if(!_249){
2020throw TypeError("Invalid pattern");
2021}
2022var _24a=_246.substr(0,_249.index);
2023var _24b=_246.substr(_249.index+_249[0].length);
2024if(_24a.search(/-/)==-1){
2025_24a=_24a+"-";
2026}
2027var _24c=_249[1];
2028var frac=(typeof (_249[2])=="string"&&_249[2]!="")?_249[2]:"";
2029var _24e=(typeof (_249[3])=="string"&&_249[3]!="");
2030var tmp=_24c.split(/,/);
2031var _250;
2032if(typeof (_248)=="undefined"){
2033_248="default";
2034}
2035if(tmp.length==1){
2036_250=null;
2037}else{
2038_250=tmp[1].length;
2039}
2040var _251=_24c.length-_24c.replace(/0/g,"").length;
2041var _252=frac.length-frac.replace(/0/g,"").length;
2042var _253=frac.length;
2043var rval=MochiKit.Format._numberFormatter(_247,_24a,_24b,_248,_24e,_253,_251,_250,_252);
2044var m=MochiKit.Base;
2045if(m){
2046var fn=arguments.callee;
2047var args=m.concat(arguments);
2048rval.repr=function(){
2049return [self.NAME,"(",map(m.repr,args).join(", "),")"].join("");
2050};
2051}
2052return rval;
2053};
2054MochiKit.Format.formatLocale=function(_258){
2055if(typeof (_258)=="undefined"||_258===null){
2056_258="default";
2057}
2058if(typeof (_258)=="string"){
2059var rval=MochiKit.Format.LOCALE[_258];
2060if(typeof (rval)=="string"){
2061rval=arguments.callee(rval);
2062MochiKit.Format.LOCALE[_258]=rval;
2063}
2064return rval;
2065}else{
2066return _258;
2067}
2068};
2069MochiKit.Format.twoDigitAverage=function(_25a,_25b){
2070if(_25b){
2071var res=_25a/_25b;
2072if(!isNaN(res)){
2073return MochiKit.Format.twoDigitFloat(_25a/_25b);
2074}
2075}
2076return "0";
2077};
2078MochiKit.Format.twoDigitFloat=function(_25d){
2079var sign=(_25d<0?"-":"");
2080var s=Math.floor(Math.abs(_25d)*100).toString();
2081if(s=="0"){
2082return s;
2083}
2084if(s.length<3){
2085while(s.charAt(s.length-1)=="0"){
2086s=s.substring(0,s.length-1);
2087}
2088return sign+"0."+s;
2089}
2090var head=sign+s.substring(0,s.length-2);
2091var tail=s.substring(s.length-2,s.length);
2092if(tail=="00"){
2093return head;
2094}else{
2095if(tail.charAt(1)=="0"){
2096return head+"."+tail.charAt(0);
2097}else{
2098return head+"."+tail;
2099}
2100}
2101};
2102MochiKit.Format.lstrip=function(str,_263){
2103str=str+"";
2104if(typeof (str)!="string"){
2105return null;
2106}
2107if(!_263){
2108return str.replace(/^\s+/,"");
2109}else{
2110return str.replace(new RegExp("^["+_263+"]+"),"");
2111}
2112};
2113MochiKit.Format.rstrip=function(str,_265){
2114str=str+"";
2115if(typeof (str)!="string"){
2116return null;
2117}
2118if(!_265){
2119return str.replace(/\s+$/,"");
2120}else{
2121return str.replace(new RegExp("["+_265+"]+$"),"");
2122}
2123};
2124MochiKit.Format.strip=function(str,_267){
2125var self=MochiKit.Format;
2126return self.rstrip(self.lstrip(str,_267),_267);
2127};
2128MochiKit.Format.truncToFixed=function(_269,_26a){
2129_269=Math.floor(_269*Math.pow(10,_26a));
2130var res=(_269*Math.pow(10,-_26a)).toFixed(_26a);
2131if(res.charAt(0)=="."){
2132res="0"+res;
2133}
2134return res;
2135};
2136MochiKit.Format.roundToFixed=function(_26c,_26d){
2137return MochiKit.Format.truncToFixed(_26c+0.5*Math.pow(10,-_26d),_26d);
2138};
2139MochiKit.Format.percentFormat=function(_26e){
2140return MochiKit.Format.twoDigitFloat(100*_26e)+"%";
2141};
2142MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"];
2143MochiKit.Format.LOCALE={en_US:{separator:",",decimal:".",percent:"%"},de_DE:{separator:".",decimal:",",percent:"%"},fr_FR:{separator:" ",decimal:",",percent:"%"},"default":"en_US"};
2144MochiKit.Format.EXPORT_OK=[];
2145MochiKit.Format.EXPORT_TAGS={":all":MochiKit.Format.EXPORT,":common":MochiKit.Format.EXPORT};
2146MochiKit.Format.__new__=function(){
2147var base=this.NAME+".";
2148var k,v,o;
2149for(k in this.LOCALE){
2150o=this.LOCALE[k];
2151if(typeof (o)=="object"){
2152o.repr=function(){
2153return this.NAME;
2154};
2155o.NAME=base+"LOCALE."+k;
2156}
2157}
2158for(k in this){
2159o=this[k];
2160if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
2161try{
2162o.NAME=base+k;
2163}
2164catch(e){
2165}
2166}
2167}
2168};
2169MochiKit.Format.__new__();
2170if(typeof (MochiKit.Base)!="undefined"){
2171MochiKit.Base._exportSymbols(this,MochiKit.Format);
2172}else{
2173(function(_273,_274){
2174if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
2175var all=_274.EXPORT_TAGS[":all"];
2176for(var i=0;i<all.length;i++){
2177_273[all[i]]=_274[all[i]];
2178}
2179}
2180})(this,MochiKit.Format);
2181}
2182if(typeof (dojo)!="undefined"){
2183dojo.provide("MochiKit.Async");
2184dojo.require("MochiKit.Base");
2185}
2186if(typeof (JSAN)!="undefined"){
2187JSAN.use("MochiKit.Base",[]);
2188}
2189try{
2190if(typeof (MochiKit.Base)=="undefined"){
2191throw "";
2192}
2193}
2194catch(e){
2195throw "MochiKit.Async depends on MochiKit.Base!";
2196}
2197if(typeof (MochiKit.Async)=="undefined"){
2198MochiKit.Async={};
2199}
2200MochiKit.Async.NAME="MochiKit.Async";
2201MochiKit.Async.VERSION="1.4";
2202MochiKit.Async.__repr__=function(){
2203return "["+this.NAME+" "+this.VERSION+"]";
2204};
2205MochiKit.Async.toString=function(){
2206return this.__repr__();
2207};
2208MochiKit.Async.Deferred=function(_277){
2209this.chain=[];
2210this.id=this._nextId();
2211this.fired=-1;
2212this.paused=0;
2213this.results=[null,null];
2214this.canceller=_277;
2215this.silentlyCancelled=false;
2216this.chained=false;
2217};
2218MochiKit.Async.Deferred.prototype={repr:function(){
2219var _278;
2220if(this.fired==-1){
2221_278="unfired";
2222}else{
2223if(this.fired===0){
2224_278="success";
2225}else{
2226_278="error";
2227}
2228}
2229return "Deferred("+this.id+", "+_278+")";
2230},toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){
2231var self=MochiKit.Async;
2232if(this.fired==-1){
2233if(this.canceller){
2234this.canceller(this);
2235}else{
2236this.silentlyCancelled=true;
2237}
2238if(this.fired==-1){
2239this.errback(new self.CancelledError(this));
2240}
2241}else{
2242if((this.fired===0)&&(this.results[0] instanceof self.Deferred)){
2243this.results[0].cancel();
2244}
2245}
2246},_resback:function(res){
2247this.fired=((res instanceof Error)?1:0);
2248this.results[this.fired]=res;
2249this._fire();
2250},_check:function(){
2251if(this.fired!=-1){
2252if(!this.silentlyCancelled){
2253throw new MochiKit.Async.AlreadyCalledError(this);
2254}
2255this.silentlyCancelled=false;
2256return;
2257}
2258},callback:function(res){
2259this._check();
2260if(res instanceof MochiKit.Async.Deferred){
2261throw new Error("Deferred instances can only be chained if they are the result of a callback");
2262}
2263this._resback(res);
2264},errback:function(res){
2265this._check();
2266var self=MochiKit.Async;
2267if(res instanceof self.Deferred){
2268throw new Error("Deferred instances can only be chained if they are the result of a callback");
2269}
2270if(!(res instanceof Error)){
2271res=new self.GenericError(res);
2272}
2273this._resback(res);
2274},addBoth:function(fn){
2275if(arguments.length>1){
2276fn=MochiKit.Base.partial.apply(null,arguments);
2277}
2278return this.addCallbacks(fn,fn);
2279},addCallback:function(fn){
2280if(arguments.length>1){
2281fn=MochiKit.Base.partial.apply(null,arguments);
2282}
2283return this.addCallbacks(fn,null);
2284},addErrback:function(fn){
2285if(arguments.length>1){
2286fn=MochiKit.Base.partial.apply(null,arguments);
2287}
2288return this.addCallbacks(null,fn);
2289},addCallbacks:function(cb,eb){
2290if(this.chained){
2291throw new Error("Chained Deferreds can not be re-used");
2292}
2293this.chain.push([cb,eb]);
2294if(this.fired>=0){
2295this._fire();
2296}
2297return this;
2298},_fire:function(){
2299var _283=this.chain;
2300var _284=this.fired;
2301var res=this.results[_284];
2302var self=this;
2303var cb=null;
2304while(_283.length>0&&this.paused===0){
2305var pair=_283.shift();
2306var f=pair[_284];
2307if(f===null){
2308continue;
2309}
2310try{
2311res=f(res);
2312_284=((res instanceof Error)?1:0);
2313if(res instanceof MochiKit.Async.Deferred){
2314cb=function(res){
2315self._resback(res);
2316self.paused--;
2317if((self.paused===0)&&(self.fired>=0)){
2318self._fire();
2319}
2320};
2321this.paused++;
2322}
2323}
2324catch(err){
2325_284=1;
2326if(!(err instanceof Error)){
2327err=new MochiKit.Async.GenericError(err);
2328}
2329res=err;
2330}
2331}
2332this.fired=_284;
2333this.results[_284]=res;
2334if(cb&&this.paused){
2335res.addBoth(cb);
2336res.chained=true;
2337}
2338}};
2339MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(){
2340return eval("("+arguments[0].responseText+")");
2341},succeed:function(_28b){
2342var d=new MochiKit.Async.Deferred();
2343d.callback.apply(d,arguments);
2344return d;
2345},fail:function(_28d){
2346var d=new MochiKit.Async.Deferred();
2347d.errback.apply(d,arguments);
2348return d;
2349},getXMLHttpRequest:function(){
2350var self=arguments.callee;
2351if(!self.XMLHttpRequest){
2352var _290=[function(){
2353return new XMLHttpRequest();
2354},function(){
2355return new ActiveXObject("Msxml2.XMLHTTP");
2356},function(){
2357return new ActiveXObject("Microsoft.XMLHTTP");
2358},function(){
2359return new ActiveXObject("Msxml2.XMLHTTP.4.0");
2360},function(){
2361throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
2362}];
2363for(var i=0;i<_290.length;i++){
2364var func=_290[i];
2365try{
2366self.XMLHttpRequest=func;
2367return func();
2368}
2369catch(e){
2370}
2371}
2372}
2373return self.XMLHttpRequest();
2374},_xhr_onreadystatechange:function(d){
2375var m=MochiKit.Base;
2376if(this.readyState==4){
2377try{
2378this.onreadystatechange=null;
2379}
2380catch(e){
2381try{
2382this.onreadystatechange=m.noop;
2383}
2384catch(e){
2385}
2386}
2387var _295=null;
2388try{
2389_295=this.status;
2390if(!_295&&m.isNotEmpty(this.responseText)){
2391_295=304;
2392}
2393}
2394catch(e){
2395}
2396if(_295==200||_295==201||_295==204||_295==304||_295==1223){
2397d.callback(this);
2398}else{
2399var err=new MochiKit.Async.XMLHttpRequestError(this,"Request failed");
2400if(err.number){
2401d.errback(err);
2402}else{
2403d.errback(err);
2404}
2405}
2406}
2407},_xhr_canceller:function(req){
2408try{
2409req.onreadystatechange=null;
2410}
2411catch(e){
2412try{
2413req.onreadystatechange=MochiKit.Base.noop;
2414}
2415catch(e){
2416}
2417}
2418req.abort();
2419},sendXMLHttpRequest:function(req,_299){
2420if(typeof (_299)=="undefined"||_299===null){
2421_299="";
2422}
2423var m=MochiKit.Base;
2424var self=MochiKit.Async;
2425var d=new self.Deferred(m.partial(self._xhr_canceller,req));
2426try{
2427req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d);
2428req.send(_299);
2429}
2430catch(e){
2431try{
2432req.onreadystatechange=null;
2433}
2434catch(ignore){
2435}
2436d.errback(e);
2437}
2438return d;
2439},doXHR:function(url,opts){
2440var self=MochiKit.Async;
2441return self.callLater(0,self._doXHR,url,opts);
2442},_doXHR:function(url,opts){
2443var m=MochiKit.Base;
2444opts=m.update({method:"GET",sendContent:""},opts);
2445var self=MochiKit.Async;
2446var req=self.getXMLHttpRequest();
2447if(opts.queryString){
2448var qs=m.queryString(opts.queryString);
2449if(qs){
2450url+="?"+qs;
2451}
2452}
2453if("username" in opts){
2454req.open(opts.method,url,true,opts.username,opts.password);
2455}else{
2456req.open(opts.method,url,true);
2457}
2458if(req.overrideMimeType&&opts.mimeType){
2459req.overrideMimeType(opts.mimeType);
2460}
2461if(opts.headers){
2462var _2a6=opts.headers;
2463if(!m.isArrayLike(_2a6)){
2464_2a6=m.items(_2a6);
2465}
2466for(var i=0;i<_2a6.length;i++){
2467var _2a8=_2a6[i];
2468var name=_2a8[0];
2469var _2aa=_2a8[1];
2470req.setRequestHeader(name,_2aa);
2471}
2472}
2473return self.sendXMLHttpRequest(req,opts.sendContent);
2474},_buildURL:function(url){
2475if(arguments.length>1){
2476var m=MochiKit.Base;
2477var qs=m.queryString.apply(null,m.extend(null,arguments,1));
2478if(qs){
2479return url+"?"+qs;
2480}
2481}
2482return url;
2483},doSimpleXMLHttpRequest:function(url){
2484var self=MochiKit.Async;
2485url=self._buildURL.apply(self,arguments);
2486return self.doXHR(url);
2487},loadJSONDoc:function(url){
2488var self=MochiKit.Async;
2489url=self._buildURL.apply(self,arguments);
2490var d=self.doXHR(url,{"mimeType":"text/plain","headers":[["Accept","application/json"]]});
2491d=d.addCallback(self.evalJSONRequest);
2492return d;
2493},wait:function(_2b3,_2b4){
2494var d=new MochiKit.Async.Deferred();
2495var m=MochiKit.Base;
2496if(typeof (_2b4)!="undefined"){
2497d.addCallback(function(){
2498return _2b4;
2499});
2500}
2501var _2b7=setTimeout(m.bind("callback",d),Math.floor(_2b3*1000));
2502d.canceller=function(){
2503try{
2504clearTimeout(_2b7);
2505}
2506catch(e){
2507}
2508};
2509return d;
2510},callLater:function(_2b8,func){
2511var m=MochiKit.Base;
2512var _2bb=m.partial.apply(m,m.extend(null,arguments,1));
2513return MochiKit.Async.wait(_2b8).addCallback(function(res){
2514return _2bb();
2515});
2516}});
2517MochiKit.Async.DeferredLock=function(){
2518this.waiting=[];
2519this.locked=false;
2520this.id=this._nextId();
2521};
2522MochiKit.Async.DeferredLock.prototype={__class__:MochiKit.Async.DeferredLock,acquire:function(){
2523var d=new MochiKit.Async.Deferred();
2524if(this.locked){
2525this.waiting.push(d);
2526}else{
2527this.locked=true;
2528d.callback(this);
2529}
2530return d;
2531},release:function(){
2532if(!this.locked){
2533throw TypeError("Tried to release an unlocked DeferredLock");
2534}
2535this.locked=false;
2536if(this.waiting.length>0){
2537this.locked=true;
2538this.waiting.shift().callback(this);
2539}
2540},_nextId:MochiKit.Base.counter(),repr:function(){
2541var _2be;
2542if(this.locked){
2543_2be="locked, "+this.waiting.length+" waiting";
2544}else{
2545_2be="unlocked";
2546}
2547return "DeferredLock("+this.id+", "+_2be+")";
2548},toString:MochiKit.Base.forwardCall("repr")};
2549MochiKit.Async.DeferredList=function(list,_2c0,_2c1,_2c2,_2c3){
2550MochiKit.Async.Deferred.apply(this,[_2c3]);
2551this.list=list;
2552var _2c4=[];
2553this.resultList=_2c4;
2554this.finishedCount=0;
2555this.fireOnOneCallback=_2c0;
2556this.fireOnOneErrback=_2c1;
2557this.consumeErrors=_2c2;
2558var cb=MochiKit.Base.bind(this._cbDeferred,this);
2559for(var i=0;i<list.length;i++){
2560var d=list[i];
2561_2c4.push(undefined);
2562d.addCallback(cb,i,true);
2563d.addErrback(cb,i,false);
2564}
2565if(list.length===0&&!_2c0){
2566this.callback(this.resultList);
2567}
2568};
2569MochiKit.Async.DeferredList.prototype=new MochiKit.Async.Deferred();
2570MochiKit.Async.DeferredList.prototype._cbDeferred=function(_2c8,_2c9,_2ca){
2571this.resultList[_2c8]=[_2c9,_2ca];
2572this.finishedCount+=1;
2573if(this.fired==-1){
2574if(_2c9&&this.fireOnOneCallback){
2575this.callback([_2c8,_2ca]);
2576}else{
2577if(!_2c9&&this.fireOnOneErrback){
2578this.errback(_2ca);
2579}else{
2580if(this.finishedCount==this.list.length){
2581this.callback(this.resultList);
2582}
2583}
2584}
2585}
2586if(!_2c9&&this.consumeErrors){
2587_2ca=null;
2588}
2589return _2ca;
2590};
2591MochiKit.Async.gatherResults=function(_2cb){
2592var d=new MochiKit.Async.DeferredList(_2cb,false,true,false);
2593d.addCallback(function(_2cd){
2594var ret=[];
2595for(var i=0;i<_2cd.length;i++){
2596ret.push(_2cd[i][1]);
2597}
2598return ret;
2599});
2600return d;
2601};
2602MochiKit.Async.maybeDeferred=function(func){
2603var self=MochiKit.Async;
2604var _2d2;
2605try{
2606var r=func.apply(null,MochiKit.Base.extend([],arguments,1));
2607if(r instanceof self.Deferred){
2608_2d2=r;
2609}else{
2610if(r instanceof Error){
2611_2d2=self.fail(r);
2612}else{
2613_2d2=self.succeed(r);
2614}
2615}
2616}
2617catch(e){
2618_2d2=self.fail(e);
2619}
2620return _2d2;
2621};
2622MochiKit.Async.EXPORT=["AlreadyCalledError","CancelledError","BrowserComplianceError","GenericError","XMLHttpRequestError","Deferred","succeed","fail","getXMLHttpRequest","doSimpleXMLHttpRequest","loadJSONDoc","wait","callLater","sendXMLHttpRequest","DeferredLock","DeferredList","gatherResults","maybeDeferred","doXHR"];
2623MochiKit.Async.EXPORT_OK=["evalJSONRequest"];
2624MochiKit.Async.__new__=function(){
2625var m=MochiKit.Base;
2626var ne=m.partial(m._newNamedError,this);
2627ne("AlreadyCalledError",function(_2d6){
2628this.deferred=_2d6;
2629});
2630ne("CancelledError",function(_2d7){
2631this.deferred=_2d7;
2632});
2633ne("BrowserComplianceError",function(msg){
2634this.message=msg;
2635});
2636ne("GenericError",function(msg){
2637this.message=msg;
2638});
2639ne("XMLHttpRequestError",function(req,msg){
2640this.req=req;
2641this.message=msg;
2642try{
2643this.number=req.status;
2644}
2645catch(e){
2646}
2647});
2648this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
2649m.nameFunctions(this);
2650};
2651MochiKit.Async.__new__();
2652MochiKit.Base._exportSymbols(this,MochiKit.Async);
2653if(typeof (dojo)!="undefined"){
2654dojo.provide("MochiKit.DOM");
2655dojo.require("MochiKit.Base");
2656}
2657if(typeof (JSAN)!="undefined"){
2658JSAN.use("MochiKit.Base",[]);
2659}
2660try{
2661if(typeof (MochiKit.Base)=="undefined"){
2662throw "";
2663}
2664}
2665catch(e){
2666throw "MochiKit.DOM depends on MochiKit.Base!";
2667}
2668if(typeof (MochiKit.DOM)=="undefined"){
2669MochiKit.DOM={};
2670}
2671MochiKit.DOM.NAME="MochiKit.DOM";
2672MochiKit.DOM.VERSION="1.4";
2673MochiKit.DOM.__repr__=function(){
2674return "["+this.NAME+" "+this.VERSION+"]";
2675};
2676MochiKit.DOM.toString=function(){
2677return this.__repr__();
2678};
2679MochiKit.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"];
2680MochiKit.DOM.EXPORT_OK=["domConverters"];
2681MochiKit.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"]];
2682MochiKit.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);");
2683MochiKit.Base.update(MochiKit.DOM,{currentWindow:function(){
2684return MochiKit.DOM._window;
2685},currentDocument:function(){
2686return MochiKit.DOM._document;
2687},withWindow:function(win,func){
2688var self=MochiKit.DOM;
2689var _2df=self._document;
2690var _2e0=self._window;
2691var rval;
2692try{
2693self._window=win;
2694self._document=win.document;
2695rval=func();
2696}
2697catch(e){
2698self._window=_2e0;
2699self._document=_2df;
2700throw e;
2701}
2702self._window=_2e0;
2703self._document=_2df;
2704return rval;
2705},formContents:function(elem){
2706var _2e3=[];
2707var _2e4=[];
2708var m=MochiKit.Base;
2709var self=MochiKit.DOM;
2710if(typeof (elem)=="undefined"||elem===null){
2711elem=self._document.body;
2712}else{
2713elem=self.getElement(elem);
2714}
2715m.nodeWalk(elem,function(elem){
2716var name=elem.name;
2717if(m.isNotEmpty(name)){
2718var _2e9=elem.tagName.toUpperCase();
2719if(_2e9==="INPUT"&&(elem.type=="radio"||elem.type=="checkbox")&&!elem.checked){
2720return null;
2721}
2722if(_2e9==="SELECT"){
2723if(elem.type=="select-one"){
2724if(elem.selectedIndex>=0){
2725var opt=elem.options[elem.selectedIndex];
2726var v=opt.value;
2727if(!v){
2728var h=opt.outerHTML;
2729if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
2730v=opt.text;
2731}
2732}
2733_2e3.push(name);
2734_2e4.push(v);
2735return null;
2736}
2737_2e3.push(name);
2738_2e4.push("");
2739return null;
2740}else{
2741var opts=elem.options;
2742if(!opts.length){
2743_2e3.push(name);
2744_2e4.push("");
2745return null;
2746}
2747for(var i=0;i<opts.length;i++){
2748var opt=opts[i];
2749if(!opt.selected){
2750continue;
2751}
2752var v=opt.value;
2753if(!v){
2754var h=opt.outerHTML;
2755if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
2756v=opt.text;
2757}
2758}
2759_2e3.push(name);
2760_2e4.push(v);
2761}
2762return null;
2763}
2764}
2765if(_2e9==="FORM"||_2e9==="P"||_2e9==="SPAN"||_2e9==="DIV"){
2766return elem.childNodes;
2767}
2768_2e3.push(name);
2769_2e4.push(elem.value||"");
2770return null;
2771}
2772return elem.childNodes;
2773});
2774return [_2e3,_2e4];
2775},withDocument:function(doc,func){
2776var self=MochiKit.DOM;
2777var _2f2=self._document;
2778var rval;
2779try{
2780self._document=doc;
2781rval=func();
2782}
2783catch(e){
2784self._document=_2f2;
2785throw e;
2786}
2787self._document=_2f2;
2788return rval;
2789},registerDOMConverter:function(name,_2f5,wrap,_2f7){
2790MochiKit.DOM.domConverters.register(name,_2f5,wrap,_2f7);
2791},coerceToDOM:function(node,ctx){
2792var m=MochiKit.Base;
2793var im=MochiKit.Iter;
2794var self=MochiKit.DOM;
2795if(im){
2796var iter=im.iter;
2797var _2fe=im.repeat;
2798var map=m.map;
2799}
2800var _300=self.domConverters;
2801var _301=arguments.callee;
2802var _302=m.NotFound;
2803while(true){
2804if(typeof (node)=="undefined"||node===null){
2805return null;
2806}
2807if(typeof (node)=="function"&&typeof (node.length)=="number"&&!(node instanceof Function)){
2808node=im.list(node);
2809}
2810if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){
2811return node;
2812}
2813if(typeof (node)=="number"||typeof (node)=="boolean"){
2814node=node.toString();
2815}
2816if(typeof (node)=="string"){
2817return self._document.createTextNode(node);
2818}
2819if(typeof (node.__dom__)=="function"){
2820node=node.__dom__(ctx);
2821continue;
2822}
2823if(typeof (node.dom)=="function"){
2824node=node.dom(ctx);
2825continue;
2826}
2827if(typeof (node)=="function"){
2828node=node.apply(ctx,[ctx]);
2829continue;
2830}
2831if(im){
2832var _303=null;
2833try{
2834_303=iter(node);
2835}
2836catch(e){
2837}
2838if(_303){
2839return map(_301,_303,_2fe(ctx));
2840}
2841}
2842try{
2843node=_300.match(node,ctx);
2844continue;
2845}
2846catch(e){
2847if(e!=_302){
2848throw e;
2849}
2850}
2851return self._document.createTextNode(node.toString());
2852}
2853return undefined;
2854},isChildNode:function(node,_305){
2855var self=MochiKit.DOM;
2856if(typeof (node)=="string"){
2857node=self.getElement(node);
2858}
2859if(typeof (_305)=="string"){
2860_305=self.getElement(_305);
2861}
2862if(node===_305){
2863return true;
2864}
2865while(node&&node.tagName.toUpperCase()!="BODY"){
2866node=node.parentNode;
2867if(node===_305){
2868return true;
2869}
2870}
2871return false;
2872},setNodeAttribute:function(node,attr,_309){
2873var o={};
2874o[attr]=_309;
2875try{
2876return MochiKit.DOM.updateNodeAttributes(node,o);
2877}
2878catch(e){
2879}
2880return null;
2881},getNodeAttribute:function(node,attr){
2882var self=MochiKit.DOM;
2883var _30e=self.attributeArray.renames[attr];
2884node=self.getElement(node);
2885try{
2886if(_30e){
2887return node[_30e];
2888}
2889return node.getAttribute(attr);
2890}
2891catch(e){
2892}
2893return null;
2894},removeNodeAttribute:function(node,attr){
2895var self=MochiKit.DOM;
2896var _312=self.attributeArray.renames[attr];
2897node=self.getElement(node);
2898try{
2899if(_312){
2900return node[_312];
2901}
2902return node.removeAttribute(attr);
2903}
2904catch(e){
2905}
2906return null;
2907},updateNodeAttributes:function(node,_314){
2908var elem=node;
2909var self=MochiKit.DOM;
2910if(typeof (node)=="string"){
2911elem=self.getElement(node);
2912}
2913if(_314){
2914var _317=MochiKit.Base.updatetree;
2915if(self.attributeArray.compliant){
2916for(var k in _314){
2917var v=_314[k];
2918if(typeof (v)=="object"&&typeof (elem[k])=="object"){
2919if(k=="style"&&MochiKit.Style){
2920MochiKit.Style.setStyle(elem,v);
2921}else{
2922_317(elem[k],v);
2923}
2924}else{
2925if(k.substring(0,2)=="on"){
2926if(typeof (v)=="string"){
2927v=new Function(v);
2928}
2929elem[k]=v;
2930}else{
2931elem.setAttribute(k,v);
2932}
2933}
2934}
2935}else{
2936var _31a=self.attributeArray.renames;
2937for(var k in _314){
2938v=_314[k];
2939var _31b=_31a[k];
2940if(k=="style"&&typeof (v)=="string"){
2941elem.style.cssText=v;
2942}else{
2943if(typeof (_31b)=="string"){
2944elem[_31b]=v;
2945}else{
2946if(typeof (elem[k])=="object"&&typeof (v)=="object"){
2947if(k=="style"&&MochiKit.Style){
2948MochiKit.Style.setStyle(elem,v);
2949}else{
2950_317(elem[k],v);
2951}
2952}else{
2953if(k.substring(0,2)=="on"){
2954if(typeof (v)=="string"){
2955v=new Function(v);
2956}
2957elem[k]=v;
2958}else{
2959elem.setAttribute(k,v);
2960}
2961}
2962}
2963}
2964}
2965}
2966}
2967return elem;
2968},appendChildNodes:function(node){
2969var elem=node;
2970var self=MochiKit.DOM;
2971if(typeof (node)=="string"){
2972elem=self.getElement(node);
2973}
2974var _31f=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
2975var _320=MochiKit.Base.concat;
2976while(_31f.length){
2977var n=_31f.shift();
2978if(typeof (n)=="undefined"||n===null){
2979}else{
2980if(typeof (n.nodeType)=="number"){
2981elem.appendChild(n);
2982}else{
2983_31f=_320(n,_31f);
2984}
2985}
2986}
2987return elem;
2988},insertSiblingNodesBefore:function(node){
2989var elem=node;
2990var self=MochiKit.DOM;
2991if(typeof (node)=="string"){
2992elem=self.getElement(node);
2993}
2994var _325=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
2995var _326=elem.parentNode;
2996var _327=MochiKit.Base.concat;
2997while(_325.length){
2998var n=_325.shift();
2999if(typeof (n)=="undefined"||n===null){
3000}else{
3001if(typeof (n.nodeType)=="number"){
3002_326.insertBefore(n,elem);
3003}else{
3004_325=_327(n,_325);
3005}
3006}
3007}
3008return _326;
3009},insertSiblingNodesAfter:function(node){
3010var elem=node;
3011var self=MochiKit.DOM;
3012if(typeof (node)=="string"){
3013elem=self.getElement(node);
3014}
3015var _32c=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
3016if(elem.nextSibling){
3017return self.insertSiblingNodesBefore(elem.nextSibling,_32c);
3018}else{
3019return self.appendChildNodes(elem.parentNode,_32c);
3020}
3021},replaceChildNodes:function(node){
3022var elem=node;
3023var self=MochiKit.DOM;
3024if(typeof (node)=="string"){
3025elem=self.getElement(node);
3026arguments[0]=elem;
3027}
3028var _330;
3029while((_330=elem.firstChild)){
3030elem.removeChild(_330);
3031}
3032if(arguments.length<2){
3033return elem;
3034}else{
3035return self.appendChildNodes.apply(this,arguments);
3036}
3037},createDOM:function(name,_332){
3038var elem;
3039var self=MochiKit.DOM;
3040var m=MochiKit.Base;
3041if(typeof (_332)=="string"||typeof (_332)=="number"){
3042var args=m.extend([name,null],arguments,1);
3043return arguments.callee.apply(this,args);
3044}
3045if(typeof (name)=="string"){
3046var _337=self._xhtml;
3047if(_332&&!self.attributeArray.compliant){
3048var _338="";
3049if("name" in _332){
3050_338+=" name=\""+self.escapeHTML(_332.name)+"\"";
3051}
3052if(name=="input"&&"type" in _332){
3053_338+=" type=\""+self.escapeHTML(_332.type)+"\"";
3054}
3055if(_338){
3056name="<"+name+_338+">";
3057_337=false;
3058}
3059}
3060var d=self._document;
3061if(_337&&d===document){
3062elem=d.createElementNS("http://www.w3.org/1999/xhtml",name);
3063}else{
3064elem=d.createElement(name);
3065}
3066}else{
3067elem=name;
3068}
3069if(_332){
3070self.updateNodeAttributes(elem,_332);
3071}
3072if(arguments.length<=2){
3073return elem;
3074}else{
3075var args=m.extend([elem],arguments,2);
3076return self.appendChildNodes.apply(this,args);
3077}
3078},createDOMFunc:function(){
3079var m=MochiKit.Base;
3080return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments));
3081},removeElement:function(elem){
3082var e=MochiKit.DOM.getElement(elem);
3083e.parentNode.removeChild(e);
3084return e;
3085},swapDOM:function(dest,src){
3086var self=MochiKit.DOM;
3087dest=self.getElement(dest);
3088var _340=dest.parentNode;
3089if(src){
3090src=self.getElement(src);
3091_340.replaceChild(src,dest);
3092}else{
3093_340.removeChild(dest);
3094}
3095return src;
3096},getElement:function(id){
3097var self=MochiKit.DOM;
3098if(arguments.length==1){
3099return ((typeof (id)=="string")?self._document.getElementById(id):id);
3100}else{
3101return MochiKit.Base.map(self.getElement,arguments);
3102}
3103},getElementsByTagAndClassName:function(_343,_344,_345){
3104var self=MochiKit.DOM;
3105if(typeof (_343)=="undefined"||_343===null){
3106_343="*";
3107}
3108if(typeof (_345)=="undefined"||_345===null){
3109_345=self._document;
3110}
3111_345=self.getElement(_345);
3112var _347=(_345.getElementsByTagName(_343)||self._document.all);
3113if(typeof (_344)=="undefined"||_344===null){
3114return MochiKit.Base.extend(null,_347);
3115}
3116var _348=[];
3117for(var i=0;i<_347.length;i++){
3118var _34a=_347[i];
3119var cls=_34a.className;
3120if(!cls){
3121continue;
3122}
3123var _34c=cls.split(" ");
3124for(var j=0;j<_34c.length;j++){
3125if(_34c[j]==_344){
3126_348.push(_34a);
3127break;
3128}
3129}
3130}
3131return _348;
3132},_newCallStack:function(path,once){
3133var rval=function(){
3134var _351=arguments.callee.callStack;
3135for(var i=0;i<_351.length;i++){
3136if(_351[i].apply(this,arguments)===false){
3137break;
3138}
3139}
3140if(once){
3141try{
3142this[path]=null;
3143}
3144catch(e){
3145}
3146}
3147};
3148rval.callStack=[];
3149return rval;
3150},addToCallStack:function(_353,path,func,once){
3151var self=MochiKit.DOM;
3152var _358=_353[path];
3153var _359=_358;
3154if(!(typeof (_358)=="function"&&typeof (_358.callStack)=="object"&&_358.callStack!==null)){
3155_359=self._newCallStack(path,once);
3156if(typeof (_358)=="function"){
3157_359.callStack.push(_358);
3158}
3159_353[path]=_359;
3160}
3161_359.callStack.push(func);
3162},addLoadEvent:function(func){
3163var self=MochiKit.DOM;
3164self.addToCallStack(self._window,"onload",func,true);
3165},focusOnLoad:function(_35c){
3166var self=MochiKit.DOM;
3167self.addLoadEvent(function(){
3168_35c=self.getElement(_35c);
3169if(_35c){
3170_35c.focus();
3171}
3172});
3173},setElementClass:function(_35e,_35f){
3174var self=MochiKit.DOM;
3175var obj=self.getElement(_35e);
3176if(self.attributeArray.compliant){
3177obj.setAttribute("class",_35f);
3178}else{
3179obj.setAttribute("className",_35f);
3180}
3181},toggleElementClass:function(_362){
3182var self=MochiKit.DOM;
3183for(var i=1;i<arguments.length;i++){
3184var obj=self.getElement(arguments[i]);
3185if(!self.addElementClass(obj,_362)){
3186self.removeElementClass(obj,_362);
3187}
3188}
3189},addElementClass:function(_366,_367){
3190var self=MochiKit.DOM;
3191var obj=self.getElement(_366);
3192var cls=obj.className;
3193if(cls==undefined||cls.length===0){
3194self.setElementClass(obj,_367);
3195return true;
3196}
3197if(cls==_367){
3198return false;
3199}
3200var _36b=cls.split(" ");
3201for(var i=0;i<_36b.length;i++){
3202if(_36b[i]==_367){
3203return false;
3204}
3205}
3206self.setElementClass(obj,cls+" "+_367);
3207return true;
3208},removeElementClass:function(_36d,_36e){
3209var self=MochiKit.DOM;
3210var obj=self.getElement(_36d);
3211var cls=obj.className;
3212if(cls==undefined||cls.length===0){
3213return false;
3214}
3215if(cls==_36e){
3216self.setElementClass(obj,"");
3217return true;
3218}
3219var _372=cls.split(" ");
3220for(var i=0;i<_372.length;i++){
3221if(_372[i]==_36e){
3222_372.splice(i,1);
3223self.setElementClass(obj,_372.join(" "));
3224return true;
3225}
3226}
3227return false;
3228},swapElementClass:function(_374,_375,_376){
3229var obj=MochiKit.DOM.getElement(_374);
3230var res=MochiKit.DOM.removeElementClass(obj,_375);
3231if(res){
3232MochiKit.DOM.addElementClass(obj,_376);
3233}
3234return res;
3235},hasElementClass:function(_379,_37a){
3236var obj=MochiKit.DOM.getElement(_379);
3237var cls=obj.className;
3238if(!cls){
3239return false;
3240}
3241var _37d=cls.split(" ");
3242for(var i=1;i<arguments.length;i++){
3243var good=false;
3244for(var j=0;j<_37d.length;j++){
3245if(_37d[j]==arguments[i]){
3246good=true;
3247break;
3248}
3249}
3250if(!good){
3251return false;
3252}
3253}
3254return true;
3255},escapeHTML:function(s){
3256return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
3257},toHTML:function(dom){
3258return MochiKit.DOM.emitHTML(dom).join("");
3259},emitHTML:function(dom,lst){
3260if(typeof (lst)=="undefined"||lst===null){
3261lst=[];
3262}
3263var _385=[dom];
3264var self=MochiKit.DOM;
3265var _387=self.escapeHTML;
3266var _388=self.attributeArray;
3267while(_385.length){
3268dom=_385.pop();
3269if(typeof (dom)=="string"){
3270lst.push(dom);
3271}else{
3272if(dom.nodeType==1){
3273lst.push("<"+dom.tagName.toLowerCase());
3274var _389=[];
3275var _38a=_388(dom);
3276for(var i=0;i<_38a.length;i++){
3277var a=_38a[i];
3278_389.push([" ",a.name,"=\"",_387(a.value),"\""]);
3279}
3280_389.sort();
3281for(i=0;i<_389.length;i++){
3282var _38d=_389[i];
3283for(var j=0;j<_38d.length;j++){
3284lst.push(_38d[j]);
3285}
3286}
3287if(dom.hasChildNodes()){
3288lst.push(">");
3289_385.push("</"+dom.tagName.toLowerCase()+">");
3290var _38f=dom.childNodes;
3291for(i=_38f.length-1;i>=0;i--){
3292_385.push(_38f[i]);
3293}
3294}else{
3295lst.push("/>");
3296}
3297}else{
3298if(dom.nodeType==3){
3299lst.push(_387(dom.nodeValue));
3300}
3301}
3302}
3303}
3304return lst;
3305},scrapeText:function(node,_391){
3306var rval=[];
3307(function(node){
3308var cn=node.childNodes;
3309if(cn){
3310for(var i=0;i<cn.length;i++){
3311arguments.callee.call(this,cn[i]);
3312}
3313}
3314var _396=node.nodeValue;
3315if(typeof (_396)=="string"){
3316rval.push(_396);
3317}
3318})(MochiKit.DOM.getElement(node));
3319if(_391){
3320return rval;
3321}else{
3322return rval.join("");
3323}
3324},removeEmptyTextNodes:function(_397){
3325_397=MochiKit.DOM.getElement(_397);
3326for(var i=0;i<_397.childNodes.length;i++){
3327var node=_397.childNodes[i];
3328if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
3329node.parentNode.removeChild(node);
3330}
3331}
3332},makeClipping:function(_39a){
3333_39a=MochiKit.DOM.getElement(_39a);
3334var _39b=_39a.style.overflow;
3335if((MochiKit.Style.getStyle(_39a,"overflow")||"visible")!="hidden"){
3336_39a.style.overflow="hidden";
3337}
3338return _39b;
3339},undoClipping:function(_39c,_39d){
3340_39c=MochiKit.DOM.getElement(_39c);
3341if(!_39d){
3342return;
3343}
3344_39c.style.overflow=_39d;
3345},makePositioned:function(_39e){
3346_39e=MochiKit.DOM.getElement(_39e);
3347var pos=MochiKit.Style.getStyle(_39e,"position");
3348if(pos=="static"||!pos){
3349_39e.style.position="relative";
3350if(/Opera/.test(navigator.userAgent)){
3351_39e.style.top=0;
3352_39e.style.left=0;
3353}
3354}
3355},undoPositioned:function(_3a0){
3356_3a0=MochiKit.DOM.getElement(_3a0);
3357if(_3a0.style.position=="relative"){
3358_3a0.style.position=_3a0.style.top=_3a0.style.left=_3a0.style.bottom=_3a0.style.right="";
3359}
3360},getFirstElementByTagAndClassName:function(_3a1,_3a2,_3a3){
3361var self=MochiKit.DOM;
3362if(typeof (_3a1)=="undefined"||_3a1===null){
3363_3a1="*";
3364}
3365if(typeof (_3a3)=="undefined"||_3a3===null){
3366_3a3=self._document;
3367}
3368_3a3=self.getElement(_3a3);
3369var _3a5=(_3a3.getElementsByTagName(_3a1)||self._document.all);
3370if(typeof (_3a2)=="undefined"||_3a2===null){
3371return _3a5[0];
3372}
3373for(var i=0;i<_3a5.length;i++){
3374var _3a7=_3a5[i];
3375var _3a8=_3a7.className.split(" ");
3376for(var j=0;j<_3a8.length;j++){
3377if(_3a8[j]==_3a2){
3378return _3a7;
3379}
3380}
3381}
3382},getFirstParentByTagAndClassName:function(elem,_3ab,_3ac){
3383var self=MochiKit.DOM;
3384elem=self.getElement(elem);
3385if(typeof (_3ab)=="undefined"||_3ab===null){
3386_3ab="*";
3387}else{
3388_3ab=_3ab.toUpperCase();
3389}
3390if(typeof (_3ac)=="undefined"||_3ac===null){
3391_3ac=null;
3392}
3393var _3ae="";
3394var _3af="";
3395while(elem&&elem.tagName){
3396elem=elem.parentNode;
3397if(_3ab=="*"&&_3ac===null){
3398return elem;
3399}
3400_3ae=elem.className.split(" ");
3401_3af=elem.tagName.toUpperCase();
3402if(_3ac===null&&_3ab==_3af){
3403return elem;
3404}else{
3405if(_3ac!==null){
3406for(var i=0;i<_3ae.length;i++){
3407if(_3ab=="*"&&_3ae[i]==_3ac){
3408return elem;
3409}else{
3410if(_3ab==_3af&&_3ae[i]==_3ac){
3411return elem;
3412}
3413}
3414}
3415}
3416}
3417}
3418return elem;
3419},isParent:function(_3b1,_3b2){
3420if(!_3b1.parentNode||_3b1==_3b2){
3421return false;
3422}
3423if(_3b1.parentNode==_3b2){
3424return true;
3425}
3426return MochiKit.DOM.isParent(_3b1.parentNode,_3b2);
3427},__new__:function(win){
3428var m=MochiKit.Base;
3429if(typeof (document)!="undefined"){
3430this._document=document;
3431var _3b5="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
3432this._xhtml=(document.documentElement&&document.createElementNS&&document.documentElement.namespaceURI===_3b5);
3433}else{
3434if(MochiKit.MockDOM){
3435this._document=MochiKit.MockDOM.document;
3436}
3437}
3438this._window=win;
3439this.domConverters=new m.AdapterRegistry();
3440var _3b6=this._document.createElement("span");
3441var _3b7;
3442if(_3b6&&_3b6.attributes&&_3b6.attributes.length>0){
3443var _3b8=m.filter;
3444_3b7=function(node){
3445return _3b8(_3b7.ignoreAttrFilter,node.attributes);
3446};
3447_3b7.ignoreAttr={};
3448var _3ba=_3b6.attributes;
3449var _3bb=_3b7.ignoreAttr;
3450for(var i=0;i<_3ba.length;i++){
3451var a=_3ba[i];
3452_3bb[a.name]=a.value;
3453}
3454_3b7.ignoreAttrFilter=function(a){
3455return (_3b7.ignoreAttr[a.name]!=a.value);
3456};
3457_3b7.compliant=false;
3458_3b7.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
3459}else{
3460_3b7=function(node){
3461return node.attributes;
3462};
3463_3b7.compliant=true;
3464_3b7.renames={};
3465}
3466this.attributeArray=_3b7;
3467var _3c0=function(_3c1,arr){
3468var _3c3=arr[1].split(".");
3469var str="";
3470var obj={};
3471str+="if (!MochiKit."+_3c3[1]+") { throw new Error(\"";
3472str+="This function has been deprecated and depends on MochiKit.";
3473str+=_3c3[1]+".\");}";
3474str+="return MochiKit."+_3c3[1]+"."+arr[0];
3475str+=".apply(this, arguments);";
3476obj[_3c3[2]]=new Function(str);
3477MochiKit.Base.update(MochiKit[_3c1],obj);
3478};
3479for(var i;i<MochiKit.DOM.DEPRECATED.length;i++){
3480_3c0("DOM",MochiKit.DOM.DEPRECATED[i]);
3481}
3482var _3c6=this.createDOMFunc;
3483this.UL=_3c6("ul");
3484this.OL=_3c6("ol");
3485this.LI=_3c6("li");
3486this.TD=_3c6("td");
3487this.TR=_3c6("tr");
3488this.TBODY=_3c6("tbody");
3489this.THEAD=_3c6("thead");
3490this.TFOOT=_3c6("tfoot");
3491this.TABLE=_3c6("table");
3492this.TH=_3c6("th");
3493this.INPUT=_3c6("input");
3494this.SPAN=_3c6("span");
3495this.A=_3c6("a");
3496this.DIV=_3c6("div");
3497this.IMG=_3c6("img");
3498this.BUTTON=_3c6("button");
3499this.TT=_3c6("tt");
3500this.PRE=_3c6("pre");
3501this.H1=_3c6("h1");
3502this.H2=_3c6("h2");
3503this.H3=_3c6("h3");
3504this.BR=_3c6("br");
3505this.HR=_3c6("hr");
3506this.LABEL=_3c6("label");
3507this.TEXTAREA=_3c6("textarea");
3508this.FORM=_3c6("form");
3509this.P=_3c6("p");
3510this.SELECT=_3c6("select");
3511this.OPTION=_3c6("option");
3512this.OPTGROUP=_3c6("optgroup");
3513this.LEGEND=_3c6("legend");
3514this.FIELDSET=_3c6("fieldset");
3515this.STRONG=_3c6("strong");
3516this.CANVAS=_3c6("canvas");
3517this.$=this.getElement;
3518this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
3519m.nameFunctions(this);
3520}});
3521MochiKit.DOM.__new__(((typeof (window)=="undefined")?this:window));
3522if(MochiKit.__export__){
3523withWindow=MochiKit.DOM.withWindow;
3524withDocument=MochiKit.DOM.withDocument;
3525}
3526MochiKit.Base._exportSymbols(this,MochiKit.DOM);
3527if(typeof (dojo)!="undefined"){
3528dojo.provide("MochiKit.Selector");
3529dojo.require("MochiKit.Base");
3530dojo.require("MochiKit.DOM");
3531dojo.require("MochiKit.Iter");
3532}
3533if(typeof (JSAN)!="undefined"){
3534JSAN.use("MochiKit.Base",[]);
3535JSAN.use("MochiKit.DOM",[]);
3536JSAN.use("MochiKit.Iter",[]);
3537}
3538try{
3539if(typeof (MochiKit.Base)==="undefined"||typeof (MochiKit.DOM)==="undefined"||typeof (MochiKit.Iter)==="undefined"){
3540throw "";
3541}
3542}
3543catch(e){
3544throw "MochiKit.Selector depends on MochiKit.Base, MochiKit.DOM and MochiKit.Iter!";
3545}
3546if(typeof (MochiKit.Selector)=="undefined"){
3547MochiKit.Selector={};
3548}
3549MochiKit.Selector.NAME="MochiKit.Selector";
3550MochiKit.Selector.VERSION="1.4";
3551MochiKit.Selector.__repr__=function(){
3552return "["+this.NAME+" "+this.VERSION+"]";
3553};
3554MochiKit.Selector.toString=function(){
3555return this.__repr__();
3556};
3557MochiKit.Selector.EXPORT=["Selector","findChildElements","findDocElements","$$"];
3558MochiKit.Selector.EXPORT_OK=[];
3559MochiKit.Selector.Selector=function(_3c7){
3560this.params={classNames:[],pseudoClassNames:[]};
3561this.expression=_3c7.toString().replace(/(^\s+|\s+$)/g,"");
3562this.parseExpression();
3563this.compileMatcher();
3564};
3565MochiKit.Selector.Selector.prototype={__class__:MochiKit.Selector.Selector,parseExpression:function(){
3566function abort(_3c8){
3567throw "Parse error in selector: "+_3c8;
3568}
3569if(this.expression==""){
3570abort("empty expression");
3571}
3572var repr=MochiKit.Base.repr;
3573var _3ca=this.params;
3574var expr=this.expression;
3575var _3cc,_3cd,_3ce,rest;
3576while(_3cc=expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)){
3577_3ca.attributes=_3ca.attributes||[];
3578_3ca.attributes.push({name:_3cc[2],operator:_3cc[3],value:_3cc[4]||_3cc[5]||""});
3579expr=_3cc[1];
3580}
3581if(expr=="*"){
3582return this.params.wildcard=true;
3583}
3584while(_3cc=expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)){
3585_3cd=_3cc[1];
3586_3ce=_3cc[2];
3587rest=_3cc[3];
3588switch(_3cd){
3589case "#":
3590_3ca.id=_3ce;
3591break;
3592case ".":
3593_3ca.classNames.push(_3ce);
3594break;
3595case ":":
3596_3ca.pseudoClassNames.push(_3ce);
3597break;
3598case "":
3599case undefined:
3600_3ca.tagName=_3ce.toUpperCase();
3601break;
3602default:
3603abort(repr(expr));
3604}
3605expr=rest;
3606}
3607if(expr.length>0){
3608abort(repr(expr));
3609}
3610},buildMatchExpression:function(){
3611var repr=MochiKit.Base.repr;
3612var _3d1=this.params;
3613var _3d2=[];
3614var _3d3,i;
3615function childElements(_3d5){
3616return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, "+_3d5+".childNodes)";
3617}
3618if(_3d1.wildcard){
3619_3d2.push("true");
3620}
3621if(_3d3=_3d1.id){
3622_3d2.push("element.id == "+repr(_3d3));
3623}
3624if(_3d3=_3d1.tagName){
3625_3d2.push("element.tagName.toUpperCase() == "+repr(_3d3));
3626}
3627if((_3d3=_3d1.classNames).length>0){
3628for(i=0;i<_3d3.length;i++){
3629_3d2.push("MochiKit.DOM.hasElementClass(element, "+repr(_3d3[i])+")");
3630}
3631}
3632if((_3d3=_3d1.pseudoClassNames).length>0){
3633for(i=0;i<_3d3.length;i++){
3634var _3d6=_3d3[i].match(/^([^(]+)(?:\((.*)\))?$/);
3635var _3d7=_3d6[1];
3636var _3d8=_3d6[2];
3637switch(_3d7){
3638case "root":
3639_3d2.push("element.nodeType == 9 || element === element.ownerDocument.documentElement");
3640break;
3641case "nth-child":
3642case "nth-last-child":
3643case "nth-of-type":
3644case "nth-last-of-type":
3645_3d6=_3d8.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/);
3646if(!_3d6){
3647throw "Invalid argument to pseudo element nth-child: "+_3d8;
3648}
3649var a,b;
3650if(_3d6[0]=="odd"){
3651a=2;
3652b=1;
3653}else{
3654if(_3d6[0]=="even"){
3655a=2;
3656b=0;
3657}else{
3658a=_3d6[2]&&parseInt(_3d6)||null;
3659b=parseInt(_3d6[3]);
3660}
3661}
3662_3d2.push("this.nthChild(element,"+a+","+b+","+!!_3d7.match("^nth-last")+","+!!_3d7.match("of-type$")+")");
3663break;
3664case "first-child":
3665_3d2.push("this.nthChild(element, null, 1)");
3666break;
3667case "last-child":
3668_3d2.push("this.nthChild(element, null, 1, true)");
3669break;
3670case "first-of-type":
3671_3d2.push("this.nthChild(element, null, 1, false, true)");
3672break;
3673case "last-of-type":
3674_3d2.push("this.nthChild(element, null, 1, true, true)");
3675break;
3676case "only-child":
3677_3d2.push(childElements("element.parentNode")+".length == 1");
3678break;
3679case "only-of-type":
3680_3d2.push("MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, "+childElements("element.parentNode")+").length == 1");
3681break;
3682case "empty":
3683_3d2.push("element.childNodes.length == 0");
3684break;
3685case "enabled":
3686_3d2.push("(this.isUIElement(element) && element.disabled === false)");
3687break;
3688case "disabled":
3689_3d2.push("(this.isUIElement(element) && element.disabled === true)");
3690break;
3691case "checked":
3692_3d2.push("(this.isUIElement(element) && element.checked === true)");
3693break;
3694case "not":
3695var _3db=new MochiKit.Selector.Selector(_3d8);
3696_3d2.push("!( "+_3db.buildMatchExpression()+")");
3697break;
3698}
3699}
3700}
3701if(_3d3=_3d1.attributes){
3702MochiKit.Base.map(function(_3dc){
3703var _3dd="MochiKit.DOM.getNodeAttribute(element, "+repr(_3dc.name)+")";
3704var _3de=function(_3df){
3705return _3dd+".split("+repr(_3df)+")";
3706};
3707switch(_3dc.operator){
3708case "=":
3709_3d2.push(_3dd+" == "+repr(_3dc.value));
3710break;
3711case "~=":
3712_3d2.push(_3dd+" && MochiKit.Base.findValue("+_3de(" ")+", "+repr(_3dc.value)+") > -1");
3713break;
3714case "^=":
3715_3d2.push(_3dd+".substring(0, "+_3dc.value.length+") == "+repr(_3dc.value));
3716break;
3717case "$=":
3718_3d2.push(_3dd+".substring("+_3dd+".length - "+_3dc.value.length+") == "+repr(_3dc.value));
3719break;
3720case "*=":
3721_3d2.push(_3dd+".match("+repr(_3dc.value)+")");
3722break;
3723case "|=":
3724_3d2.push(_3dd+" && "+_3de("-")+"[0].toUpperCase() == "+repr(_3dc.value.toUpperCase()));
3725break;
3726case "!=":
3727_3d2.push(_3dd+" != "+repr(_3dc.value));
3728break;
3729case "":
3730case undefined:
3731_3d2.push(_3dd+" != null");
3732break;
3733default:
3734throw "Unknown operator "+_3dc.operator+" in selector";
3735}
3736},_3d3);
3737}
3738return _3d2.join(" && ");
3739},compileMatcher:function(){
3740this.match=new Function("element","if (!element.tagName) return false; return "+this.buildMatchExpression());
3741},nthChild:function(_3e0,a,b,_3e3,_3e4){
3742var _3e5=MochiKit.Base.filter(function(node){
3743return node.nodeType==1;
3744},_3e0.parentNode.childNodes);
3745if(_3e4){
3746_3e5=MochiKit.Base.filter(function(node){
3747return node.tagName==_3e0.tagName;
3748},_3e5);
3749}
3750if(_3e3){
3751_3e5=MochiKit.Iter.reversed(_3e5);
3752}
3753if(a){
3754var _3e8=MochiKit.Base.findIdentical(_3e5,_3e0);
3755return ((_3e8+1-b)/a)%1==0;
3756}else{
3757return b==MochiKit.Base.findIdentical(_3e5,_3e0)+1;
3758}
3759},isUIElement:function(_3e9){
3760return MochiKit.Base.findValue(["input","button","select","option","textarea","object"],_3e9.tagName.toLowerCase())>-1;
3761},findElements:function(_3ea,axis){
3762var _3ec;
3763if(axis==undefined){
3764axis="";
3765}
3766function inScope(_3ed,_3ee){
3767if(axis==""){
3768return MochiKit.DOM.isChildNode(_3ed,_3ee);
3769}else{
3770if(axis==">"){
3771return _3ed.parentNode==_3ee;
3772}else{
3773if(axis=="+"){
3774return _3ed==nextSiblingElement(_3ee);
3775}else{
3776if(axis=="~"){
3777var _3ef=_3ee;
3778while(_3ef=nextSiblingElement(_3ef)){
3779if(_3ed==_3ef){
3780return true;
3781}
3782}
3783return false;
3784}else{
3785throw "Invalid axis: "+axis;
3786}
3787}
3788}
3789}
3790}
3791if(_3ec=MochiKit.DOM.getElement(this.params.id)){
3792if(this.match(_3ec)){
3793if(!_3ea||inScope(_3ec,_3ea)){
3794return [_3ec];
3795}
3796}
3797}
3798function nextSiblingElement(node){
3799node=node.nextSibling;
3800while(node&&node.nodeType!=1){
3801node=node.nextSibling;
3802}
3803return node;
3804}
3805if(axis==""){
3806_3ea=(_3ea||MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName||"*");
3807}else{
3808if(axis==">"){
3809if(!_3ea){
3810throw "> combinator not allowed without preceeding expression";
3811}
3812_3ea=MochiKit.Base.filter(function(node){
3813return node.nodeType==1;
3814},_3ea.childNodes);
3815}else{
3816if(axis=="+"){
3817if(!_3ea){
3818throw "+ combinator not allowed without preceeding expression";
3819}
3820_3ea=nextSiblingElement(_3ea)&&[nextSiblingElement(_3ea)];
3821}else{
3822if(axis=="~"){
3823if(!_3ea){
3824throw "~ combinator not allowed without preceeding expression";
3825}
3826var _3f2=[];
3827while(nextSiblingElement(_3ea)){
3828_3ea=nextSiblingElement(_3ea);
3829_3f2.push(_3ea);
3830}
3831_3ea=_3f2;
3832}
3833}
3834}
3835}
3836if(!_3ea){
3837return [];
3838}
3839var _3f3=MochiKit.Base.filter(MochiKit.Base.bind(function(_3f4){
3840return this.match(_3f4);
3841},this),_3ea);
3842return _3f3;
3843},repr:function(){
3844return "Selector("+this.expression+")";
3845},toString:MochiKit.Base.forwardCall("repr")};
3846MochiKit.Base.update(MochiKit.Selector,{findChildElements:function(_3f5,_3f6){
3847return MochiKit.Base.flattenArray(MochiKit.Base.map(function(_3f7){
3848var _3f8="";
3849return MochiKit.Iter.reduce(function(_3f9,expr){
3850if(match=expr.match(/^[>+~]$/)){
3851_3f8=match[0];
3852return _3f9;
3853}else{
3854var _3fb=new MochiKit.Selector.Selector(expr);
3855var _3fc=MochiKit.Iter.reduce(function(_3fd,_3fe){
3856return MochiKit.Base.extend(_3fd,_3fb.findElements(_3fe||_3f5,_3f8));
3857},_3f9,[]);
3858_3f8="";
3859return _3fc;
3860}
3861},_3f7.replace(/(^\s+|\s+$)/g,"").split(/\s+/),[null]);
3862},_3f6));
3863},findDocElements:function(){
3864return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(),arguments);
3865},__new__:function(){
3866var m=MochiKit.Base;
3867this.$$=this.findDocElements;
3868this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
3869m.nameFunctions(this);
3870}});
3871MochiKit.Selector.__new__();
3872MochiKit.Base._exportSymbols(this,MochiKit.Selector);
3873if(typeof (dojo)!="undefined"){
3874dojo.provide("MochiKit.Style");
3875dojo.require("MochiKit.Base");
3876dojo.require("MochiKit.DOM");
3877}
3878if(typeof (JSAN)!="undefined"){
3879JSAN.use("MochiKit.Base",[]);
3880JSAN.use("MochiKit.DOM",[]);
3881}
3882try{
3883if(typeof (MochiKit.Base)=="undefined"){
3884throw "";
3885}
3886}
3887catch(e){
3888throw "MochiKit.Style depends on MochiKit.Base!";
3889}
3890try{
3891if(typeof (MochiKit.DOM)=="undefined"){
3892throw "";
3893}
3894}
3895catch(e){
3896throw "MochiKit.Style depends on MochiKit.DOM!";
3897}
3898if(typeof (MochiKit.Style)=="undefined"){
3899MochiKit.Style={};
3900}
3901MochiKit.Style.NAME="MochiKit.Style";
3902MochiKit.Style.VERSION="1.4";
3903MochiKit.Style.__repr__=function(){
3904return "["+this.NAME+" "+this.VERSION+"]";
3905};
3906MochiKit.Style.toString=function(){
3907return this.__repr__();
3908};
3909MochiKit.Style.EXPORT_OK=[];
3910MochiKit.Style.EXPORT=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
3911MochiKit.Style.Dimensions=function(w,h){
3912this.w=w;
3913this.h=h;
3914};
3915MochiKit.Style.Dimensions.prototype.__repr__=function(){
3916var repr=MochiKit.Base.repr;
3917return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}";
3918};
3919MochiKit.Style.Dimensions.prototype.toString=function(){
3920return this.__repr__();
3921};
3922MochiKit.Style.Coordinates=function(x,y){
3923this.x=x;
3924this.y=y;
3925};
3926MochiKit.Style.Coordinates.prototype.__repr__=function(){
3927var repr=MochiKit.Base.repr;
3928return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}";
3929};
3930MochiKit.Style.Coordinates.prototype.toString=function(){
3931return this.__repr__();
3932};
3933MochiKit.Base.update(MochiKit.Style,{getStyle:function(elem,_407){
3934var dom=MochiKit.DOM;
3935var d=dom._document;
3936elem=dom.getElement(elem);
3937_407=MochiKit.Base.camelize(_407);
3938if(!elem||elem==d){
3939return undefined;
3940}
3941if(_407=="opacity"&&elem.filters){
3942var _40a=(MochiKit.Style.getStyle(elem,"filter")||"").match(/alpha\(opacity=(.*)\)/);
3943if(_40a&&_40a[1]){
3944return parseFloat(_40a[1])/100;
3945}
3946return 1;
3947}
3948var _40b=elem.style?elem.style[_407]:null;
3949if(!_40b){
3950if(d.defaultView&&d.defaultView.getComputedStyle){
3951var css=d.defaultView.getComputedStyle(elem,null);
3952_407=_407.replace(/([A-Z])/g,"-$1").toLowerCase();
3953_40b=css?css.getPropertyValue(_407):null;
3954}else{
3955if(elem.currentStyle){
3956_40b=elem.currentStyle[_407];
3957}
3958}
3959}
3960if(_407=="opacity"){
3961_40b=parseFloat(_40b);
3962}
3963if(/Opera/.test(navigator.userAgent)&&(MochiKit.Base.find(["left","top","right","bottom"],_407)!=-1)){
3964if(MochiKit.Style.getStyle(elem,"position")=="static"){
3965_40b="auto";
3966}
3967}
3968return _40b=="auto"?null:_40b;
3969},setStyle:function(elem,_40e){
3970elem=MochiKit.DOM.getElement(elem);
3971for(var name in _40e){
3972if(name=="opacity"){
3973MochiKit.Style.setOpacity(elem,_40e[name]);
3974}else{
3975elem.style[MochiKit.Base.camelize(name)]=_40e[name];
3976}
3977}
3978},setOpacity:function(elem,o){
3979elem=MochiKit.DOM.getElement(elem);
3980var self=MochiKit.Style;
3981if(o==1){
3982var _413=/Gecko/.test(navigator.userAgent)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent));
3983elem.style["opacity"]=_413?0.999999:1;
3984if(/MSIE/.test(navigator.userAgent)){
3985elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"");
3986}
3987}else{
3988if(o<0.00001){
3989o=0;
3990}
3991elem.style["opacity"]=o;
3992if(/MSIE/.test(navigator.userAgent)){
3993elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o*100+")";
3994}
3995}
3996},getElementPosition:function(elem,_415){
3997var self=MochiKit.Style;
3998var dom=MochiKit.DOM;
3999elem=dom.getElement(elem);
4000if(!elem||(!(elem.x&&elem.y)&&(!elem.parentNode===null||self.getStyle(elem,"display")=="none"))){
4001return undefined;
4002}
4003var c=new self.Coordinates(0,0);
4004var box=null;
4005var _41a=null;
4006var d=MochiKit.DOM._document;
4007var de=d.documentElement;
4008var b=d.body;
4009if(!elem.parentNode&&elem.x&&elem.y){
4010c.x+=elem.x||0;
4011c.y+=elem.y||0;
4012}else{
4013if(elem.getBoundingClientRect){
4014box=elem.getBoundingClientRect();
4015c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
4016c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
4017}else{
4018if(elem.offsetParent){
4019c.x+=elem.offsetLeft;
4020c.y+=elem.offsetTop;
4021_41a=elem.offsetParent;
4022if(_41a!=elem){
4023while(_41a){
4024c.x+=_41a.offsetLeft;
4025c.y+=_41a.offsetTop;
4026_41a=_41a.offsetParent;
4027}
4028}
4029var ua=navigator.userAgent.toLowerCase();
4030if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("AppleWebKit")!=-1&&self.getStyle(elem,"position")=="absolute")){
4031c.x-=b.offsetLeft;
4032c.y-=b.offsetTop;
4033}
4034}
4035}
4036}
4037if(typeof (_415)!="undefined"){
4038_415=arguments.callee(_415);
4039if(_415){
4040c.x-=(_415.x||0);
4041c.y-=(_415.y||0);
4042}
4043}
4044if(elem.parentNode){
4045_41a=elem.parentNode;
4046}else{
4047_41a=null;
4048}
4049while(_41a){
4050var _41f=_41a.tagName.toUpperCase();
4051if(_41f==="BODY"||_41f==="HTML"){
4052break;
4053}
4054var disp=self.getStyle(_41a,"display");
4055if(disp!="inline"&&disp!="table-row"){
4056c.x-=_41a.scrollLeft;
4057c.y-=_41a.scrollTop;
4058}
4059if(_41a.parentNode){
4060_41a=_41a.parentNode;
4061}else{
4062_41a=null;
4063}
4064}
4065return c;
4066},setElementPosition:function(elem,_422,_423){
4067elem=MochiKit.DOM.getElement(elem);
4068if(typeof (_423)=="undefined"){
4069_423="px";
4070}
4071var _424={};
4072var _425=MochiKit.Base.isUndefinedOrNull;
4073if(!_425(_422.x)){
4074_424["left"]=_422.x+_423;
4075}
4076if(!_425(_422.y)){
4077_424["top"]=_422.y+_423;
4078}
4079MochiKit.DOM.updateNodeAttributes(elem,{"style":_424});
4080},getElementDimensions:function(elem){
4081var self=MochiKit.Style;
4082var dom=MochiKit.DOM;
4083if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){
4084return new self.Dimensions(elem.w||0,elem.h||0);
4085}
4086elem=dom.getElement(elem);
4087if(!elem){
4088return undefined;
4089}
4090var disp=self.getStyle(elem,"display");
4091if(disp!="none"&&disp!==""&&typeof (disp)!="undefined"){
4092return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0);
4093}
4094var s=elem.style;
4095var _42b=s.visibility;
4096var _42c=s.position;
4097s.visibility="hidden";
4098s.position="absolute";
4099s.display="";
4100var _42d=elem.offsetWidth;
4101var _42e=elem.offsetHeight;
4102s.display="none";
4103s.position=_42c;
4104s.visibility=_42b;
4105return new self.Dimensions(_42d,_42e);
4106},setElementDimensions:function(elem,_430,_431){
4107elem=MochiKit.DOM.getElement(elem);
4108if(typeof (_431)=="undefined"){
4109_431="px";
4110}
4111var _432={};
4112var _433=MochiKit.Base.isUndefinedOrNull;
4113if(!_433(_430.w)){
4114_432["width"]=_430.w+_431;
4115}
4116if(!_433(_430.h)){
4117_432["height"]=_430.h+_431;
4118}
4119MochiKit.DOM.updateNodeAttributes(elem,{"style":_432});
4120},setDisplayForElement:function(_434,_435){
4121var _436=MochiKit.Base.extend(null,arguments,1);
4122var _437=MochiKit.DOM.getElement;
4123for(var i=0;i<_436.length;i++){
4124_435=_437(_436[i]);
4125if(_435){
4126_435.style.display=_434;
4127}
4128}
4129},getViewportDimensions:function(){
4130var d=new MochiKit.Style.Dimensions();
4131var w=MochiKit.DOM._window;
4132var b=MochiKit.DOM._document.body;
4133if(w.innerWidth){
4134d.w=w.innerWidth;
4135d.h=w.innerHeight;
4136}else{
4137if(b.parentElement.clientWidth){
4138d.w=b.parentElement.clientWidth;
4139d.h=b.parentElement.clientHeight;
4140}else{
4141if(b&&b.clientWidth){
4142d.w=b.clientWidth;
4143d.h=b.clientHeight;
4144}
4145}
4146}
4147return d;
4148},getViewportPosition:function(){
4149var c=new MochiKit.Style.Coordinates(0,0);
4150var d=MochiKit.DOM._document;
4151var de=d.documentElement;
4152var db=d.body;
4153if(de&&(de.scrollTop||de.scrollLeft)){
4154c.x=de.scrollLeft;
4155c.y=de.scrollTop;
4156}else{
4157if(db){
4158c.x=db.scrollLeft;
4159c.y=db.scrollTop;
4160}
4161}
4162return c;
4163},__new__:function(){
4164var m=MochiKit.Base;
4165this.elementPosition=this.getElementPosition;
4166this.elementDimensions=this.getElementDimensions;
4167this.hideElement=m.partial(this.setDisplayForElement,"none");
4168this.showElement=m.partial(this.setDisplayForElement,"block");
4169this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
4170m.nameFunctions(this);
4171}});
4172MochiKit.Style.__new__();
4173MochiKit.Base._exportSymbols(this,MochiKit.Style);
4174if(typeof (dojo)!="undefined"){
4175dojo.provide("MochiKit.LoggingPane");
4176dojo.require("MochiKit.Logging");
4177dojo.require("MochiKit.Base");
4178}
4179if(typeof (JSAN)!="undefined"){
4180JSAN.use("MochiKit.Logging",[]);
4181JSAN.use("MochiKit.Base",[]);
4182}
4183try{
4184if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Logging)=="undefined"){
4185throw "";
4186}
4187}
4188catch(e){
4189throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!";
4190}
4191if(typeof (MochiKit.LoggingPane)=="undefined"){
4192MochiKit.LoggingPane={};
4193}
4194MochiKit.LoggingPane.NAME="MochiKit.LoggingPane";
4195MochiKit.LoggingPane.VERSION="1.4";
4196MochiKit.LoggingPane.__repr__=function(){
4197return "["+this.NAME+" "+this.VERSION+"]";
4198};
4199MochiKit.LoggingPane.toString=function(){
4200return this.__repr__();
4201};
4202MochiKit.LoggingPane.createLoggingPane=function(_441){
4203var m=MochiKit.LoggingPane;
4204_441=!(!_441);
4205if(m._loggingPane&&m._loggingPane.inline!=_441){
4206m._loggingPane.closePane();
4207m._loggingPane=null;
4208}
4209if(!m._loggingPane||m._loggingPane.closed){
4210m._loggingPane=new m.LoggingPane(_441,MochiKit.Logging.logger);
4211}
4212return m._loggingPane;
4213};
4214MochiKit.LoggingPane.LoggingPane=function(_443,_444){
4215if(typeof (_444)=="undefined"||_444===null){
4216_444=MochiKit.Logging.logger;
4217}
4218this.logger=_444;
4219var _445=MochiKit.Base.update;
4220var _446=MochiKit.Base.updatetree;
4221var bind=MochiKit.Base.bind;
4222var _448=MochiKit.Base.clone;
4223var win=window;
4224var uid="_MochiKit_LoggingPane";
4225if(typeof (MochiKit.DOM)!="undefined"){
4226win=MochiKit.DOM.currentWindow();
4227}
4228if(!_443){
4229var url=win.location.href.split("?")[0].replace(/[#:\/.><&-]/g,"_");
4230var name=uid+"_"+url;
4231var nwin=win.open("",name,"dependent,resizable,height=200");
4232if(!nwin){
4233alert("Not able to open debugging window due to pop-up blocking.");
4234return undefined;
4235}
4236nwin.document.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" "+"\"http://www.w3.org/TR/html4/loose.dtd\">"+"<html><head><title>[MochiKit.LoggingPane]</title></head>"+"<body></body></html>");
4237nwin.document.close();
4238nwin.document.title+=" "+win.document.title;
4239win=nwin;
4240}
4241var doc=win.document;
4242this.doc=doc;
4243var _44f=doc.getElementById(uid);
4244var _450=!!_44f;
4245if(_44f&&typeof (_44f.loggingPane)!="undefined"){
4246_44f.loggingPane.logger=this.logger;
4247_44f.loggingPane.buildAndApplyFilter();
4248return _44f.loggingPane;
4249}
4250if(_450){
4251var _451;
4252while((_451=_44f.firstChild)){
4253_44f.removeChild(_451);
4254}
4255}else{
4256_44f=doc.createElement("div");
4257_44f.id=uid;
4258}
4259_44f.loggingPane=this;
4260var _452=doc.createElement("input");
4261var _453=doc.createElement("input");
4262var _454=doc.createElement("button");
4263var _455=doc.createElement("button");
4264var _456=doc.createElement("button");
4265var _457=doc.createElement("button");
4266var _458=doc.createElement("div");
4267var _459=doc.createElement("div");
4268var _45a=uid+"_Listener";
4269this.colorTable=_448(this.colorTable);
4270var _45b=[];
4271var _45c=null;
4272var _45d=function(msg){
4273var _45f=msg.level;
4274if(typeof (_45f)=="number"){
4275_45f=MochiKit.Logging.LogLevel[_45f];
4276}
4277return _45f;
4278};
4279var _460=function(msg){
4280return msg.info.join(" ");
4281};
4282var _462=bind(function(msg){
4283var _464=_45d(msg);
4284var text=_460(msg);
4285var c=this.colorTable[_464];
4286var p=doc.createElement("span");
4287p.className="MochiKit-LogMessage MochiKit-LogLevel-"+_464;
4288p.style.cssText="margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: "+c;
4289p.appendChild(doc.createTextNode(_464+": "+text));
4290_459.appendChild(p);
4291_459.appendChild(doc.createElement("br"));
4292if(_458.offsetHeight>_458.scrollHeight){
4293_458.scrollTop=0;
4294}else{
4295_458.scrollTop=_458.scrollHeight;
4296}
4297},this);
4298var _468=function(msg){
4299_45b[_45b.length]=msg;
4300_462(msg);
4301};
4302var _46a=function(){
4303var _46b,_46c;
4304try{
4305_46b=new RegExp(_452.value);
4306_46c=new RegExp(_453.value);
4307}
4308catch(e){
4309logDebug("Error in filter regex: "+e.message);
4310return null;
4311}
4312return function(msg){
4313return (_46b.test(_45d(msg))&&_46c.test(_460(msg)));
4314};
4315};
4316var _46e=function(){
4317while(_459.firstChild){
4318_459.removeChild(_459.firstChild);
4319}
4320};
4321var _46f=function(){
4322_45b=[];
4323_46e();
4324};
4325var _470=bind(function(){
4326if(this.closed){
4327return;
4328}
4329this.closed=true;
4330if(MochiKit.LoggingPane._loggingPane==this){
4331MochiKit.LoggingPane._loggingPane=null;
4332}
4333this.logger.removeListener(_45a);
4334try{
4335try{
4336_44f.loggingPane=null;
4337}
4338catch(e){
4339logFatal("Bookmarklet was closed incorrectly.");
4340}
4341if(_443){
4342_44f.parentNode.removeChild(_44f);
4343}else{
4344this.win.close();
4345}
4346}
4347catch(e){
4348}
4349},this);
4350var _471=function(){
4351_46e();
4352for(var i=0;i<_45b.length;i++){
4353var msg=_45b[i];
4354if(_45c===null||_45c(msg)){
4355_462(msg);
4356}
4357}
4358};
4359this.buildAndApplyFilter=function(){
4360_45c=_46a();
4361_471();
4362this.logger.removeListener(_45a);
4363this.logger.addListener(_45a,_45c,_468);
4364};
4365var _474=bind(function(){
4366_45b=this.logger.getMessages();
4367_471();
4368},this);
4369var _475=bind(function(_476){
4370_476=_476||window.event;
4371key=_476.which||_476.keyCode;
4372if(key==13){
4373this.buildAndApplyFilter();
4374}
4375},this);
4376var _477="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont;
4377if(_443){
4378_477+="; height: 10em; border-top: 2px solid black";
4379}else{
4380_477+="; height: 100%;";
4381}
4382_44f.style.cssText=_477;
4383if(!_450){
4384doc.body.appendChild(_44f);
4385}
4386_477={"cssText":"width: 33%; display: inline; font: "+this.logFont};
4387_446(_452,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_475,"style":_477});
4388_44f.appendChild(_452);
4389_446(_453,{"value":".*","onkeypress":_475,"style":_477});
4390_44f.appendChild(_453);
4391_477="width: 8%; display:inline; font: "+this.logFont;
4392_454.appendChild(doc.createTextNode("Filter"));
4393_454.onclick=bind("buildAndApplyFilter",this);
4394_454.style.cssText=_477;
4395_44f.appendChild(_454);
4396_455.appendChild(doc.createTextNode("Load"));
4397_455.onclick=_474;
4398_455.style.cssText=_477;
4399_44f.appendChild(_455);
4400_456.appendChild(doc.createTextNode("Clear"));
4401_456.onclick=_46f;
4402_456.style.cssText=_477;
4403_44f.appendChild(_456);
4404_457.appendChild(doc.createTextNode("Close"));
4405_457.onclick=_470;
4406_457.style.cssText=_477;
4407_44f.appendChild(_457);
4408_458.style.cssText="overflow: auto; width: 100%";
4409_459.style.cssText="width: 100%; height: "+(_443?"8em":"100%");
4410_458.appendChild(_459);
4411_44f.appendChild(_458);
4412this.buildAndApplyFilter();
4413_474();
4414if(_443){
4415this.win=undefined;
4416}else{
4417this.win=win;
4418}
4419this.inline=_443;
4420this.closePane=_470;
4421this.closed=false;
4422return this;
4423};
4424MochiKit.LoggingPane.LoggingPane.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}};
4425MochiKit.LoggingPane.EXPORT_OK=["LoggingPane"];
4426MochiKit.LoggingPane.EXPORT=["createLoggingPane"];
4427MochiKit.LoggingPane.__new__=function(){
4428this.EXPORT_TAGS={":common":this.EXPORT,":all":MochiKit.Base.concat(this.EXPORT,this.EXPORT_OK)};
4429MochiKit.Base.nameFunctions(this);
4430MochiKit.LoggingPane._loggingPane=null;
4431};
4432MochiKit.LoggingPane.__new__();
4433MochiKit.Base._exportSymbols(this,MochiKit.LoggingPane);
4434if(typeof (dojo)!="undefined"){
4435dojo.provide("MochiKit.Color");
4436dojo.require("MochiKit.Base");
4437dojo.require("MochiKit.DOM");
4438dojo.require("MochiKit.Style");
4439}
4440if(typeof (JSAN)!="undefined"){
4441JSAN.use("MochiKit.Base",[]);
4442JSAN.use("MochiKit.DOM",[]);
4443JSAN.use("MochiKit.Style",[]);
4444}
4445try{
4446if(typeof (MochiKit.Base)=="undefined"){
4447throw "";
4448}
4449}
4450catch(e){
4451throw "MochiKit.Color depends on MochiKit.Base";
4452}
4453try{
4454if(typeof (MochiKit.DOM)=="undefined"){
4455throw "";
4456}
4457}
4458catch(e){
4459throw "MochiKit.Color depends on MochiKit.DOM";
4460}
4461try{
4462if(typeof (MochiKit.Style)=="undefined"){
4463throw "";
4464}
4465}
4466catch(e){
4467throw "MochiKit.Color depends on MochiKit.Style";
4468}
4469if(typeof (MochiKit.Color)=="undefined"){
4470MochiKit.Color={};
4471}
4472MochiKit.Color.NAME="MochiKit.Color";
4473MochiKit.Color.VERSION="1.4";
4474MochiKit.Color.__repr__=function(){
4475return "["+this.NAME+" "+this.VERSION+"]";
4476};
4477MochiKit.Color.toString=function(){
4478return this.__repr__();
4479};
4480MochiKit.Color.Color=function(red,_479,blue,_47b){
4481if(typeof (_47b)=="undefined"||_47b===null){
4482_47b=1;
4483}
4484this.rgb={r:red,g:_479,b:blue,a:_47b};
4485};
4486MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_47c){
4487var rgb=this.rgb;
4488var m=MochiKit.Color;
4489return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_47c);
4490},colorWithHue:function(hue){
4491var hsl=this.asHSL();
4492hsl.h=hue;
4493var m=MochiKit.Color;
4494return m.Color.fromHSL(hsl);
4495},colorWithSaturation:function(_482){
4496var hsl=this.asHSL();
4497hsl.s=_482;
4498var m=MochiKit.Color;
4499return m.Color.fromHSL(hsl);
4500},colorWithLightness:function(_485){
4501var hsl=this.asHSL();
4502hsl.l=_485;
4503var m=MochiKit.Color;
4504return m.Color.fromHSL(hsl);
4505},darkerColorWithLevel:function(_488){
4506var hsl=this.asHSL();
4507hsl.l=Math.max(hsl.l-_488,0);
4508var m=MochiKit.Color;
4509return m.Color.fromHSL(hsl);
4510},lighterColorWithLevel:function(_48b){
4511var hsl=this.asHSL();
4512hsl.l=Math.min(hsl.l+_48b,1);
4513var m=MochiKit.Color;
4514return m.Color.fromHSL(hsl);
4515},blendedColor:function(_48e,_48f){
4516if(typeof (_48f)=="undefined"||_48f===null){
4517_48f=0.5;
4518}
4519var sf=1-_48f;
4520var s=this.rgb;
4521var d=_48e.rgb;
4522var df=_48f;
4523return 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));
4524},compareRGB:function(_494){
4525var a=this.asRGB();
4526var b=_494.asRGB();
4527return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]);
4528},isLight:function(){
4529return this.asHSL().b>0.5;
4530},isDark:function(){
4531return (!this.isLight());
4532},toHSLString:function(){
4533var c=this.asHSL();
4534var ccc=MochiKit.Color.clampColorComponent;
4535var rval=this._hslString;
4536if(!rval){
4537var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%");
4538var a=c.a;
4539if(a>=1){
4540a=1;
4541rval="hsl("+mid+")";
4542}else{
4543if(a<=0){
4544a=0;
4545}
4546rval="hsla("+mid+","+a+")";
4547}
4548this._hslString=rval;
4549}
4550return rval;
4551},toRGBString:function(){
4552var c=this.rgb;
4553var ccc=MochiKit.Color.clampColorComponent;
4554var rval=this._rgbString;
4555if(!rval){
4556var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0));
4557if(c.a!=1){
4558rval="rgba("+mid+","+c.a+")";
4559}else{
4560rval="rgb("+mid+")";
4561}
4562this._rgbString=rval;
4563}
4564return rval;
4565},asRGB:function(){
4566return MochiKit.Base.clone(this.rgb);
4567},toHexString:function(){
4568var m=MochiKit.Color;
4569var c=this.rgb;
4570var ccc=MochiKit.Color.clampColorComponent;
4571var rval=this._hexString;
4572if(!rval){
4573rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255)));
4574this._hexString=rval;
4575}
4576return rval;
4577},asHSV:function(){
4578var hsv=this.hsv;
4579var c=this.rgb;
4580if(typeof (hsv)=="undefined"||hsv===null){
4581hsv=MochiKit.Color.rgbToHSV(this.rgb);
4582this.hsv=hsv;
4583}
4584return MochiKit.Base.clone(hsv);
4585},asHSL:function(){
4586var hsl=this.hsl;
4587var c=this.rgb;
4588if(typeof (hsl)=="undefined"||hsl===null){
4589hsl=MochiKit.Color.rgbToHSL(this.rgb);
4590this.hsl=hsl;
4591}
4592return MochiKit.Base.clone(hsl);
4593},toString:function(){
4594return this.toRGBString();
4595},repr:function(){
4596var c=this.rgb;
4597var col=[c.r,c.g,c.b,c.a];
4598return this.__class__.NAME+"("+col.join(", ")+")";
4599}};
4600MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_4ab,blue,_4ad){
4601var _4ae=MochiKit.Color.Color;
4602if(arguments.length==1){
4603var rgb=red;
4604red=rgb.r;
4605_4ab=rgb.g;
4606blue=rgb.b;
4607if(typeof (rgb.a)=="undefined"){
4608_4ad=undefined;
4609}else{
4610_4ad=rgb.a;
4611}
4612}
4613return new _4ae(red,_4ab,blue,_4ad);
4614},fromHSL:function(hue,_4b1,_4b2,_4b3){
4615var m=MochiKit.Color;
4616return m.Color.fromRGB(m.hslToRGB.apply(m,arguments));
4617},fromHSV:function(hue,_4b6,_4b7,_4b8){
4618var m=MochiKit.Color;
4619return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments));
4620},fromName:function(name){
4621var _4bb=MochiKit.Color.Color;
4622if(name.charAt(0)=="\""){
4623name=name.substr(1,name.length-2);
4624}
4625var _4bc=_4bb._namedColors[name.toLowerCase()];
4626if(typeof (_4bc)=="string"){
4627return _4bb.fromHexString(_4bc);
4628}else{
4629if(name=="transparent"){
4630return _4bb.transparentColor();
4631}
4632}
4633return null;
4634},fromString:function(_4bd){
4635var self=MochiKit.Color.Color;
4636var _4bf=_4bd.substr(0,3);
4637if(_4bf=="rgb"){
4638return self.fromRGBString(_4bd);
4639}else{
4640if(_4bf=="hsl"){
4641return self.fromHSLString(_4bd);
4642}else{
4643if(_4bd.charAt(0)=="#"){
4644return self.fromHexString(_4bd);
4645}
4646}
4647}
4648return self.fromName(_4bd);
4649},fromHexString:function(_4c0){
4650if(_4c0.charAt(0)=="#"){
4651_4c0=_4c0.substring(1);
4652}
4653var _4c1=[];
4654var i,hex;
4655if(_4c0.length==3){
4656for(i=0;i<3;i++){
4657hex=_4c0.substr(i,1);
4658_4c1.push(parseInt(hex+hex,16)/255);
4659}
4660}else{
4661for(i=0;i<6;i+=2){
4662hex=_4c0.substr(i,2);
4663_4c1.push(parseInt(hex,16)/255);
4664}
4665}
4666var _4c4=MochiKit.Color.Color;
4667return _4c4.fromRGB.apply(_4c4,_4c1);
4668},_fromColorString:function(pre,_4c6,_4c7,_4c8){
4669if(_4c8.indexOf(pre)===0){
4670_4c8=_4c8.substring(_4c8.indexOf("(",3)+1,_4c8.length-1);
4671}
4672var _4c9=_4c8.split(/\s*,\s*/);
4673var _4ca=[];
4674for(var i=0;i<_4c9.length;i++){
4675var c=_4c9[i];
4676var val;
4677var _4ce=c.substring(c.length-3);
4678if(c.charAt(c.length-1)=="%"){
4679val=0.01*parseFloat(c.substring(0,c.length-1));
4680}else{
4681if(_4ce=="deg"){
4682val=parseFloat(c)/360;
4683}else{
4684if(_4ce=="rad"){
4685val=parseFloat(c)/(Math.PI*2);
4686}else{
4687val=_4c7[i]*parseFloat(c);
4688}
4689}
4690}
4691_4ca.push(val);
4692}
4693return this[_4c6].apply(this,_4ca);
4694},fromComputedStyle:function(elem,_4d0){
4695var d=MochiKit.DOM;
4696var cls=MochiKit.Color.Color;
4697for(elem=d.getElement(elem);elem;elem=elem.parentNode){
4698var _4d3=MochiKit.Style.getStyle.apply(d,arguments);
4699if(!_4d3){
4700continue;
4701}
4702var _4d4=cls.fromString(_4d3);
4703if(!_4d4){
4704break;
4705}
4706if(_4d4.asRGB().a>0){
4707return _4d4;
4708}
4709}
4710return null;
4711},fromBackground:function(elem){
4712var cls=MochiKit.Color.Color;
4713return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor();
4714},fromText:function(elem){
4715var cls=MochiKit.Color.Color;
4716return cls.fromComputedStyle(elem,"color","color")||cls.blackColor();
4717},namedColors:function(){
4718return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
4719}});
4720MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_4da){
4721v*=_4da;
4722if(v<0){
4723return 0;
4724}else{
4725if(v>_4da){
4726return _4da;
4727}else{
4728return v;
4729}
4730}
4731},_hslValue:function(n1,n2,hue){
4732if(hue>6){
4733hue-=6;
4734}else{
4735if(hue<0){
4736hue+=6;
4737}
4738}
4739var val;
4740if(hue<1){
4741val=n1+(n2-n1)*hue;
4742}else{
4743if(hue<3){
4744val=n2;
4745}else{
4746if(hue<4){
4747val=n1+(n2-n1)*(4-hue);
4748}else{
4749val=n1;
4750}
4751}
4752}
4753return val;
4754},hsvToRGB:function(hue,_4e0,_4e1,_4e2){
4755if(arguments.length==1){
4756var hsv=hue;
4757hue=hsv.h;
4758_4e0=hsv.s;
4759_4e1=hsv.v;
4760_4e2=hsv.a;
4761}
4762var red;
4763var _4e5;
4764var blue;
4765if(_4e0===0){
4766red=_4e1;
4767_4e5=_4e1;
4768blue=_4e1;
4769}else{
4770var i=Math.floor(hue*6);
4771var f=(hue*6)-i;
4772var p=_4e1*(1-_4e0);
4773var q=_4e1*(1-(_4e0*f));
4774var t=_4e1*(1-(_4e0*(1-f)));
4775switch(i){
4776case 1:
4777red=q;
4778_4e5=_4e1;
4779blue=p;
4780break;
4781case 2:
4782red=p;
4783_4e5=_4e1;
4784blue=t;
4785break;
4786case 3:
4787red=p;
4788_4e5=q;
4789blue=_4e1;
4790break;
4791case 4:
4792red=t;
4793_4e5=p;
4794blue=_4e1;
4795break;
4796case 5:
4797red=_4e1;
4798_4e5=p;
4799blue=q;
4800break;
4801case 6:
4802case 0:
4803red=_4e1;
4804_4e5=t;
4805blue=p;
4806break;
4807}
4808}
4809return {r:red,g:_4e5,b:blue,a:_4e2};
4810},hslToRGB:function(hue,_4ed,_4ee,_4ef){
4811if(arguments.length==1){
4812var hsl=hue;
4813hue=hsl.h;
4814_4ed=hsl.s;
4815_4ee=hsl.l;
4816_4ef=hsl.a;
4817}
4818var red;
4819var _4f2;
4820var blue;
4821if(_4ed===0){
4822red=_4ee;
4823_4f2=_4ee;
4824blue=_4ee;
4825}else{
4826var m2;
4827if(_4ee<=0.5){
4828m2=_4ee*(1+_4ed);
4829}else{
4830m2=_4ee+_4ed-(_4ee*_4ed);
4831}
4832var m1=(2*_4ee)-m2;
4833var f=MochiKit.Color._hslValue;
4834var h6=hue*6;
4835red=f(m1,m2,h6+2);
4836_4f2=f(m1,m2,h6);
4837blue=f(m1,m2,h6-2);
4838}
4839return {r:red,g:_4f2,b:blue,a:_4ef};
4840},rgbToHSV:function(red,_4f9,blue,_4fb){
4841if(arguments.length==1){
4842var rgb=red;
4843red=rgb.r;
4844_4f9=rgb.g;
4845blue=rgb.b;
4846_4fb=rgb.a;
4847}
4848var max=Math.max(Math.max(red,_4f9),blue);
4849var min=Math.min(Math.min(red,_4f9),blue);
4850var hue;
4851var _500;
4852var _501=max;
4853if(min==max){
4854hue=0;
4855_500=0;
4856}else{
4857var _502=(max-min);
4858_500=_502/max;
4859if(red==max){
4860hue=(_4f9-blue)/_502;
4861}else{
4862if(_4f9==max){
4863hue=2+((blue-red)/_502);
4864}else{
4865hue=4+((red-_4f9)/_502);
4866}
4867}
4868hue/=6;
4869if(hue<0){
4870hue+=1;
4871}
4872if(hue>1){
4873hue-=1;
4874}
4875}
4876return {h:hue,s:_500,v:_501,a:_4fb};
4877},rgbToHSL:function(red,_504,blue,_506){
4878if(arguments.length==1){
4879var rgb=red;
4880red=rgb.r;
4881_504=rgb.g;
4882blue=rgb.b;
4883_506=rgb.a;
4884}
4885var max=Math.max(red,Math.max(_504,blue));
4886var min=Math.min(red,Math.min(_504,blue));
4887var hue;
4888var _50b;
4889var _50c=(max+min)/2;
4890var _50d=max-min;
4891if(_50d===0){
4892hue=0;
4893_50b=0;
4894}else{
4895if(_50c<=0.5){
4896_50b=_50d/(max+min);
4897}else{
4898_50b=_50d/(2-max-min);
4899}
4900if(red==max){
4901hue=(_504-blue)/_50d;
4902}else{
4903if(_504==max){
4904hue=2+((blue-red)/_50d);
4905}else{
4906hue=4+((red-_504)/_50d);
4907}
4908}
4909hue/=6;
4910if(hue<0){
4911hue+=1;
4912}
4913if(hue>1){
4914hue-=1;
4915}
4916}
4917return {h:hue,s:_50b,l:_50c,a:_506};
4918},toColorPart:function(num){
4919num=Math.round(num);
4920var _50f=num.toString(16);
4921if(num<16){
4922return "0"+_50f;
4923}
4924return _50f;
4925},__new__:function(){
4926var m=MochiKit.Base;
4927this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]);
4928this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]);
4929var _511=1/3;
4930var _512={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_511,_511,_511],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_511,2*_511,2*_511],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]};
4931var _513=function(name,r,g,b,a){
4932var rval=this.fromRGB(r,g,b,a);
4933this[name]=function(){
4934return rval;
4935};
4936return rval;
4937};
4938for(var k in _512){
4939var name=k+"Color";
4940var _51c=m.concat([_513,this.Color,name],_512[k]);
4941this.Color[name]=m.bind.apply(null,_51c);
4942}
4943var _51d=function(){
4944for(var i=0;i<arguments.length;i++){
4945if(!(arguments[i] instanceof Color)){
4946return false;
4947}
4948}
4949return true;
4950};
4951var _51f=function(a,b){
4952return a.compareRGB(b);
4953};
4954m.nameFunctions(this);
4955m.registerComparator(this.Color.NAME,_51d,_51f);
4956this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
4957}});
4958MochiKit.Color.EXPORT=["Color"];
4959MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
4960MochiKit.Color.__new__();
4961MochiKit.Base._exportSymbols(this,MochiKit.Color);
4962MochiKit.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"};
4963if(typeof (dojo)!="undefined"){
4964dojo.provide("MochiKit.Signal");
4965dojo.require("MochiKit.Base");
4966dojo.require("MochiKit.DOM");
4967dojo.require("MochiKit.Style");
4968}
4969if(typeof (JSAN)!="undefined"){
4970JSAN.use("MochiKit.Base",[]);
4971JSAN.use("MochiKit.DOM",[]);
4972JSAN.use("MochiKit.Style",[]);
4973}
4974try{
4975if(typeof (MochiKit.Base)=="undefined"){
4976throw "";
4977}
4978}
4979catch(e){
4980throw "MochiKit.Signal depends on MochiKit.Base!";
4981}
4982try{
4983if(typeof (MochiKit.DOM)=="undefined"){
4984throw "";
4985}
4986}
4987catch(e){
4988throw "MochiKit.Signal depends on MochiKit.DOM!";
4989}
4990try{
4991if(typeof (MochiKit.Style)=="undefined"){
4992throw "";
4993}
4994}
4995catch(e){
4996throw "MochiKit.Signal depends on MochiKit.Style!";
4997}
4998if(typeof (MochiKit.Signal)=="undefined"){
4999MochiKit.Signal={};
5000}
5001MochiKit.Signal.NAME="MochiKit.Signal";
5002MochiKit.Signal.VERSION="1.4";
5003MochiKit.Signal._observers=[];
5004MochiKit.Signal.Event=function(src,e){
5005this._event=e||window.event;
5006this._src=src;
5007};
5008MochiKit.Base.update(MochiKit.Signal.Event.prototype,{__repr__:function(){
5009var repr=MochiKit.Base.repr;
5010var str="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
5011if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
5012str+=", modifier(): "+"{alt: "+repr(this.modifier().alt)+", ctrl: "+repr(this.modifier().ctrl)+", meta: "+repr(this.modifier().meta)+", shift: "+repr(this.modifier().shift)+", any: "+repr(this.modifier().any)+"}";
5013}
5014if(this.type()&&this.type().indexOf("key")===0){
5015str+=", key(): {code: "+repr(this.key().code)+", string: "+repr(this.key().string)+"}";
5016}
5017if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
5018str+=", mouse(): {page: "+repr(this.mouse().page)+", client: "+repr(this.mouse().client);
5019if(this.type()!="mousemove"){
5020str+=", button: {left: "+repr(this.mouse().button.left)+", middle: "+repr(this.mouse().button.middle)+", right: "+repr(this.mouse().button.right)+"}}";
5021}else{
5022str+="}";
5023}
5024}
5025if(this.type()=="mouseover"||this.type()=="mouseout"){
5026str+=", relatedTarget(): "+repr(this.relatedTarget());
5027}
5028str+="}";
5029return str;
5030},toString:function(){
5031return this.__repr__();
5032},src:function(){
5033return this._src;
5034},event:function(){
5035return this._event;
5036},type:function(){
5037return this._event.type||undefined;
5038},target:function(){
5039return this._event.target||this._event.srcElement;
5040},_relatedTarget:null,relatedTarget:function(){
5041if(this._relatedTarget!==null){
5042return this._relatedTarget;
5043}
5044var elem=null;
5045if(this.type()=="mouseover"){
5046elem=(this._event.relatedTarget||this._event.fromElement);
5047}else{
5048if(this.type()=="mouseout"){
5049elem=(this._event.relatedTarget||this._event.toElement);
5050}
5051}
5052if(elem!==null){
5053this._relatedTarget=elem;
5054return elem;
5055}
5056return undefined;
5057},_modifier:null,modifier:function(){
5058if(this._modifier!==null){
5059return this._modifier;
5060}
5061var m={};
5062m.alt=this._event.altKey;
5063m.ctrl=this._event.ctrlKey;
5064m.meta=this._event.metaKey||false;
5065m.shift=this._event.shiftKey;
5066m.any=m.alt||m.ctrl||m.shift||m.meta;
5067this._modifier=m;
5068return m;
5069},_key:null,key:function(){
5070if(this._key!==null){
5071return this._key;
5072}
5073var k={};
5074if(this.type()&&this.type().indexOf("key")===0){
5075if(this.type()=="keydown"||this.type()=="keyup"){
5076k.code=this._event.keyCode;
5077k.string=(MochiKit.Signal._specialKeys[k.code]||"KEY_UNKNOWN");
5078this._key=k;
5079return k;
5080}else{
5081if(this.type()=="keypress"){
5082k.code=0;
5083k.string="";
5084if(typeof (this._event.charCode)!="undefined"&&this._event.charCode!==0&&!MochiKit.Signal._specialMacKeys[this._event.charCode]){
5085k.code=this._event.charCode;
5086k.string=String.fromCharCode(k.code);
5087}else{
5088if(this._event.keyCode&&typeof (this._event.charCode)=="undefined"){
5089k.code=this._event.keyCode;
5090k.string=String.fromCharCode(k.code);
5091}
5092}
5093this._key=k;
5094return k;
5095}
5096}
5097}
5098return undefined;
5099},_mouse:null,mouse:function(){
5100if(this._mouse!==null){
5101return this._mouse;
5102}
5103var m={};
5104var e=this._event;
5105if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
5106m.client=new MochiKit.Style.Coordinates(0,0);
5107if(e.clientX||e.clientY){
5108m.client.x=(!e.clientX||e.clientX<0)?0:e.clientX;
5109m.client.y=(!e.clientY||e.clientY<0)?0:e.clientY;
5110}
5111m.page=new MochiKit.Style.Coordinates(0,0);
5112if(e.pageX||e.pageY){
5113m.page.x=(!e.pageX||e.pageX<0)?0:e.pageX;
5114m.page.y=(!e.pageY||e.pageY<0)?0:e.pageY;
5115}else{
5116var de=MochiKit.DOM._document.documentElement;
5117var b=MochiKit.DOM._document.body;
5118m.page.x=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
5119m.page.y=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
5120}
5121if(this.type()!="mousemove"){
5122m.button={};
5123m.button.left=false;
5124m.button.right=false;
5125m.button.middle=false;
5126if(e.which){
5127m.button.left=(e.which==1);
5128m.button.middle=(e.which==2);
5129m.button.right=(e.which==3);
5130}else{
5131m.button.left=!!(e.button&1);
5132m.button.right=!!(e.button&2);
5133m.button.middle=!!(e.button&4);
5134}
5135}
5136this._mouse=m;
5137return m;
5138}
5139return undefined;
5140},stop:function(){
5141this.stopPropagation();
5142this.preventDefault();
5143},stopPropagation:function(){
5144if(this._event.stopPropagation){
5145this._event.stopPropagation();
5146}else{
5147this._event.cancelBubble=true;
5148}
5149},preventDefault:function(){
5150if(this._event.preventDefault){
5151this._event.preventDefault();
5152}else{
5153if(this._confirmUnload===null){
5154this._event.returnValue=false;
5155}
5156}
5157},_confirmUnload:null,confirmUnload:function(msg){
5158if(this.type()=="beforeunload"){
5159this._confirmUnload=msg;
5160this._event.returnValue=msg;
5161}
5162}});
5163MochiKit.Signal._specialMacKeys={3:"KEY_ENTER",63289:"KEY_NUM_PAD_CLEAR",63276:"KEY_PAGE_UP",63277:"KEY_PAGE_DOWN",63275:"KEY_END",63273:"KEY_HOME",63234:"KEY_ARROW_LEFT",63232:"KEY_ARROW_UP",63235:"KEY_ARROW_RIGHT",63233:"KEY_ARROW_DOWN",63302:"KEY_INSERT",63272:"KEY_DELETE"};
5164(function(){
5165var _52e=MochiKit.Signal._specialMacKeys;
5166for(i=63236;i<=63242;i++){
5167_52e[i]="KEY_F"+(i-63236+1);
5168}
5169})();
5170MochiKit.Signal._specialKeys={8:"KEY_BACKSPACE",9:"KEY_TAB",12:"KEY_NUM_PAD_CLEAR",13:"KEY_ENTER",16:"KEY_SHIFT",17:"KEY_CTRL",18:"KEY_ALT",19:"KEY_PAUSE",20:"KEY_CAPS_LOCK",27:"KEY_ESCAPE",32:"KEY_SPACEBAR",33:"KEY_PAGE_UP",34:"KEY_PAGE_DOWN",35:"KEY_END",36:"KEY_HOME",37:"KEY_ARROW_LEFT",38:"KEY_ARROW_UP",39:"KEY_ARROW_RIGHT",40:"KEY_ARROW_DOWN",44:"KEY_PRINT_SCREEN",45:"KEY_INSERT",46:"KEY_DELETE",59:"KEY_SEMICOLON",91:"KEY_WINDOWS_LEFT",92:"KEY_WINDOWS_RIGHT",93:"KEY_SELECT",106:"KEY_NUM_PAD_ASTERISK",107:"KEY_NUM_PAD_PLUS_SIGN",109:"KEY_NUM_PAD_HYPHEN-MINUS",110:"KEY_NUM_PAD_FULL_STOP",111:"KEY_NUM_PAD_SOLIDUS",144:"KEY_NUM_LOCK",145:"KEY_SCROLL_LOCK",186:"KEY_SEMICOLON",187:"KEY_EQUALS_SIGN",188:"KEY_COMMA",189:"KEY_HYPHEN-MINUS",190:"KEY_FULL_STOP",191:"KEY_SOLIDUS",192:"KEY_GRAVE_ACCENT",219:"KEY_LEFT_SQUARE_BRACKET",220:"KEY_REVERSE_SOLIDUS",221:"KEY_RIGHT_SQUARE_BRACKET",222:"KEY_APOSTROPHE"};
5171(function(){
5172var _52f=MochiKit.Signal._specialKeys;
5173for(var i=48;i<=57;i++){
5174_52f[i]="KEY_"+(i-48);
5175}
5176for(i=65;i<=90;i++){
5177_52f[i]="KEY_"+String.fromCharCode(i);
5178}
5179for(i=96;i<=105;i++){
5180_52f[i]="KEY_NUM_PAD_"+(i-96);
5181}
5182for(i=112;i<=123;i++){
5183_52f[i]="KEY_F"+(i-112+1);
5184}
5185})();
5186MochiKit.Signal.Ident=function(_531){
5187this.source=_531.source;
5188this.signal=_531.signal;
5189this.listener=_531.listener;
5190this.isDOM=_531.isDOM;
5191this.objOrFunc=_531.objOrFunc;
5192this.funcOrStr=_531.funcOrStr;
5193this.connected=_531.connected;
5194};
5195MochiKit.Signal.Ident.prototype={};
5196MochiKit.Base.update(MochiKit.Signal,{__repr__:function(){
5197return "["+this.NAME+" "+this.VERSION+"]";
5198},toString:function(){
5199return this.__repr__();
5200},_unloadCache:function(){
5201var self=MochiKit.Signal;
5202var _533=self._observers;
5203for(var i=0;i<_533.length;i++){
5204if(_533[i].signal!=="onload"&&_533[i].signal!=="onunload"){
5205self._disconnect(_533[i]);
5206}
5207}
5208},_listener:function(src,sig,func,obj,_539){
5209var self=MochiKit.Signal;
5210var E=self.Event;
5211if(!_539){
5212return MochiKit.Base.bind(func,obj);
5213}
5214obj=obj||src;
5215if(typeof (func)=="string"){
5216if(sig==="onload"||sig==="onunload"){
5217return function(_53c){
5218obj[func].apply(obj,[new E(src,_53c)]);
5219var _53d=new MochiKit.Signal.Ident({source:src,signal:sig,objOrFunc:obj,funcOrStr:func});
5220MochiKit.Signal._disconnect(_53d);
5221};
5222}else{
5223return function(_53e){
5224obj[func].apply(obj,[new E(src,_53e)]);
5225};
5226}
5227}else{
5228if(sig==="onload"||sig==="onunload"){
5229return function(_53f){
5230func.apply(obj,[new E(src,_53f)]);
5231MochiKit.Signal.disconnect(src,sig,func);
5232var _540=new MochiKit.Signal.Ident({source:src,signal:sig,objOrFunc:func});
5233MochiKit.Signal._disconnect(_540);
5234};
5235}else{
5236return function(_541){
5237func.apply(obj,[new E(src,_541)]);
5238};
5239}
5240}
5241},_browserAlreadyHasMouseEnterAndLeave:function(){
5242return /MSIE/.test(navigator.userAgent);
5243},_mouseEnterListener:function(src,sig,func,obj){
5244var E=MochiKit.Signal.Event;
5245return function(_547){
5246var e=new E(src,_547);
5247try{
5248e.relatedTarget().nodeName;
5249}
5250catch(err){
5251return;
5252}
5253e.stop();
5254if(MochiKit.DOM.isChildNode(e.relatedTarget(),src)){
5255return;
5256}
5257e.type=function(){
5258return sig;
5259};
5260if(typeof (func)=="string"){
5261return obj[func].apply(obj,[e]);
5262}else{
5263return func.apply(obj,[e]);
5264}
5265};
5266},_getDestPair:function(_549,_54a){
5267var obj=null;
5268var func=null;
5269if(typeof (_54a)!="undefined"){
5270obj=_549;
5271func=_54a;
5272if(typeof (_54a)=="string"){
5273if(typeof (_549[_54a])!="function"){
5274throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
5275}
5276}else{
5277if(typeof (_54a)!="function"){
5278throw new Error("'funcOrStr' must be a function or string");
5279}
5280}
5281}else{
5282if(typeof (_549)!="function"){
5283throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
5284}else{
5285func=_549;
5286}
5287}
5288return [obj,func];
5289},connect:function(src,sig,_54f,_550){
5290src=MochiKit.DOM.getElement(src);
5291var self=MochiKit.Signal;
5292if(typeof (sig)!="string"){
5293throw new Error("'sig' must be a string");
5294}
5295var _552=self._getDestPair(_54f,_550);
5296var obj=_552[0];
5297var func=_552[1];
5298if(typeof (obj)=="undefined"||obj===null){
5299obj=src;
5300}
5301var _555=!!(src.addEventListener||src.attachEvent);
5302if(_555&&(sig==="onmouseenter"||sig==="onmouseleave")&&!self._browserAlreadyHasMouseEnterAndLeave()){
5303var _556=self._mouseEnterListener(src,sig.substr(2),func,obj);
5304if(sig==="onmouseenter"){
5305sig="onmouseover";
5306}else{
5307sig="onmouseout";
5308}
5309}else{
5310var _556=self._listener(src,sig,func,obj,_555);
5311}
5312if(src.addEventListener){
5313src.addEventListener(sig.substr(2),_556,false);
5314}else{
5315if(src.attachEvent){
5316src.attachEvent(sig,_556);
5317}
5318}
5319var _557=new MochiKit.Signal.Ident({source:src,signal:sig,listener:_556,isDOM:_555,objOrFunc:_54f,funcOrStr:_550,connected:true});
5320self._observers.push(_557);
5321if(!_555&&typeof (src.__connect__)=="function"){
5322var args=MochiKit.Base.extend([_557],arguments,1);
5323src.__connect__.apply(src,args);
5324}
5325return _557;
5326},_disconnect:function(_559){
5327if(!_559.connected){
5328return;
5329}
5330_559.connected=false;
5331if(!_559.isDOM){
5332return;
5333}
5334var src=_559.source;
5335var sig=_559.signal;
5336var _55c=_559.listener;
5337if(src.removeEventListener){
5338src.removeEventListener(sig.substr(2),_55c,false);
5339}else{
5340if(src.detachEvent){
5341src.detachEvent(sig,_55c);
5342}else{
5343throw new Error("'src' must be a DOM element");
5344}
5345}
5346},disconnect:function(_55d){
5347var self=MochiKit.Signal;
5348var _55f=self._observers;
5349var m=MochiKit.Base;
5350if(arguments.length>1){
5351var src=MochiKit.DOM.getElement(arguments[0]);
5352var sig=arguments[1];
5353var obj=arguments[2];
5354var func=arguments[3];
5355for(var i=_55f.length-1;i>=0;i--){
5356var o=_55f[i];
5357if(o.source===src&&o.signal===sig&&o.objOrFunc===obj&&o.funcOrStr===func){
5358self._disconnect(o);
5359if(!self._lock){
5360_55f.splice(i,1);
5361}else{
5362self._dirty=true;
5363}
5364return true;
5365}
5366}
5367}else{
5368var idx=m.findIdentical(_55f,_55d);
5369if(idx>=0){
5370self._disconnect(_55d);
5371if(!self._lock){
5372_55f.splice(idx,1);
5373}else{
5374self._dirty=true;
5375}
5376return true;
5377}
5378}
5379return false;
5380},disconnectAllTo:function(_568,_569){
5381var self=MochiKit.Signal;
5382var _56b=self._observers;
5383var _56c=self._disconnect;
5384var _56d=self._lock;
5385var _56e=self._dirty;
5386if(typeof (_569)==="undefined"){
5387_569=null;
5388}
5389for(var i=_56b.length-1;i>=0;i--){
5390var _570=_56b[i];
5391if(_570.objOrFunc===_568&&(_569===null||_570.funcOrStr===_569)){
5392_56c(_570);
5393if(_56d){
5394_56e=true;
5395}else{
5396_56b.splice(i,1);
5397}
5398}
5399}
5400self._dirty=_56e;
5401},disconnectAll:function(src,sig){
5402src=MochiKit.DOM.getElement(src);
5403var m=MochiKit.Base;
5404var _574=m.flattenArguments(m.extend(null,arguments,1));
5405var self=MochiKit.Signal;
5406var _576=self._disconnect;
5407var _577=self._observers;
5408var i,_579;
5409var _57a=self._lock;
5410var _57b=self._dirty;
5411if(_574.length===0){
5412for(i=_577.length-1;i>=0;i--){
5413_579=_577[i];
5414if(_579.source===src){
5415_576(_579);
5416if(!_57a){
5417_577.splice(i,1);
5418}else{
5419_57b=true;
5420}
5421}
5422}
5423}else{
5424var sigs={};
5425for(i=0;i<_574.length;i++){
5426sigs[_574[i]]=true;
5427}
5428for(i=_577.length-1;i>=0;i--){
5429_579=_577[i];
5430if(_579.source===src&&_579.signal in sigs){
5431_576(_579);
5432if(!_57a){
5433_577.splice(i,1);
5434}else{
5435_57b=true;
5436}
5437}
5438}
5439}
5440self._dirty=_57b;
5441},signal:function(src,sig){
5442var self=MochiKit.Signal;
5443var _580=self._observers;
5444src=MochiKit.DOM.getElement(src);
5445var args=MochiKit.Base.extend(null,arguments,2);
5446var _582=[];
5447self._lock=true;
5448for(var i=0;i<_580.length;i++){
5449var _584=_580[i];
5450if(_584.source===src&&_584.signal===sig){
5451try{
5452_584.listener.apply(src,args);
5453}
5454catch(e){
5455_582.push(e);
5456}
5457}
5458}
5459self._lock=false;
5460if(self._dirty){
5461self._dirty=false;
5462for(var i=_580.length-1;i>=0;i--){
5463if(!_580[i].connected){
5464_580.splice(i,1);
5465}
5466}
5467}
5468if(_582.length==1){
5469throw _582[0];
5470}else{
5471if(_582.length>1){
5472var e=new Error("Multiple errors thrown in handling 'sig', see errors property");
5473e.errors=_582;
5474throw e;
5475}
5476}
5477}});
5478MochiKit.Signal.EXPORT_OK=[];
5479MochiKit.Signal.EXPORT=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
5480MochiKit.Signal.__new__=function(win){
5481var m=MochiKit.Base;
5482this._document=document;
5483this._window=win;
5484this._lock=false;
5485this._dirty=false;
5486try{
5487this.connect(window,"onunload",this._unloadCache);
5488}
5489catch(e){
5490}
5491this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
5492m.nameFunctions(this);
5493};
5494MochiKit.Signal.__new__(this);
5495if(MochiKit.__export__){
5496connect=MochiKit.Signal.connect;
5497disconnect=MochiKit.Signal.disconnect;
5498disconnectAll=MochiKit.Signal.disconnectAll;
5499signal=MochiKit.Signal.signal;
5500}
5501MochiKit.Base._exportSymbols(this,MochiKit.Signal);
5502if(typeof (dojo)!="undefined"){
5503dojo.provide("MochiKit.Position");
5504dojo.require("MochiKit.Base");
5505dojo.require("MochiKit.DOM");
5506dojo.require("MochiKit.Style");
5507}
5508if(typeof (JSAN)!="undefined"){
5509JSAN.use("MochiKit.Base",[]);
5510JSAN.use("MochiKit.DOM",[]);
5511JSAN.use("MochiKit.Style",[]);
5512}
5513try{
5514if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.Style)=="undefined"||typeof (MochiKit.DOM)=="undefined"){
5515throw "";
5516}
5517}
5518catch(e){
5519throw "MochiKit.Style depends on MochiKit.Base, MochiKit.DOM, and MochiKit.Style!";
5520}
5521if(typeof (MochiKit.Position)=="undefined"){
5522MochiKit.Position={};
5523}
5524MochiKit.Position.NAME="MochiKit.Position";
5525MochiKit.Position.VERSION="1.4";
5526MochiKit.Position.__repr__=function(){
5527return "["+this.NAME+" "+this.VERSION+"]";
5528};
5529MochiKit.Position.toString=function(){
5530return this.__repr__();
5531};
5532MochiKit.Position.EXPORT_OK=[];
5533MochiKit.Position.EXPORT=[];
5534MochiKit.Base.update(MochiKit.Position,{includeScrollOffsets:false,prepare:function(){
5535var _588=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
5536var _589=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
5537this.windowOffset=new MochiKit.Style.Coordinates(_588,_589);
5538},cumulativeOffset:function(_58a){
5539var _58b=0;
5540var _58c=0;
5541do{
5542_58b+=_58a.offsetTop||0;
5543_58c+=_58a.offsetLeft||0;
5544_58a=_58a.offsetParent;
5545}while(_58a);
5546return new MochiKit.Style.Coordinates(_58c,_58b);
5547},realOffset:function(_58d){
5548var _58e=0;
5549var _58f=0;
5550do{
5551_58e+=_58d.scrollTop||0;
5552_58f+=_58d.scrollLeft||0;
5553_58d=_58d.parentNode;
5554}while(_58d);
5555return new MochiKit.Style.Coordinates(_58f,_58e);
5556},within:function(_590,x,y){
5557if(this.includeScrollOffsets){
5558return this.withinIncludingScrolloffsets(_590,x,y);
5559}
5560this.xcomp=x;
5561this.ycomp=y;
5562this.offset=this.cumulativeOffset(_590);
5563if(_590.style.position=="fixed"){
5564this.offset.x+=this.windowOffset.x;
5565this.offset.y+=this.windowOffset.y;
5566}
5567return (y>=this.offset.y&&y<this.offset.y+_590.offsetHeight&&x>=this.offset.x&&x<this.offset.x+_590.offsetWidth);
5568},withinIncludingScrolloffsets:function(_593,x,y){
5569var _596=this.realOffset(_593);
5570this.xcomp=x+_596.x-this.windowOffset.x;
5571this.ycomp=y+_596.y-this.windowOffset.y;
5572this.offset=this.cumulativeOffset(_593);
5573return (this.ycomp>=this.offset.y&&this.ycomp<this.offset.y+_593.offsetHeight&&this.xcomp>=this.offset.x&&this.xcomp<this.offset.x+_593.offsetWidth);
5574},overlap:function(mode,_598){
5575if(!mode){
5576return 0;
5577}
5578if(mode=="vertical"){
5579return ((this.offset.y+_598.offsetHeight)-this.ycomp)/_598.offsetHeight;
5580}
5581if(mode=="horizontal"){
5582return ((this.offset.x+_598.offsetWidth)-this.xcomp)/_598.offsetWidth;
5583}
5584},absolutize:function(_599){
5585_599=MochiKit.DOM.getElement(_599);
5586if(_599.style.position=="absolute"){
5587return;
5588}
5589MochiKit.Position.prepare();
5590var _59a=MochiKit.Position.positionedOffset(_599);
5591var _59b=_599.clientWidth;
5592var _59c=_599.clientHeight;
5593var _59d={"position":_599.style.position,"left":_59a.x-parseFloat(_599.style.left||0),"top":_59a.y-parseFloat(_599.style.top||0),"width":_599.style.width,"height":_599.style.height};
5594_599.style.position="absolute";
5595_599.style.top=_59a.y+"px";
5596_599.style.left=_59a.x+"px";
5597_599.style.width=_59b+"px";
5598_599.style.height=_59c+"px";
5599return _59d;
5600},positionedOffset:function(_59e){
5601var _59f=0,_5a0=0;
5602do{
5603_59f+=_59e.offsetTop||0;
5604_5a0+=_59e.offsetLeft||0;
5605_59e=_59e.offsetParent;
5606if(_59e){
5607p=MochiKit.Style.getStyle(_59e,"position");
5608if(p=="relative"||p=="absolute"){
5609break;
5610}
5611}
5612}while(_59e);
5613return new MochiKit.Style.Coordinates(_5a0,_59f);
5614},relativize:function(_5a1,_5a2){
5615_5a1=MochiKit.DOM.getElement(_5a1);
5616if(_5a1.style.position=="relative"){
5617return;
5618}
5619MochiKit.Position.prepare();
5620var top=parseFloat(_5a1.style.top||0)-(_5a2["top"]||0);
5621var left=parseFloat(_5a1.style.left||0)-(_5a2["left"]||0);
5622_5a1.style.position=_5a2["position"];
5623_5a1.style.top=top+"px";
5624_5a1.style.left=left+"px";
5625_5a1.style.width=_5a2["width"];
5626_5a1.style.height=_5a2["height"];
5627},clone:function(_5a5,_5a6){
5628_5a5=MochiKit.DOM.getElement(_5a5);
5629_5a6=MochiKit.DOM.getElement(_5a6);
5630_5a6.style.position="absolute";
5631var _5a7=this.cumulativeOffset(_5a5);
5632_5a6.style.top=_5a7.y+"px";
5633_5a6.style.left=_5a7.x+"px";
5634_5a6.style.width=_5a5.offsetWidth+"px";
5635_5a6.style.height=_5a5.offsetHeight+"px";
5636},page:function(_5a8){
5637var _5a9=0;
5638var _5aa=0;
5639var _5ab=_5a8;
5640do{
5641_5a9+=_5ab.offsetTop||0;
5642_5aa+=_5ab.offsetLeft||0;
5643if(_5ab.offsetParent==document.body&&MochiKit.Style.getStyle(_5ab,"position")=="absolute"){
5644break;
5645}
5646}while(_5ab=_5ab.offsetParent);
5647_5ab=_5a8;
5648do{
5649_5a9-=_5ab.scrollTop||0;
5650_5aa-=_5ab.scrollLeft||0;
5651}while(_5ab=_5ab.parentNode);
5652return new MochiKit.Style.Coordinates(_5aa,_5a9);
5653}});
5654MochiKit.Position.__new__=function(win){
5655var m=MochiKit.Base;
5656this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
5657m.nameFunctions(this);
5658};
5659MochiKit.Position.__new__(this);
5660if(typeof (dojo)!="undefined"){
5661dojo.provide("MochiKit.Visual");
5662dojo.require("MochiKit.Base");
5663dojo.require("MochiKit.DOM");
5664dojo.require("MochiKit.Style");
5665dojo.require("MochiKit.Color");
5666dojo.require("MochiKit.Position");
5667}
5668if(typeof (JSAN)!="undefined"){
5669JSAN.use("MochiKit.Base",[]);
5670JSAN.use("MochiKit.DOM",[]);
5671JSAN.use("MochiKit.Style",[]);
5672JSAN.use("MochiKit.Color",[]);
5673JSAN.use("MochiKit.Position",[]);
5674}
5675try{
5676if(typeof (MochiKit.Base)==="undefined"||typeof (MochiKit.DOM)==="undefined"||typeof (MochiKit.Style)==="undefined"||typeof (MochiKit.Position)==="undefined"||typeof (MochiKit.Color)==="undefined"){
5677throw "";
5678}
5679}
5680catch(e){
5681throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM, MochiKit.Style, MochiKit.Position and MochiKit.Color!";
5682}
5683if(typeof (MochiKit.Visual)=="undefined"){
5684MochiKit.Visual={};
5685}
5686MochiKit.Visual.NAME="MochiKit.Visual";
5687MochiKit.Visual.VERSION="1.4";
5688MochiKit.Visual.__repr__=function(){
5689return "["+this.NAME+" "+this.VERSION+"]";
5690};
5691MochiKit.Visual.toString=function(){
5692return this.__repr__();
5693};
5694MochiKit.Visual._RoundCorners=function(e,_5af){
5695e=MochiKit.DOM.getElement(e);
5696this._setOptions(_5af);
5697if(this.options.__unstable__wrapElement){
5698e=this._doWrap(e);
5699}
5700var _5b0=this.options.color;
5701var C=MochiKit.Color.Color;
5702if(this.options.color==="fromElement"){
5703_5b0=C.fromBackground(e);
5704}else{
5705if(!(_5b0 instanceof C)){
5706_5b0=C.fromString(_5b0);
5707}
5708}
5709this.isTransparent=(_5b0.asRGB().a<=0);
5710var _5b2=this.options.bgColor;
5711if(this.options.bgColor==="fromParent"){
5712_5b2=C.fromBackground(e.offsetParent);
5713}else{
5714if(!(_5b2 instanceof C)){
5715_5b2=C.fromString(_5b2);
5716}
5717}
5718this._roundCornersImpl(e,_5b0,_5b2);
5719};
5720MochiKit.Visual._RoundCorners.prototype={_doWrap:function(e){
5721var _5b4=e.parentNode;
5722var doc=MochiKit.DOM.currentDocument();
5723if(typeof (doc.defaultView)==="undefined"||doc.defaultView===null){
5724return e;
5725}
5726var _5b6=doc.defaultView.getComputedStyle(e,null);
5727if(typeof (_5b6)==="undefined"||_5b6===null){
5728return e;
5729}
5730var _5b7=MochiKit.DOM.DIV({"style":{display:"block",marginTop:_5b6.getPropertyValue("padding-top"),marginRight:_5b6.getPropertyValue("padding-right"),marginBottom:_5b6.getPropertyValue("padding-bottom"),marginLeft:_5b6.getPropertyValue("padding-left"),padding:"0px"}});
5731_5b7.innerHTML=e.innerHTML;
5732e.innerHTML="";
5733e.appendChild(_5b7);
5734return e;
5735},_roundCornersImpl:function(e,_5b9,_5ba){
5736if(this.options.border){
5737this._renderBorder(e,_5ba);
5738}
5739if(this._isTopRounded()){
5740this._roundTopCorners(e,_5b9,_5ba);
5741}
5742if(this._isBottomRounded()){
5743this._roundBottomCorners(e,_5b9,_5ba);
5744}
5745},_renderBorder:function(el,_5bc){
5746var _5bd="1px solid "+this._borderColor(_5bc);
5747var _5be="border-left: "+_5bd;
5748var _5bf="border-right: "+_5bd;
5749var _5c0="style='"+_5be+";"+_5bf+"'";
5750el.innerHTML="<div "+_5c0+">"+el.innerHTML+"</div>";
5751},_roundTopCorners:function(el,_5c2,_5c3){
5752var _5c4=this._createCorner(_5c3);
5753for(var i=0;i<this.options.numSlices;i++){
5754_5c4.appendChild(this._createCornerSlice(_5c2,_5c3,i,"top"));
5755}
5756el.style.paddingTop=0;
5757el.insertBefore(_5c4,el.firstChild);
5758},_roundBottomCorners:function(el,_5c7,_5c8){
5759var _5c9=this._createCorner(_5c8);
5760for(var i=(this.options.numSlices-1);i>=0;i--){
5761_5c9.appendChild(this._createCornerSlice(_5c7,_5c8,i,"bottom"));
5762}
5763el.style.paddingBottom=0;
5764el.appendChild(_5c9);
5765},_createCorner:function(_5cb){
5766var dom=MochiKit.DOM;
5767return dom.DIV({style:{backgroundColor:_5cb.toString()}});
5768},_createCornerSlice:function(_5cd,_5ce,n,_5d0){
5769var _5d1=MochiKit.DOM.SPAN();
5770var _5d2=_5d1.style;
5771_5d2.backgroundColor=_5cd.toString();
5772_5d2.display="block";
5773_5d2.height="1px";
5774_5d2.overflow="hidden";
5775_5d2.fontSize="1px";
5776var _5d3=this._borderColor(_5cd,_5ce);
5777if(this.options.border&&n===0){
5778_5d2.borderTopStyle="solid";
5779_5d2.borderTopWidth="1px";
5780_5d2.borderLeftWidth="0px";
5781_5d2.borderRightWidth="0px";
5782_5d2.borderBottomWidth="0px";
5783_5d2.height="0px";
5784_5d2.borderColor=_5d3.toString();
5785}else{
5786if(_5d3){
5787_5d2.borderColor=_5d3.toString();
5788_5d2.borderStyle="solid";
5789_5d2.borderWidth="0px 1px";
5790}
5791}
5792if(!this.options.compact&&(n==(this.options.numSlices-1))){
5793_5d2.height="2px";
5794}
5795this._setMargin(_5d1,n,_5d0);
5796this._setBorder(_5d1,n,_5d0);
5797return _5d1;
5798},_setOptions:function(_5d4){
5799this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,__unstable__wrapElement:false};
5800MochiKit.Base.update(this.options,_5d4);
5801this.options.numSlices=(this.options.compact?2:4);
5802},_whichSideTop:function(){
5803var _5d5=this.options.corners;
5804if(this._hasString(_5d5,"all","top")){
5805return "";
5806}
5807var _5d6=(_5d5.indexOf("tl")!=-1);
5808var _5d7=(_5d5.indexOf("tr")!=-1);
5809if(_5d6&&_5d7){
5810return "";
5811}
5812if(_5d6){
5813return "left";
5814}
5815if(_5d7){
5816return "right";
5817}
5818return "";
5819},_whichSideBottom:function(){
5820var _5d8=this.options.corners;
5821if(this._hasString(_5d8,"all","bottom")){
5822return "";
5823}
5824var _5d9=(_5d8.indexOf("bl")!=-1);
5825var _5da=(_5d8.indexOf("br")!=-1);
5826if(_5d9&&_5da){
5827return "";
5828}
5829if(_5d9){
5830return "left";
5831}
5832if(_5da){
5833return "right";
5834}
5835return "";
5836},_borderColor:function(_5db,_5dc){
5837if(_5db=="transparent"){
5838return _5dc;
5839}else{
5840if(this.options.border){
5841return this.options.border;
5842}else{
5843if(this.options.blend){
5844return _5dc.blendedColor(_5db);
5845}
5846}
5847}
5848return "";
5849},_setMargin:function(el,n,_5df){
5850var _5e0=this._marginSize(n)+"px";
5851var _5e1=(_5df=="top"?this._whichSideTop():this._whichSideBottom());
5852var _5e2=el.style;
5853if(_5e1=="left"){
5854_5e2.marginLeft=_5e0;
5855_5e2.marginRight="0px";
5856}else{
5857if(_5e1=="right"){
5858_5e2.marginRight=_5e0;
5859_5e2.marginLeft="0px";
5860}else{
5861_5e2.marginLeft=_5e0;
5862_5e2.marginRight=_5e0;
5863}
5864}
5865},_setBorder:function(el,n,_5e5){
5866var _5e6=this._borderSize(n)+"px";
5867var _5e7=(_5e5=="top"?this._whichSideTop():this._whichSideBottom());
5868var _5e8=el.style;
5869if(_5e7=="left"){
5870_5e8.borderLeftWidth=_5e6;
5871_5e8.borderRightWidth="0px";
5872}else{
5873if(_5e7=="right"){
5874_5e8.borderRightWidth=_5e6;
5875_5e8.borderLeftWidth="0px";
5876}else{
5877_5e8.borderLeftWidth=_5e6;
5878_5e8.borderRightWidth=_5e6;
5879}
5880}
5881},_marginSize:function(n){
5882if(this.isTransparent){
5883return 0;
5884}
5885var o=this.options;
5886if(o.compact&&o.blend){
5887var _5eb=[1,0];
5888return _5eb[n];
5889}else{
5890if(o.compact){
5891var _5ec=[2,1];
5892return _5ec[n];
5893}else{
5894if(o.blend){
5895var _5ed=[3,2,1,0];
5896return _5ed[n];
5897}else{
5898var _5ee=[5,3,2,1];
5899return _5ee[n];
5900}
5901}
5902}
5903},_borderSize:function(n){
5904var o=this.options;
5905var _5f1;
5906if(o.compact&&(o.blend||this.isTransparent)){
5907return 1;
5908}else{
5909if(o.compact){
5910_5f1=[1,0];
5911}else{
5912if(o.blend){
5913_5f1=[2,1,1,1];
5914}else{
5915if(o.border){
5916_5f1=[0,2,0,0];
5917}else{
5918if(this.isTransparent){
5919_5f1=[5,3,2,1];
5920}else{
5921return 0;
5922}
5923}
5924}
5925}
5926}
5927return _5f1[n];
5928},_hasString:function(str){
5929for(var i=1;i<arguments.length;i++){
5930if(str.indexOf(arguments[i])!=-1){
5931return true;
5932}
5933}
5934return false;
5935},_isTopRounded:function(){
5936return this._hasString(this.options.corners,"all","top","tl","tr");
5937},_isBottomRounded:function(){
5938return this._hasString(this.options.corners,"all","bottom","bl","br");
5939},_hasSingleTextChild:function(el){
5940return (el.childNodes.length==1&&el.childNodes[0].nodeType==3);
5941}};
5942MochiKit.Visual.roundElement=function(e,_5f6){
5943new MochiKit.Visual._RoundCorners(e,_5f6);
5944};
5945MochiKit.Visual.roundClass=function(_5f7,_5f8,_5f9){
5946var _5fa=MochiKit.DOM.getElementsByTagAndClassName(_5f7,_5f8);
5947for(var i=0;i<_5fa.length;i++){
5948MochiKit.Visual.roundElement(_5fa[i],_5f9);
5949}
5950};
5951MochiKit.Visual.tagifyText=function(_5fc,_5fd){
5952_5fd=_5fd||"position:relative";
5953if(/MSIE/.test(navigator.userAgent)){
5954_5fd+=";zoom:1";
5955}
5956_5fc=MochiKit.DOM.getElement(_5fc);
5957var ma=MochiKit.Base.map;
5958ma(function(_5ff){
5959if(_5ff.nodeType==3){
5960ma(function(_600){
5961_5fc.insertBefore(MochiKit.DOM.SPAN({style:_5fd},_600==" "?String.fromCharCode(160):_600),_5ff);
5962},_5ff.nodeValue.split(""));
5963MochiKit.DOM.removeElement(_5ff);
5964}
5965},_5fc.childNodes);
5966};
5967MochiKit.Visual.forceRerendering=function(_601){
5968try{
5969_601=MochiKit.DOM.getElement(_601);
5970var n=document.createTextNode(" ");
5971_601.appendChild(n);
5972_601.removeChild(n);
5973}
5974catch(e){
5975}
5976};
5977MochiKit.Visual.multiple=function(_603,_604,_605){
5978_605=MochiKit.Base.update({speed:0.1,delay:0},_605||{});
5979var _606=_605.delay;
5980var _607=0;
5981MochiKit.Base.map(function(_608){
5982_605.delay=_607*_605.speed+_606;
5983new _604(_608,_605);
5984_607+=1;
5985},_603);
5986};
5987MochiKit.Visual.PAIRS={"slide":["slideDown","slideUp"],"blind":["blindDown","blindUp"],"appear":["appear","fade"],"size":["grow","shrink"]};
5988MochiKit.Visual.toggle=function(_609,_60a,_60b){
5989_609=MochiKit.DOM.getElement(_609);
5990_60a=(_60a||"appear").toLowerCase();
5991_60b=MochiKit.Base.update({queue:{position:"end",scope:(_609.id||"global"),limit:1}},_60b||{});
5992var v=MochiKit.Visual;
5993v[_609.style.display!="none"?v.PAIRS[_60a][1]:v.PAIRS[_60a][0]](_609,_60b);
5994};
5995MochiKit.Visual.Transitions={};
5996MochiKit.Visual.Transitions.linear=function(pos){
5997return pos;
5998};
5999MochiKit.Visual.Transitions.sinoidal=function(pos){
6000return (-Math.cos(pos*Math.PI)/2)+0.5;
6001};
6002MochiKit.Visual.Transitions.reverse=function(pos){
6003return 1-pos;
6004};
6005MochiKit.Visual.Transitions.flicker=function(pos){
6006return ((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;
6007};
6008MochiKit.Visual.Transitions.wobble=function(pos){
6009return (-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;
6010};
6011MochiKit.Visual.Transitions.pulse=function(pos,_613){
6012if(!_613){
6013return (Math.floor(pos*10)%2===0?(pos*10-Math.floor(pos*10)):1-(pos*10-Math.floor(pos*10)));
6014}
6015return (Math.round((pos%(1/_613))*_613)==0?((pos*_613*2)-Math.floor(pos*_613*2)):1-((pos*_613*2)-Math.floor(pos*_613*2)));
6016};
6017MochiKit.Visual.Transitions.none=function(pos){
6018return 0;
6019};
6020MochiKit.Visual.Transitions.full=function(pos){
6021return 1;
6022};
6023MochiKit.Visual.ScopedQueue=function(){
6024var cls=arguments.callee;
6025if(!(this instanceof cls)){
6026return new cls();
6027}
6028this.__init__();
6029};
6030MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype,{__init__:function(){
6031this.effects=[];
6032this.interval=null;
6033},add:function(_617){
6034var _618=new Date().getTime();
6035var _619=(typeof (_617.options.queue)=="string")?_617.options.queue:_617.options.queue.position;
6036var ma=MochiKit.Base.map;
6037switch(_619){
6038case "front":
6039ma(function(e){
6040if(e.state=="idle"){
6041e.startOn+=_617.finishOn;
6042e.finishOn+=_617.finishOn;
6043}
6044},this.effects);
6045break;
6046case "end":
6047var _61c;
6048ma(function(e){
6049var i=e.finishOn;
6050if(i>=(_61c||i)){
6051_61c=i;
6052}
6053},this.effects);
6054_618=_61c||_618;
6055break;
6056case "break":
6057ma(function(e){
6058e.finalize();
6059},this.effects);
6060break;
6061}
6062_617.startOn+=_618;
6063_617.finishOn+=_618;
6064if(!_617.options.queue.limit||this.effects.length<_617.options.queue.limit){
6065this.effects.push(_617);
6066}
6067if(!this.interval){
6068this.interval=this.startLoop(MochiKit.Base.bind(this.loop,this),40);
6069}
6070},startLoop:function(func,_621){
6071return setInterval(func,_621);
6072},remove:function(_622){
6073this.effects=MochiKit.Base.filter(function(e){
6074return e!=_622;
6075},this.effects);
6076if(!this.effects.length){
6077this.stopLoop(this.interval);
6078this.interval=null;
6079}
6080},stopLoop:function(_624){
6081clearInterval(_624);
6082},loop:function(){
6083var _625=new Date().getTime();
6084MochiKit.Base.map(function(_626){
6085_626.loop(_625);
6086},this.effects);
6087}});
6088MochiKit.Visual.Queues={instances:{},get:function(_627){
6089if(typeof (_627)!="string"){
6090return _627;
6091}
6092if(!this.instances[_627]){
6093this.instances[_627]=new MochiKit.Visual.ScopedQueue();
6094}
6095return this.instances[_627];
6096}};
6097MochiKit.Visual.Queue=MochiKit.Visual.Queues.get("global");
6098MochiKit.Visual.DefaultOptions={transition:MochiKit.Visual.Transitions.sinoidal,duration:1,fps:25,sync:false,from:0,to:1,delay:0,queue:"parallel"};
6099MochiKit.Visual.Base=function(){
6100};
6101MochiKit.Visual.Base.prototype={__class__:MochiKit.Visual.Base,start:function(_628){
6102var v=MochiKit.Visual;
6103this.options=MochiKit.Base.setdefault(_628||{},v.DefaultOptions);
6104this.currentFrame=0;
6105this.state="idle";
6106this.startOn=this.options.delay*1000;
6107this.finishOn=this.startOn+(this.options.duration*1000);
6108this.event("beforeStart");
6109if(!this.options.sync){
6110v.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).add(this);
6111}
6112},loop:function(_62a){
6113if(_62a>=this.startOn){
6114if(_62a>=this.finishOn){
6115return this.finalize();
6116}
6117var pos=(_62a-this.startOn)/(this.finishOn-this.startOn);
6118var _62c=Math.round(pos*this.options.fps*this.options.duration);
6119if(_62c>this.currentFrame){
6120this.render(pos);
6121this.currentFrame=_62c;
6122}
6123}
6124},render:function(pos){
6125if(this.state=="idle"){
6126this.state="running";
6127this.event("beforeSetup");
6128this.setup();
6129this.event("afterSetup");
6130}
6131if(this.state=="running"){
6132if(this.options.transition){
6133pos=this.options.transition(pos);
6134}
6135pos*=(this.options.to-this.options.from);
6136pos+=this.options.from;
6137this.event("beforeUpdate");
6138this.update(pos);
6139this.event("afterUpdate");
6140}
6141},cancel:function(){
6142if(!this.options.sync){
6143MochiKit.Visual.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).remove(this);
6144}
6145this.state="finished";
6146},finalize:function(){
6147this.render(1);
6148this.cancel();
6149this.event("beforeFinish");
6150this.finish();
6151this.event("afterFinish");
6152},setup:function(){
6153},finish:function(){
6154},update:function(_62e){
6155},event:function(_62f){
6156if(this.options[_62f+"Internal"]){
6157this.options[_62f+"Internal"](this);
6158}
6159if(this.options[_62f]){
6160this.options[_62f](this);
6161}
6162},repr:function(){
6163return "["+this.__class__.NAME+", options:"+MochiKit.Base.repr(this.options)+"]";
6164}};
6165MochiKit.Visual.Parallel=function(_630,_631){
6166var cls=arguments.callee;
6167if(!(this instanceof cls)){
6168return new cls(_630,_631);
6169}
6170this.__init__(_630,_631);
6171};
6172MochiKit.Visual.Parallel.prototype=new MochiKit.Visual.Base();
6173MochiKit.Base.update(MochiKit.Visual.Parallel.prototype,{__class__:MochiKit.Visual.Parallel,__init__:function(_633,_634){
6174this.effects=_633||[];
6175this.start(_634);
6176},update:function(_635){
6177MochiKit.Base.map(function(_636){
6178_636.render(_635);
6179},this.effects);
6180},finish:function(){
6181MochiKit.Base.map(function(_637){
6182_637.finalize();
6183},this.effects);
6184}});
6185MochiKit.Visual.Opacity=function(_638,_639){
6186var cls=arguments.callee;
6187if(!(this instanceof cls)){
6188return new cls(_638,_639);
6189}
6190this.__init__(_638,_639);
6191};
6192MochiKit.Visual.Opacity.prototype=new MochiKit.Visual.Base();
6193MochiKit.Base.update(MochiKit.Visual.Opacity.prototype,{__class__:MochiKit.Visual.Opacity,__init__:function(_63b,_63c){
6194var b=MochiKit.Base;
6195var s=MochiKit.Style;
6196this.element=MochiKit.DOM.getElement(_63b);
6197if(this.element.currentStyle&&(!this.element.currentStyle.hasLayout)){
6198s.setStyle(this.element,{zoom:1});
6199}
6200_63c=b.update({from:s.getStyle(this.element,"opacity")||0,to:1},_63c||{});
6201this.start(_63c);
6202},update:function(_63f){
6203MochiKit.Style.setStyle(this.element,{"opacity":_63f});
6204}});
6205MochiKit.Visual.Move=function(_640,_641){
6206var cls=arguments.callee;
6207if(!(this instanceof cls)){
6208return new cls(_640,_641);
6209}
6210this.__init__(_640,_641);
6211};
6212MochiKit.Visual.Move.prototype=new MochiKit.Visual.Base();
6213MochiKit.Base.update(MochiKit.Visual.Move.prototype,{__class__:MochiKit.Visual.Move,__init__:function(_643,_644){
6214this.element=MochiKit.DOM.getElement(_643);
6215_644=MochiKit.Base.update({x:0,y:0,mode:"relative"},_644||{});
6216this.start(_644);
6217},setup:function(){
6218MochiKit.DOM.makePositioned(this.element);
6219var s=this.element.style;
6220var _646=s.visibility;
6221var _647=s.display;
6222if(_647=="none"){
6223s.visibility="hidden";
6224s.display="";
6225}
6226this.originalLeft=parseFloat(MochiKit.Style.getStyle(this.element,"left")||"0");
6227this.originalTop=parseFloat(MochiKit.Style.getStyle(this.element,"top")||"0");
6228if(this.options.mode=="absolute"){
6229this.options.x-=this.originalLeft;
6230this.options.y-=this.originalTop;
6231}
6232if(_647=="none"){
6233s.visibility=_646;
6234s.display=_647;
6235}
6236},update:function(_648){
6237MochiKit.Style.setStyle(this.element,{left:Math.round(this.options.x*_648+this.originalLeft)+"px",top:Math.round(this.options.y*_648+this.originalTop)+"px"});
6238}});
6239MochiKit.Visual.Scale=function(_649,_64a,_64b){
6240var cls=arguments.callee;
6241if(!(this instanceof cls)){
6242return new cls(_649,_64a,_64b);
6243}
6244this.__init__(_649,_64a,_64b);
6245};
6246MochiKit.Visual.Scale.prototype=new MochiKit.Visual.Base();
6247MochiKit.Base.update(MochiKit.Visual.Scale.prototype,{__class__:MochiKit.Visual.Scale,__init__:function(_64d,_64e,_64f){
6248this.element=MochiKit.DOM.getElement(_64d);
6249_64f=MochiKit.Base.update({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_64e},_64f||{});
6250this.start(_64f);
6251},setup:function(){
6252this.restoreAfterFinish=this.options.restoreAfterFinish||false;
6253this.elementPositioning=MochiKit.Style.getStyle(this.element,"position");
6254var ma=MochiKit.Base.map;
6255var b=MochiKit.Base.bind;
6256this.originalStyle={};
6257ma(b(function(k){
6258this.originalStyle[k]=this.element.style[k];
6259},this),["top","left","width","height","fontSize"]);
6260this.originalTop=this.element.offsetTop;
6261this.originalLeft=this.element.offsetLeft;
6262var _653=MochiKit.Style.getStyle(this.element,"font-size")||"100%";
6263ma(b(function(_654){
6264if(_653.indexOf(_654)>0){
6265this.fontSize=parseFloat(_653);
6266this.fontSizeType=_654;
6267}
6268},this),["em","px","%"]);
6269this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;
6270if(/^content/.test(this.options.scaleMode)){
6271this.dims=[this.element.scrollHeight,this.element.scrollWidth];
6272}else{
6273if(this.options.scaleMode=="box"){
6274this.dims=[this.element.offsetHeight,this.element.offsetWidth];
6275}else{
6276this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];
6277}
6278}
6279},update:function(_655){
6280var _656=(this.options.scaleFrom/100)+(this.factor*_655);
6281if(this.options.scaleContent&&this.fontSize){
6282MochiKit.Style.setStyle(this.element,{fontSize:this.fontSize*_656+this.fontSizeType});
6283}
6284this.setDimensions(this.dims[0]*_656,this.dims[1]*_656);
6285},finish:function(){
6286if(this.restoreAfterFinish){
6287MochiKit.Style.setStyle(this.element,this.originalStyle);
6288}
6289},setDimensions:function(_657,_658){
6290var d={};
6291var r=Math.round;
6292if(/MSIE/.test(navigator.userAgent)){
6293r=Math.ceil;
6294}
6295if(this.options.scaleX){
6296d.width=r(_658)+"px";
6297}
6298if(this.options.scaleY){
6299d.height=r(_657)+"px";
6300}
6301if(this.options.scaleFromCenter){
6302var topd=(_657-this.dims[0])/2;
6303var _65c=(_658-this.dims[1])/2;
6304if(this.elementPositioning=="absolute"){
6305if(this.options.scaleY){
6306d.top=this.originalTop-topd+"px";
6307}
6308if(this.options.scaleX){
6309d.left=this.originalLeft-_65c+"px";
6310}
6311}else{
6312if(this.options.scaleY){
6313d.top=-topd+"px";
6314}
6315if(this.options.scaleX){
6316d.left=-_65c+"px";
6317}
6318}
6319}
6320MochiKit.Style.setStyle(this.element,d);
6321}});
6322MochiKit.Visual.Highlight=function(_65d,_65e){
6323var cls=arguments.callee;
6324if(!(this instanceof cls)){
6325return new cls(_65d,_65e);
6326}
6327this.__init__(_65d,_65e);
6328};
6329MochiKit.Visual.Highlight.prototype=new MochiKit.Visual.Base();
6330MochiKit.Base.update(MochiKit.Visual.Highlight.prototype,{__class__:MochiKit.Visual.Highlight,__init__:function(_660,_661){
6331this.element=MochiKit.DOM.getElement(_660);
6332_661=MochiKit.Base.update({startcolor:"#ffff99"},_661||{});
6333this.start(_661);
6334},setup:function(){
6335var b=MochiKit.Base;
6336var s=MochiKit.Style;
6337if(s.getStyle(this.element,"display")=="none"){
6338this.cancel();
6339return;
6340}
6341this.oldStyle={backgroundImage:s.getStyle(this.element,"background-image")};
6342s.setStyle(this.element,{backgroundImage:"none"});
6343if(!this.options.endcolor){
6344this.options.endcolor=MochiKit.Color.Color.fromBackground(this.element).toHexString();
6345}
6346if(b.isUndefinedOrNull(this.options.restorecolor)){
6347this.options.restorecolor=s.getStyle(this.element,"background-color");
6348}
6349this._base=b.map(b.bind(function(i){
6350return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);
6351},this),[0,1,2]);
6352this._delta=b.map(b.bind(function(i){
6353return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];
6354},this),[0,1,2]);
6355},update:function(_666){
6356var m="#";
6357MochiKit.Base.map(MochiKit.Base.bind(function(i){
6358m+=MochiKit.Color.toColorPart(Math.round(this._base[i]+this._delta[i]*_666));
6359},this),[0,1,2]);
6360MochiKit.Style.setStyle(this.element,{backgroundColor:m});
6361},finish:function(){
6362MochiKit.Style.setStyle(this.element,MochiKit.Base.update(this.oldStyle,{backgroundColor:this.options.restorecolor}));
6363}});
6364MochiKit.Visual.ScrollTo=function(_669,_66a){
6365var cls=arguments.callee;
6366if(!(this instanceof cls)){
6367return new cls(_669,_66a);
6368}
6369this.__init__(_669,_66a);
6370};
6371MochiKit.Visual.ScrollTo.prototype=new MochiKit.Visual.Base();
6372MochiKit.Base.update(MochiKit.Visual.ScrollTo.prototype,{__class__:MochiKit.Visual.ScrollTo,__init__:function(_66c,_66d){
6373this.element=MochiKit.DOM.getElement(_66c);
6374this.start(_66d||{});
6375},setup:function(){
6376var p=MochiKit.Position;
6377p.prepare();
6378var _66f=p.cumulativeOffset(this.element);
6379if(this.options.offset){
6380_66f.y+=this.options.offset;
6381}
6382var max;
6383if(window.innerHeight){
6384max=window.innerHeight-window.height;
6385}else{
6386if(document.documentElement&&document.documentElement.clientHeight){
6387max=document.documentElement.clientHeight-document.body.scrollHeight;
6388}else{
6389if(document.body){
6390max=document.body.clientHeight-document.body.scrollHeight;
6391}
6392}
6393}
6394this.scrollStart=p.windowOffset.y;
6395this.delta=(_66f.y>max?max:_66f.y)-this.scrollStart;
6396},update:function(_671){
6397var p=MochiKit.Position;
6398p.prepare();
6399window.scrollTo(p.windowOffset.x,this.scrollStart+(_671*this.delta));
6400}});
6401MochiKit.Visual.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
6402MochiKit.Visual.Morph=function(_673,_674){
6403var cls=arguments.callee;
6404if(!(this instanceof cls)){
6405return new cls(_673,_674);
6406}
6407this.__init__(_673,_674);
6408};
6409MochiKit.Visual.Morph.prototype=new MochiKit.Visual.Base();
6410MochiKit.Base.update(MochiKit.Visual.Morph.prototype,{__class__:MochiKit.Visual.Morph,__init__:function(_676,_677){
6411this.element=MochiKit.DOM.getElement(_676);
6412this.start(_677||{});
6413},setup:function(){
6414var b=MochiKit.Base;
6415var _679=this.options.style;
6416this.styleStart={};
6417this.styleEnd={};
6418this.units={};
6419var _67a,unit;
6420for(var s in _679){
6421_67a=_679[s];
6422s=b.camelize(s);
6423if(MochiKit.Visual.CSS_LENGTH.test(_67a)){
6424var _67d=_67a.match(/^([\+\-]?[0-9\.]+)(.*)$/);
6425_67a=parseFloat(_67d[1]);
6426unit=(_67d.length==3)?_67d[2]:null;
6427this.styleEnd[s]=_67a;
6428this.units[s]=unit;
6429_67a=MochiKit.Style.getStyle(this.element,s);
6430_67d=_67a.match(/^([\+\-]?[0-9\.]+)(.*)$/);
6431_67a=parseFloat(_67d[1]);
6432this.styleStart[s]=_67a;
6433}else{
6434var c=MochiKit.Color.Color;
6435_67a=c.fromString(_67a);
6436if(_67a){
6437this.units[s]="color";
6438this.styleEnd[s]=_67a.toHexString();
6439_67a=MochiKit.Style.getStyle(this.element,s);
6440this.styleStart[s]=c.fromString(_67a).toHexString();
6441this.styleStart[s]=b.map(b.bind(function(i){
6442return parseInt(this.styleStart[s].slice(i*2+1,i*2+3),16);
6443},this),[0,1,2]);
6444this.styleEnd[s]=b.map(b.bind(function(i){
6445return parseInt(this.styleEnd[s].slice(i*2+1,i*2+3),16);
6446},this),[0,1,2]);
6447}
6448}
6449}
6450},update:function(_681){
6451var _682;
6452for(var s in this.styleStart){
6453if(this.units[s]=="color"){
6454var m="#";
6455var _685=this.styleStart[s];
6456var end=this.styleEnd[s];
6457MochiKit.Base.map(MochiKit.Base.bind(function(i){
6458m+=MochiKit.Color.toColorPart(Math.round(_685[i]+(end[i]-_685[i])*_681));
6459},this),[0,1,2]);
6460this.element.style[s]=m;
6461}else{
6462_682=this.styleStart[s]+Math.round((this.styleEnd[s]-this.styleStart[s])*_681*1000)/1000+this.units[s];
6463this.element.style[s]=_682;
6464}
6465}
6466}});
6467MochiKit.Visual.fade=function(_688,_689){
6468var s=MochiKit.Style;
6469var _68b=s.getStyle(_688,"opacity");
6470_689=MochiKit.Base.update({from:s.getStyle(_688,"opacity")||1,to:0,afterFinishInternal:function(_68c){
6471if(_68c.options.to!==0){
6472return;
6473}
6474s.hideElement(_68c.element);
6475s.setStyle(_68c.element,{"opacity":_68b});
6476}},_689||{});
6477return new MochiKit.Visual.Opacity(_688,_689);
6478};
6479MochiKit.Visual.appear=function(_68d,_68e){
6480var s=MochiKit.Style;
6481var v=MochiKit.Visual;
6482_68e=MochiKit.Base.update({from:(s.getStyle(_68d,"display")=="none"?0:s.getStyle(_68d,"opacity")||0),to:1,afterFinishInternal:function(_691){
6483v.forceRerendering(_691.element);
6484},beforeSetupInternal:function(_692){
6485s.setStyle(_692.element,{"opacity":_692.options.from});
6486s.showElement(_692.element);
6487}},_68e||{});
6488return new v.Opacity(_68d,_68e);
6489};
6490MochiKit.Visual.puff=function(_693,_694){
6491var s=MochiKit.Style;
6492var v=MochiKit.Visual;
6493_693=MochiKit.DOM.getElement(_693);
6494var _697={position:s.getStyle(_693,"position"),top:_693.style.top,left:_693.style.left,width:_693.style.width,height:_693.style.height,opacity:s.getStyle(_693,"opacity")};
6495_694=MochiKit.Base.update({beforeSetupInternal:function(_698){
6496MochiKit.Position.absolutize(_698.effects[0].element);
6497},afterFinishInternal:function(_699){
6498s.hideElement(_699.effects[0].element);
6499s.setStyle(_699.effects[0].element,_697);
6500},scaleContent:true,scaleFromCenter:true},_694||{});
6501return new v.Parallel([new v.Scale(_693,200,{sync:true,scaleFromCenter:_694.scaleFromCenter,scaleContent:_694.scaleContent,restoreAfterFinish:true}),new v.Opacity(_693,{sync:true,to:0})],_694);
6502};
6503MochiKit.Visual.blindUp=function(_69a,_69b){
6504var d=MochiKit.DOM;
6505_69a=d.getElement(_69a);
6506var _69d=d.makeClipping(_69a);
6507_69b=MochiKit.Base.update({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_69e){
6508MochiKit.Style.hideElement(_69e.element);
6509d.undoClipping(_69e.element,_69d);
6510}},_69b||{});
6511return new MochiKit.Visual.Scale(_69a,0,_69b);
6512};
6513MochiKit.Visual.blindDown=function(_69f,_6a0){
6514var d=MochiKit.DOM;
6515var s=MochiKit.Style;
6516_69f=d.getElement(_69f);
6517var _6a3=s.getElementDimensions(_69f);
6518var _6a4;
6519_6a0=MochiKit.Base.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6a3.h,originalWidth:_6a3.w},restoreAfterFinish:true,afterSetupInternal:function(_6a5){
6520_6a4=d.makeClipping(_6a5.element);
6521s.setStyle(_6a5.element,{height:"0px"});
6522s.showElement(_6a5.element);
6523},afterFinishInternal:function(_6a6){
6524d.undoClipping(_6a6.element,_6a4);
6525}},_6a0||{});
6526return new MochiKit.Visual.Scale(_69f,100,_6a0);
6527};
6528MochiKit.Visual.switchOff=function(_6a7,_6a8){
6529var d=MochiKit.DOM;
6530_6a7=d.getElement(_6a7);
6531var _6aa=MochiKit.Style.getStyle(_6a7,"opacity");
6532var _6ab;
6533_6a8=MochiKit.Base.update({duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetupInternal:function(_6ac){
6534d.makePositioned(_6ac.element);
6535_6ab=d.makeClipping(_6ac.element);
6536},afterFinishInternal:function(_6ad){
6537MochiKit.Style.hideElement(_6ad.element);
6538d.undoClipping(_6ad.element,_6ab);
6539d.undoPositioned(_6ad.element);
6540MochiKit.Style.setStyle(_6ad.element,{"opacity":_6aa});
6541}},_6a8||{});
6542var v=MochiKit.Visual;
6543return new v.appear(_6a7,{duration:0.4,from:0,transition:v.Transitions.flicker,afterFinishInternal:function(_6af){
6544new v.Scale(_6af.element,1,_6a8);
6545}});
6546};
6547MochiKit.Visual.dropOut=function(_6b0,_6b1){
6548var d=MochiKit.DOM;
6549var s=MochiKit.Style;
6550_6b0=d.getElement(_6b0);
6551var _6b4={top:s.getStyle(_6b0,"top"),left:s.getStyle(_6b0,"left"),opacity:s.getStyle(_6b0,"opacity")};
6552_6b1=MochiKit.Base.update({duration:0.5,distance:100,beforeSetupInternal:function(_6b5){
6553d.makePositioned(_6b5.effects[0].element);
6554},afterFinishInternal:function(_6b6){
6555s.hideElement(_6b6.effects[0].element);
6556d.undoPositioned(_6b6.effects[0].element);
6557s.setStyle(_6b6.effects[0].element,_6b4);
6558}},_6b1||{});
6559var v=MochiKit.Visual;
6560return new v.Parallel([new v.Move(_6b0,{x:0,y:_6b1.distance,sync:true}),new v.Opacity(_6b0,{sync:true,to:0})],_6b1);
6561};
6562MochiKit.Visual.shake=function(_6b8,_6b9){
6563var d=MochiKit.DOM;
6564var v=MochiKit.Visual;
6565var s=MochiKit.Style;
6566_6b8=d.getElement(_6b8);
6567_6b9=MochiKit.Base.update({x:-20,y:0,duration:0.05,afterFinishInternal:function(_6bd){
6568d.undoPositioned(_6bd.element);
6569s.setStyle(_6bd.element,_6be);
6570}},_6b9||{});
6571var _6be={top:s.getStyle(_6b8,"top"),left:s.getStyle(_6b8,"left")};
6572return new v.Move(_6b8,{x:20,y:0,duration:0.05,afterFinishInternal:function(_6bf){
6573new v.Move(_6bf.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c0){
6574new v.Move(_6c0.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6c1){
6575new v.Move(_6c1.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c2){
6576new v.Move(_6c2.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6c3){
6577new v.Move(_6c3.element,_6b9);
6578}});
6579}});
6580}});
6581}});
6582}});
6583};
6584MochiKit.Visual.slideDown=function(_6c4,_6c5){
6585var d=MochiKit.DOM;
6586var b=MochiKit.Base;
6587var s=MochiKit.Style;
6588_6c4=d.getElement(_6c4);
6589if(!_6c4.firstChild){
6590throw "MochiKit.Visual.slideDown must be used on a element with a child";
6591}
6592d.removeEmptyTextNodes(_6c4);
6593var _6c9=s.getStyle(_6c4.firstChild,"bottom")||0;
6594var _6ca=s.getElementDimensions(_6c4);
6595var _6cb;
6596_6c5=b.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6ca.h,originalWidth:_6ca.w},restoreAfterFinish:true,afterSetupInternal:function(_6cc){
6597d.makePositioned(_6cc.element);
6598d.makePositioned(_6cc.element.firstChild);
6599if(/Opera/.test(navigator.userAgent)){
6600s.setStyle(_6cc.element,{top:""});
6601}
6602_6cb=d.makeClipping(_6cc.element);
6603s.setStyle(_6cc.element,{height:"0px"});
6604s.showElement(_6cc.element);
6605},afterUpdateInternal:function(_6cd){
6606s.setStyle(_6cd.element.firstChild,{bottom:(_6cd.dims[0]-_6cd.element.clientHeight)+"px"});
6607},afterFinishInternal:function(_6ce){
6608d.undoClipping(_6ce.element,_6cb);
6609if(/MSIE/.test(navigator.userAgent)){
6610d.undoPositioned(_6ce.element);
6611d.undoPositioned(_6ce.element.firstChild);
6612}else{
6613d.undoPositioned(_6ce.element.firstChild);
6614d.undoPositioned(_6ce.element);
6615}
6616s.setStyle(_6ce.element.firstChild,{bottom:_6c9});
6617}},_6c5||{});
6618return new MochiKit.Visual.Scale(_6c4,100,_6c5);
6619};
6620MochiKit.Visual.slideUp=function(_6cf,_6d0){
6621var d=MochiKit.DOM;
6622var b=MochiKit.Base;
6623var s=MochiKit.Style;
6624_6cf=d.getElement(_6cf);
6625if(!_6cf.firstChild){
6626throw "MochiKit.Visual.slideUp must be used on a element with a child";
6627}
6628d.removeEmptyTextNodes(_6cf);
6629var _6d4=s.getStyle(_6cf.firstChild,"bottom");
6630var _6d5;
6631_6d0=b.update({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_6d6){
6632d.makePositioned(_6d6.element);
6633d.makePositioned(_6d6.element.firstChild);
6634if(/Opera/.test(navigator.userAgent)){
6635s.setStyle(_6d6.element,{top:""});
6636}
6637_6d5=d.makeClipping(_6d6.element);
6638s.showElement(_6d6.element);
6639},afterUpdateInternal:function(_6d7){
6640s.setStyle(_6d7.element.firstChild,{bottom:(_6d7.dims[0]-_6d7.element.clientHeight)+"px"});
6641},afterFinishInternal:function(_6d8){
6642s.hideElement(_6d8.element);
6643d.undoClipping(_6d8.element,_6d5);
6644d.undoPositioned(_6d8.element.firstChild);
6645d.undoPositioned(_6d8.element);
6646s.setStyle(_6d8.element.firstChild,{bottom:_6d4});
6647}},_6d0||{});
6648return new MochiKit.Visual.Scale(_6cf,0,_6d0);
6649};
6650MochiKit.Visual.squish=function(_6d9,_6da){
6651var d=MochiKit.DOM;
6652var b=MochiKit.Base;
6653var _6dd;
6654_6da=b.update({restoreAfterFinish:true,beforeSetupInternal:function(_6de){
6655_6dd=d.makeClipping(_6de.element);
6656},afterFinishInternal:function(_6df){
6657MochiKit.Style.hideElement(_6df.element);
6658d.undoClipping(_6df.element,_6dd);
6659}},_6da||{});
6660return new MochiKit.Visual.Scale(_6d9,/Opera/.test(navigator.userAgent)?1:0,_6da);
6661};
6662MochiKit.Visual.grow=function(_6e0,_6e1){
6663var d=MochiKit.DOM;
6664var v=MochiKit.Visual;
6665var s=MochiKit.Style;
6666_6e0=d.getElement(_6e0);
6667_6e1=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.full,scaleContent:true,scaleFromCenter:false},_6e1||{});
6668var _6e5={top:_6e0.style.top,left:_6e0.style.left,height:_6e0.style.height,width:_6e0.style.width,opacity:s.getStyle(_6e0,"opacity")};
6669var dims=s.getElementDimensions(_6e0);
6670var _6e7,_6e8;
6671var _6e9,_6ea;
6672switch(_6e1.direction){
6673case "top-left":
6674_6e7=_6e8=_6e9=_6ea=0;
6675break;
6676case "top-right":
6677_6e7=dims.w;
6678_6e8=_6ea=0;
6679_6e9=-dims.w;
6680break;
6681case "bottom-left":
6682_6e7=_6e9=0;
6683_6e8=dims.h;
6684_6ea=-dims.h;
6685break;
6686case "bottom-right":
6687_6e7=dims.w;
6688_6e8=dims.h;
6689_6e9=-dims.w;
6690_6ea=-dims.h;
6691break;
6692case "center":
6693_6e7=dims.w/2;
6694_6e8=dims.h/2;
6695_6e9=-dims.w/2;
6696_6ea=-dims.h/2;
6697break;
6698}
6699var _6eb=MochiKit.Base.update({beforeSetupInternal:function(_6ec){
6700s.setStyle(_6ec.effects[0].element,{height:"0px"});
6701s.showElement(_6ec.effects[0].element);
6702},afterFinishInternal:function(_6ed){
6703d.undoClipping(_6ed.effects[0].element);
6704d.undoPositioned(_6ed.effects[0].element);
6705s.setStyle(_6ed.effects[0].element,_6e5);
6706}},_6e1||{});
6707return new v.Move(_6e0,{x:_6e7,y:_6e8,duration:0.01,beforeSetupInternal:function(_6ee){
6708s.hideElement(_6ee.element);
6709d.makeClipping(_6ee.element);
6710d.makePositioned(_6ee.element);
6711},afterFinishInternal:function(_6ef){
6712new v.Parallel([new v.Opacity(_6ef.element,{sync:true,to:1,from:0,transition:_6e1.opacityTransition}),new v.Move(_6ef.element,{x:_6e9,y:_6ea,sync:true,transition:_6e1.moveTransition}),new v.Scale(_6ef.element,100,{scaleMode:{originalHeight:dims.h,originalWidth:dims.w},sync:true,scaleFrom:/Opera/.test(navigator.userAgent)?1:0,transition:_6e1.scaleTransition,scaleContent:_6e1.scaleContent,scaleFromCenter:_6e1.scaleFromCenter,restoreAfterFinish:true})],_6eb);
6713}});
6714};
6715MochiKit.Visual.shrink=function(_6f0,_6f1){
6716var d=MochiKit.DOM;
6717var v=MochiKit.Visual;
6718var s=MochiKit.Style;
6719_6f0=d.getElement(_6f0);
6720_6f1=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.none,scaleContent:true,scaleFromCenter:false},_6f1||{});
6721var _6f5={top:_6f0.style.top,left:_6f0.style.left,height:_6f0.style.height,width:_6f0.style.width,opacity:s.getStyle(_6f0,"opacity")};
6722var dims=s.getElementDimensions(_6f0);
6723var _6f7,_6f8;
6724switch(_6f1.direction){
6725case "top-left":
6726_6f7=_6f8=0;
6727break;
6728case "top-right":
6729_6f7=dims.w;
6730_6f8=0;
6731break;
6732case "bottom-left":
6733_6f7=0;
6734_6f8=dims.h;
6735break;
6736case "bottom-right":
6737_6f7=dims.w;
6738_6f8=dims.h;
6739break;
6740case "center":
6741_6f7=dims.w/2;
6742_6f8=dims.h/2;
6743break;
6744}
6745var _6f9;
6746var _6fa=MochiKit.Base.update({beforeStartInternal:function(_6fb){
6747_6f9=d.makePositioned(_6fb.effects[0].element);
6748d.makeClipping(_6fb.effects[0].element);
6749},afterFinishInternal:function(_6fc){
6750s.hideElement(_6fc.effects[0].element);
6751d.undoClipping(_6fc.effects[0].element,_6f9);
6752d.undoPositioned(_6fc.effects[0].element);
6753s.setStyle(_6fc.effects[0].element,_6f5);
6754}},_6f1||{});
6755return new v.Parallel([new v.Opacity(_6f0,{sync:true,to:0,from:1,transition:_6f1.opacityTransition}),new v.Scale(_6f0,/Opera/.test(navigator.userAgent)?1:0,{sync:true,transition:_6f1.scaleTransition,scaleContent:_6f1.scaleContent,scaleFromCenter:_6f1.scaleFromCenter,restoreAfterFinish:true}),new v.Move(_6f0,{x:_6f7,y:_6f8,sync:true,transition:_6f1.moveTransition})],_6fa);
6756};
6757MochiKit.Visual.pulsate=function(_6fd,_6fe){
6758var d=MochiKit.DOM;
6759var v=MochiKit.Visual;
6760var b=MochiKit.Base;
6761var _702=MochiKit.Style.getStyle(_6fd,"opacity");
6762_6fe=b.update({duration:3,from:0,afterFinishInternal:function(_703){
6763MochiKit.Style.setStyle(_703.element,{"opacity":_702});
6764}},_6fe||{});
6765var _704=_6fe.transition||v.Transitions.sinoidal;
6766var _705=b.bind(function(pos){
6767return _704(1-v.Transitions.pulse(pos,_6fe.pulses));
6768},_704);
6769b.bind(_705,_704);
6770return new v.Opacity(_6fd,b.update({transition:_705},_6fe));
6771};
6772MochiKit.Visual.fold=function(_707,_708){
6773var d=MochiKit.DOM;
6774var v=MochiKit.Visual;
6775var s=MochiKit.Style;
6776_707=d.getElement(_707);
6777var _70c={top:_707.style.top,left:_707.style.left,width:_707.style.width,height:_707.style.height};
6778var _70d=d.makeClipping(_707);
6779_708=MochiKit.Base.update({scaleContent:false,scaleX:false,afterFinishInternal:function(_70e){
6780new v.Scale(_707,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_70f){
6781s.hideElement(_70f.element);
6782d.undoClipping(_70f.element,_70d);
6783s.setStyle(_70f.element,_70c);
6784}});
6785}},_708||{});
6786return new v.Scale(_707,5,_708);
6787};
6788MochiKit.Visual.Color=MochiKit.Color.Color;
6789MochiKit.Visual.getElementsComputedStyle=MochiKit.DOM.computedStyle;
6790MochiKit.Visual.__new__=function(){
6791var m=MochiKit.Base;
6792m.nameFunctions(this);
6793this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
6794};
6795MochiKit.Visual.EXPORT=["roundElement","roundClass","tagifyText","multiple","toggle","Parallel","Opacity","Move","Scale","Highlight","ScrollTo","Morph","fade","appear","puff","blindUp","blindDown","switchOff","dropOut","shake","slideDown","slideUp","squish","grow","shrink","pulsate","fold"];
6796MochiKit.Visual.EXPORT_OK=["Base","PAIRS"];
6797MochiKit.Visual.__new__();
6798MochiKit.Base._exportSymbols(this,MochiKit.Visual);
6799if(typeof (MochiKit)=="undefined"){
6800MochiKit={};
6801}
6802if(typeof (MochiKit.MochiKit)=="undefined"){
6803MochiKit.MochiKit={};
6804}
6805MochiKit.MochiKit.NAME="MochiKit.MochiKit";
6806MochiKit.MochiKit.VERSION="1.4";
6807MochiKit.MochiKit.__repr__=function(){
6808return "["+this.NAME+" "+this.VERSION+"]";
6809};
6810MochiKit.MochiKit.toString=function(){
6811return this.__repr__();
6812};
6813MochiKit.MochiKit.SUBMODULES=["Base","Iter","Logging","DateTime","Format","Async","DOM","Selector","Style","LoggingPane","Color","Signal","Position","Visual"];
6814if(typeof (JSAN)!="undefined"||typeof (dojo)!="undefined"){
6815if(typeof (dojo)!="undefined"){
6816dojo.provide("MochiKit.MochiKit");
6817dojo.require("MochiKit.*");
6818}
6819if(typeof (JSAN)!="undefined"){
6820(function(lst){
6821for(var i=0;i<lst.length;i++){
6822JSAN.use("MochiKit."+lst[i],[]);
6823}
6824})(MochiKit.MochiKit.SUBMODULES);
6825}
6826(function(){
6827var _713=MochiKit.Base.extend;
6828var self=MochiKit.MochiKit;
6829var _715=self.SUBMODULES;
6830var _716=[];
6831var _717=[];
6832var _718={};
6833var i,k,m,all;
6834for(i=0;i<_715.length;i++){
6835m=MochiKit[_715[i]];
6836_713(_716,m.EXPORT);
6837_713(_717,m.EXPORT_OK);
6838for(k in m.EXPORT_TAGS){
6839_718[k]=_713(_718[k],m.EXPORT_TAGS[k]);
6840}
6841all=m.EXPORT_TAGS[":all"];
6842if(!all){
6843all=_713(null,m.EXPORT,m.EXPORT_OK);
6844}
6845var j;
6846for(j=0;j<all.length;j++){
6847k=all[j];
6848self[k]=m[k];
6849}
6850}
6851self.EXPORT=_716;
6852self.EXPORT_OK=_717;
6853self.EXPORT_TAGS=_718;
6854}());
6855}else{
6856if(typeof (MochiKit.__compat__)=="undefined"){
6857MochiKit.__compat__=true;
6858}
6859(function(){
6860if(typeof (document)=="undefined"){
6861return;
6862}
6863var _71e=document.getElementsByTagName("script");
6864var _71f="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
6865var base=null;
6866var _721=null;
6867var _722={};
6868var i;
6869for(i=0;i<_71e.length;i++){
6870var src=_71e[i].getAttribute("src");
6871if(!src){
6872continue;
6873}
6874_722[src]=true;
6875if(src.match(/MochiKit.js$/)){
6876base=src.substring(0,src.lastIndexOf("MochiKit.js"));
6877_721=_71e[i];
6878}
6879}
6880if(base===null){
6881return;
6882}
6883var _725=MochiKit.MochiKit.SUBMODULES;
6884for(var i=0;i<_725.length;i++){
6885if(MochiKit[_725[i]]){
6886continue;
6887}
6888var uri=base+_725[i]+".js";
6889if(uri in _722){
6890continue;
6891}
6892if(document.documentElement&&document.documentElement.namespaceURI==_71f){
6893var s=document.createElementNS(_71f,"script");
6894s.setAttribute("id","MochiKit_"+base+_725[i]);
6895s.setAttribute("src",uri);
6896s.setAttribute("type","application/x-javascript");
6897_721.parentNode.appendChild(s);
6898}else{
6899document.write("<script src=\""+uri+"\" type=\"text/javascript\"></script>");
6900}
6901}
6902})();
6903}
6904
6905
6906/***
6907
6908 PlotKit.PlotKit 0.9.1 : PACKED VERSION
6909
6910 THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please
6911 diff against the source tree, not this file.
6912
6913 For more information, <http://www.liquidx.net/plotkit/>.
6914
6915 Copyright (c) 2006. Alastair Tse.
6916
6917***/
6918
6919try{
6920if(typeof (MochiKit.Base)=="undefined"||typeof (MochiKit.DOM)=="undefined"||typeof (MochiKit.Color)=="undefined"||typeof (MochiKit.Format)=="undefined"){
6921throw "";
6922}
6923}
6924catch(e){
6925throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format}";
6926}
6927MochiKit.Base.update(MochiKit.Color.Color.prototype,{asFillColor:function(){
6928return this.lighterColorWithLevel(0.3);
6929},asStrokeColor:function(){
6930return this.darkerColorWithLevel(0.1);
6931},asPointColor:function(){
6932return this.lighterColorWithLevel(0.1);
6933}});
6934if(typeof (PlotKit)=="undefined"){
6935PlotKit={};
6936}
6937PlotKit.NAME="PlotKit";
6938PlotKit.VERSION="0.8";
6939PlotKit.__repr__=function(){
6940return "["+this.NAME+" "+this.VERSION+"]";
6941};
6942PlotKit.toString=function(){
6943return this.__repr__();
6944};
6945if(typeof (PlotKit.Base)=="undefined"){
6946PlotKit.Base={};
6947}
6948PlotKit.Base.NAME="PlotKit.Base";
6949PlotKit.Base.VERSION=PlotKit.VERSION;
6950PlotKit.Base.__repr__=function(){
6951return "["+this.NAME+" "+this.VERSION+"]";
6952};
6953PlotKit.Base.toString=function(){
6954return this.__repr__();
6955};
6956PlotKit.Base.usingPrototype=function(){
6957try{
6958return (typeof (Object.extend)=="function");
6959}
6960catch(e){
6961return false;
6962}
6963};
6964MochiKit.Base.update(PlotKit.Base,{roundInterval:function(_1,_2,_3){
6965var _4=MochiKit.Format.roundToFixed;
6966var _5=_1/_2;
6967return parseFloat(_4(_5,_3));
6968},collapse:function(_6){
6969var m=MochiKit.Base;
6970var _8=new Array();
6971for(var i=0;i<_6.length;i++){
6972_8=m.concat(_8,_6[i]);
6973}
6974if(PlotKit.Base.usingPrototype()){
6975delete _8.extend;
6976delete _8.from;
6977delete _8.inspect;
6978}
6979return _8;
6980},uniq:function(_10){
6981var m=MochiKit.Base;
6982if(!m.isArrayLike(_10)||(_10.length<1)){
6983return new Array();
6984}
6985var _11=new Array();
6986var _12=_10[0];
6987_11.push(_10[0]);
6988for(var i=1;i<_10.length;i++){
6989if(m.compare(_10[i],_12)!=0){
6990_12=_10[i];
6991_11.push(_10[i]);
6992}
6993}
6994return _11;
6995},colorScheme:function(){
6996var mb=MochiKit.Base;
6997var mc=MochiKit.Color;
6998var _15=["red","orange","yellow","green","cyan","blue","purple","magenta"];
6999var _16=function(_17){
7000return mc.Color[_17+"Color"]();
7001};
7002return mb.map(_16,_15);
7003},baseDarkPrimaryColors:function(){
7004var _18=MochiKit.Color.Color.fromHexString;
7005return [_18("#ad3f40"),_18("#ddac2c"),_18("#dfdd0c"),_18("#5276c4"),_18("#739c5a")];
7006},basePrimaryColors:function(){
7007var _19=MochiKit.Color.Color.fromHexString;
7008return [_19("#d24c4d"),_19("#f2b32f"),_19("#ece90e"),_19("#5d83da"),_19("#78a15d")];
7009},baseBlueColors:function(){
7010var _20=MochiKit.Color.Color.fromHexString;
7011return [_20("#4b6b94"),_20("#5d81b4"),_20("#acbad2")];
7012},palette:function(_21,_22,_23,_24){
7013var _25=MochiKit.Base.isUndefinedOrNull;
7014var _26=new Array();
7015if(_25(_24)){
7016_24=0.1;
7017}
7018if(_25(_23)){
7019_23=0.4;
7020}
7021if(_25(_22)){
7022_22=-0.2;
7023}
7024var _27=_22;
7025while(_27<=_23){
7026_26.push(_27);
7027_27+=_24;
7028}
7029var _28=function(_29,_30){
7030return _29.lighterColorWithLevel(_30);
7031};
7032return MochiKit.Base.map(partial(_28,_21),_26);
7033},excanvasSupported:function(){
7034if(/MSIE/.test(navigator.userAgent)&&!window.opera){
7035return true;
7036}
7037return false;
7038},findPosX:function(obj){
7039var _32=0;
7040if(obj.offsetParent){
7041while(obj.offsetParent){
7042_32+=obj.offsetLeft;
7043obj=obj.offsetParent;
7044}
7045}else{
7046if(obj.x){
7047_32+=obj.x;
7048}
7049}
7050return _32;
7051},findPosY:function(obj){
7052var _33=0;
7053if(obj.offsetParent){
7054while(obj.offsetParent){
7055_33+=obj.offsetTop;
7056obj=obj.offsetParent;
7057}
7058}else{
7059if(obj.y){
7060_33+=obj.y;
7061}
7062}
7063return _33;
7064},isFuncLike:function(obj){
7065return (typeof (obj)=="function");
7066}});
7067PlotKit.Base.map=function(fn,lst){
7068if(PlotKit.Base.usingPrototype()){
7069var _36=[];
7070for(var x in lst){
7071if(typeof (lst[x])=="function"){
7072continue;
7073}
7074_36.push(fn(lst[x]));
7075}
7076return _36;
7077}else{
7078return MochiKit.Base.map(fn,lst);
7079}
7080};
7081PlotKit.Base.items=function(lst){
7082if(PlotKit.Base.usingPrototype()){
7083var _38=[];
7084for(var x in lst){
7085if(typeof (lst[x])=="function"){
7086continue;
7087}
7088_38.push([x,lst[x]]);
7089}
7090return _38;
7091}else{
7092return MochiKit.Base.items(lst);
7093}
7094};
7095PlotKit.Base.keys=function(lst){
7096if(PlotKit.Base.usingPrototype()){
7097var _39=[];
7098for(var x in lst){
7099if(typeof (lst[x])=="function"){
7100continue;
7101}
7102_39.push(x);
7103}
7104return _39;
7105}else{
7106return MochiKit.Base.keys(lst);
7107}
7108};
7109PlotKit.Base.baseColors=function(){
7110var _40=MochiKit.Color.Color.fromHexString;
7111return [_40("#476fb2"),_40("#be2c2b"),_40("#85b730"),_40("#734a99"),_40("#26a1c5"),_40("#fb8707"),_40("#000000")];
7112};
7113PlotKit.Base.officeBaseStyle={"axisLineWidth":2,"axisLabelColor":Color.grayColor(),"axisLineColor":Color.whiteColor(),"padding":{top:5,bottom:10,left:30,right:30}};
7114MochiKit.Base.update(PlotKit.Base,{officeBlue:function(){
7115var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"backgroundColor":PlotKit.Base.baseColors()[0].lighterColorWithLevel(0.45)};
7116MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7117return r;
7118},officeRed:function(){
7119var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"backgroundColor":PlotKit.Base.baseColors()[1].lighterColorWithLevel(0.5)};
7120MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7121return r;
7122},officeGreen:function(){
7123var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[2]),"backgroundColor":PlotKit.Base.baseColors()[2].lighterColorWithLevel(0.5)};
7124MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7125return r;
7126},officePurple:function(){
7127var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[3]),"backgroundColor":PlotKit.Base.baseColors()[3].lighterColorWithLevel(0.5)};
7128MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7129return r;
7130},officeCyan:function(){
7131var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[4]),"backgroundColor":PlotKit.Base.baseColors()[4].lighterColorWithLevel(0.5)};
7132MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7133return r;
7134},officeOrange:function(){
7135var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[5]),"backgroundColor":PlotKit.Base.baseColors()[5].lighterColorWithLevel(0.4)};
7136MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7137return r;
7138},officeBlack:function(){
7139var r={"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[6],0,0.6),"backgroundColor":PlotKit.Base.baseColors()[6].lighterColorWithLevel(0.9)};
7140MochiKit.Base.update(r,PlotKit.Base.officeBaseStyle);
7141return r;
7142}});
7143PlotKit.Base.EXPORT=["baseColors","collapse","colorScheme","findPosX","findPosY","officeBaseStyle","officeBlue","officeRed","officeGreen","officePurple","officeCyan","officeOrange","officeBlack","roundInterval","uniq","isFuncLike","excanvasSupported"];
7144PlotKit.Base.EXPORT_OK=[];
7145PlotKit.Base.__new__=function(){
7146var m=MochiKit.Base;
7147m.nameFunctions(this);
7148this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
7149};
7150PlotKit.Base.__new__();
7151MochiKit.Base._exportSymbols(this,PlotKit.Base);
7152try{
7153if(typeof (PlotKit.Base)=="undefined"){
7154throw "";
7155}
7156}
7157catch(e){
7158throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Base";
7159}
7160if(typeof (PlotKit.Layout)=="undefined"){
7161PlotKit.Layout={};
7162}
7163PlotKit.Layout.NAME="PlotKit.Layout";
7164PlotKit.Layout.VERSION=PlotKit.VERSION;
7165PlotKit.Layout.__repr__=function(){
7166return "["+this.NAME+" "+this.VERSION+"]";
7167};
7168PlotKit.Layout.toString=function(){
7169return this.__repr__();
7170};
7171PlotKit.Layout.valid_styles=["bar","line","pie","point"];
7172PlotKit.Layout=function(_42,_43){
7173this.options={"barWidthFillFraction":0.75,"barOrientation":"vertical","xOriginIsZero":true,"yOriginIsZero":true,"xAxis":null,"yAxis":null,"xTicks":null,"yTicks":null,"xNumberOfTicks":10,"yNumberOfTicks":5,"xTickPrecision":1,"yTickPrecision":1,"pieRadius":0.4};
7174this.style=_42;
7175MochiKit.Base.update(this.options,_43?_43:{});
7176if(!MochiKit.Base.isUndefinedOrNull(this.options.xAxis)){
7177this.minxval=this.options.xAxis[0];
7178this.maxxval=this.options.xAxis[1];
7179this.xscale=this.maxxval-this.minxval;
7180}else{
7181this.minxval=0;
7182this.maxxval=null;
7183this.xscale=null;
7184}
7185if(!MochiKit.Base.isUndefinedOrNull(this.options.yAxis)){
7186this.minyval=this.options.yAxis[0];
7187this.maxyval=this.options.yAxis[1];
7188this.yscale=this.maxyval-this.minyval;
7189}else{
7190this.minyval=0;
7191this.maxyval=null;
7192this.yscale=null;
7193}
7194this.bars=new Array();
7195this.points=new Array();
7196this.slices=new Array();
7197this.xticks=new Array();
7198this.yticks=new Array();
7199this.datasets=new Array();
7200this.minxdelta=0;
7201this.xrange=1;
7202this.yrange=1;
7203this.hitTestCache={x2maxy:null};
7204};
7205PlotKit.Layout.prototype.addDataset=function(_44,_45){
7206this.datasets[_44]=_45;
7207};
7208PlotKit.Layout.prototype.removeDataset=function(_46,_47){
7209delete this.datasets[_46];
7210};
7211PlotKit.Layout.prototype.addDatasetFromTable=function(_48,_49,_50,_51,_52){
7212var _53=MochiKit.Base.isUndefinedOrNull;
7213var _54=MochiKit.DOM.scrapeText;
7214var _55=MochiKit.Format.strip;
7215if(_53(_50)){
7216_50=0;
7217}
7218if(_53(_51)){
7219_51=1;
7220}
7221if(_53(_52)){
7222_52=-1;
7223}
7224var _56=_49.tBodies[0].rows;
7225var _57=new Array();
7226var _58=new Array();
7227if(!_53(_56)){
7228for(var i=0;i<_56.length;i++){
7229_57.push([parseFloat(_55(_54(_56[i].cells[_50]))),parseFloat(_55(_54(_56[i].cells[_51])))]);
7230if(_52>=0){
7231_58.push({v:parseFloat(_55(_54(_56[i].cells[_50]))),label:_55(_54(_56[i].cells[_52]))});
7232}
7233}
7234this.addDataset(_48,_57);
7235if(_52>=0){
7236this.options.xTicks=_58;
7237}
7238return true;
7239}
7240return false;
7241};
7242PlotKit.Layout.prototype.evaluate=function(){
7243this._evaluateLimits();
7244this._evaluateScales();
7245if(this.style=="bar"){
7246if(this.options.barOrientation=="horizontal"){
7247this._evaluateHorizBarCharts();
7248}else{
7249this._evaluateBarCharts();
7250}
7251this._evaluateBarTicks();
7252}else{
7253if(this.style=="line"){
7254this._evaluateLineCharts();
7255this._evaluateLineTicks();
7256}else{
7257if(this.style=="pie"){
7258this._evaluatePieCharts();
7259this._evaluatePieTicks();
7260}
7261}
7262}
7263};
7264PlotKit.Layout.prototype.hitTest=function(x,y){
7265var f=MochiKit.Format.twoDigitFloat;
7266if((this.style=="bar")&&this.bars&&(this.bars.length>0)){
7267for(var i=0;i<this.bars.length;i++){
7268var bar=this.bars[i];
7269if((x>=bar.x)&&(x<=bar.x+bar.w)&&(y>=bar.y)&&(y-bar.y<=bar.h)){
7270return bar;
7271}
7272}
7273}else{
7274if(this.style=="line"){
7275if(this.hitTestCache.x2maxy==null){
7276this._regenerateHitTestCache();
7277}
7278var _62=x/this.xscale;
7279var _63=this.hitTestCache.xvalues;
7280var _64=null;
7281var _65=null;
7282for(var i=1;i<_63.length;i++){
7283if(_63[i]>_62){
7284_64=_63[i-1];
7285_65=_63[i];
7286break;
7287}
7288}
7289if((_64!=null)){
7290var _66=this.hitTestCache.x2maxy[_64];
7291var _67=this.hitTestCache.x2maxy[_65];
7292var _68=(1-y)/this.yscale;
7293var _69=(_67-_66)/(_65-_64);
7294var _70=_66+_69*(_62-_64);
7295if(_70>=_68){
7296var obj={xval:_62,yval:_68,xafter:_65,yafter:_67,xbefore:_64,ybefore:_66,yprojected:_70};
7297return obj;
7298}
7299}
7300}else{
7301if(this.style=="pie"){
7302var _71=Math.sqrt((y-0.5)*(y-0.5)+(x-0.5)*(x-0.5));
7303if(_71>this.options.pieRadius){
7304return null;
7305}
7306var _72=Math.atan2(y-0.5,x-0.5)-Math.PI/2;
7307for(var i=0;i<this.slices.length;i++){
7308var _73=this.slices[i];
7309if(_73.startAngle<_72&&_73.endAngle>=_72){
7310return _73;
7311}
7312}
7313}
7314}
7315}
7316return null;
7317};
7318PlotKit.Layout.prototype.rectForX=function(x){
7319return null;
7320};
7321PlotKit.Layout.prototype.angleRangeForX=function(x){
7322return null;
7323};
7324PlotKit.Layout.prototype._evaluateLimits=function(){
7325var map=PlotKit.Base.map;
7326var _75=PlotKit.Base.items;
7327var _76=MochiKit.Base.itemgetter;
7328var _77=PlotKit.Base.collapse;
7329var _78=MochiKit.Base.listMin;
7330var _79=MochiKit.Base.listMax;
7331var _80=MochiKit.Base.isUndefinedOrNull;
7332var all=_77(map(_76(1),_75(this.datasets)));
7333if(_80(this.options.xAxis)){
7334if(this.options.xOriginIsZero){
7335this.minxval=0;
7336}else{
7337this.minxval=_78(map(parseFloat,map(_76(0),all)));
7338}
7339this.maxxval=_79(map(parseFloat,map(_76(0),all)));
7340}else{
7341this.minxval=this.options.xAxis[0];
7342this.maxxval=this.options.xAxis[1];
7343this.xscale=this.maxval-this.minxval;
7344}
7345if(_80(this.options.yAxis)){
7346if(this.options.yOriginIsZero){
7347this.minyval=0;
7348}else{
7349this.minyval=_78(map(parseFloat,map(_76(1),all)));
7350}
7351this.maxyval=_79(map(parseFloat,map(_76(1),all)));
7352}else{
7353this.minyval=this.options.yAxis[0];
7354this.maxyval=this.options.yAxis[1];
7355this.yscale=this.maxyval-this.minyval;
7356}
7357};
7358PlotKit.Layout.prototype._evaluateScales=function(){
7359var _82=MochiKit.Base.isUndefinedOrNull;
7360this.xrange=this.maxxval-this.minxval;
7361if(this.xrange==0){
7362this.xscale=1;
7363}else{
7364this.xscale=1/this.xrange;
7365}
7366this.yrange=this.maxyval-this.minyval;
7367if(this.yrange==0){
7368this.yscale=1;
7369}else{
7370this.yscale=1/this.yrange;
7371}
7372};
7373PlotKit.Layout.prototype._uniqueXValues=function(){
7374var _83=PlotKit.Base.collapse;
7375var map=PlotKit.Base.map;
7376var _84=PlotKit.Base.uniq;
7377var _85=MochiKit.Base.itemgetter;
7378var _86=PlotKit.Base.items;
7379var _87=map(parseFloat,map(_85(0),_83(map(_85(1),_86(this.datasets)))));
7380_87.sort(MochiKit.Base.compare);
7381return _84(_87);
7382};
7383PlotKit.Layout.prototype._evaluateBarCharts=function(){
7384var _88=PlotKit.Base.items;
7385var _89=_88(this.datasets).length;
7386var _90=10000000;
7387var _91=this._uniqueXValues();
7388for(var i=1;i<_91.length;i++){
7389_90=Math.min(Math.abs(_91[i]-_91[i-1]),_90);
7390}
7391var _92=0;
7392var _93=0;
7393var _94=0;
7394if(_91.length==1){
7395_90=1;
7396this.xscale=1;
7397this.minxval=_91[0];
7398_92=1*this.options.barWidthFillFraction;
7399_93=_92/_89;
7400_94=(1-this.options.barWidthFillFraction)/2;
7401}else{
7402if(this.xrange==1){
7403this.xscale=0.5;
7404}else{
7405if(this.xrange==2){
7406this.xscale=1/3;
7407}else{
7408this.xscale=(1-_90/this.xrange)/this.xrange;
7409}
7410}
7411_92=_90*this.xscale*this.options.barWidthFillFraction;
7412_93=_92/_89;
7413_94=_90*this.xscale*(1-this.options.barWidthFillFraction)/2;
7414}
7415this.minxdelta=_90;
7416this.bars=new Array();
7417var i=0;
7418for(var _95 in this.datasets){
7419var _96=this.datasets[_95];
7420if(PlotKit.Base.isFuncLike(_96)){
7421continue;
7422}
7423for(var j=0;j<_96.length;j++){
7424var _98=_96[j];
7425var _99={x:((parseFloat(_98[0])-this.minxval)*this.xscale)+(i*_93)+_94,y:1-((parseFloat(_98[1])-this.minyval)*this.yscale),w:_93,h:((parseFloat(_98[1])-this.minyval)*this.yscale),xval:parseFloat(_98[0]),yval:parseFloat(_98[1]),name:_95};
7426if((_99.x>=0)&&(_99.x<=1)&&(_99.y>=0)&&(_99.y<=1)){
7427this.bars.push(_99);
7428}
7429}
7430i++;
7431}
7432};
7433PlotKit.Layout.prototype._evaluateHorizBarCharts=function(){
7434var _100=PlotKit.Base.items;
7435var _101=_100(this.datasets).length;
7436var _102=10000000;
7437var _103=this._uniqueXValues();
7438for(var i=1;i<_103.length;i++){
7439_102=Math.min(Math.abs(_103[i]-_103[i-1]),_102);
7440}
7441var _104=0;
7442var _105=0;
7443var _106=0;
7444if(_103.length==1){
7445_102=1;
7446this.xscale=1;
7447this.minxval=_103[0];
7448_104=1*this.options.barWidthFillFraction;
7449_105=_104/_101;
7450_106=(1-this.options.barWidthFillFraction)/2;
7451}else{
7452this.xscale=(1-_102/this.xrange)/this.xrange;
7453_104=_102*this.xscale*this.options.barWidthFillFraction;
7454_105=_104/_101;
7455_106=_102*this.xscale*(1-this.options.barWidthFillFraction)/2;
7456}
7457this.minxdelta=_102;
7458this.bars=new Array();
7459var i=0;
7460for(var _107 in this.datasets){
7461var _108=this.datasets[_107];
7462if(PlotKit.Base.isFuncLike(_108)){
7463continue;
7464}
7465for(var j=0;j<_108.length;j++){
7466var item=_108[j];
7467var rect={y:((parseFloat(item[0])-this.minxval)*this.xscale)+(i*_105)+_106,x:0,h:_105,w:((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_107};
7468if(rect.y<=0){
7469rect.y=0;
7470}
7471if(rect.y>=1){
7472rect.y=1;
7473}
7474if((rect.x>=0)&&(rect.x<=1)){
7475this.bars.push(rect);
7476}
7477}
7478i++;
7479}
7480};
7481PlotKit.Layout.prototype._evaluateLineCharts=function(){
7482var _111=PlotKit.Base.items;
7483var _112=_111(this.datasets).length;
7484this.points=new Array();
7485var i=0;
7486for(var _113 in this.datasets){
7487var _114=this.datasets[_113];
7488if(PlotKit.Base.isFuncLike(_114)){
7489continue;
7490}
7491_114.sort(function(a,b){
7492return compare(parseFloat(a[0]),parseFloat(b[0]));
7493});
7494for(var j=0;j<_114.length;j++){
7495var item=_114[j];
7496var _117={x:((parseFloat(item[0])-this.minxval)*this.xscale),y:1-((parseFloat(item[1])-this.minyval)*this.yscale),xval:parseFloat(item[0]),yval:parseFloat(item[1]),name:_113};
7497if(_117.y<=0){
7498_117.y=0;
7499}
7500if(_117.y>=1){
7501_117.y=1;
7502}
7503if((_117.x>=0)&&(_117.x<=1)){
7504this.points.push(_117);
7505}
7506}
7507i++;
7508}
7509};
7510PlotKit.Layout.prototype._evaluatePieCharts=function(){
7511var _118=PlotKit.Base.items;
7512var sum=MochiKit.Iter.sum;
7513var _120=MochiKit.Base.itemgetter;
7514var _121=_118(this.datasets).length;
7515var _122=_118(this.datasets)[0][1];
7516var _123=sum(map(_120(1),_122));
7517this.slices=new Array();
7518var _124=0;
7519for(var i=0;i<_122.length;i++){
7520var _125=_122[i][1]/_123;
7521var _126=_124*Math.PI*2;
7522var _127=(_124+_125)*Math.PI*2;
7523var _128={fraction:_125,xval:_122[i][0],yval:_122[i][1],startAngle:_126,endAngle:_127};
7524if(_122[i][1]!=0){
7525this.slices.push(_128);
7526}
7527_124+=_125;
7528}
7529};
7530PlotKit.Layout.prototype._evaluateLineTicksForXAxis=function(){
7531var _129=MochiKit.Base.isUndefinedOrNull;
7532if(this.options.xTicks){
7533this.xticks=new Array();
7534var _130=function(tick){
7535var _132=tick.label;
7536if(_129(_132)){
7537_132=tick.v.toString();
7538}
7539var pos=this.xscale*(tick.v-this.minxval);
7540if((pos>=0)&&(pos<=1)){
7541this.xticks.push([pos,_132]);
7542}
7543};
7544MochiKit.Iter.forEach(this.options.xTicks,bind(_130,this));
7545}else{
7546if(this.options.xNumberOfTicks){
7547var _134=this._uniqueXValues();
7548var _135=this.xrange/this.options.xNumberOfTicks;
7549var _136=0;
7550this.xticks=new Array();
7551for(var i=0;i<=_134.length;i++){
7552if((_134[i]-this.minxval)>=(_136*_135)){
7553var pos=this.xscale*(_134[i]-this.minxval);
7554if((pos>1)||(pos<0)){
7555continue;
7556}
7557this.xticks.push([pos,_134[i]]);
7558_136++;
7559}
7560if(_136>this.options.xNumberOfTicks){
7561break;
7562}
7563}
7564}
7565}
7566};
7567PlotKit.Layout.prototype._evaluateLineTicksForYAxis=function(){
7568var _137=MochiKit.Base.isUndefinedOrNull;
7569if(this.options.yTicks){
7570this.yticks=new Array();
7571var _138=function(tick){
7572var _139=tick.label;
7573if(_137(_139)){
7574_139=tick.v.toString();
7575}
7576var pos=1-(this.yscale*(tick.v-this.minyval));
7577if((pos>=0)&&(pos<=1)){
7578this.yticks.push([pos,_139]);
7579}
7580};
7581MochiKit.Iter.forEach(this.options.yTicks,bind(_138,this));
7582}else{
7583if(this.options.yNumberOfTicks){
7584this.yticks=new Array();
7585var _140=PlotKit.Base.roundInterval;
7586var prec=this.options.yTickPrecision;
7587var _142=_140(this.yrange,this.options.yNumberOfTicks,prec);
7588for(var i=0;i<=this.options.yNumberOfTicks;i++){
7589var yval=this.minyval+(i*_142);
7590var pos=1-((yval-this.minyval)*this.yscale);
7591if((pos>1)||(pos<0)){
7592continue;
7593}
7594this.yticks.push([pos,MochiKit.Format.roundToFixed(yval,prec)]);
7595}
7596}
7597}
7598};
7599PlotKit.Layout.prototype._evaluateLineTicks=function(){
7600this._evaluateLineTicksForXAxis();
7601this._evaluateLineTicksForYAxis();
7602};
7603PlotKit.Layout.prototype._evaluateBarTicks=function(){
7604this._evaluateLineTicks();
7605var _144=function(tick){
7606return [tick[0]+(this.minxdelta*this.xscale)/2,tick[1]];
7607};
7608this.xticks=MochiKit.Base.map(bind(_144,this),this.xticks);
7609if(this.options.barOrientation=="horizontal"){
7610var _145=this.xticks;
7611this.xticks=this.yticks;
7612this.yticks=_145;
7613var _146=function(tick){
7614return [1-tick[0],tick[1]];
7615};
7616this.xticks=MochiKit.Base.map(_146,this.xticks);
7617}
7618};
7619PlotKit.Layout.prototype._evaluatePieTicks=function(){
7620var _147=MochiKit.Base.isUndefinedOrNull;
7621var _148=MochiKit.Format.numberFormatter("#%");
7622this.xticks=new Array();
7623if(this.options.xTicks){
7624var _149=new Array();
7625for(var i=0;i<this.slices.length;i++){
7626_149[this.slices[i].xval]=this.slices[i];
7627}
7628for(var i=0;i<this.options.xTicks.length;i++){
7629var tick=this.options.xTicks[i];
7630var _150=_149[tick.v];
7631var _151=tick.label;
7632if(_150){
7633if(_147(_151)){
7634_151=tick.v.toString();
7635}
7636_151+=" ("+_148(_150.fraction)+")";
7637this.xticks.push([tick.v,_151]);
7638}
7639}
7640}else{
7641for(var i=0;i<this.slices.length;i++){
7642var _150=this.slices[i];
7643var _151=_150.xval+" ("+_148(_150.fraction)+")";
7644this.xticks.push([_150.xval,_151]);
7645}
7646}
7647};
7648PlotKit.Layout.prototype._regenerateHitTestCache=function(){
7649this.hitTestCache.xvalues=this._uniqueXValues();
7650this.hitTestCache.xlookup=new Array();
7651this.hitTestCache.x2maxy=new Array();
7652var _152=MochiKit.Base.listMax;
7653var _153=MochiKit.Base.itemgetter;
7654var map=MochiKit.Base.map;
7655var _154=keys(this.datasets);
7656for(var i=0;i<_154.length;i++){
7657var _155=this.datasets[_154[i]];
7658for(var j=0;j<_155.length;j++){
7659var xval=_155[j][0];
7660var yval=_155[j][1];
7661if(this.hitTestCache.xlookup[xval]){
7662this.hitTestCache.xlookup[xval].push([yval,_154[i]]);
7663}else{
7664this.hitTestCache.xlookup[xval]=[[yval,_154[i]]];
7665}
7666}
7667}
7668for(var x in this.hitTestCache.xlookup){
7669var _157=this.hitTestCache.xlookup[x];
7670this.hitTestCache.x2maxy[x]=_152(map(_153(0),_157));
7671}
7672};
7673PlotKit.LayoutModule={};
7674PlotKit.LayoutModule.Layout=PlotKit.Layout;
7675PlotKit.LayoutModule.EXPORT=["Layout"];
7676PlotKit.LayoutModule.EXPORT_OK=[];
7677PlotKit.LayoutModule.__new__=function(){
7678var m=MochiKit.Base;
7679m.nameFunctions(this);
7680this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
7681};
7682PlotKit.LayoutModule.__new__();
7683MochiKit.Base._exportSymbols(this,PlotKit.LayoutModule);
7684try{
7685if((typeof (PlotKit.Base)=="undefined")||(typeof (PlotKit.Layout)=="undefined")){
7686throw "";
7687}
7688}
7689catch(e){
7690throw "PlotKit.Layout depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Base,Layout}";
7691}
7692if(typeof (PlotKit.CanvasRenderer)=="undefined"){
7693PlotKit.CanvasRenderer={};
7694}
7695PlotKit.CanvasRenderer.NAME="PlotKit.CanvasRenderer";
7696PlotKit.CanvasRenderer.VERSION=PlotKit.VERSION;
7697PlotKit.CanvasRenderer.__repr__=function(){
7698return "["+this.NAME+" "+this.VERSION+"]";
7699};
7700PlotKit.CanvasRenderer.toString=function(){
7701return this.__repr__();
7702};
7703PlotKit.CanvasRenderer=function(_158,_159,_160){
7704if(arguments.length>0){
7705this.__init__(_158,_159,_160);
7706}
7707};
7708PlotKit.CanvasRenderer.prototype.__init__=function(_161,_162,_163){
7709var _164=MochiKit.Base.isUndefinedOrNull;
7710var _165=MochiKit.Color.Color;
7711this.options={"drawBackground":true,"backgroundColor":_165.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[0]),"strokeColor":_165.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":_165.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":_165.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"pieRadius":0.4,"enableEvents":true};
7712MochiKit.Base.update(this.options,_163?_163:{});
7713this.layout=_162;
7714this.element=MochiKit.DOM.getElement(_161);
7715this.container=this.element.parentNode;
7716this.isIE=PlotKit.Base.excanvasSupported();
7717if(this.isIE&&!_164(G_vmlCanvasManager)){
7718this.IEDelay=0.5;
7719this.maxTries=5;
7720this.renderDelay=null;
7721this.clearDelay=null;
7722this.element=G_vmlCanvasManager.initElement(this.element);
7723}
7724this.height=this.element.height;
7725this.width=this.element.width;
7726if(_164(this.element)){
7727throw "CanvasRenderer() - passed canvas is not found";
7728}
7729if(!this.isIE&&!(PlotKit.CanvasRenderer.isSupported(this.element))){
7730throw "CanvasRenderer() - Canvas is not supported.";
7731}
7732if(_164(this.container)||(this.container.nodeName.toLowerCase()!="div")){
7733throw "CanvasRenderer() - <canvas> needs to be enclosed in <div>";
7734}
7735this.xlabels=new Array();
7736this.ylabels=new Array();
7737this.isFirstRender=true;
7738this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom};
7739MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}});
7740};
7741PlotKit.CanvasRenderer.prototype.render=function(){
7742if(this.isIE){
7743try{
7744if(this.renderDelay){
7745this.renderDelay.cancel();
7746this.renderDelay=null;
7747}
7748var _166=this.element.getContext("2d");
7749}
7750catch(e){
7751this.isFirstRender=false;
7752if(this.maxTries-->0){
7753this.renderDelay=MochiKit.Async.wait(this.IEDelay);
7754this.renderDelay.addCallback(bind(this.render,this));
7755}
7756return;
7757}
7758}
7759if(this.options.drawBackground){
7760this._renderBackground();
7761}
7762if(this.layout.style=="bar"){
7763this._renderBarChart();
7764this._renderBarAxis();
7765}else{
7766if(this.layout.style=="pie"){
7767this._renderPieChart();
7768this._renderPieAxis();
7769}else{
7770if(this.layout.style=="line"){
7771this._renderLineChart();
7772this._renderLineAxis();
7773}
7774}
7775}
7776};
7777PlotKit.CanvasRenderer.prototype._renderBarChartWrap=function(data,_168){
7778var _169=this.element.getContext("2d");
7779var _170=this.options.colorScheme.length;
7780var _171=this.options.colorScheme;
7781var _172=MochiKit.Base.keys(this.layout.datasets);
7782var _173=_172.length;
7783for(var i=0;i<_173;i++){
7784var _174=_172[i];
7785var _175=_171[i%_170];
7786_169.save();
7787_169.fillStyle=_175.toRGBString();
7788if(this.options.strokeColor){
7789_169.strokeStyle=this.options.strokeColor.toRGBString();
7790}else{
7791if(this.options.strokeColorTransform){
7792_169.strokeStyle=_175[this.options.strokeColorTransform]().toRGBString();
7793}
7794}
7795_169.lineWidth=this.options.strokeWidth;
7796var _176=function(obj){
7797if(obj.name==_174){
7798_168(_169,obj);
7799}
7800};
7801MochiKit.Iter.forEach(data,bind(_176,this));
7802_169.restore();
7803}
7804};
7805PlotKit.CanvasRenderer.prototype._renderBarChart=function(){
7806var bind=MochiKit.Base.bind;
7807var _178=function(_179,bar){
7808var x=this.area.w*bar.x+this.area.x;
7809var y=this.area.h*bar.y+this.area.y;
7810var w=this.area.w*bar.w;
7811var h=this.area.h*bar.h;
7812if((w<1)||(h<1)){
7813return;
7814}
7815if(this.options.shouldFill){
7816_179.fillRect(x,y,w,h);
7817}
7818if(this.options.shouldStroke){
7819_179.strokeRect(x,y,w,h);
7820}
7821};
7822this._renderBarChartWrap(this.layout.bars,bind(_178,this));
7823};
7824PlotKit.CanvasRenderer.prototype._renderLineChart=function(){
7825var _182=this.element.getContext("2d");
7826var _183=this.options.colorScheme.length;
7827var _184=this.options.colorScheme;
7828var _185=MochiKit.Base.keys(this.layout.datasets);
7829var _186=_185.length;
7830var bind=MochiKit.Base.bind;
7831var _187=MochiKit.Base.partial;
7832for(var i=0;i<_186;i++){
7833var _188=_185[i];
7834var _189=_184[i%_183];
7835var _190=this.options.strokeColorTransform;
7836_182.save();
7837_182.fillStyle=_189.toRGBString();
7838if(this.options.strokeColor){
7839_182.strokeStyle=this.options.strokeColor.toRGBString();
7840}else{
7841if(this.options.strokeColorTransform){
7842_182.strokeStyle=_189[_190]().toRGBString();
7843}
7844}
7845_182.lineWidth=this.options.strokeWidth;
7846var _191=function(ctx){
7847ctx.beginPath();
7848ctx.moveTo(this.area.x,this.area.y+this.area.h);
7849var _193=function(ctx_,_195){
7850if(_195.name==_188){
7851ctx_.lineTo(this.area.w*_195.x+this.area.x,this.area.h*_195.y+this.area.y);
7852}
7853};
7854MochiKit.Iter.forEach(this.layout.points,_187(_193,ctx),this);
7855ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y);
7856ctx.lineTo(this.area.x,this.area.y+this.area.h);
7857ctx.closePath();
7858};
7859if(this.options.shouldFill){
7860bind(_191,this)(_182);
7861_182.fill();
7862}
7863if(this.options.shouldStroke){
7864bind(_191,this)(_182);
7865_182.stroke();
7866}
7867_182.restore();
7868}
7869};
7870PlotKit.CanvasRenderer.prototype._renderPieChart=function(){
7871var _196=this.element.getContext("2d");
7872var _197=this.options.colorScheme.length;
7873var _198=this.layout.slices;
7874var _199=this.area.x+this.area.w*0.5;
7875var _200=this.area.y+this.area.h*0.5;
7876var _201=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
7877if(this.isIE){
7878_199=parseInt(_199);
7879_200=parseInt(_200);
7880_201=parseInt(_201);
7881}
7882for(var i=0;i<_198.length;i++){
7883var _202=this.options.colorScheme[i%_197];
7884_196.save();
7885_196.fillStyle=_202.toRGBString();
7886var _203=function(){
7887_196.beginPath();
7888_196.moveTo(_199,_200);
7889_196.arc(_199,_200,_201,_198[i].startAngle-Math.PI/2,_198[i].endAngle-Math.PI/2,false);
7890_196.lineTo(_199,_200);
7891_196.closePath();
7892};
7893if(Math.abs(_198[i].startAngle-_198[i].endAngle)>0.001){
7894if(this.options.shouldFill){
7895_203();
7896_196.fill();
7897}
7898if(this.options.shouldStroke){
7899_203();
7900_196.lineWidth=this.options.strokeWidth;
7901if(this.options.strokeColor){
7902_196.strokeStyle=this.options.strokeColor.toRGBString();
7903}else{
7904if(this.options.strokeColorTransform){
7905_196.strokeStyle=_202[this.options.strokeColorTransform]().toRGBString();
7906}
7907}
7908_196.stroke();
7909}
7910}
7911_196.restore();
7912}
7913};
7914PlotKit.CanvasRenderer.prototype._renderBarAxis=function(){
7915this._renderAxis();
7916};
7917PlotKit.CanvasRenderer.prototype._renderLineAxis=function(){
7918this._renderAxis();
7919};
7920PlotKit.CanvasRenderer.prototype._renderAxis=function(){
7921if(!this.options.drawXAxis&&!this.options.drawYAxis){
7922return;
7923}
7924var _204=this.element.getContext("2d");
7925var _205={"style":{"position":"absolute","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
7926_204.save();
7927_204.strokeStyle=this.options.axisLineColor.toRGBString();
7928_204.lineWidth=this.options.axisLineWidth;
7929if(this.options.drawYAxis){
7930if(this.layout.yticks){
7931var _206=function(tick){
7932if(typeof (tick)=="function"){
7933return;
7934}
7935var x=this.area.x;
7936var y=this.area.y+tick[0]*this.area.h;
7937_204.beginPath();
7938_204.moveTo(x,y);
7939_204.lineTo(x-this.options.axisTickSize,y);
7940_204.closePath();
7941_204.stroke();
7942var _207=DIV(_205,tick[1]);
7943_207.style.top=(y-this.options.axisLabelFontSize)+"px";
7944_207.style.left=(x-this.options.padding.left-this.options.axisTickSize)+"px";
7945_207.style.textAlign="right";
7946_207.style.width=(this.options.padding.left-this.options.axisTickSize*2)+"px";
7947MochiKit.DOM.appendChildNodes(this.container,_207);
7948this.ylabels.push(_207);
7949};
7950MochiKit.Iter.forEach(this.layout.yticks,bind(_206,this));
7951}
7952_204.beginPath();
7953_204.moveTo(this.area.x,this.area.y);
7954_204.lineTo(this.area.x,this.area.y+this.area.h);
7955_204.closePath();
7956_204.stroke();
7957}
7958if(this.options.drawXAxis){
7959if(this.layout.xticks){
7960var _206=function(tick){
7961if(typeof (dataset)=="function"){
7962return;
7963}
7964var x=this.area.x+tick[0]*this.area.w;
7965var y=this.area.y+this.area.h;
7966_204.beginPath();
7967_204.moveTo(x,y);
7968_204.lineTo(x,y+this.options.axisTickSize);
7969_204.closePath();
7970_204.stroke();
7971var _208=DIV(_205,tick[1]);
7972_208.style.top=(y+this.options.axisTickSize)+"px";
7973_208.style.left=(x-this.options.axisLabelWidth/2)+"px";
7974_208.style.textAlign="center";
7975_208.style.width=this.options.axisLabelWidth+"px";
7976MochiKit.DOM.appendChildNodes(this.container,_208);
7977this.xlabels.push(_208);
7978};
7979MochiKit.Iter.forEach(this.layout.xticks,bind(_206,this));
7980}
7981_204.beginPath();
7982_204.moveTo(this.area.x,this.area.y+this.area.h);
7983_204.lineTo(this.area.x+this.area.w,this.area.y+this.area.h);
7984_204.closePath();
7985_204.stroke();
7986}
7987_204.restore();
7988};
7989PlotKit.CanvasRenderer.prototype._renderPieAxis=function(){
7990if(!this.options.drawXAxis){
7991return;
7992}
7993if(this.layout.xticks){
7994var _209=new Array();
7995for(var i=0;i<this.layout.slices.length;i++){
7996_209[this.layout.slices[i].xval]=this.layout.slices[i];
7997}
7998var _210=this.area.x+this.area.w*0.5;
7999var _211=this.area.y+this.area.h*0.5;
8000var _212=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
8001var _213=this.options.axisLabelWidth;
8002for(var i=0;i<this.layout.xticks.length;i++){
8003var _214=_209[this.layout.xticks[i][0]];
8004if(MochiKit.Base.isUndefinedOrNull(_214)){
8005continue;
8006}
8007var _215=(_214.startAngle+_214.endAngle)/2;
8008var _216=_215;
8009if(_216>Math.PI*2){
8010_216=_216-Math.PI*2;
8011}else{
8012if(_216<0){
8013_216=_216+Math.PI*2;
8014}
8015}
8016var _217=_210+Math.sin(_216)*(_212+10);
8017var _218=_211-Math.cos(_216)*(_212+10);
8018var _219={"position":"absolute","zIndex":11,"width":_213+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
8019if(_216<=Math.PI*0.5){
8020_219["textAlign"]="left";
8021_219["verticalAlign"]="top";
8022_219["left"]=_217+"px";
8023_219["top"]=(_218-this.options.axisLabelFontSize)+"px";
8024}else{
8025if((_216>Math.PI*0.5)&&(_216<=Math.PI)){
8026_219["textAlign"]="left";
8027_219["verticalAlign"]="bottom";
8028_219["left"]=_217+"px";
8029_219["top"]=_218+"px";
8030}else{
8031if((_216>Math.PI)&&(_216<=Math.PI*1.5)){
8032_219["textAlign"]="right";
8033_219["verticalAlign"]="bottom";
8034_219["left"]=(_217-_213)+"px";
8035_219["top"]=_218+"px";
8036}else{
8037_219["textAlign"]="right";
8038_219["verticalAlign"]="bottom";
8039_219["left"]=(_217-_213)+"px";
8040_219["top"]=(_218-this.options.axisLabelFontSize)+"px";
8041}
8042}
8043}
8044var _220=DIV({"style":_219},this.layout.xticks[i][1]);
8045this.xlabels.push(_220);
8046MochiKit.DOM.appendChildNodes(this.container,_220);
8047}
8048}
8049};
8050PlotKit.CanvasRenderer.prototype._renderBackground=function(){
8051var _221=this.element.getContext("2d");
8052_221.save();
8053_221.fillStyle=this.options.backgroundColor.toRGBString();
8054_221.fillRect(0,0,this.width,this.height);
8055_221.restore();
8056};
8057PlotKit.CanvasRenderer.prototype.clear=function(){
8058if(this.isIE){
8059try{
8060if(this.clearDelay){
8061this.clearDelay.cancel();
8062this.clearDelay=null;
8063}
8064var _222=this.element.getContext("2d");
8065}
8066catch(e){
8067this.isFirstRender=false;
8068this.clearDelay=MochiKit.Async.wait(this.IEDelay);
8069this.clearDelay.addCallback(bind(this.clear,this));
8070return;
8071}
8072}
8073var _222=this.element.getContext("2d");
8074_222.clearRect(0,0,this.width,this.height);
8075MochiKit.Iter.forEach(this.xlabels,MochiKit.DOM.removeElement);
8076MochiKit.Iter.forEach(this.ylabels,MochiKit.DOM.removeElement);
8077this.xlabels=new Array();
8078this.ylabels=new Array();
8079};
8080PlotKit.CanvasRenderer.prototype._initialiseEvents=function(){
8081var _223=MochiKit.Signal.connect;
8082var bind=MochiKit.Base.bind;
8083_223(this.element,"onclick",bind(this.onclick,this));
8084};
8085PlotKit.CanvasRenderer.prototype._resolveObject=function(e){
8086var x=(e.mouse().page.x-PlotKit.Base.findPosX(this.element)-this.area.x)/this.area.w;
8087var y=(e.mouse().page.y-PlotKit.Base.findPosY(this.element)-this.area.y)/this.area.h;
8088var _225=this.layout.hitTest(x,y);
8089if(_225){
8090return _225;
8091}
8092return null;
8093};
8094PlotKit.CanvasRenderer.prototype._createEventObject=function(_226,e){
8095if(_226==null){
8096return null;
8097}
8098e.chart=_226;
8099return e;
8100};
8101PlotKit.CanvasRenderer.prototype.onclick=function(e){
8102var _227=this._resolveObject(e);
8103var _228=this._createEventObject(_227,e);
8104if(_228!=null){
8105MochiKit.Signal.signal(this,"onclick",_228);
8106}
8107};
8108PlotKit.CanvasRenderer.prototype.onmouseover=function(e){
8109var _229=this._resolveObject(e);
8110var _230=this._createEventObject(_229,e);
8111if(_230!=null){
8112signal(this,"onmouseover",_230);
8113}
8114};
8115PlotKit.CanvasRenderer.prototype.onmouseout=function(e){
8116var _231=this._resolveObject(e);
8117var _232=this._createEventObject(_231,e);
8118if(_232==null){
8119signal(this,"onmouseout",e);
8120}else{
8121signal(this,"onmouseout",_232);
8122}
8123};
8124PlotKit.CanvasRenderer.prototype.onmousemove=function(e){
8125var _233=this._resolveObject(e);
8126var _234=this._createEventObject(_233,e);
8127if((_233==null)&&(this.event_isinside==null)){
8128return;
8129}
8130if((_233!=null)&&(this.event_isinside==null)){
8131signal(this,"onmouseover",_234);
8132}
8133if((_233==null)&&(this.event_isinside!=null)){
8134signal(this,"onmouseout",_234);
8135}
8136if((_233!=null)&&(this.event_isinside!=null)){
8137signal(this,"onmousemove",_234);
8138}
8139this.event_isinside=_233;
8140};
8141PlotKit.CanvasRenderer.isSupported=function(_235){
8142var _236=null;
8143try{
8144if(MochiKit.Base.isUndefinedOrNull(_235)){
8145_236=MochiKit.DOM.CANVAS({});
8146}else{
8147_236=MochiKit.DOM.getElement(_235);
8148}
8149var _237=_236.getContext("2d");
8150}
8151catch(e){
8152var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
8153var _239=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
8154if((!ie)||(ie[1]<6)||(_239)){
8155return false;
8156}
8157return true;
8158}
8159return true;
8160};
8161PlotKit.Canvas={};
8162PlotKit.Canvas.CanvasRenderer=PlotKit.CanvasRenderer;
8163PlotKit.Canvas.EXPORT=["CanvasRenderer"];
8164PlotKit.Canvas.EXPORT_OK=["CanvasRenderer"];
8165PlotKit.Canvas.__new__=function(){
8166var m=MochiKit.Base;
8167m.nameFunctions(this);
8168this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
8169};
8170PlotKit.Canvas.__new__();
8171MochiKit.Base._exportSymbols(this,PlotKit.Canvas);
8172try{
8173if(typeof (PlotKit.Layout)=="undefined"){
8174throw "";
8175}
8176}
8177catch(e){
8178throw "PlotKit depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.Layout";
8179}
8180PlotKit.SVGRenderer=function(_240,_241,_242){
8181if(arguments.length>0){
8182this.__init__(_240,_241,_242);
8183}
8184};
8185PlotKit.SVGRenderer.NAME="PlotKit.SVGRenderer";
8186PlotKit.SVGRenderer.VERSION=PlotKit.VERSION;
8187PlotKit.SVGRenderer.__repr__=function(){
8188return "["+this.NAME+" "+this.VERSION+"]";
8189};
8190PlotKit.SVGRenderer.toString=function(){
8191return this.__repr__();
8192};
8193PlotKit.SVGRenderer.SVGNS="http://www.w3.org/2000/svg";
8194PlotKit.SVGRenderer.prototype.__init__=function(_243,_244,_245){
8195var _246=MochiKit.Base.isUndefinedOrNull;
8196this.options={"drawBackground":true,"backgroundColor":Color.whiteColor(),"padding":{left:30,right:30,top:5,bottom:10},"colorScheme":PlotKit.Base.palette(PlotKit.Base.baseColors()[1]),"strokeColor":Color.whiteColor(),"strokeColorTransform":"asStrokeColor","strokeWidth":0.5,"shouldFill":true,"shouldStroke":true,"drawXAxis":true,"drawYAxis":true,"axisLineColor":Color.blackColor(),"axisLineWidth":0.5,"axisTickSize":3,"axisLabelColor":Color.blackColor(),"axisLabelFont":"Arial","axisLabelFontSize":9,"axisLabelWidth":50,"axisLabelUseDiv":true,"pieRadius":0.4,"enableEvents":true};
8197MochiKit.Base.update(this.options,_245?_245:{});
8198this.layout=_244;
8199this.element=MochiKit.DOM.getElement(_243);
8200this.container=this.element.parentNode;
8201this.height=parseInt(this.element.getAttribute("height"));
8202this.width=parseInt(this.element.getAttribute("width"));
8203this.document=document;
8204this.root=this.element;
8205try{
8206this.document=this.element.getSVGDocument();
8207this.root=_246(this.document.documentElement)?this.element:this.document.documentElement;
8208}
8209catch(e){
8210}
8211this.element.style.zIndex=1;
8212if(_246(this.element)){
8213throw "SVGRenderer() - passed SVG object is not found";
8214}
8215if(_246(this.container)||this.container.nodeName.toLowerCase()!="div"){
8216throw "SVGRenderer() - No DIV's around the SVG.";
8217}
8218this.xlabels=new Array();
8219this.ylabels=new Array();
8220this.defs=this.createSVGElement("defs");
8221this.area={x:this.options.padding.left,y:this.options.padding.top,w:this.width-this.options.padding.left-this.options.padding.right,h:this.height-this.options.padding.top-this.options.padding.bottom};
8222MochiKit.DOM.updateNodeAttributes(this.container,{"style":{"position":"relative","width":this.width+"px"}});
8223};
8224PlotKit.SVGRenderer.prototype.render=function(){
8225if(this.options.drawBackground){
8226this._renderBackground();
8227}
8228if(this.layout.style=="bar"){
8229this._renderBarChart();
8230this._renderBarAxis();
8231}else{
8232if(this.layout.style=="pie"){
8233this._renderPieChart();
8234this._renderPieAxis();
8235}else{
8236if(this.layout.style=="line"){
8237this._renderLineChart();
8238this._renderLineAxis();
8239}
8240}
8241}
8242};
8243PlotKit.SVGRenderer.prototype._renderBarOrLine=function(data,_247,_248,_249){
8244var _250=this.options.colorScheme.length;
8245var _251=this.options.colorScheme;
8246var _252=MochiKit.Base.keys(this.layout.datasets);
8247var _253=_252.length;
8248for(var i=0;i<_253;i++){
8249var _254=_252[i];
8250var _255=new Array();
8251var _256=_251[i%_250];
8252if(this.options.shouldFill){
8253_255["fill"]=_256.toRGBString();
8254}else{
8255_255["fill"]="none";
8256}
8257if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
8258if(this.options.strokeColor){
8259_255["stroke"]=this.options.strokeColor.toRGBString();
8260}else{
8261if(this.options.strokeColorTransform){
8262_255["stroke"]=_256[this.options.strokeColorTransform]().toRGBString();
8263}
8264}
8265_255["strokeWidth"]=this.options.strokeWidth;
8266}
8267if(_248){
8268_248(_255);
8269}
8270var _257=function(obj){
8271if(obj.name==_254){
8272_247(_255,obj);
8273}
8274};
8275MochiKit.Iter.forEach(data,bind(_257,this));
8276if(_249){
8277_249(_255);
8278}
8279}
8280};
8281PlotKit.SVGRenderer.prototype._renderBarChart=function(){
8282var bind=MochiKit.Base.bind;
8283var _258=function(_259,bar){
8284var x=this.area.w*bar.x+this.area.x;
8285var y=this.area.h*bar.y+this.area.y;
8286var w=this.area.w*bar.w;
8287var h=this.area.h*bar.h;
8288this._drawRect(x,y,w,h,_259);
8289};
8290this._renderBarOrLine(this.layout.bars,bind(_258,this));
8291};
8292PlotKit.SVGRenderer.prototype._renderLineChart=function(){
8293var bind=MochiKit.Base.bind;
8294var _260=function(_261,_262){
8295this._tempPointsBuffer+=(this.area.w*_262.x+this.area.x)+","+(this.area.h*_262.y+this.area.y)+" ";
8296};
8297var _263=function(_264){
8298this._tempPointsBuffer="";
8299this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
8300};
8301var _265=function(_266){
8302this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
8303_266["points"]=this._tempPointsBuffer;
8304var elem=this.createSVGElement("polygon",_266);
8305this.root.appendChild(elem);
8306};
8307this._renderBarOrLine(this.layout.points,bind(_260,this),bind(_263,this),bind(_265,this));
8308};
8309PlotKit.SVGRenderer.prototype._renderPieChart=function(){
8310var _268=this.options.colorScheme.length;
8311var _269=this.layout.slices;
8312var _270=this.area.x+this.area.w*0.5;
8313var _271=this.area.y+this.area.h*0.5;
8314var _272=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
8315if(_269.length==1&&(Math.abs(_269[0].startAngle)-Math.abs(_269[0].endAngle)<0.1)){
8316var _273={"cx":_270,"cy":_271,"r":_272};
8317var _274=this.options.colorScheme[0];
8318if(this.options.shouldFill){
8319_273["fill"]=_274.toRGBString();
8320}else{
8321_273["fill"]="none";
8322}
8323if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
8324if(this.options.strokeColor){
8325_273["stroke"]=this.options.strokeColor.toRGBString();
8326}else{
8327if(this.options.strokeColorTransform){
8328_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString();
8329}
8330}
8331_273["style"]="stroke-width: "+this.options.strokeWidth;
8332}
8333this.root.appendChild(this.createSVGElement("circle",_273));
8334return;
8335}
8336for(var i=0;i<_269.length;i++){
8337var _273=new Array();
8338var _274=this.options.colorScheme[i%_268];
8339if(this.options.shouldFill){
8340_273["fill"]=_274.toRGBString();
8341}else{
8342_273["fill"]="none";
8343}
8344if(this.options.shouldStroke&&(this.options.strokeColor||this.options.strokeColorTransform)){
8345if(this.options.strokeColor){
8346_273["stroke"]=this.options.strokeColor.toRGBString();
8347}else{
8348if(this.options.strokeColorTransform){
8349_273["stroke"]=_274[this.options.strokeColorTransform]().toRGBString();
8350}
8351}
8352_273["style"]="stroke-width:"+this.options.strokeWidth;
8353}
8354var _275=0;
8355if(Math.abs(_269[i].endAngle-_269[i].startAngle)>Math.PI){
8356_275=1;
8357}
8358var x1=Math.cos(_269[i].startAngle-Math.PI/2)*_272;
8359var y1=Math.sin(_269[i].startAngle-Math.PI/2)*_272;
8360var x2=Math.cos(_269[i].endAngle-Math.PI/2)*_272;
8361var y2=Math.sin(_269[i].endAngle-Math.PI/2)*_272;
8362var rx=x2-x1;
8363var ry=y2-y1;
8364var _282="M"+_270+","+_271+" ";
8365_282+="l"+x1+","+y1+" ";
8366_282+="a"+_272+","+_272+" 0 "+_275+",1 "+rx+","+ry+" z";
8367_273["d"]=_282;
8368var elem=this.createSVGElement("path",_273);
8369this.root.appendChild(elem);
8370}
8371};
8372PlotKit.SVGRenderer.prototype._renderBarAxis=function(){
8373this._renderAxis();
8374};
8375PlotKit.SVGRenderer.prototype._renderLineAxis=function(){
8376this._renderAxis();
8377};
8378PlotKit.SVGRenderer.prototype._renderAxis=function(){
8379if(!this.options.drawXAxis&&!this.options.drawYAxis){
8380return;
8381}
8382var _283={"style":{"position":"absolute","textAlign":"center","fontSize":this.options.axisLabelFontSize+"px","zIndex":10,"color":this.options.axisLabelColor.toRGBString(),"width":this.options.axisLabelWidth+"px","overflow":"hidden"}};
8383var _284={"stroke":this.options.axisLineColor.toRGBString(),"strokeWidth":this.options.axisLineWidth};
8384if(this.options.drawYAxis){
8385if(this.layout.yticks){
8386var _285=function(tick){
8387var x=this.area.x;
8388var y=this.area.y+tick[0]*this.area.h;
8389this._drawLine(x,y,x-3,y,_284);
8390if(this.options.axisLabelUseDiv){
8391var _286=DIV(_283,tick[1]);
8392_286.style.top=(y-this.options.axisLabelFontSize)+"px";
8393_286.style.left=(x-this.options.padding.left+this.options.axisTickSize)+"px";
8394_286.style.textAlign="left";
8395_286.style.width=(this.options.padding.left-3)+"px";
8396MochiKit.DOM.appendChildNodes(this.container,_286);
8397this.ylabels.push(_286);
8398}else{
8399var _287={y:y+3,x:(x-this.options.padding.left+3),width:(this.options.padding.left-this.options.axisTickSize)+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString()};
8400var _286=this.createSVGElement("text",_287);
8401_286.appendChild(this.document.createTextNode(tick[1]));
8402this.root.appendChild(_286);
8403}
8404};
8405MochiKit.Iter.forEach(this.layout.yticks,bind(_285,this));
8406}
8407this._drawLine(this.area.x,this.area.y,this.area.x,this.area.y+this.area.h,_284);
8408}
8409if(this.options.drawXAxis){
8410if(this.layout.xticks){
8411var _285=function(tick){
8412var x=this.area.x+tick[0]*this.area.w;
8413var y=this.area.y+this.area.h;
8414this._drawLine(x,y,x,y+this.options.axisTickSize,_284);
8415if(this.options.axisLabelUseDiv){
8416var _288=DIV(_283,tick[1]);
8417_288.style.top=(y+this.options.axisTickSize)+"px";
8418_288.style.left=(x-this.options.axisLabelWidth/2)+"px";
8419_288.style.textAlign="center";
8420_288.style.width=this.options.axisLabelWidth+"px";
8421MochiKit.DOM.appendChildNodes(this.container,_288);
8422this.xlabels.push(_288);
8423}else{
8424var _289={y:(y+this.options.axisTickSize+this.options.axisLabelFontSize),x:x-3,width:this.options.axisLabelWidth+"px",height:(this.options.axisLabelFontSize+3)+"px",fontFamily:"Arial",fontSize:this.options.axisLabelFontSize+"px",fill:this.options.axisLabelColor.toRGBString(),textAnchor:"middle"};
8425var _288=this.createSVGElement("text",_289);
8426_288.appendChild(this.document.createTextNode(tick[1]));
8427this.root.appendChild(_288);
8428}
8429};
8430MochiKit.Iter.forEach(this.layout.xticks,bind(_285,this));
8431}
8432this._drawLine(this.area.x,this.area.y+this.area.h,this.area.x+this.area.w,this.area.y+this.area.h,_284);
8433}
8434};
8435PlotKit.SVGRenderer.prototype._renderPieAxis=function(){
8436if(this.layout.xticks){
8437var _290=new Array();
8438for(var i=0;i<this.layout.slices.length;i++){
8439_290[this.layout.slices[i].xval]=this.layout.slices[i];
8440}
8441var _291=this.area.x+this.area.w*0.5;
8442var _292=this.area.y+this.area.h*0.5;
8443var _293=Math.min(this.area.w*this.options.pieRadius+10,this.area.h*this.options.pieRadius+10);
8444var _294=this.options.axisLabelWidth;
8445for(var i=0;i<this.layout.xticks.length;i++){
8446var _295=_290[this.layout.xticks[i][0]];
8447if(MochiKit.Base.isUndefinedOrNull(_295)){
8448continue;
8449}
8450var _296=(_295.startAngle+_295.endAngle)/2;
8451var _297=_296;
8452if(_297>Math.PI*2){
8453_297=_297-Math.PI*2;
8454}else{
8455if(_297<0){
8456_297=_297+Math.PI*2;
8457}
8458}
8459var _298=_291+Math.sin(_297)*(_293+10);
8460var _299=_292-Math.cos(_297)*(_293+10);
8461var _300={"position":"absolute","zIndex":11,"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","overflow":"hidden","color":this.options.axisLabelColor.toHexString()};
8462var _301={"width":_294+"px","fontSize":this.options.axisLabelFontSize+"px","height":(this.options.axisLabelFontSize+3)+"px","fill":this.options.axisLabelColor.toRGBString()};
8463if(_297<=Math.PI*0.5){
8464MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"top","left":_298+"px","top":(_299-this.options.axisLabelFontSize)+"px"});
8465MochiKit.Base.update(_301,{"x":_298,"y":(_299-this.options.axisLabelFontSize),"textAnchor":"left"});
8466}else{
8467if((_297>Math.PI*0.5)&&(_297<=Math.PI)){
8468MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
8469MochiKit.Base.update(_301,{"textAnchor":"left","x":_298,"y":_299});
8470}else{
8471if((_297>Math.PI)&&(_297<=Math.PI*1.5)){
8472MochiKit.Base.update(_300,{"textAlign":"right","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
8473MochiKit.Base.update(_301,{"textAnchor":"right","x":_298-_294,"y":_299});
8474}else{
8475MochiKit.Base.update(_300,{"textAlign":"left","verticalAlign":"bottom","left":_298+"px","top":_299+"px"});
8476MochiKit.Base.update(_301,{"textAnchor":"left","x":_298-_294,"y":_299-this.options.axisLabelFontSize});
8477}
8478}
8479}
8480if(this.options.axisLabelUseDiv){
8481var _302=DIV({"style":_300},this.layout.xticks[i][1]);
8482this.xlabels.push(_302);
8483MochiKit.DOM.appendChildNodes(this.container,_302);
8484}else{
8485var _302=this.createSVGElement("text",_301);
8486_302.appendChild(this.document.createTextNode(this.layout.xticks[i][1]));
8487this.root.appendChild(_302);
8488}
8489}
8490}
8491};
8492PlotKit.SVGRenderer.prototype._renderBackground=function(){
8493var opts={"stroke":"none","fill":this.options.backgroundColor.toRGBString()};
8494this._drawRect(0,0,this.width,this.height,opts);
8495};
8496PlotKit.SVGRenderer.prototype._drawRect=function(x,y,w,h,_304){
8497var _305={x:x+"px",y:y+"px",width:w+"px",height:h+"px"};
8498if(_304){
8499MochiKit.Base.update(_305,_304);
8500}
8501var elem=this.createSVGElement("rect",_305);
8502this.root.appendChild(elem);
8503};
8504PlotKit.SVGRenderer.prototype._drawLine=function(x1,y1,x2,y2,_306){
8505var _307={x1:x1+"px",y1:y1+"px",x2:x2+"px",y2:y2+"px"};
8506if(_306){
8507MochiKit.Base.update(_307,_306);
8508}
8509var elem=this.createSVGElement("line",_307);
8510this.root.appendChild(elem);
8511};
8512PlotKit.SVGRenderer.prototype.clear=function(){
8513while(this.element.firstChild){
8514this.element.removeChild(this.element.firstChild);
8515}
8516if(this.options.axisLabelUseDiv){
8517for(var i=0;i<this.xlabels.length;i++){
8518MochiKit.DOM.removeElement(this.xlabels[i]);
8519}
8520for(var i=0;i<this.ylabels.length;i++){
8521MochiKit.DOM.removeElement(this.ylabels[i]);
8522}
8523}
8524this.xlabels=new Array();
8525this.ylabels=new Array();
8526};
8527PlotKit.SVGRenderer.prototype.createSVGElement=function(name,_309){
8528var _310=MochiKit.Base.isUndefinedOrNull;
8529var elem;
8530var doc=_310(this.document)?document:this.document;
8531try{
8532elem=doc.createElementNS(PlotKit.SVGRenderer.SVGNS,name);
8533}
8534catch(e){
8535elem=doc.createElement(name);
8536elem.setAttribute("xmlns",PlotKit.SVGRenderer.SVGNS);
8537}
8538if(_309){
8539MochiKit.DOM.updateNodeAttributes(elem,_309);
8540}
8541return elem;
8542};
8543PlotKit.SVGRenderer.SVG=function(_312){
8544var ie=navigator.appVersion.match(/MSIE (\d\.\d)/);
8545var _313=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
8546if(ie&&(ie[1]>=6)&&(!_313)){
8547var _314=_312["width"]?_312["width"]:"100";
8548var _315=_312["height"]?_312["height"]:"100";
8549var eid=_312["id"]?_312["id"]:"notunique";
8550var html="<svg:svg width=\""+_314+"\" height=\""+_315+"\" ";
8551html+="id=\""+eid+"\" version=\"1.1\" baseProfile=\"full\" />";
8552var _318=document.createElement(html);
8553var _319=_318.getSVGDocument().createElementNS(PlotKit.SVGRenderer.SVGNS,"svg");
8554_319.setAttribute("width",_314);
8555_319.setAttribute("height",_315);
8556_318.getSVGDocument().appendChild(_319);
8557return _318;
8558}else{
8559return PlotKit.SVGRenderer.prototype.createSVGElement("svg",_312);
8560}
8561};
8562PlotKit.SVGRenderer.isSupported=function(){
8563var _320=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
8564var _321=navigator.appVersion.match(/MSIE (\d\.\d)/);
8565var _322=navigator.userAgent.match(/AppleWebKit\/(\d+)/);
8566var _323=navigator.userAgent.match(/Opera\/(\d*\.\d*)/);
8567var _324=navigator.userAgent.match(/rv:(\d*\.\d*).*Gecko/);
8568var _325="http://www.w3.org/TR/SVG11/feature#SVG";
8569if(_321&&(_321[1]>=6)&&!_320){
8570return document.implementation.hasFeature(_325,"1.1");
8571}
8572if(_323&&(_323[1]>8.9)){
8573return true;
8574}
8575if(_324&&(_324>1.7)){
8576return true;
8577}
8578return false;
8579};
8580PlotKit.SVG={};
8581PlotKit.SVG.SVGRenderer=PlotKit.SVGRenderer;
8582PlotKit.SVG.EXPORT=["SVGRenderer"];
8583PlotKit.SVG.EXPORT_OK=["SVGRenderer"];
8584PlotKit.SVG.__new__=function(){
8585var m=MochiKit.Base;
8586m.nameFunctions(this);
8587this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
8588};
8589PlotKit.SVG.__new__();
8590MochiKit.Base._exportSymbols(this,PlotKit.SVG);
8591try{
8592if(typeof (PlotKit.CanvasRenderer)=="undefined"){
8593throw "";
8594}
8595}
8596catch(e){
8597throw "SweetCanvas depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, Canvas}";
8598}
8599if(typeof (PlotKit.SweetCanvasRenderer)=="undefined"){
8600PlotKit.SweetCanvasRenderer={};
8601}
8602PlotKit.SweetCanvasRenderer=function(_326,_327,_328){
8603if(arguments.length>0){
8604this.__init__(_326,_327,_328);
8605}
8606};
8607PlotKit.SweetCanvasRenderer.NAME="PlotKit.SweetCanvasRenderer";
8608PlotKit.SweetCanvasRenderer.VERSION=PlotKit.VERSION;
8609PlotKit.SweetCanvasRenderer.__repr__=function(){
8610return "["+this.NAME+" "+this.VERSION+"]";
8611};
8612PlotKit.SweetCanvasRenderer.toString=function(){
8613return this.__repr__();
8614};
8615PlotKit.SweetCanvasRenderer.prototype=new PlotKit.CanvasRenderer();
8616PlotKit.SweetCanvasRenderer.prototype.constructor=PlotKit.SweetCanvasRenderer;
8617PlotKit.SweetCanvasRenderer.__super__=PlotKit.CanvasRenderer.prototype;
8618PlotKit.SweetCanvasRenderer.prototype.__init__=function(el,_330,opts){
8619var _331=PlotKit.Base.officeBlue();
8620MochiKit.Base.update(_331,opts);
8621PlotKit.SweetCanvasRenderer.__super__.__init__.call(this,el,_330,_331);
8622};
8623PlotKit.SweetCanvasRenderer.prototype._renderBarChart=function(){
8624var bind=MochiKit.Base.bind;
8625var _332=Color.blackColor().colorWithAlpha(0.1).toRGBString();
8626var _333=function(_334,x,y,w,h){
8627_334.fillStyle=_332;
8628_334.fillRect(x-2,y-2,w+4,h+2);
8629_334.fillStyle=_332;
8630_334.fillRect(x-1,y-1,w+2,h+1);
8631};
8632var _335=this.options.colorScheme.length;
8633var _336=this.options.colorScheme;
8634var _337=PlotKit.Base.keys(this.layout.datasets);
8635var _338=_337.length;
8636var _339=function(name){
8637for(var i=0;i<_338;i++){
8638if(name==_337[i]){
8639return _336[i%_335];
8640}
8641}
8642return _336[0];
8643};
8644var _340=function(_341,bar){
8645var x=this.area.w*bar.x+this.area.x;
8646var y=this.area.h*bar.y+this.area.y;
8647var w=this.area.w*bar.w;
8648var h=this.area.h*bar.h;
8649if((w<1)||(h<1)){
8650return;
8651}
8652_341.save();
8653_341.shadowBlur=5;
8654_341.shadowColor=Color.fromHexString("#888888").toRGBString();
8655if(this.isIE){
8656_341.save();
8657_341.fillStyle="#cccccc";
8658_341.fillRect(x-2,y-2,w+4,h+2);
8659_341.restore();
8660}else{
8661_333(_341,x,y,w,h);
8662}
8663if(this.options.shouldFill){
8664_341.fillStyle=_339(bar.name).toRGBString();
8665_341.fillRect(x,y,w,h);
8666}
8667_341.shadowBlur=0;
8668_341.strokeStyle=Color.whiteColor().toRGBString();
8669_341.lineWidth=2;
8670if(this.options.shouldStroke){
8671_341.strokeRect(x,y,w,h);
8672}
8673_341.restore();
8674};
8675this._renderBarChartWrap(this.layout.bars,bind(_340,this));
8676};
8677PlotKit.SweetCanvasRenderer.prototype._renderLineChart=function(){
8678var _342=this.element.getContext("2d");
8679var _343=this.options.colorScheme.length;
8680var _344=this.options.colorScheme;
8681var _345=PlotKit.Base.keys(this.layout.datasets);
8682var _346=_345.length;
8683var bind=MochiKit.Base.bind;
8684for(var i=0;i<_346;i++){
8685var _347=_345[i];
8686var _348=_344[i%_343];
8687var _349=this.options.strokeColorTransform;
8688_342.save();
8689var _350=function(ctx){
8690ctx.beginPath();
8691ctx.moveTo(this.area.x,this.area.y+this.area.h);
8692var _351=function(ctx_,_352){
8693if(_352.name==_347){
8694ctx_.lineTo(this.area.w*_352.x+this.area.x,this.area.h*_352.y+this.area.y);
8695}
8696};
8697MochiKit.Iter.forEach(this.layout.points,partial(_351,ctx),this);
8698ctx.lineTo(this.area.w+this.area.x,this.area.h+this.area.y);
8699ctx.lineTo(this.area.x,this.area.y+this.area.h);
8700ctx.closePath();
8701};
8702if(this.options.shouldFill){
8703_342.save();
8704if(this.isIE){
8705_342.fillStyle="#cccccc";
8706}else{
8707_342.fillStyle=Color.blackColor().colorWithAlpha(0.2).toRGBString();
8708}
8709_342.translate(-1,-2);
8710bind(_350,this)(_342);
8711if(this.options.shouldFill){
8712_342.fill();
8713}
8714_342.restore();
8715}
8716_342.shadowBlur=5;
8717_342.shadowColor=Color.fromHexString("#888888").toRGBString();
8718_342.fillStyle=_348.toRGBString();
8719_342.lineWidth=2;
8720_342.strokeStyle=Color.whiteColor().toRGBString();
8721if(this.options.shouldFill){
8722bind(_350,this)(_342);
8723_342.fill();
8724}
8725if(this.options.shouldStroke){
8726bind(_350,this)(_342);
8727_342.stroke();
8728}
8729_342.restore();
8730}
8731};
8732PlotKit.SweetCanvasRenderer.prototype._renderPieChart=function(){
8733var _353=this.element.getContext("2d");
8734var _354=this.options.colorScheme.length;
8735var _355=this.layout.slices;
8736var _356=this.area.x+this.area.w*0.5;
8737var _357=this.area.y+this.area.h*0.5;
8738var _358=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
8739if(this.isIE){
8740_356=parseInt(_356);
8741_357=parseInt(_357);
8742_358=parseInt(_358);
8743}
8744if(!this.isIE){
8745_353.save();
8746var _359=Color.blackColor().colorWithAlpha(0.2);
8747_353.fillStyle=_359.toRGBString();
8748_353.shadowBlur=5;
8749_353.shadowColor=Color.fromHexString("#888888").toRGBString();
8750_353.translate(1,1);
8751_353.beginPath();
8752_353.moveTo(_356,_357);
8753_353.arc(_356,_357,_358+2,0,Math.PI*2,false);
8754_353.closePath();
8755_353.fill();
8756_353.restore();
8757}
8758_353.save();
8759_353.strokeStyle=Color.whiteColor().toRGBString();
8760_353.lineWidth=2;
8761for(var i=0;i<_355.length;i++){
8762var _360=this.options.colorScheme[i%_354];
8763_353.fillStyle=_360.toRGBString();
8764var _361=function(){
8765_353.beginPath();
8766_353.moveTo(_356,_357);
8767_353.arc(_356,_357,_358,_355[i].startAngle-Math.PI/2,_355[i].endAngle-Math.PI/2,false);
8768_353.lineTo(_356,_357);
8769_353.closePath();
8770};
8771if(Math.abs(_355[i].startAngle-_355[i].endAngle)>0.0001){
8772if(this.options.shouldFill){
8773_361();
8774_353.fill();
8775}
8776if(this.options.shouldStroke){
8777_361();
8778_353.stroke();
8779}
8780}
8781}
8782_353.restore();
8783};
8784PlotKit.SweetCanvasRenderer.prototype._renderBackground=function(){
8785var _362=this.element.getContext("2d");
8786if(this.layout.style=="bar"||this.layout.style=="line"){
8787_362.save();
8788_362.fillStyle=this.options.backgroundColor.toRGBString();
8789_362.fillRect(this.area.x,this.area.y,this.area.w,this.area.h);
8790_362.strokeStyle=this.options.axisLineColor.toRGBString();
8791_362.lineWidth=1;
8792var _363=this.layout.yticks;
8793var _364=false;
8794if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
8795_363=this.layout.xticks;
8796_364=true;
8797}
8798for(var i=0;i<_363.length;i++){
8799var x1=0;
8800var y1=0;
8801var x2=0;
8802var y2=0;
8803if(_364){
8804x1=_363[i][0]*this.area.w+this.area.x;
8805y1=this.area.y;
8806x2=x1;
8807y2=y1+this.area.h;
8808}else{
8809x1=this.area.x;
8810y1=_363[i][0]*this.area.h+this.area.y;
8811x2=x1+this.area.w;
8812y2=y1;
8813}
8814_362.beginPath();
8815_362.moveTo(x1,y1);
8816_362.lineTo(x2,y2);
8817_362.closePath();
8818_362.stroke();
8819}
8820_362.restore();
8821}else{
8822PlotKit.SweetCanvasRenderer.__super__._renderBackground.call(this);
8823}
8824};
8825PlotKit.SweetCanvas={};
8826PlotKit.SweetCanvas.SweetCanvasRenderer=PlotKit.SweetCanvasRenderer;
8827PlotKit.SweetCanvas.EXPORT=["SweetCanvasRenderer"];
8828PlotKit.SweetCanvas.EXPORT_OK=["SweetCanvasRenderer"];
8829PlotKit.SweetCanvas.__new__=function(){
8830var m=MochiKit.Base;
8831m.nameFunctions(this);
8832this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
8833};
8834PlotKit.SweetCanvas.__new__();
8835MochiKit.Base._exportSymbols(this,PlotKit.SweetCanvas);
8836try{
8837if(typeof (PlotKit.SVGRenderer)=="undefined"){
8838throw "";
8839}
8840}
8841catch(e){
8842throw "SweetSVG depends on MochiKit.{Base,Color,DOM,Format} and PlotKit.{Layout, SVG}";
8843}
8844if(typeof (PlotKit.SweetSVGRenderer)=="undefined"){
8845PlotKit.SweetSVGRenderer={};
8846}
8847PlotKit.SweetSVGRenderer=function(_365,_366,_367){
8848if(arguments.length>0){
8849this.__init__(_365,_366,_367);
8850}
8851};
8852PlotKit.SweetSVGRenderer.NAME="PlotKit.SweetSVGRenderer";
8853PlotKit.SweetSVGRenderer.VERSION=PlotKit.VERSION;
8854PlotKit.SweetSVGRenderer.__repr__=function(){
8855return "["+this.NAME+" "+this.VERSION+"]";
8856};
8857PlotKit.SweetSVGRenderer.toString=function(){
8858return this.__repr__();
8859};
8860PlotKit.SweetSVGRenderer.prototype=new PlotKit.SVGRenderer();
8861PlotKit.SweetSVGRenderer.prototype.constructor=PlotKit.SweetSVGRenderer;
8862PlotKit.SweetSVGRenderer.__super__=PlotKit.SVGRenderer.prototype;
8863PlotKit.SweetSVGRenderer.prototype.__init__=function(_368,_369,_370){
8864var _371=PlotKit.Base.officeBlue();
8865MochiKit.Base.update(_371,_370);
8866PlotKit.SweetSVGRenderer.__super__.__init__.call(this,_368,_369,_371);
8867};
8868PlotKit.SweetSVGRenderer.prototype._addDropShadowFilter=function(){
8869var _372=this.createSVGElement("filter",{x:0,y:0,"id":"dropShadow"});
8870var _373=this.createSVGElement("feOffset",{"in":"SourceGraphic","dx":0,"dy":0,"result":"topCopy"});
8871var blur=this.createSVGElement("feGaussianBlur",{"in":"SourceAlpha","StdDeviation":2,"result":"shadow"});
8872var _375=this.createSVGElement("feOffset",{"in":"shadow","dx":-1,"dy":-2,"result":"movedShadow"});
8873var _376=this.createSVGElement("feMerge");
8874var _377=this.createSVGElement("feMergeNode",{"in":"topCopy"});
8875var _378=this.createSVGElement("feMergeNode",{"in":"movedShadow"});
8876_376.appendChild(_377);
8877_376.appendChild(_378);
8878_372.appendChild(_373);
8879_372.appendChild(blur);
8880_372.appendChild(_375);
8881_372.appendChild(_376);
8882this.defs.appendChild(_372);
8883};
8884PlotKit.SweetSVGRenderer.prototype._renderBarChart=function(){
8885var bind=MochiKit.Base.bind;
8886var _379=Color.blackColor().toRGBString();
8887var _380="fill:"+_379+";fill-opacity:0.15";
8888var _381="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
8889var _382=function(_383,bar){
8890var x=this.area.w*bar.x+this.area.x;
8891var y=this.area.h*bar.y+this.area.y;
8892var w=this.area.w*bar.w;
8893var h=this.area.h*bar.h;
8894if((w<1)||(h<1)){
8895return;
8896}
8897_383["style"]=_381;
8898this._drawRect(x-2,y-1,w+4,h+2,{"style":_380});
8899this._drawRect(x,y,w,h,_383);
8900};
8901this._renderBarOrLine(this.layout.bars,bind(_382,this));
8902};
8903PlotKit.SweetSVGRenderer.prototype._renderLineChart=function(){
8904var bind=MochiKit.Base.bind;
8905var _384=Color.blackColor().toRGBString();
8906var _385="fill:"+_384+";fill-opacity:0.15";
8907var _386="stroke-width: 2.0; stroke:"+Color.whiteColor().toRGBString();
8908var _387=function(_388,_389){
8909this._tempPointsBuffer+=(this.area.w*_389.x+this.area.x)+","+(this.area.h*_389.y+this.area.y)+" ";
8910};
8911var _390=function(_391){
8912this._tempPointsBuffer="";
8913this._tempPointsBuffer+=(this.area.x)+","+(this.area.y+this.area.h)+" ";
8914};
8915var _392=function(_393){
8916this._tempPointsBuffer+=(this.area.w+this.area.x)+","+(this.area.h+this.area.y);
8917_393["points"]=this._tempPointsBuffer;
8918_393["stroke"]="none";
8919_393["transform"]="translate(-2, -1)";
8920_393["style"]=_385;
8921var _394=this.createSVGElement("polygon",_393);
8922this.root.appendChild(_394);
8923_393["transform"]="";
8924_393["style"]=_386;
8925var elem=this.createSVGElement("polygon",_393);
8926this.root.appendChild(elem);
8927};
8928this._renderBarOrLine(this.layout.points,bind(_387,this),bind(_390,this),bind(_392,this));
8929};
8930PlotKit.SweetSVGRenderer.prototype._renderPieChart=function(){
8931var _395=this.area.x+this.area.w*0.5;
8932var _396=this.area.y+this.area.h*0.5;
8933var _397=Color.blackColor().toRGBString();
8934var _398=Math.min(this.area.w*this.options.pieRadius,this.area.h*this.options.pieRadius);
8935var _399="fill:"+_397+";fill-opacity:0.15";
8936var _400=this.createSVGElement("circle",{"style":_399,"cx":_395+1,"cy":_396+1,"r":_398+1});
8937this.root.appendChild(_400);
8938PlotKit.SweetSVGRenderer.__super__._renderPieChart.call(this);
8939};
8940PlotKit.SweetSVGRenderer.prototype._renderBackground=function(){
8941var _401={"fill":this.options.backgroundColor.toRGBString(),"stroke":"none"};
8942if(this.layout.style=="bar"||this.layout.style=="line"){
8943this._drawRect(this.area.x,this.area.y,this.area.w,this.area.h,_401);
8944var _402=this.layout.yticks;
8945var _403=false;
8946if(this.layout.style=="bar"&&this.layout.options.barOrientation=="horizontal"){
8947_402=this.layout.xticks;
8948_403=true;
8949}
8950for(var i=0;i<_402.length;i++){
8951var x=0;
8952var y=0;
8953var w=0;
8954var h=0;
8955if(_403){
8956x=_402[i][0]*this.area.w+this.area.x;
8957y=this.area.y;
8958w=1;
8959h=this.area.w;
8960}else{
8961x=this.area.x;
8962y=_402[i][0]*this.area.h+this.area.y;
8963w=this.area.w;
8964h=1;
8965}
8966this._drawRect(x,y,w,h,{"fill":this.options.axisLineColor.toRGBString()});
8967}
8968}else{
8969PlotKit.SweetSVGRenderer.__super__._renderBackground.call(this);
8970}
8971};
8972PlotKit.SweetSVG={};
8973PlotKit.SweetSVG.SweetSVGRenderer=PlotKit.SweetSVGRenderer;
8974PlotKit.SweetSVG.EXPORT=["SweetSVGRenderer"];
8975PlotKit.SweetSVG.EXPORT_OK=["SweetSVGRenderer"];
8976PlotKit.SweetSVG.__new__=function(){
8977var m=MochiKit.Base;
8978m.nameFunctions(this);
8979this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
8980};
8981PlotKit.SweetSVG.__new__();
8982MochiKit.Base._exportSymbols(this,PlotKit.SweetSVG);
8983try{
8984if(typeof (PlotKit.CanvasRenderer)=="undefined"){
8985throw "";
8986}
8987}
8988catch(e){
8989throw "PlotKit.EasyPlot depends on all of PlotKit's components";
8990}
8991if(typeof (PlotKit.EasyPlot)=="undefined"){
8992PlotKit.EasyPlot={};
8993}
8994PlotKit.EasyPlot.NAME="PlotKit.EasyPlot";
8995PlotKit.EasyPlot.VERSION=PlotKit.VERSION;
8996PlotKit.EasyPlot.__repr__=function(){
8997return "["+this.NAME+" "+this.VERSION+"]";
8998};
8999PlotKit.EasyPlot.toString=function(){
9000return this.__repr__();
9001};
9002PlotKit.EasyPlot=function(_404,_405,_406,_407){
9003this.layout=new Layout(_404,_405);
9004this.divElem=_406;
9005this.width=parseInt(_406.getAttribute("width"));
9006this.height=parseInt(_406.getAttribute("height"));
9007this.deferredCount=0;
9008if(this.width<1){
9009this.width=this.divElem.width?this.divElem.width:300;
9010}
9011if(this.height<1){
9012this.height=this.divElem.height?this.divElem.height:300;
9013}
9014if(isArrayLike(_407)){
9015for(var i=0;i<_407.length;i++){
9016if(typeof (_407[i])=="string"){
9017this.deferredCount++;
9018var d=MochiKit.Async.doSimpleXMLHttpRequest(_407[i]);
9019d.addCallback(MochiKit.Base.bind(PlotKit.EasyPlot.onDataLoaded,this));
9020}else{
9021if(isArrayLike(_407[i])){
9022this.layout.addDataset("data-"+i,_407[i]);
9023}
9024}
9025}
9026}else{
9027if(!isUndefinedOrNull(_407)){
9028throw "Passed datasources are not Array like";
9029}
9030}
9031if(CanvasRenderer.isSupported()){
9032this.element=CANVAS({"id":this.divElem.getAttribute("id")+"-canvas","width":this.width,"height":this.height},"");
9033this.divElem.appendChild(this.element);
9034this.renderer=new SweetCanvasRenderer(this.element,this.layout,_405);
9035}else{
9036if(SVGRenderer.isSupported()){
9037this.element=SVGRenderer.SVG({"id":this.divElem.getAttribute("id")+"-svg","width":this.width,"height":this.height,"version":"1.1","baseProfile":"full"},"");
9038this.divElem.appendChild(this.element);
9039this.renderer=new SweetSVGRenderer(this.element,this.layout,_405);
9040}
9041}
9042if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
9043this.layout.evaluate();
9044this.renderer.clear();
9045this.renderer.render();
9046}
9047};
9048PlotKit.EasyPlot.onDataLoaded=function(_409){
9049var _410=new Array();
9050var _411=_409.responseText.split("\n");
9051for(var i=0;i<_411.length;i++){
9052var _412=MochiKit.Format.strip(_411[i]);
9053if((_412.length>1)&&(_412.charAt(0)!="#")){
9054_410.push(_412.split(","));
9055}
9056}
9057this.layout.addDataset("data-ajax-"+this.deferredCount,_410);
9058this.deferredCount--;
9059if((this.deferredCount==0)&&(PlotKit.Base.keys(this.layout.datasets).length>0)){
9060this.layout.evaluate();
9061this.renderer.clear();
9062this.renderer.render();
9063}
9064};
9065PlotKit.EasyPlot.prototype.reload=function(){
9066this.layout.evaluate();
9067this.renderer.clear();
9068this.renderer.render();
9069};
9070PlotKit.EasyPlotModule={};
9071PlotKit.EasyPlotModule.EasyPlot=PlotKit.EasyPlot;
9072PlotKit.EasyPlotModule.EXPORT=["EasyPlot"];
9073PlotKit.EasyPlotModule.EXPORT_OK=[];
9074PlotKit.EasyPlotModule.__new__=function(){
9075var m=MochiKit.Base;
9076m.nameFunctions(this);
9077this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
9078};
9079PlotKit.EasyPlotModule.__new__();
9080MochiKit.Base._exportSymbols(this,PlotKit.EasyPlotModule);
9081
9082
9083// Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
9084// All Rights Reserved.
9085
9086/**
9087 * @fileoverview Subclasses various parts of PlotKit to meet the additional
9088 * needs of DateGraph: grid overlays and error bars
9089 */
9090
9091// Subclass PlotKit.Layout to add:
9092// 1. Sigma/errorBars properties
9093// 2. Copy error terms for PlotKit.CanvasRenderer._renderLineChart
9094
9095/**
9096 * Creates a new DateGraphLayout object. Options are the same as those allowed
9097 * by the PlotKit.Layout constructor.
9098 * @param {Object} options Options for PlotKit.Layout
9099 * @return {Object} The DateGraphLayout object
9100 */
9101DateGraphLayout = function(options) {
9102 PlotKit.Layout.call(this, "line", options);
9103};
9104DateGraphLayout.prototype = new PlotKit.Layout();
9105
9106/**
9107 * Behaves the same way as PlotKit.Layout, but also copies the errors
9108 * @private
9109 */
9110DateGraphLayout.prototype.evaluateWithError = function() {
9111 this.evaluate();
9112 if (!this.options.errorBars) return;
9113
9114 // Copy over the error terms
9115 var i = 0; // index in this.points
9116 for (var setName in this.datasets) {
9117 var j = 0;
9118 var dataset = this.datasets[setName];
9119 if (PlotKit.Base.isFuncLike(dataset)) continue;
9120 for (var j = 0; j < dataset.length; j++, i++) {
9121 var item = dataset[j];
9122 var xv = parseFloat(item[0]);
9123 var yv = parseFloat(item[1]);
9124
9125 if (xv == this.points[i].xval &&
9126 yv == this.points[i].yval) {
9127 this.points[i].errorMinus = parseFloat(item[2]);
9128 this.points[i].errorPlus = parseFloat(item[3]);
9129 }
9130 }
9131 }
9132};
9133
9134/**
9135 * Convenience function to remove all the data sets from a graph
9136 */
9137DateGraphLayout.prototype.removeAllDatasets = function() {
9138 delete this.datasets;
9139 this.datasets = new Array();
9140};
9141
9142/**
9143 * Change the values of various layout options
9144 * @param {Object} new_options an associative array of new properties
9145 */
9146DateGraphLayout.prototype.updateOptions = function(new_options) {
9147 MochiKit.Base.update(this.options, new_options ? new_options : {});
9148};
9149
9150// Subclass PlotKit.CanvasRenderer to add:
9151// 1. X/Y grid overlay
9152// 2. Ability to draw error bars (if required)
9153
9154/**
9155 * Sets some PlotKit.CanvasRenderer options
9156 * @param {Object} element The canvas to attach to
9157 * @param {Layout} layout The DateGraphLayout object for this graph.
9158 * @param {Object} options Options to pass on to CanvasRenderer
9159 */
9160DateGraphCanvasRenderer = function(element, layout, options) {
9161 PlotKit.CanvasRenderer.call(this, element, layout, options);
9162 this.options.shouldFill = false;
9163 this.options.shouldStroke = true;
9164 this.options.drawYGrid = true;
9165 this.options.drawXGrid = true;
9166 this.options.gridLineColor = MochiKit.Color.Color.grayColor();
9167 MochiKit.Base.update(this.options, options);
9168
9169 // TODO(danvk) This shouldn't be necessary: effects should be overlaid
9170 this.options.drawBackground = false;
9171};
9172DateGraphCanvasRenderer.prototype = new PlotKit.CanvasRenderer();
9173
9174/**
9175 * Draw an X/Y grid on top of the existing plot
9176 */
9177DateGraphCanvasRenderer.prototype.render = function() {
9178 // Do the ordinary rendering, as before
9179 // TODO(danvk) Call super.render()
9180 this._renderLineChart();
9181 this._renderLineAxis();
9182
9183 // Draw the new X/Y grid
9184 var ctx = this.element.getContext("2d");
9185 if (this.options.drawYGrid) {
9186 var ticks = this.layout.yticks;
9187 ctx.save();
9188 ctx.strokeStyle = this.options.gridLineColor.toRGBString();
9189 ctx.lineWidth = this.options.axisLineWidth;
9190 for (var i = 0; i < ticks.length; i++) {
9191 var x = this.area.x;
9192 var y = this.area.y + ticks[i][0] * this.area.h;
9193 ctx.beginPath();
9194 ctx.moveTo(x, y);
9195 ctx.lineTo(x + this.area.w, y);
9196 ctx.closePath();
9197 ctx.stroke();
9198 }
9199 }
9200
9201 if (this.options.drawXGrid) {
9202 var ticks = this.layout.xticks;
9203 ctx.save();
9204 ctx.strokeStyle = this.options.gridLineColor.toRGBString();
9205 ctx.lineWidth = this.options.axisLineWidth;
9206 for (var i=0; i<ticks.length; i++) {
9207 var x = this.area.x + ticks[i][0] * this.area.w;
9208 var y = this.area.y + this.area.h;
9209 ctx.beginPath();
9210 ctx.moveTo(x, y);
9211 ctx.lineTo(x, this.area.y);
9212 ctx.closePath();
9213 ctx.stroke();
9214 }
9215 }
9216};
9217
9218/**
9219 * Overrides the CanvasRenderer method to draw error bars
9220 */
9221DateGraphCanvasRenderer.prototype._renderLineChart = function() {
9222 var context = this.element.getContext("2d");
9223 var colorCount = this.options.colorScheme.length;
9224 var colorScheme = this.options.colorScheme;
9225 var setNames = MochiKit.Base.keys(this.layout.datasets);
9226 var errorBars = this.layout.options.errorBars;
9227 var setCount = setNames.length;
9228 var bind = MochiKit.Base.bind;
9229 var partial = MochiKit.Base.partial;
9230
9231 //Update Points
9232 var updatePoint = function(point) {
9233 point.canvasx = this.area.w * point.x + this.area.x;
9234 point.canvasy = this.area.h * point.y + this.area.y;
9235 }
9236 MochiKit.Iter.forEach(this.layout.points, updatePoint, this);
9237
9238 // create paths
9239 var makePath = function(ctx) {
9240 for (var i = 0; i < setCount; i++) {
9241 var setName = setNames[i];
9242 var color = colorScheme[i%colorCount];
9243 var strokeX = this.options.strokeColorTransform;
9244
9245 // setup graphics context
9246 context.save();
9247 context.strokeStyle = color.toRGBString();
9248 context.lineWidth = this.options.strokeWidth;
9249 ctx.beginPath();
9250 var point = this.layout.points[0];
9251 var first_point = true;
9252 var addPoint = function(ctx_, point) {
9253 if (point.name == setName) {
9254 if (first_point)
9255 ctx_.moveTo(point.canvasx, point.canvasy);
9256 else
9257 ctx_.lineTo(point.canvasx, point.canvasy);
9258 first_point = false;
9259 }
9260 };
9261 MochiKit.Iter.forEach(this.layout.points, partial(addPoint, ctx), this);
9262 ctx.stroke();
9263 }
9264 };
9265
9266 var makeErrorBars = function(ctx) {
9267 for (var i = 0; i < setCount; i++) {
9268 var setName = setNames[i];
9269 var color = colorScheme[i % colorCount];
9270 var strokeX = this.options.strokeColorTransform;
9271
9272 // setup graphics context
9273 context.save();
9274 context.strokeStyle = color.toRGBString();
9275 context.lineWidth = this.options.strokeWidth;
9276 var prevX = -1;
9277 var prevYs = [-1, -1];
9278 var count = 0;
9279 var yscale = this.layout.yscale;
9280 var errorTrapezoid = function(ctx_,point) {
9281 count++;
9282 if (point.name == setName) {
9283 var newYs = [ point.y - point.errorPlus * yscale,
9284 point.y + point.errorMinus * yscale ];
9285 newYs[0] = this.area.h * newYs[0] + this.area.y;
9286 newYs[1] = this.area.h * newYs[1] + this.area.y;
9287 if (prevX >= 0) {
9288 ctx_.moveTo(prevX, prevYs[0]);
9289 ctx_.lineTo(point.canvasx, newYs[0]);
9290 ctx_.lineTo(point.canvasx, newYs[1]);
9291 ctx_.lineTo(prevX, prevYs[1]);
9292 ctx_.closePath();
9293 }
9294 prevYs[0] = newYs[0];
9295 prevYs[1] = newYs[1];
9296 prevX = point.canvasx;
9297 }
9298 };
9299 // should be same color as the lines
9300 var err_color = color.colorWithAlpha(0.15);
9301 ctx.fillStyle = err_color.toRGBString();
9302 ctx.beginPath();
9303 MochiKit.Iter.forEach(this.layout.points, partial(errorTrapezoid, ctx), this);
9304 ctx.fill();
9305 }
9306 };
9307
9308 if (errorBars)
9309 bind(makeErrorBars, this)(context);
9310 bind(makePath, this)(context);
9311 context.restore();
9312};
9313// Copyright 2006 Dan Vanderkam (danvdk@gmail.com)
9314// All Rights Reserved.
9315
9316/**
9317 * @fileoverview Creates an interactive, zoomable graph based on a CSV file or
9318 * string. DateGraph can handle multiple series with or without error bars. The
9319 * date/value ranges will be automatically set. DateGraph uses the
9320 * &lt;canvas&gt; tag, so it only works in FF1.5+.
9321 * @author danvdk@gmail.com (Dan Vanderkam)
9322
9323 Usage:
9324 <div id="graphdiv" style="width:800px; height:500px;"></div>
9325 <script type="text/javascript">
9326 new DateGraph(document.getElementById("graphdiv"),
9327 "datafile.csv",
9328 ["Series 1", "Series 2"],
9329 { }); // options
9330 </script>
9331
9332 The CSV file is of the form
9333
9334 YYYYMMDD,A1,B1,C1
9335 YYYYMMDD,A2,B2,C2
9336
9337 If null is passed as the third parameter (series names), then the first line
9338 of the CSV file is assumed to contain names for each series.
9339
9340 If the 'errorBars' option is set in the constructor, the input should be of
9341 the form
9342
9343 YYYYMMDD,A1,sigmaA1,B1,sigmaB1,...
9344 YYYYMMDD,A2,sigmaA2,B2,sigmaB2,...
9345
9346 If the 'fractions' option is set, the input should be of the form:
9347
9348 YYYYMMDD,A1/B1,A2/B2,...
9349 YYYYMMDD,A1/B1,A2/B2,...
9350
9351 And error bars will be calculated automatically using a binomial distribution.
9352
9353 For further documentation and examples, see http://www/~danvk/dg/
9354
9355 */
9356
9357/**
9358 * An interactive, zoomable graph
9359 * @param {String | Function} file A file containing CSV data or a function that
9360 * returns this data. The expected format for each line is
9361 * YYYYMMDD,val1,val2,... or, if attrs.errorBars is set,
9362 * YYYYMMDD,val1,stddev1,val2,stddev2,...
9363 * @param {Array.<String>} labels Labels for the data series
9364 * @param {Object} attrs Various other attributes, e.g. errorBars determines
9365 * whether the input data contains error ranges.
9366 */
9367DateGraph = function(div, file, labels, attrs) {
9368 if (arguments.length > 0)
9369 this.__init__(div, file, labels, attrs);
9370};
9371
9372DateGraph.NAME = "DateGraph";
9373DateGraph.VERSION = "1.1";
9374DateGraph.__repr__ = function() {
9375 return "[" + this.NAME + " " + this.VERSION + "]";
9376};
9377DateGraph.toString = function() {
9378 return this.__repr__();
9379};
9380
9381// Various default values
9382DateGraph.DEFAULT_ROLL_PERIOD = 1;
9383DateGraph.DEFAULT_WIDTH = 480;
9384DateGraph.DEFAULT_HEIGHT = 320;
9385DateGraph.DEFAULT_STROKE_WIDTH = 1.0;
9386DateGraph.AXIS_LINE_WIDTH = 0.3;
9387
9388/**
9389 * Initializes the DateGraph. This creates a new DIV and constructs the PlotKit
9390 * and interaction &lt;canvas&gt; inside of it. See the constructor for details
9391 * on the parameters.
9392 * @param {String | Function} file Source data
9393 * @param {Array.<String>} labels Names of the data series
9394 * @param {Object} attrs Miscellaneous other options
9395 * @private
9396 */
9397DateGraph.prototype.__init__ = function(div, file, labels, attrs) {
9398 // Copy the important bits into the object
9399 this.maindiv_ = div;
9400 this.labels_ = labels;
9401 this.file_ = file;
9402 this.rollPeriod_ = attrs.rollPeriod || DateGraph.DEFAULT_ROLL_PERIOD;
9403 this.previousVerticalX_ = -1;
9404 this.width_ = parseInt(div.style.width, 10);
9405 this.height_ = parseInt(div.style.height, 10);
9406 this.errorBars_ = attrs.errorBars || false;
9407 this.fractions_ = attrs.fractions || false;
9408 this.strokeWidth_ = attrs.strokeWidth || DateGraph.DEFAULT_STROKE_WIDTH;
9409 this.dateWindow_ = attrs.dateWindow || null;
9410 this.valueRange_ = attrs.valueRange || null;
9411 this.labelsSeparateLines = attrs.labelsSeparateLines || false;
9412 this.labelsDiv_ = attrs.labelsDiv || null;
9413 this.labelsKMB_ = attrs.labelsKMB || false;
9414 this.minTickSize_ = attrs.minTickSize || 0;
9415 this.xValueParser_ = attrs.xValueParser || DateGraph.prototype.dateParser;
9416 this.xValueFormatter_ = attrs.xValueFormatter ||
9417 DateGraph.prototype.dateString_;
9418 this.xTicker_ = attrs.xTicker || DateGraph.prototype.dateTicker;
9419 this.sigma_ = attrs.sigma || 2.0;
9420 this.wilsonInterval_ = attrs.wilsonInterval || true;
9421 this.customBars_ = attrs.customBars || false;
9422 this.attrs_ = attrs;
9423
9424 // Make a note of whether labels will be pulled from the CSV file.
9425 this.labelsFromCSV_ = (this.labels_ == null);
9426 if (this.labels_ == null)
9427 this.labels_ = [];
9428
9429 // Prototype of the callback is "void clickCallback(event, date)"
9430 this.clickCallback_ = attrs.clickCallback || null;
9431
9432 // Prototype of zoom callback is "void dragCallback(minDate, maxDate)"
9433 this.zoomCallback_ = attrs.zoomCallback || null;
9434
9435 // Create the containing DIV and other interactive elements
9436 this.createInterface_();
9437
9438 // Create the PlotKit grapher
9439 this.layoutOptions_ = { 'errorBars': (this.errorBars_ || this.customBars_),
9440 'xOriginIsZero': false };
9441 MochiKit.Base.update(this.layoutOptions_, attrs);
9442 this.setColors_(attrs);
9443
9444 this.layout_ = new DateGraphLayout(this.layoutOptions_);
9445
9446 this.renderOptions_ = { colorScheme: this.colors_,
9447 strokeColor: null,
9448 strokeWidth: this.strokeWidth_,
9449 axisLabelFontSize: 14,
9450 axisLineWidth: DateGraph.AXIS_LINE_WIDTH };
9451 MochiKit.Base.update(this.renderOptions_, attrs);
9452 this.plotter_ = new DateGraphCanvasRenderer(this.hidden_, this.layout_,
9453 this.renderOptions_);
9454
9455 this.createStatusMessage_();
9456 this.createRollInterface_();
9457 this.createDragInterface_();
9458
9459 MochiKit.DOM.addLoadEvent(this.start_());
9460};
9461
9462/**
9463 * Returns the current rolling period, as set by the user or an option.
9464 * @return {Number} The number of days in the rolling window
9465 */
9466DateGraph.prototype.rollPeriod = function() {
9467 return this.rollPeriod_;
9468}
9469
9470/**
9471 * Generates interface elements for the DateGraph: a containing div, a div to
9472 * display the current point, and a textbox to adjust the rolling average
9473 * period.
9474 * @private
9475 */
9476DateGraph.prototype.createInterface_ = function() {
9477 // Create the all-enclosing graph div
9478 var enclosing = this.maindiv_;
9479
9480 this.graphDiv = MochiKit.DOM.DIV( { style: { 'width': this.width_ + "px",
9481 'height': this.height_ + "px"
9482 }});
9483 appendChildNodes(enclosing, this.graphDiv);
9484
9485 // Create the canvas to store
9486 var canvas = MochiKit.DOM.CANVAS;
9487 this.canvas_ = canvas( { style: { 'position': 'absolute' },
9488 width: this.width_,
9489 height: this.height_});
9490 appendChildNodes(this.graphDiv, this.canvas_);
9491
9492 this.hidden_ = this.createPlotKitCanvas_(this.canvas_);
9493 connect(this.hidden_, 'onmousemove', this, function(e) { this.mouseMove_(e) });
9494 connect(this.hidden_, 'onmouseout', this, function(e) { this.mouseOut_(e) });
9495}
9496
9497/**
9498 * Creates the canvas containing the PlotKit graph. Only plotkit ever draws on
9499 * this particular canvas. All DateGraph work is done on this.canvas_.
9500 * @param {Object} canvas The DateGraph canvas to over which to overlay the plot
9501 * @return {Object} The newly-created canvas
9502 * @private
9503 */
9504DateGraph.prototype.createPlotKitCanvas_ = function(canvas) {
9505 var h = document.createElement("canvas");
9506 h.style.position = "absolute";
9507 h.style.top = canvas.style.top;
9508 h.style.left = canvas.style.left;
9509 h.width = this.width_;
9510 h.height = this.height_;
9511 MochiKit.DOM.appendChildNodes(this.graphDiv, h);
9512 return h;
9513};
9514
9515/**
9516 * Generate a set of distinct colors for the data series. This is done with a
9517 * color wheel. Saturation/Value are customizable, and the hue is
9518 * equally-spaced around the color wheel. If a custom set of colors is
9519 * specified, that is used instead.
9520 * @param {Object} attrs Various attributes, e.g. saturation and value
9521 * @private
9522 */
9523DateGraph.prototype.setColors_ = function(attrs) {
9524 var num = this.labels_.length;
9525 this.colors_ = [];
9526 if (!attrs.colors) {
9527 var sat = attrs.colorSaturation || 1.0;
9528 var val = attrs.colorValue || 0.5;
9529 for (var i = 1; i <= num; i++) {
9530 var hue = (1.0*i/(1+num));
9531 this.colors_.push( MochiKit.Color.Color.fromHSV(hue, sat, val) );
9532 }
9533 } else {
9534 for (var i = 0; i < num; i++) {
9535 var colorStr = attrs.colors[i % attrs.colors.length];
9536 this.colors_.push( MochiKit.Color.Color.fromString(colorStr) );
9537 }
9538 }
9539}
9540
9541/**
9542 * Create the div that contains information on the selected point(s)
9543 * This goes in the top right of the canvas, unless an external div has already
9544 * been specified.
9545 * @private
9546 */
9547DateGraph.prototype.createStatusMessage_ = function(){
9548 if (!this.labelsDiv_) {
9549 var divWidth = 250;
9550 var messagestyle = { "style": {
9551 "position": "absolute",
9552 "fontSize": "14px",
9553 "zIndex": 10,
9554 "width": divWidth + "px",
9555 "top": "0px",
9556 "left": this.width_ - divWidth + "px",
9557 "background": "white",
9558 "textAlign": "left",
9559 "overflow": "hidden"}};
9560 this.labelsDiv_ = MochiKit.DOM.DIV(messagestyle);
9561 MochiKit.DOM.appendChildNodes(this.graphDiv, this.labelsDiv_);
9562 }
9563};
9564
9565/**
9566 * Create the text box to adjust the averaging period
9567 * @return {Object} The newly-created text box
9568 * @private
9569 */
9570DateGraph.prototype.createRollInterface_ = function() {
9571 var padding = this.plotter_.options.padding;
9572 var textAttr = { "type": "text",
9573 "size": "2",
9574 "value": this.rollPeriod_,
9575 "style": { "position": "absolute",
9576 "zIndex": 10,
9577 "top": (this.height_ - 25 - padding.bottom) + "px",
9578 "left": (padding.left+1) + "px" }
9579 };
9580 var roller = MochiKit.DOM.INPUT(textAttr);
9581 var pa = this.graphDiv;
9582 MochiKit.DOM.appendChildNodes(pa, roller);
9583 connect(roller, 'onchange', this,
9584 function() { this.adjustRoll(roller.value); });
9585 return roller;
9586}
9587
9588/**
9589 * Set up all the mouse handlers needed to capture dragging behavior for zoom
9590 * events. Uses MochiKit.Signal to attach all the event handlers.
9591 * @private
9592 */
9593DateGraph.prototype.createDragInterface_ = function() {
9594 var self = this;
9595
9596 // Tracks whether the mouse is down right now
9597 var mouseDown = false;
9598 var dragStartX = null;
9599 var dragStartY = null;
9600 var dragEndX = null;
9601 var dragEndY = null;
9602 var prevEndX = null;
9603
9604 // Utility function to convert page-wide coordinates to canvas coords
9605 var px = PlotKit.Base.findPosX(this.canvas_);
9606 var py = PlotKit.Base.findPosY(this.canvas_);
9607 var getX = function(e) { return e.mouse().page.x - px };
9608 var getY = function(e) { return e.mouse().page.y - py };
9609
9610 // Draw zoom rectangles when the mouse is down and the user moves around
9611 connect(this.hidden_, 'onmousemove', function(event) {
9612 if (mouseDown) {
9613 dragEndX = getX(event);
9614 dragEndY = getY(event);
9615
9616 self.drawZoomRect_(dragStartX, dragEndX, prevEndX);
9617 prevEndX = dragEndX;
9618 }
9619 });
9620
9621 // Track the beginning of drag events
9622 connect(this.hidden_, 'onmousedown', function(event) {
9623 mouseDown = true;
9624 dragStartX = getX(event);
9625 dragStartY = getY(event);
9626 });
9627
9628 // If the user releases the mouse button during a drag, but not over the
9629 // canvas, then it doesn't count as a zooming action.
9630 connect(document, 'onmouseup', this, function(event) {
9631 if (mouseDown) {
9632 mouseDown = false;
9633 dragStartX = null;
9634 dragStartY = null;
9635 }
9636 });
9637
9638 // Temporarily cancel the dragging event when the mouse leaves the graph
9639 connect(this.hidden_, 'onmouseout', this, function(event) {
9640 if (mouseDown) {
9641 dragEndX = null;
9642 dragEndY = null;
9643 }
9644 });
9645
9646 // If the mouse is released on the canvas during a drag event, then it's a
9647 // zoom. Only do the zoom if it's over a large enough area (>= 10 pixels)
9648 connect(this.hidden_, 'onmouseup', this, function(event) {
9649 if (mouseDown) {
9650 mouseDown = false;
9651 dragEndX = getX(event);
9652 dragEndY = getY(event);
9653 var regionWidth = Math.abs(dragEndX - dragStartX);
9654 var regionHeight = Math.abs(dragEndY - dragStartY);
9655
9656 if (regionWidth < 2 && regionHeight < 2 &&
9657 self.clickCallback_ != null &&
9658 self.lastx_ != undefined) {
9659 self.clickCallback_(event, new Date(self.lastx_));
9660 }
9661
9662 if (regionWidth >= 10) {
9663 self.doZoom_(Math.min(dragStartX, dragEndX),
9664 Math.max(dragStartX, dragEndX));
9665 } else {
9666 self.canvas_.getContext("2d").clearRect(0, 0,
9667 self.canvas_.width,
9668 self.canvas_.height);
9669 }
9670
9671 dragStartX = null;
9672 dragStartY = null;
9673 }
9674 });
9675
9676 // Double-clicking zooms back out
9677 connect(this.hidden_, 'ondblclick', this, function(event) {
9678 self.dateWindow_ = null;
9679 self.drawGraph_(self.rawData_);
9680 var minDate = self.rawData_[0][0];
9681 var maxDate = self.rawData_[self.rawData_.length - 1][0];
9682 self.zoomCallback_(minDate, maxDate);
9683 });
9684};
9685
9686/**
9687 * Draw a gray zoom rectangle over the desired area of the canvas. Also clears
9688 * up any previous zoom rectangles that were drawn. This could be optimized to
9689 * avoid extra redrawing, but it's tricky to avoid interactions with the status
9690 * dots.
9691 * @param {Number} startX The X position where the drag started, in canvas
9692 * coordinates.
9693 * @param {Number} endX The current X position of the drag, in canvas coords.
9694 * @param {Number} prevEndX The value of endX on the previous call to this
9695 * function. Used to avoid excess redrawing
9696 * @private
9697 */
9698DateGraph.prototype.drawZoomRect_ = function(startX, endX, prevEndX) {
9699 var ctx = this.canvas_.getContext("2d");
9700
9701 // Clean up from the previous rect if necessary
9702 if (prevEndX) {
9703 ctx.clearRect(Math.min(startX, prevEndX), 0,
9704 Math.abs(startX - prevEndX), this.height_);
9705 }
9706
9707 // Draw a light-grey rectangle to show the new viewing area
9708 if (endX && startX) {
9709 ctx.fillStyle = "rgba(128,128,128,0.33)";
9710 ctx.fillRect(Math.min(startX, endX), 0,
9711 Math.abs(endX - startX), this.height_);
9712 }
9713};
9714
9715/**
9716 * Zoom to something containing [lowX, highX]. These are pixel coordinates
9717 * in the canvas. The exact zoom window may be slightly larger if there are no
9718 * data points near lowX or highX. This function redraws the graph.
9719 * @param {Number} lowX The leftmost pixel value that should be visible.
9720 * @param {Number} highX The rightmost pixel value that should be visible.
9721 * @private
9722 */
9723DateGraph.prototype.doZoom_ = function(lowX, highX) {
9724 // Find the earliest and latest dates contained in this canvasx range.
9725 var points = this.layout_.points;
9726 var minDate = null;
9727 var maxDate = null;
9728 // Find the nearest [minDate, maxDate] that contains [lowX, highX]
9729 for (var i = 0; i < points.length; i++) {
9730 var cx = points[i].canvasx;
9731 var x = points[i].xval;
9732 if (cx < lowX && (minDate == null || x > minDate)) minDate = x;
9733 if (cx > highX && (maxDate == null || x < maxDate)) maxDate = x;
9734 }
9735 // Use the extremes if either is missing
9736 if (minDate == null) minDate = points[0].xval;
9737 if (maxDate == null) maxDate = points[points.length-1].xval;
9738
9739 this.dateWindow_ = [minDate, maxDate];
9740 this.drawGraph_(this.rawData_);
9741 this.zoomCallback_(minDate, maxDate);
9742};
9743
9744/**
9745 * When the mouse moves in the canvas, display information about a nearby data
9746 * point and draw dots over those points in the data series. This function
9747 * takes care of cleanup of previously-drawn dots.
9748 * @param {Object} event The mousemove event from the browser.
9749 * @private
9750 */
9751DateGraph.prototype.mouseMove_ = function(event) {
9752 var canvasx = event.mouse().page.x - PlotKit.Base.findPosX(this.hidden_);
9753 var points = this.layout_.points;
9754
9755 var lastx = -1;
9756 var lasty = -1;
9757
9758 // Loop through all the points and find the date nearest to our current
9759 // location.
9760 var minDist = 1e+100;
9761 var idx = -1;
9762 for (var i = 0; i < points.length; i++) {
9763 var dist = Math.abs(points[i].canvasx - canvasx);
9764 if (dist > minDist) break;
9765 minDist = dist;
9766 idx = i;
9767 }
9768 if (idx >= 0) lastx = points[idx].xval;
9769 // Check that you can really highlight the last day's data
9770 if (canvasx > points[points.length-1].canvasx)
9771 lastx = points[points.length-1].xval;
9772
9773 // Extract the points we've selected
9774 var selPoints = [];
9775 for (var i = 0; i < points.length; i++) {
9776 if (points[i].xval == lastx) {
9777 selPoints.push(points[i]);
9778 }
9779 }
9780
9781 // Clear the previously drawn vertical, if there is one
9782 var circleSize = 3;
9783 var ctx = this.canvas_.getContext("2d");
9784 if (this.previousVerticalX_ >= 0) {
9785 var px = this.previousVerticalX_;
9786 ctx.clearRect(px - circleSize - 1, 0, 2 * circleSize + 2, this.height_);
9787 }
9788
9789 if (selPoints.length > 0) {
9790 var canvasx = selPoints[0].canvasx;
9791
9792 // Set the status message to indicate the selected point(s)
9793 var replace = this.xValueFormatter_(lastx) + ":";
9794 var clen = this.colors_.length;
9795 for (var i = 0; i < selPoints.length; i++) {
9796 if (this.labelsSeparateLines) {
9797 replace += "<br/>";
9798 }
9799 var point = selPoints[i];
9800 replace += " <b><font color='" + this.colors_[i%clen].toHexString() + "'>"
9801 + point.name + "</font></b>:"
9802 + this.round_(point.yval, 2);
9803 }
9804 this.labelsDiv_.innerHTML = replace;
9805
9806 // Save last x position for callbacks.
9807 this.lastx_ = lastx;
9808
9809 // Draw colored circles over the center of each selected point
9810 ctx.save()
9811 for (var i = 0; i < selPoints.length; i++) {
9812 ctx.beginPath();
9813 ctx.fillStyle = this.colors_[i%clen].toRGBString();
9814 ctx.arc(canvasx, selPoints[i%clen].canvasy, circleSize, 0, 360, false);
9815 ctx.fill();
9816 }
9817 ctx.restore();
9818
9819 this.previousVerticalX_ = canvasx;
9820 }
9821};
9822
9823/**
9824 * The mouse has left the canvas. Clear out whatever artifacts remain
9825 * @param {Object} event the mouseout event from the browser.
9826 * @private
9827 */
9828DateGraph.prototype.mouseOut_ = function(event) {
9829 // Get rid of the overlay data
9830 var ctx = this.canvas_.getContext("2d");
9831 ctx.clearRect(0, 0, this.width_, this.height_);
9832 this.labelsDiv_.innerHTML = "";
9833};
9834
9835/**
9836 * Convert a JS date (millis since epoch) to YYYY/MM/DD
9837 * @param {Number} date The JavaScript date (ms since epoch)
9838 * @return {String} A date of the form "YYYY/MM/DD"
9839 * @private
9840 */
9841DateGraph.prototype.dateString_ = function(date) {
9842 var d = new Date(date);
9843
9844 // Get the year:
9845 var year = "" + d.getFullYear();
9846 // Get a 0 padded month string
9847 var month = "" + (d.getMonth() + 1); //months are 0-offset, sigh
9848 if (month.length < 2) month = "0" + month;
9849 // Get a 0 padded day string
9850 var day = "" + d.getDate();
9851 if (day.length < 2) day = "0" + day;
9852
9853 return year + "/" + month + "/" + day;
9854};
9855
9856/**
9857 * Round a number to the specified number of digits past the decimal point.
9858 * @param {Number} num The number to round
9859 * @param {Number} places The number of decimals to which to round
9860 * @return {Number} The rounded number
9861 * @private
9862 */
9863DateGraph.prototype.round_ = function(num, places) {
9864 var shift = Math.pow(10, places);
9865 return Math.round(num * shift)/shift;
9866};
9867
9868/**
9869 * Fires when there's data available to be graphed.
9870 * @param {String} data Raw CSV data to be plotted
9871 * @private
9872 */
9873DateGraph.prototype.loadedEvent_ = function(data) {
9874 this.rawData_ = this.parseCSV_(data);
9875 this.drawGraph_(this.rawData_);
9876};
9877
9878DateGraph.prototype.months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
9879 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
9880DateGraph.prototype.quarters = ["Jan", "Apr", "Jul", "Oct"];
9881
9882/**
9883 * Add ticks on the x-axis representing years, months, quarters, weeks, or days
9884 * @private
9885 */
9886DateGraph.prototype.addXTicks_ = function() {
9887 // Determine the correct ticks scale on the x-axis: quarterly, monthly, ...
9888 var startDate, endDate;
9889 if (this.dateWindow_) {
9890 startDate = this.dateWindow_[0];
9891 endDate = this.dateWindow_[1];
9892 } else {
9893 startDate = this.rawData_[0][0];
9894 endDate = this.rawData_[this.rawData_.length - 1][0];
9895 }
9896
9897 var xTicks = this.xTicker_(startDate, endDate);
9898 this.layout_.updateOptions({xTicks: xTicks});
9899}
9900
9901/**
9902 * Add ticks to the x-axis based on a date range.
9903 * @param {Number} startDate Start of the date window (millis since epoch)
9904 * @param {Number} endDate End of the date window (millis since epoch)
9905 * @return {Array.<Object>} Array of {label, value} tuples.
9906 * @public
9907 */
9908DateGraph.prototype.dateTicker = function(startDate, endDate) {
9909 var ONE_DAY = 24*60*60*1000;
9910 startDate = startDate / ONE_DAY;
9911 endDate = endDate / ONE_DAY;
9912 var dateSpan = endDate - startDate;
9913
9914 var scale = [];
9915 var isMonthly = false;
9916 var yearMod = 1;
9917 if (dateSpan > 30 * 366) { // decadal
9918 isMonthly = true;
9919 scale = ["Jan"];
9920 yearMod = 10;
9921 } else if (dateSpan > 4*366) { // annual
9922 scale = ["Jan"];
9923 isMonthly = true;
9924 } else if (dateSpan > 366) { // quarterly
9925 scale = this.quarters;
9926 isMonthly = true;
9927 } else if (dateSpan > 40) { // monthly
9928 scale = this.months;
9929 isMonthly = true;
9930 } else if (dateSpan > 10) { // weekly
9931 for (var week = startDate - 14; week < endDate + 14; week += 7) {
9932 scale.push(week * ONE_DAY);
9933 }
9934 } else { // daily
9935 for (var day = startDate - 14; day < endDate + 14; day += 1) {
9936 scale.push(day * ONE_DAY);
9937 }
9938 }
9939
9940 var xTicks = [];
9941
9942 if (isMonthly) {
9943 var startYear = 1900 + (new Date(startDate* ONE_DAY)).getYear();
9944 var endYear = 1900 + (new Date(endDate * ONE_DAY)).getYear();
9945 for (var i = startYear; i <= endYear; i++) {
9946 if (i % yearMod != 0) continue;
9947 for (var j = 0; j < scale.length; j++ ) {
9948 var date = Date.parse(scale[j] + " 1, " + i);
9949 xTicks.push( {label: scale[j] + "'" + ("" + i).substr(2,2), v: date } );
9950 }
9951 }
9952 } else {
9953 for (var i = 0; i < scale.length; i++) {
9954 var date = new Date(scale[i]);
9955 var year = date.getFullYear().toString();
9956 var label = this.months[date.getMonth()] + date.getDate();
9957 label += "'" + year.substr(year.length - 2, 2);
9958 xTicks.push( {label: label, v: date} );
9959 }
9960 }
9961 return xTicks;
9962};
9963
9964/**
9965 * Add ticks when the x axis has numbers on it (instead of dates)
9966 * @param {Number} startDate Start of the date window (millis since epoch)
9967 * @param {Number} endDate End of the date window (millis since epoch)
9968 * @return {Array.<Object>} Array of {label, value} tuples.
9969 * @public
9970 */
9971DateGraph.prototype.numericTicks = function(minV, maxV) {
9972 var scale;
9973 if (maxV <= 0.0) {
9974 scale = 1.0;
9975 } else {
9976 scale = Math.pow( 10, Math.floor(Math.log(maxV)/Math.log(10.0)) );
9977 }
9978
9979 // Add a smallish number of ticks at human-friendly points
9980 var nTicks = (maxV - minV) / scale;
9981 while (2 * nTicks < 20) {
9982 nTicks *= 2;
9983 }
9984 if ((maxV - minV) / nTicks < this.minTickSize_) {
9985 nTicks = this.round_((maxV - minV) / this.minTickSize_, 1);
9986 }
9987
9988 // Construct labels for the ticks
9989 var ticks = [];
9990 for (var i = 0; i <= nTicks; i++) {
9991 var tickV = minV + i * (maxV - minV) / nTicks;
9992 var label = this.round_(tickV, 2);
9993 if (this.labelsKMB_) {
9994 var k = 1000;
9995 if (tickV >= k*k*k) {
9996 label = this.round_(tickV/(k*k*k), 1) + "B";
9997 } else if (tickV >= k*k) {
9998 label = this.round_(tickV/(k*k), 1) + "M";
9999 } else if (tickV >= k) {
10000 label = this.round_(tickV/k, 1) + "K";
10001 }
10002 }
10003 ticks.push( {label: label, v: tickV} );
10004 }
10005 return ticks;
10006};
10007
10008/**
10009 * Adds appropriate ticks on the y-axis
10010 * @param {Number} minY The minimum Y value in the data set
10011 * @param {Number} maxY The maximum Y value in the data set
10012 * @private
10013 */
10014DateGraph.prototype.addYTicks_ = function(minY, maxY) {
10015 // Set the number of ticks so that the labels are human-friendly.
10016 var ticks = this.numericTicks(minY, maxY);
10017 this.layout_.updateOptions( { yAxis: [minY, maxY],
10018 yTicks: ticks } );
10019};
10020
10021/**
10022 * Update the graph with new data. Data is in the format
10023 * [ [date1, val1, val2, ...], [date2, val1, val2, ...] if errorBars=false
10024 * or, if errorBars=true,
10025 * [ [date1, [val1,stddev1], [val2,stddev2], ...], [date2, ...], ...]
10026 * @param {Array.<Object>} data The data (see above)
10027 * @private
10028 */
10029DateGraph.prototype.drawGraph_ = function(data) {
10030 var maxY = null;
10031 this.layout_.removeAllDatasets();
10032 // Loop over all fields in the dataset
10033 for (var i = 1; i < data[0].length; i++) {
10034 var series = [];
10035 for (var j = 0; j < data.length; j++) {
10036 var date = data[j][0];
10037 series[j] = [date, data[j][i]];
10038 }
10039 series = this.rollingAverage(series, this.rollPeriod_);
10040
10041 // Prune down to the desired range, if necessary (for zooming)
10042 var bars = this.errorBars_ || this.customBars_;
10043 if (this.dateWindow_) {
10044 var low = this.dateWindow_[0];
10045 var high= this.dateWindow_[1];
10046 var pruned = [];
10047 for (var k = 0; k < series.length; k++) {
10048 if (series[k][0] >= low && series[k][0] <= high) {
10049 pruned.push(series[k]);
10050 var y = bars ? series[k][1][0] : series[k][1];
10051 if (maxY == null || y > maxY) maxY = y;
10052 }
10053 }
10054 series = pruned;
10055 } else {
10056 for (var j = 0; j < series.length; j++) {
10057 var y = bars ? series[j][1][0] : series[j][1];
10058 if (maxY == null || y > maxY) {
10059 maxY = bars ? y + series[j][1][1] : y;
10060 }
10061 }
10062 }
10063
10064 if (bars) {
10065 var vals = [];
10066 for (var j=0; j<series.length; j++)
10067 vals[j] = [series[j][0],
10068 series[j][1][0], series[j][1][1], series[j][1][2]];
10069 this.layout_.addDataset(this.labels_[i - 1], vals);
10070 } else {
10071 this.layout_.addDataset(this.labels_[i - 1], series);
10072 }
10073 }
10074
10075 // Use some heuristics to come up with a good maxY value, unless it's been
10076 // set explicitly by the user.
10077 if (this.valueRange_ != null) {
10078 this.addYTicks_(this.valueRange_[0], this.valueRange_[1]);
10079 } else {
10080 // Add some padding and round up to an integer to be human-friendly.
10081 maxY *= 1.1;
10082 if (maxY <= 0.0) maxY = 1.0;
10083 else {
10084 var scale = Math.pow(10, Math.floor(Math.log(maxY) / Math.log(10.0)));
10085 maxY = scale * Math.ceil(maxY / scale);
10086 }
10087 this.addYTicks_(0, maxY);
10088 }
10089
10090 this.addXTicks_();
10091
10092 // Tell PlotKit to use this new data and render itself
10093 this.layout_.evaluateWithError();
10094 this.plotter_.clear();
10095 this.plotter_.render();
10096 this.canvas_.getContext('2d').clearRect(0, 0,
10097 this.canvas_.width, this.canvas_.height);
10098};
10099
10100/**
10101 * Calculates the rolling average of a data set.
10102 * If originalData is [label, val], rolls the average of those.
10103 * If originalData is [label, [, it's interpreted as [value, stddev]
10104 * and the roll is returned in the same form, with appropriately reduced
10105 * stddev for each value.
10106 * Note that this is where fractional input (i.e. '5/10') is converted into
10107 * decimal values.
10108 * @param {Array} originalData The data in the appropriate format (see above)
10109 * @param {Number} rollPeriod The number of days over which to average the data
10110 */
10111DateGraph.prototype.rollingAverage = function(originalData, rollPeriod) {
10112 if (originalData.length < 2)
10113 return originalData;
10114 var rollPeriod = Math.min(rollPeriod, originalData.length - 1);
10115 var rollingData = [];
10116 var sigma = this.sigma_;
10117
10118 if (this.fractions_) {
10119 var num = 0;
10120 var den = 0; // numerator/denominator
10121 var mult = 100.0;
10122 for (var i = 0; i < originalData.length; i++) {
10123 num += originalData[i][1][0];
10124 den += originalData[i][1][1];
10125 if (i - rollPeriod >= 0) {
10126 num -= originalData[i - rollPeriod][1][0];
10127 den -= originalData[i - rollPeriod][1][1];
10128 }
10129
10130 var date = originalData[i][0];
10131 var value = den ? num / den : 0.0;
10132 if (this.errorBars_) {
10133 if (this.wilsonInterval_) {
10134 // For more details on this confidence interval, see:
10135 // http://en.wikipedia.org/wiki/Binomial_confidence_interval
10136 if (den) {
10137 var p = value < 0 ? 0 : value, n = den;
10138 var pm = sigma * Math.sqrt(p*(1-p)/n + sigma*sigma/(4*n*n));
10139 var denom = 1 + sigma * sigma / den;
10140 var low = (p + sigma * sigma / (2 * den) - pm) / denom;
10141 var high = (p + sigma * sigma / (2 * den) + pm) / denom;
10142 rollingData[i] = [date,
10143 [p * mult, (p - low) * mult, (high - p) * mult]];
10144 } else {
10145 rollingData[i] = [date, [0, 0, 0]];
10146 }
10147 } else {
10148 var stddev = den ? sigma * Math.sqrt(value * (1 - value) / den) : 1.0;
10149 rollingData[i] = [date, [mult * value, mult * stddev, mult * stddev]];
10150 }
10151 } else {
10152 rollingData[i] = [date, mult * value];
10153 }
10154 }
10155 } else if (this.customBars_) {
10156 // just ignore the rolling for now.
10157 // TODO(danvk): do something reasonable.
10158 for (var i = 0; i < originalData.length; i++) {
10159 var data = originalData[i][1];
10160 var y = data[1];
10161 rollingData[i] = [originalData[i][0], [y, y - data[0], data[2] - y]];
10162 }
10163 } else {
10164 // Calculate the rolling average for the first rollPeriod - 1 points where
10165 // there is not enough data to roll over the full number of days
10166 var num_init_points = Math.min(rollPeriod - 1, originalData.length - 2);
10167 if (!this.errorBars_){
10168 for (var i = 0; i < num_init_points; i++) {
10169 var sum = 0;
10170 for (var j = 0; j < i + 1; j++)
10171 sum += originalData[j][1];
10172 rollingData[i] = [originalData[i][0], sum / (i + 1)];
10173 }
10174 // Calculate the rolling average for the remaining points
10175 for (var i = Math.min(rollPeriod - 1, originalData.length - 2);
10176 i < originalData.length;
10177 i++) {
10178 var sum = 0;
10179 for (var j = i - rollPeriod + 1; j < i + 1; j++)
10180 sum += originalData[j][1];
10181 rollingData[i] = [originalData[i][0], sum / rollPeriod];
10182 }
10183 } else {
10184 for (var i = 0; i < num_init_points; i++) {
10185 var sum = 0;
10186 var variance = 0;
10187 for (var j = 0; j < i + 1; j++) {
10188 sum += originalData[j][1][0];
10189 variance += Math.pow(originalData[j][1][1], 2);
10190 }
10191 var stddev = Math.sqrt(variance)/(i+1);
10192 rollingData[i] = [originalData[i][0],
10193 [sum/(i+1), sigma * stddev, sigma * stddev]];
10194 }
10195 // Calculate the rolling average for the remaining points
10196 for (var i = Math.min(rollPeriod - 1, originalData.length - 2);
10197 i < originalData.length;
10198 i++) {
10199 var sum = 0;
10200 var variance = 0;
10201 for (var j = i - rollPeriod + 1; j < i + 1; j++) {
10202 sum += originalData[j][1][0];
10203 variance += Math.pow(originalData[j][1][1], 2);
10204 }
10205 var stddev = Math.sqrt(variance) / rollPeriod;
10206 rollingData[i] = [originalData[i][0],
10207 [sum / rollPeriod, sigma * stddev, sigma * stddev]];
10208 }
10209 }
10210 }
10211
10212 return rollingData;
10213};
10214
10215/**
10216 * Parses a date, returning the number of milliseconds since epoch. This can be
10217 * passed in as an xValueParser in the DateGraph constructor.
10218 * @param {String} A date in YYYYMMDD format.
10219 * @return {Number} Milliseconds since epoch.
10220 * @public
10221 */
10222DateGraph.prototype.dateParser = function(dateStr) {
10223 var dateStrSlashed;
10224 if (dateStr.search("-") != -1) {
10225 dateStrSlashed = dateStr.replace("-", "/", "g");
10226 } else if (dateStr.search("/") != -1) {
10227 return Date.parse(dateStr);
10228 } else {
10229 dateStrSlashed = dateStr.substr(0,4) + "/" + dateStr.substr(4,2)
10230 + "/" + dateStr.substr(6,2);
10231 }
10232 return Date.parse(dateStrSlashed);
10233};
10234
10235/**
10236 * Parses a string in a special csv format. We expect a csv file where each
10237 * line is a date point, and the first field in each line is the date string.
10238 * We also expect that all remaining fields represent series.
10239 * if this.errorBars_ is set, then interpret the fields as:
10240 * date, series1, stddev1, series2, stddev2, ...
10241 * @param {Array.<Object>} data See above.
10242 * @private
10243 */
10244DateGraph.prototype.parseCSV_ = function(data) {
10245 var ret = [];
10246 var lines = data.split("\n");
10247 var start = this.labelsFromCSV_ ? 1 : 0;
10248 if (this.labelsFromCSV_) {
10249 var labels = lines[0].split(",");
10250 labels.shift(); // a "date" parameter is assumed.
10251 this.labels_ = labels;
10252 // regenerate automatic colors.
10253 this.setColors_(this.attrs_);
10254 this.renderOptions_.colorScheme = this.colors_;
10255 MochiKit.Base.update(this.plotter_.options, this.renderOptions_);
10256 MochiKit.Base.update(this.layoutOptions_, this.attrs_);
10257 }
10258
10259 for (var i = start; i < lines.length; i++) {
10260 var line = lines[i];
10261 if (line.length == 0) continue; // skip blank lines
10262 var inFields = line.split(',');
10263 if (inFields.length < 2)
10264 continue;
10265
10266 var fields = [];
10267 fields[0] = this.xValueParser_(inFields[0]);
10268
10269 // If fractions are expected, parse the numbers as "A/B"
10270 if (this.fractions_) {
10271 for (var j = 1; j < inFields.length; j++) {
10272 // TODO(danvk): figure out an appropriate way to flag parse errors.
10273 var vals = inFields[j].split("/");
10274 fields[j] = [parseFloat(vals[0]), parseFloat(vals[1])];
10275 }
10276 } else if (this.errorBars_) {
10277 // If there are error bars, values are (value, stddev) pairs
10278 for (var j = 1; j < inFields.length; j += 2)
10279 fields[(j + 1) / 2] = [parseFloat(inFields[j]),
10280 parseFloat(inFields[j + 1])];
10281 } else if (this.customBars_) {
10282 // Bars are a low;center;high tuple
10283 for (var j = 1; j < inFields.length; j++) {
10284 var vals = inFields[j].split(";");
10285 fields[j] = [ parseFloat(vals[0]),
10286 parseFloat(vals[1]),
10287 parseFloat(vals[2]) ];
10288 }
10289 } else {
10290 // Values are just numbers
10291 for (var j = 1; j < inFields.length; j++)
10292 fields[j] = parseFloat(inFields[j]);
10293 }
10294 ret.push(fields);
10295 }
10296 return ret;
10297};
10298
10299/**
10300 * Get the CSV data. If it's in a function, call that function. If it's in a
10301 * file, do an XMLHttpRequest to get it.
10302 * @private
10303 */
10304DateGraph.prototype.start_ = function() {
10305 if (typeof this.file_ == 'function') {
10306 // Stubbed out to allow this to run off a filesystem
10307 this.loadedEvent_(this.file_());
10308 } else {
10309 var req = new XMLHttpRequest();
10310 var caller = this;
10311 req.onreadystatechange = function () {
10312 if (req.readyState == 4) {
10313 if (req.status == 200) {
10314 caller.loadedEvent_(req.responseText);
10315 }
10316 }
10317 };
10318
10319 req.open("GET", this.file_, true);
10320 req.send(null);
10321 }
10322};
10323
10324/**
10325 * Changes various properties of the graph. These can include:
10326 * <ul>
10327 * <li>file: changes the source data for the graph</li>
10328 * <li>errorBars: changes whether the data contains stddev</li>
10329 * </ul>
10330 * @param {Object} attrs The new properties and values
10331 */
10332DateGraph.prototype.updateOptions = function(attrs) {
10333 if (attrs.errorBars) {
10334 this.errorBars_ = attrs.errorBars;
10335 }
10336 if (attrs.customBars) {
10337 this.customBars_ = attrs.customBars;
10338 }
10339 if (attrs.strokeWidth) {
10340 this.strokeWidth_ = attrs.strokeWidth;
10341 }
10342 if (attrs.rollPeriod) {
10343 this.rollPeriod_ = attrs.rollPeriod;
10344 }
10345 if (attrs.dateWindow) {
10346 this.dateWindow_ = attrs.dateWindow;
10347 }
10348 if (attrs.valueRange) {
10349 this.valueRange_ = attrs.valueRange;
10350 }
10351 if (attrs.minTickSize) {
10352 this.minTickSize_ = attrs.minTickSize;
10353 }
10354 if (typeof(attrs.labels) != 'undefined') {
10355 this.labels_ = attrs.labels;
10356 this.labelsFromCSV_ = (attrs.labels == null);
10357 }
10358 this.layout_.updateOptions({ 'errorBars': this.errorBars_ });
10359 if (attrs['file'] && attrs['file'] != this.file_) {
10360 this.file_ = attrs['file'];
10361 this.start_();
10362 } else {
10363 this.drawGraph_(this.rawData_);
10364 }
10365};
10366
10367/**
10368 * Adjusts the number of days in the rolling average. Updates the graph to
10369 * reflect the new averaging period.
10370 * @param {Number} length Number of days over which to average the data.
10371 */
10372DateGraph.prototype.adjustRoll = function(length) {
10373 this.rollPeriod_ = length;
10374 this.drawGraph_(this.rawData_);
10375};