


function bindTo(fn,obj) {
  var args = [];
  for (var n = 2; n < arguments.length; n++)
    args.push(arguments[n]);
  return function () { return fn.apply(obj, args); };
}
var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}
function rmClass(elm, c) {
  elm.className = elm.className.replace(c,'');
}
function addClass(elm,c) {
  elm.className = elm.className += ' '+ c;
}
function hasClassName( elm, className ) {
  if ( !elm || !className )
    return false ;
  return elm.className.match( className ) ? true : false;
}
function exists(s) {
  return ( s && s != 'undefined' ) || false;
}
function getElementsByClassName( className, parent ) {
  try {
    var children = (parent || document.body).getElementsByTagName('*');
    var elements = [], child;
    for (var i = 0, length = children.length; i < length; i++) {
      child = children[i];
      if ( hasClassName(child, className) )
        elements.push(child);
    }
    return elements;
  } catch (e) {}
}
function setHeight(elm,h) {
  if ( !h || h == 0 ) {
    elm.style.display = 'none';
  } else {
    elm.style.height = h +'px';
  }
}
function getHeight(elm) {
  if ( !elm || !elm.className )
    return false ;
  return getDimensions(elm).height;
}
function getDimensions(elm) {
  try {
    var display = getStyle(elm, 'display');
    if (display != 'none' && display != null) 
      return {width: elm.offsetWidth, height: elm.offsetHeight};
    
    
    var els = elm.style;
    var originalVisibility = els.visibility;
    var originalPosition = els.position;
    var originalDisplay = els.display;
    els.visibility = 'hidden';
    els.position = 'absolute';
    els.display = 'block';
    var originalWidth = elm.clientWidth;
    var originalHeight = elm.clientHeight;
    els.display = originalDisplay;
    els.position = originalPosition;
    els.visibility = originalVisibility;
    return {width: originalWidth, height: originalHeight};
  } catch(e) {}
}
function getStyle(elm, style) {
  try {
    style = camelize(style);
    var value = elm.style[style];
    if (!value) {
      if (document.defaultView && document.defaultView.getComputedStyle) {
        var css = document.defaultView.getComputedStyle(elm, null);
        value = css ? css[style] : null;
      } else if (elm.currentStyle) {
        value = elm.currentStyle[style];
      }
    }
    return value;
  } catch (e) {}
}
function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.substring(1).toLowerCase();
}
function camelize(str) {
  var parts = str.split('-'), len = parts.length;
  if (len == 1) return parts[0];
  var camelized = this.charAt(0) == '-'
    ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
      : parts[0];
  for (var i = 1; i < len; i++)
    camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
  return camelized;
}
/***
    MochiKit.MochiKit 1.4 : PACKED VERSION
    THIS FILE IS AUTOMATICALLY GENERATED.  If creating patches, please
    diff against the source tree, not this file.
    See <http://mochikit.com/> for documentation, downloads, license, etc.
    (c) 2005 Bob Ippolito.  All rights Reserved.
***/
if(typeof (dojo)!="undefined"){
dojo.provide("MochiKit.Base");
}
if(typeof (MochiKit)=="undefined"){
MochiKit={};
}
if(typeof (MochiKit.Base)=="undefined"){
MochiKit.Base={};
}
if(typeof (MochiKit.__export__)=="undefined"){
MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined"));
}
MochiKit.Base.VERSION="1.4";
MochiKit.Base.NAME="MochiKit.Base";
MochiKit.Base.update=function(_1,_2){
if(_1===null||_1===undefined){
_1={};
}
for(var i=1;i<arguments.length;i++){
var o=arguments[i];
if(typeof (o)!="undefined"&&o!==null){
for(var k in o){
_1[k]=o[k];
}
}
}
return _1;
};
MochiKit.Base.update(MochiKit.Base,{__repr__:function(){
return "["+this.NAME+" "+this.VERSION+"]";
},toString:function(){
return this.__repr__();
},camelize:function(_6){
var _7=_6.split("-");
var cc=_7[0];
for(var i=1;i<_7.length;i++){
cc+=_7[i].charAt(0).toUpperCase()+_7[i].substring(1);
}
return cc;
},counter:function(n){
if(arguments.length===0){
n=1;
}
return function(){
return n++;
};
},clone:function(_b){
var me=arguments.callee;
if(arguments.length==1){
me.prototype=_b;
return new me();
}
},_deps:function(_d,_e){
if(!(_d in MochiKit)){
MochiKit[_d]={};
}
if(typeof (dojo)!="undefined"){
dojo.provide("MochiKit."+_d);
}
for(var i=0;i<_e.length;i++){
if(typeof (dojo)!="undefined"){
dojo.require("MochiKit."+_e[i]);
}
if(typeof (JSAN)!="undefined"){
JSAN.use("MochiKit."+_e[i],[]);
}
if(!(_e[i] in MochiKit)){
throw "MochiKit."+_d+" depends on MochiKit."+_e[i]+"!";
}
}
},_flattenArray:function(res,lst){
for(var i=0;i<lst.length;i++){
var o=lst[i];
if(o instanceof Array){
arguments.callee(res,o);
}else{
res.push(o);
}
}
return res;
},flattenArray:function(lst){
return MochiKit.Base._flattenArray([],lst);
},flattenArguments:function(lst){
var res=[];
var m=MochiKit.Base;
var _18=m.extend(null,arguments);
while(_18.length){
var o=_18.shift();
if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
for(var i=o.length-1;i>=0;i--){
_18.unshift(o[i]);
}
}else{
res.push(o);
}
}
return res;
},extend:function(_1b,obj,_1d){
if(!_1d){
_1d=0;
}
if(obj){
var l=obj.length;
if(typeof (l)!="number"){
if(typeof (MochiKit.Iter)!="undefined"){
obj=MochiKit.Iter.list(obj);
l=obj.length;
}else{
throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
}
}
if(!_1b){
_1b=[];
}
for(var i=_1d;i<l;i++){
_1b.push(obj[i]);
}
}
return _1b;
},updatetree:function(_20,obj){
if(_20===null||_20===undefined){
_20={};
}
for(var i=1;i<arguments.length;i++){
var o=arguments[i];
if(typeof (o)!="undefined"&&o!==null){
for(var k in o){
var v=o[k];
if(typeof (_20[k])=="object"&&typeof (v)=="object"){
arguments.callee(_20[k],v);
}else{
_20[k]=v;
}
}
}
}
return _20;
},setdefault:function(_26,obj){
if(_26===null||_26===undefined){
_26={};
}
for(var i=1;i<arguments.length;i++){
var o=arguments[i];
for(var k in o){
if(!(k in _26)){
_26[k]=o[k];
}
}
}
return _26;
},keys:function(obj){
var _2c=[];
for(var _2d in obj){
_2c.push(_2d);
}
return _2c;
},values:function(obj){
var _2f=[];
for(var _30 in obj){
_2f.push(obj[_30]);
}
return _2f;
},items:function(obj){
var _32=[];
var e;
for(var _34 in obj){
var v;
try{
v=obj[_34];
}
catch(e){
continue;
}
_32.push([_34,v]);
}
return _32;
},_newNamedError:function(_36,_37,_38){
_38.prototype=new MochiKit.Base.NamedError(_36.NAME+"."+_37);
_36[_37]=_38;
},operator:{truth:function(a){
return !!a;
},lognot:function(a){
return !a;
},identity:function(a){
return a;
},not:function(a){
return ~a;
},neg:function(a){
return -a;
},add:function(a,b){
return a+b;
},sub:function(a,b){
return a-b;
},div:function(a,b){
return a/b;
},mod:function(a,b){
return a%b;
},mul:function(a,b){
return a*b;
},and:function(a,b){
return a&b;
},or:function(a,b){
return a|b;
},xor:function(a,b){
return a^b;
},lshift:function(a,b){
return a<<b;
},rshift:function(a,b){
return a>>b;
},zrshift:function(a,b){
return a>>>b;
},eq:function(a,b){
return a==b;
},ne:function(a,b){
return a!=b;
},gt:function(a,b){
return a>b;
},ge:function(a,b){
return a>=b;
},lt:function(a,b){
return a<b;
},le:function(a,b){
return a<=b;
},seq:function(a,b){
return a===b;
},sne:function(a,b){
return a!==b;
},ceq:function(a,b){
return MochiKit.Base.compare(a,b)===0;
},cne:function(a,b){
return MochiKit.Base.compare(a,b)!==0;
},cgt:function(a,b){
return MochiKit.Base.compare(a,b)==1;
},cge:function(a,b){
return MochiKit.Base.compare(a,b)!=-1;
},clt:function(a,b){
return MochiKit.Base.compare(a,b)==-1;
},cle:function(a,b){
return MochiKit.Base.compare(a,b)!=1;
},logand:function(a,b){
return a&&b;
},logor:function(a,b){
return a||b;
},contains:function(a,b){
return b in a;
}},forwardCall:function(_76){
return function(){
return this[_76].apply(this,arguments);
};
},itemgetter:function(_77){
return function(arg){
return arg[_77];
};
},typeMatcher:function(){
var _79={};
for(var i=0;i<arguments.length;i++){
var typ=arguments[i];
_79[typ]=typ;
}
return function(){
for(var i=0;i<arguments.length;i++){
if(!(typeof (arguments[i]) in _79)){
return false;
}
}
return true;
};
},isNull:function(){
for(var i=0;i<arguments.length;i++){
if(arguments[i]!==null){
return false;
}
}
return true;
},isUndefinedOrNull:function(){
for(var i=0;i<arguments.length;i++){
var o=arguments[i];
if(!(typeof (o)=="undefined"||o===null)){
return false;
}
}
return true;
},isEmpty:function(obj){
return !MochiKit.Base.isNotEmpty.apply(this,arguments);
},isNotEmpty:function(obj){
for(var i=0;i<arguments.length;i++){
var o=arguments[i];
if(!(o&&o.length)){
return false;
}
}
return true;
},isArrayLike:function(){
for(var i=0;i<arguments.length;i++){
var o=arguments[i];
var typ=typeof (o);
if((typ!="object"&&!(typ=="function"&&typeof (o.item)=="function"))||o===null||typeof (o.length)!="number"||o.nodeType===3||o.nodeType===4){
return false;
}
}
return true;
},isDateLike:function(){
for(var i=0;i<arguments.length;i++){
var o=arguments[i];
if(typeof (o)!="object"||o===null||typeof (o.getTime)!="function"){
return false;
}
}
return true;
},xmap:function(fn){
if(fn===null){
return MochiKit.Base.extend(null,arguments,1);
}
var _8a=[];
for(var i=1;i<arguments.length;i++){
_8a.push(fn(arguments[i]));
}
return _8a;
},map:function(fn,lst){
var m=MochiKit.Base;
var itr=MochiKit.Iter;
var _90=m.isArrayLike;
if(arguments.length<=2){
if(!_90(lst)){
if(itr){
lst=itr.list(lst);
if(fn===null){
return lst;
}
}else{
throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
}
}
if(fn===null){
return m.extend(null,lst);
}
var _91=[];
for(var i=0;i<lst.length;i++){
_91.push(fn(lst[i]));
}
return _91;
}else{
if(fn===null){
fn=Array;
}
var _93=null;
for(i=1;i<arguments.length;i++){
if(!_90(arguments[i])){
if(itr){
return itr.list(itr.imap.apply(null,arguments));
}else{
throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
}
}
var l=arguments[i].length;
if(_93===null||_93>l){
_93=l;
}
}
_91=[];
for(i=0;i<_93;i++){
var _95=[];
for(var j=1;j<arguments.length;j++){
_95.push(arguments[j][i]);
}
_91.push(fn.apply(this,_95));
}
return _91;
}
},xfilter:function(fn){
var _98=[];
if(fn===null){
fn=MochiKit.Base.operator.truth;
}
for(var i=1;i<arguments.length;i++){
var o=arguments[i];
if(fn(o)){
_98.push(o);
}
}
return _98;
},filter:function(fn,lst,_9d){
var _9e=[];
var m=MochiKit.Base;
if(!m.isArrayLike(lst)){
if(MochiKit.Iter){
lst=MochiKit.Iter.list(lst);
}else{
throw new TypeError("Argument not an array-like and MochiKit.Iter not present");
}
}
if(fn===null){
fn=m.operator.truth;
}
if(typeof (Array.prototype.filter)=="function"){
return Array.prototype.filter.call(lst,fn,_9d);
}else{
if(typeof (_9d)=="undefined"||_9d===null){
for(var i=0;i<lst.length;i++){
var o=lst[i];
if(fn(o)){
_9e.push(o);
}
}
}else{
for(i=0;i<lst.length;i++){
o=lst[i];
if(fn.call(_9d,o)){
_9e.push(o);
}
}
}
}
return _9e;
},_wrapDumbFunction:function(_a2){
return function(){
switch(arguments.length){
case 0:
return _a2();
case 1:
return _a2(arguments[0]);
case 2:
return _a2(arguments[0],arguments[1]);
case 3:
return _a2(arguments[0],arguments[1],arguments[2]);
}
var _a3=[];
for(var i=0;i<arguments.length;i++){
_a3.push("arguments["+i+"]");
}
return eval("(func("+_a3.join(",")+"))");
};
},methodcaller:function(_a5){
var _a6=MochiKit.Base.extend(null,arguments,1);
if(typeof (_a5)=="function"){
return function(obj){
return _a5.apply(obj,_a6);
};
}else{
return function(obj){
return obj[_a5].apply(obj,_a6);
};
}
},method:function(_a9,_aa){
var m=MochiKit.Base;
return m.bind.apply(this,m.extend([_aa,_a9],arguments,2));
},compose:function(f1,f2){
var _ae=[];
var m=MochiKit.Base;
if(arguments.length===0){
throw new TypeError("compose() requires at least one argument");
}
for(var i=0;i<arguments.length;i++){
var fn=arguments[i];
if(typeof (fn)!="function"){
throw new TypeError(m.repr(fn)+" is not a function");
}
_ae.push(fn);
}
return function(){
var _b2=arguments;
for(var i=_ae.length-1;i>=0;i--){
_b2=[_ae[i].apply(this,_b2)];
}
return _b2[0];
};
},bind:function(_b4,_b5){
if(typeof (_b4)=="string"){
_b4=_b5[_b4];
}
var _b6=_b4.im_func;
var _b7=_b4.im_preargs;
var _b8=_b4.im_self;
var m=MochiKit.Base;
if(typeof (_b4)=="function"&&typeof (_b4.apply)=="undefined"){
_b4=m._wrapDumbFunction(_b4);
}
if(typeof (_b6)!="function"){
_b6=_b4;
}
if(typeof (_b5)!="undefined"){
_b8=_b5;
}
if(typeof (_b7)=="undefined"){
_b7=[];
}else{
_b7=_b7.slice();
}
m.extend(_b7,arguments,2);
var _ba=function(){
var _bb=arguments;
var me=arguments.callee;
if(me.im_preargs.length>0){
_bb=m.concat(me.im_preargs,_bb);
}
var _bd=me.im_self;
if(!_bd){
_bd=this;
}
return me.im_func.apply(_bd,_bb);
};
_ba.im_self=_b8;
_ba.im_func=_b6;
_ba.im_preargs=_b7;
return _ba;
},bindMethods:function(_be){
var _bf=MochiKit.Base.bind;
for(var k in _be){
var _c1=_be[k];
if(typeof (_c1)=="function"){
_be[k]=_bf(_c1,_be);
}
}
},registerComparator:function(_c2,_c3,_c4,_c5){
MochiKit.Base.comparatorRegistry.register(_c2,_c3,_c4,_c5);
},_primitives:{"boolean":true,"string":true,"number":true},compare:function(a,b){
if(a==b){
return 0;
}
var _c8=(typeof (a)=="undefined"||a===null);
var _c9=(typeof (b)=="undefined"||b===null);
if(_c8&&_c9){
return 0;
}else{
if(_c8){
return -1;
}else{
if(_c9){
return 1;
}
}
}
var m=MochiKit.Base;
var _cb=m._primitives;
if(!(typeof (a) in _cb&&typeof (b) in _cb)){
try{
return m.comparatorRegistry.match(a,b);
}
catch(e){
if(e!=m.NotFound){
throw e;
}
}
}
if(a<b){
return -1;
}else{
if(a>b){
return 1;
}
}
var _cc=m.repr;
throw new TypeError(_cc(a)+" and "+_cc(b)+" can not be compared");
},compareDateLike:function(a,b){
return MochiKit.Base.compare(a.getTime(),b.getTime());
},compareArrayLike:function(a,b){
var _d1=MochiKit.Base.compare;
var _d2=a.length;
var _d3=0;
if(_d2>b.length){
_d3=1;
_d2=b.length;
}else{
if(_d2<b.length){
_d3=-1;
}
}
for(var i=0;i<_d2;i++){
var cmp=_d1(a[i],b[i]);
if(cmp){
return cmp;
}
}
return _d3;
},registerRepr:function(_d6,_d7,_d8,_d9){
MochiKit.Base.reprRegistry.register(_d6,_d7,_d8,_d9);
},repr:function(o){
if(typeof (o)=="undefined"){
return "undefined";
}else{
if(o===null){
return "null";
}
}
try{
if(typeof (o.__repr__)=="function"){
return o.__repr__();
}else{
if(typeof (o.repr)=="function"&&o.repr!=arguments.callee){
return o.repr();
}
}
return MochiKit.Base.reprRegistry.match(o);
}
catch(e){
if(typeof (o.NAME)=="string"&&(o.toString==Function.prototype.toString||o.toString==Object.prototype.toString)){
return o.NAME;
}
}
try{
var _db=(o+"");
}
catch(e){
return "["+typeof (o)+"]";
}
if(typeof (o)=="function"){
_db=_db.replace(/^\s+/,"").replace(/\s+/g," ");
var idx=_db.indexOf("{");
if(idx!=-1){
_db=_db.substr(0,idx)+"{...}";
}
}
return _db;
},reprArrayLike:function(o){
var m=MochiKit.Base;
return "["+m.map(m.repr,o).join(", ")+"]";
},reprString:function(o){
return ("\""+o.replace(/(["\\])/g,"\\$1")+"\"").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r");
},reprNumber:function(o){
return o+"";
},registerJSON:function(_e1,_e2,_e3,_e4){
MochiKit.Base.jsonRegistry.register(_e1,_e2,_e3,_e4);
},evalJSON:function(){
return eval("("+MochiKit.Base._filterJSON(arguments[0])+")");
},_filterJSON:function(s){
var m=s.match(/^\s*\/\*(.*)\*\/\s*$/);
if(m){
return m[1];
}
return s;
},serializeJSON:function(o){
var _e8=typeof (o);
if(_e8=="number"||_e8=="boolean"){
return o+"";
}else{
if(o===null){
return "null";
}
}
var m=MochiKit.Base;
var _ea=m.reprString;
if(_e8=="string"){
return _ea(o);
}
var me=arguments.callee;
var _ec;
if(typeof (o.__json__)=="function"){
_ec=o.__json__();
if(o!==_ec){
return me(_ec);
}
}
if(typeof (o.json)=="function"){
_ec=o.json();
if(o!==_ec){
return me(_ec);
}
}
if(_e8!="function"&&typeof (o.length)=="number"){
var res=[];
for(var i=0;i<o.length;i++){
var val=me(o[i]);
if(typeof (val)!="string"){
val="undefined";
}
res.push(val);
}
return "["+res.join(", ")+"]";
}
try{
_ec=m.jsonRegistry.match(o);
if(o!==_ec){
return me(_ec);
}
}
catch(e){
if(e!=m.NotFound){
throw e;
}
}
if(_e8=="undefined"){
throw new TypeError("undefined can not be serialized as JSON");
}
if(_e8=="function"){
return null;
}
res=[];
for(var k in o){
var _f1;
if(typeof (k)=="number"){
_f1="\""+k+"\"";
}else{
if(typeof (k)=="string"){
_f1=_ea(k);
}else{
continue;
}
}
val=me(o[k]);
if(typeof (val)!="string"){
continue;
}
res.push(_f1+":"+val);
}
return "{"+res.join(", ")+"}";
},objEqual:function(a,b){
return (MochiKit.Base.compare(a,b)===0);
},arrayEqual:function(_f4,arr){
if(_f4.length!=arr.length){
return false;
}
return (MochiKit.Base.compare(_f4,arr)===0);
},concat:function(){
var _f6=[];
var _f7=MochiKit.Base.extend;
for(var i=0;i<arguments.length;i++){
_f7(_f6,arguments[i]);
}
return _f6;
},keyComparator:function(key){
var m=MochiKit.Base;
var _fb=m.compare;
if(arguments.length==1){
return function(a,b){
return _fb(a[key],b[key]);
};
}
var _fe=m.extend(null,arguments);
return function(a,b){
var rval=0;
for(var i=0;(rval===0)&&(i<_fe.length);i++){
var key=_fe[i];
rval=_fb(a[key],b[key]);
}
return rval;
};
},reverseKeyComparator:function(key){
var _105=MochiKit.Base.keyComparator.apply(this,arguments);
return function(a,b){
return _105(b,a);
};
},partial:function(func){
var m=MochiKit.Base;
return m.bind.apply(this,m.extend([func,undefined],arguments,1));
},listMinMax:function(_10a,lst){
if(lst.length===0){
return null;
}
var cur=lst[0];
var _10d=MochiKit.Base.compare;
for(var i=1;i<lst.length;i++){
var o=lst[i];
if(_10d(o,cur)==_10a){
cur=o;
}
}
return cur;
},objMax:function(){
return MochiKit.Base.listMinMax(1,arguments);
},objMin:function(){
return MochiKit.Base.listMinMax(-1,arguments);
},findIdentical:function(lst,_111,_112,end){
if(typeof (end)=="undefined"||end===null){
end=lst.length;
}
if(typeof (_112)=="undefined"||_112===null){
_112=0;
}
for(var i=_112;i<end;i++){
if(lst[i]===_111){
return i;
}
}
return -1;
},mean:function(){
var sum=0;
var m=MochiKit.Base;
var args=m.extend(null,arguments);
var _118=args.length;
while(args.length){
var o=args.shift();
if(o&&typeof (o)=="object"&&typeof (o.length)=="number"){
_118+=o.length-1;
for(var i=o.length-1;i>=0;i--){
sum+=o[i];
}
}else{
sum+=o;
}
}
if(_118<=0){
throw new TypeError("mean() requires at least one argument");
}
return sum/_118;
},median:function(){
var data=MochiKit.Base.flattenArguments(arguments);
if(data.length===0){
throw new TypeError("median() requires at least one argument");
}
data.sort(compare);
if(data.length%2==0){
var _11c=data.length/2;
return (data[_11c]+data[_11c-1])/2;
}else{
return data[(data.length-1)/2];
}
},findValue:function(lst,_11e,_11f,end){
if(typeof (end)=="undefined"||end===null){
end=lst.length;
}
if(typeof (_11f)=="undefined"||_11f===null){
_11f=0;
}
var cmp=MochiKit.Base.compare;
for(var i=_11f;i<end;i++){
if(cmp(lst[i],_11e)===0){
return i;
}
}
return -1;
},nodeWalk:function(node,_124){
var _125=[node];
var _126=MochiKit.Base.extend;
while(_125.length){
var res=_124(_125.shift());
if(res){
_126(_125,res);
}
}
},nameFunctions:function(_128){
var base=_128.NAME;
if(typeof (base)=="undefined"){
base="";
}else{
base=base+".";
}
for(var name in _128){
var o=_128[name];
if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
try{
o.NAME=base+name;
}
catch(e){
}
}
}
},queryString:function(_12c,_12d){
if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_12c)=="string"||(typeof (_12c.nodeType)!="undefined"&&_12c.nodeType>0))){
var kv=MochiKit.DOM.formContents(_12c);
_12c=kv[0];
_12d=kv[1];
}else{
if(arguments.length==1){
if(typeof (_12c.length)=="number"&&_12c.length==2){
return arguments.callee(_12c[0],_12c[1]);
}
var o=_12c;
_12c=[];
_12d=[];
for(var k in o){
var v=o[k];
if(typeof (v)=="function"){
continue;
}else{
if(MochiKit.Base.isArrayLike(v)){
for(var i=0;i<v.length;i++){
_12c.push(k);
_12d.push(v[i]);
}
}else{
_12c.push(k);
_12d.push(v);
}
}
}
}
}
var rval=[];
var len=Math.min(_12c.length,_12d.length);
var _135=MochiKit.Base.urlEncode;
for(var i=0;i<len;i++){
v=_12d[i];
if(typeof (v)!="undefined"&&v!==null){
rval.push(_135(_12c[i])+"="+_135(v));
}
}
return rval.join("&");
},parseQueryString:function(_136,_137){
var qstr=(_136.charAt(0)=="?")?_136.substring(1):_136;
var _139=qstr.replace(/\+/g,"%20").split(/(\&amp\;|\&\#38\;|\&#x26;|\&)/);
var o={};
var _13b;
if(typeof (decodeURIComponent)!="undefined"){
_13b=decodeURIComponent;
}else{
_13b=unescape;
}
if(_137){
for(var i=0;i<_139.length;i++){
var pair=_139[i].split("=");
var name=_13b(pair.shift());
if(!name){
continue;
}
var arr=o[name];
if(!(arr instanceof Array)){
arr=[];
o[name]=arr;
}
arr.push(_13b(pair.join("=")));
}
}else{
for(i=0;i<_139.length;i++){
pair=_139[i].split("=");
var name=pair.shift();
if(!name){
continue;
}
o[_13b(name)]=_13b(pair.join("="));
}
}
return o;
}});
MochiKit.Base.AdapterRegistry=function(){
this.pairs=[];
};
MochiKit.Base.AdapterRegistry.prototype={register:function(name,_141,wrap,_143){
if(_143){
this.pairs.unshift([name,_141,wrap]);
}else{
this.pairs.push([name,_141,wrap]);
}
},match:function(){
for(var i=0;i<this.pairs.length;i++){
var pair=this.pairs[i];
if(pair[1].apply(this,arguments)){
return pair[2].apply(this,arguments);
}
}
throw MochiKit.Base.NotFound;
},unregister:function(name){
for(var i=0;i<this.pairs.length;i++){
var pair=this.pairs[i];
if(pair[0]==name){
this.pairs.splice(i,1);
return true;
}
}
return false;
}};
MochiKit.Base.EXPORT=["flattenArray","noop","camelize","counter","clone","extend","update","updatetree","setdefault","keys","values","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isEmpty","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","methodcaller","compose","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments","method","average","mean","median"];
MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"];
MochiKit.Base._exportSymbols=function(_149,_14a){
if(!MochiKit.__export__){
return;
}
var all=_14a.EXPORT_TAGS[":all"];
for(var i=0;i<all.length;i++){
_149[all[i]]=_14a[all[i]];
}
};
MochiKit.Base.__new__=function(){
var m=this;
m.noop=m.operator.identity;
m.forward=m.forwardCall;
m.find=m.findValue;
if(typeof (encodeURIComponent)!="undefined"){
m.urlEncode=function(_14e){
return encodeURIComponent(_14e).replace(/\'/g,"%27");
};
}else{
m.urlEncode=function(_14f){
return escape(_14f).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27");
};
}
m.NamedError=function(name){
this.message=name;
this.name=name;
};
m.NamedError.prototype=new Error();
m.update(m.NamedError.prototype,{repr:function(){
if(this.message&&this.message!=this.name){
return this.name+"("+m.repr(this.message)+")";
}else{
return this.name+"()";
}
},toString:m.forwardCall("repr")});
m.NotFound=new m.NamedError("MochiKit.Base.NotFound");
m.listMax=m.partial(m.listMinMax,1);
m.listMin=m.partial(m.listMinMax,-1);
m.isCallable=m.typeMatcher("function");
m.isUndefined=m.typeMatcher("undefined");
m.merge=m.partial(m.update,null);
m.zip=m.partial(m.map,null);
m.average=m.mean;
m.comparatorRegistry=new m.AdapterRegistry();
m.registerComparator("dateLike",m.isDateLike,m.compareDateLike);
m.registerComparator("arrayLike",m.isArrayLike,m.compareArrayLike);
m.reprRegistry=new m.AdapterRegistry();
m.registerRepr("arrayLike",m.isArrayLike,m.reprArrayLike);
m.registerRepr("string",m.typeMatcher("string"),m.reprString);
m.registerRepr("numbers",m.typeMatcher("number","boolean"),m.reprNumber);
m.jsonRegistry=new m.AdapterRegistry();
var all=m.concat(m.EXPORT,m.EXPORT_OK);
m.EXPORT_TAGS={":common":m.concat(m.EXPORT_OK),":all":all};
m.nameFunctions(this);
};
MochiKit.Base.__new__();
if(MochiKit.__export__){
compare=MochiKit.Base.compare;
compose=MochiKit.Base.compose;
serializeJSON=MochiKit.Base.serializeJSON;
mean=MochiKit.Base.mean;
median=MochiKit.Base.median;
}
MochiKit.Base._exportSymbols(this,MochiKit.Base);
MochiKit.Base._deps("Iter",["Base"]);
MochiKit.Iter.NAME="MochiKit.Iter";
MochiKit.Iter.VERSION="1.4";
MochiKit.Base.update(MochiKit.Iter,{__repr__:function(){
return "["+this.NAME+" "+this.VERSION+"]";
},toString:function(){
return this.__repr__();
},registerIteratorFactory:function(name,_153,_154,_155){
MochiKit.Iter.iteratorRegistry.register(name,_153,_154,_155);
},iter:function(_156,_157){
var self=MochiKit.Iter;
if(arguments.length==2){
return self.takewhile(function(a){
return a!=_157;
},_156);
}
if(typeof (_156.next)=="function"){
return _156;
}else{
if(typeof (_156.iter)=="function"){
return _156.iter();
}
}
try{
return self.iteratorRegistry.match(_156);
}
catch(e){
var m=MochiKit.Base;
if(e==m.NotFound){
e=new TypeError(typeof (_156)+": "+m.repr(_156)+" is not iterable");
}
throw e;
}
},count:function(n){
if(!n){
n=0;
}
var m=MochiKit.Base;
return {repr:function(){
return "count("+n+")";
},toString:m.forwardCall("repr"),next:m.counter(n)};
},cycle:function(p){
var self=MochiKit.Iter;
var m=MochiKit.Base;
var lst=[];
var _161=self.iter(p);
return {repr:function(){
return "cycle(...)";
},toString:m.forwardCall("repr"),next:function(){
try{
var rval=_161.next();
lst.push(rval);
return rval;
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
if(lst.length===0){
this.next=function(){
throw self.StopIteration;
};
}else{
var i=-1;
this.next=function(){
i=(i+1)%lst.length;
return lst[i];
};
}
return this.next();
}
}};
},repeat:function(elem,n){
var m=MochiKit.Base;
if(typeof (n)=="undefined"){
return {repr:function(){
return "repeat("+m.repr(elem)+")";
},toString:m.forwardCall("repr"),next:function(){
return elem;
}};
}
return {repr:function(){
return "repeat("+m.repr(elem)+", "+n+")";
},toString:m.forwardCall("repr"),next:function(){
if(n<=0){
throw MochiKit.Iter.StopIteration;
}
n-=1;
return elem;
}};
},next:function(_167){
return _167.next();
},izip:function(p,q){
var m=MochiKit.Base;
var self=MochiKit.Iter;
var next=self.next;
var _16d=m.map(self.iter,arguments);
return {repr:function(){
return "izip(...)";
},toString:m.forwardCall("repr"),next:function(){
return m.map(next,_16d);
}};
},ifilter:function(pred,seq){
var m=MochiKit.Base;
seq=MochiKit.Iter.iter(seq);
if(pred===null){
pred=m.operator.truth;
}
return {repr:function(){
return "ifilter(...)";
},toString:m.forwardCall("repr"),next:function(){
while(true){
var rval=seq.next();
if(pred(rval)){
return rval;
}
}
return undefined;
}};
},ifilterfalse:function(pred,seq){
var m=MochiKit.Base;
seq=MochiKit.Iter.iter(seq);
if(pred===null){
pred=m.operator.truth;
}
return {repr:function(){
return "ifilterfalse(...)";
},toString:m.forwardCall("repr"),next:function(){
while(true){
var rval=seq.next();
if(!pred(rval)){
return rval;
}
}
return undefined;
}};
},islice:function(seq){
var self=MochiKit.Iter;
var m=MochiKit.Base;
seq=self.iter(seq);
var _179=0;
var stop=0;
var step=1;
var i=-1;
if(arguments.length==2){
stop=arguments[1];
}else{
if(arguments.length==3){
_179=arguments[1];
stop=arguments[2];
}else{
_179=arguments[1];
stop=arguments[2];
step=arguments[3];
}
}
return {repr:function(){
return "islice("+["...",_179,stop,step].join(", ")+")";
},toString:m.forwardCall("repr"),next:function(){
var rval;
while(i<_179){
rval=seq.next();
i++;
}
if(_179>=stop){
throw self.StopIteration;
}
_179+=step;
return rval;
}};
},imap:function(fun,p,q){
var m=MochiKit.Base;
var self=MochiKit.Iter;
var _183=m.map(self.iter,m.extend(null,arguments,1));
var map=m.map;
var next=self.next;
return {repr:function(){
return "imap(...)";
},toString:m.forwardCall("repr"),next:function(){
return fun.apply(this,map(next,_183));
}};
},applymap:function(fun,seq,self){
seq=MochiKit.Iter.iter(seq);
var m=MochiKit.Base;
return {repr:function(){
return "applymap(...)";
},toString:m.forwardCall("repr"),next:function(){
return fun.apply(self,seq.next());
}};
},chain:function(p,q){
var self=MochiKit.Iter;
var m=MochiKit.Base;
if(arguments.length==1){
return self.iter(arguments[0]);
}
var _18e=m.map(self.iter,arguments);
return {repr:function(){
return "chain(...)";
},toString:m.forwardCall("repr"),next:function(){
while(_18e.length>1){
try{
return _18e[0].next();
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
_18e.shift();
}
}
if(_18e.length==1){
var arg=_18e.shift();
this.next=m.bind("next",arg);
return this.next();
}
throw self.StopIteration;
}};
},takewhile:function(pred,seq){
var self=MochiKit.Iter;
seq=self.iter(seq);
return {repr:function(){
return "takewhile(...)";
},toString:MochiKit.Base.forwardCall("repr"),next:function(){
var rval=seq.next();
if(!pred(rval)){
this.next=function(){
throw self.StopIteration;
};
this.next();
}
return rval;
}};
},dropwhile:function(pred,seq){
seq=MochiKit.Iter.iter(seq);
var m=MochiKit.Base;
var bind=m.bind;
return {"repr":function(){
return "dropwhile(...)";
},"toString":m.forwardCall("repr"),"next":function(){
while(true){
var rval=seq.next();
if(!pred(rval)){
break;
}
}
this.next=bind("next",seq);
return rval;
}};
},_tee:function(_199,sync,_19b){
sync.pos[_199]=-1;
var m=MochiKit.Base;
var _19d=m.listMin;
return {repr:function(){
return "tee("+_199+", ...)";
},toString:m.forwardCall("repr"),next:function(){
var rval;
var i=sync.pos[_199];
if(i==sync.max){
rval=_19b.next();
sync.deque.push(rval);
sync.max+=1;
sync.pos[_199]+=1;
}else{
rval=sync.deque[i-sync.min];
sync.pos[_199]+=1;
if(i==sync.min&&_19d(sync.pos)!=sync.min){
sync.min+=1;
sync.deque.shift();
}
}
return rval;
}};
},tee:function(_1a0,n){
var rval=[];
var sync={"pos":[],"deque":[],"max":-1,"min":-1};
if(arguments.length==1||typeof (n)=="undefined"||n===null){
n=2;
}
var self=MochiKit.Iter;
_1a0=self.iter(_1a0);
var _tee=self._tee;
for(var i=0;i<n;i++){
rval.push(_tee(i,sync,_1a0));
}
return rval;
},list:function(_1a7){
var rval;
if(_1a7 instanceof Array){
return _1a7.slice();
}
if(typeof (_1a7)=="function"&&!(_1a7 instanceof Function)&&typeof (_1a7.length)=="number"){
rval=[];
for(var i=0;i<_1a7.length;i++){
rval.push(_1a7[i]);
}
return rval;
}
var self=MochiKit.Iter;
_1a7=self.iter(_1a7);
var rval=[];
try{
while(true){
rval.push(_1a7.next());
}
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
return rval;
}
return undefined;
},reduce:function(fn,_1ac,_1ad){
var i=0;
var x=_1ad;
var self=MochiKit.Iter;
_1ac=self.iter(_1ac);
if(arguments.length<3){
try{
x=_1ac.next();
}
catch(e){
if(e==self.StopIteration){
e=new TypeError("reduce() of empty sequence with no initial value");
}
throw e;
}
i++;
}
try{
while(true){
x=fn(x,_1ac.next());
}
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
}
return x;
},range:function(){
var _1b1=0;
var stop=0;
var step=1;
if(arguments.length==1){
stop=arguments[0];
}else{
if(arguments.length==2){
_1b1=arguments[0];
stop=arguments[1];
}else{
if(arguments.length==3){
_1b1=arguments[0];
stop=arguments[1];
step=arguments[2];
}else{
throw new TypeError("range() takes 1, 2, or 3 arguments!");
}
}
}
if(step===0){
throw new TypeError("range() step must not be 0");
}
return {next:function(){
if((step>0&&_1b1>=stop)||(step<0&&_1b1<=stop)){
throw MochiKit.Iter.StopIteration;
}
var rval=_1b1;
_1b1+=step;
return rval;
},repr:function(){
return "range("+[_1b1,stop,step].join(", ")+")";
},toString:MochiKit.Base.forwardCall("repr")};
},sum:function(_1b5,_1b6){
if(typeof (_1b6)=="undefined"||_1b6===null){
_1b6=0;
}
var x=_1b6;
var self=MochiKit.Iter;
_1b5=self.iter(_1b5);
try{
while(true){
x+=_1b5.next();
}
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
}
return x;
},exhaust:function(_1b9){
var self=MochiKit.Iter;
_1b9=self.iter(_1b9);
try{
while(true){
_1b9.next();
}
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
}
},forEach:function(_1bb,func,self){
var m=MochiKit.Base;
if(arguments.length>2){
func=m.bind(func,self);
}
if(m.isArrayLike(_1bb)){
try{
for(var i=0;i<_1bb.length;i++){
func(_1bb[i]);
}
}
catch(e){
if(e!=MochiKit.Iter.StopIteration){
throw e;
}
}
}else{
self=MochiKit.Iter;
self.exhaust(self.imap(func,_1bb));
}
},every:function(_1c0,func){
var self=MochiKit.Iter;
try{
self.ifilterfalse(func,_1c0).next();
return false;
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
return true;
}
},sorted:function(_1c3,cmp){
var rval=MochiKit.Iter.list(_1c3);
if(arguments.length==1){
cmp=MochiKit.Base.compare;
}
rval.sort(cmp);
return rval;
},reversed:function(_1c6){
var rval=MochiKit.Iter.list(_1c6);
rval.reverse();
return rval;
},some:function(_1c8,func){
var self=MochiKit.Iter;
try{
self.ifilter(func,_1c8).next();
return true;
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
return false;
}
},iextend:function(lst,_1cc){
if(MochiKit.Base.isArrayLike(_1cc)){
for(var i=0;i<_1cc.length;i++){
lst.push(_1cc[i]);
}
}else{
var self=MochiKit.Iter;
_1cc=self.iter(_1cc);
try{
while(true){
lst.push(_1cc.next());
}
}
catch(e){
if(e!=self.StopIteration){
throw e;
}
}
}
return lst;
},groupby:function(_1cf,_1d0){
var m=MochiKit.Base;
var self=MochiKit.Iter;
if(arguments.length<2){
_1d0=m.operator.identity;
}
_1cf=self.iter(_1cf);
var pk=undefined;
var k=undefined;
var v;
function fetch(){
v=_1cf.next();
k=_1d0(v);
}
function eat(){
var ret=v;
v=undefined;
return ret;
}
var _1d7=true;
var _1d8=m.compare;
return {repr:function(){
return "groupby(...)";
},next:function(){
while(_1d8(k,pk)===0){
fetch();
if(_1d7){
_1d7=false;
break;
}
}
pk=k;
return [k,{next:function(){
if(v==undefined){
fetch();
}
if(_1d8(k,pk)!==0){
throw self.StopIteration;
}
return eat();
}}];
}};
},groupby_as_array:function(_1d9,_1da){
var m=MochiKit.Base;
var self=MochiKit.Iter;
if(arguments.length<2){
_1da=m.operator.identity;
}
_1d9=self.iter(_1d9);
var _1dd=[];
var _1de=true;
var _1df;
var _1e0=m.compare;
while(true){
try{
var _1e1=_1d9.next();
var key=_1da(_1e1);
}
catch(e){
if(e==self.StopIteration){
break;
}
throw e;
}
if(_1de||_1e0(key,_1df)!==0){
var _1e3=[];
_1dd.push([key,_1e3]);
}
_1e3.push(_1e1);
_1de=false;
_1df=key;
}
return _1dd;
},arrayLikeIter:function(_1e4){
var i=0;
return {repr:function(){
return "arrayLikeIter(...)";
},toString:MochiKit.Base.forwardCall("repr"),next:function(){
if(i>=_1e4.length){
throw MochiKit.Iter.StopIteration;
}
return _1e4[i++];
}};
},hasIterateNext:function(_1e6){
return (_1e6&&typeof (_1e6.iterateNext)=="function");
},iterateNextIter:function(_1e7){
return {repr:function(){
return "iterateNextIter(...)";
},toString:MochiKit.Base.forwardCall("repr"),next:function(){
var rval=_1e7.iterateNext();
if(rval===null||rval===undefined){
throw MochiKit.Iter.StopIteration;
}
return rval;
}};
}});
MochiKit.Iter.EXPORT_OK=["iteratorRegistry","arrayLikeIter","hasIterateNext","iterateNextIter"];
MochiKit.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"];
MochiKit.Iter.__new__=function(){
var m=MochiKit.Base;
if(typeof (StopIteration)!="undefined"){
this.StopIteration=StopIteration;
}else{
this.StopIteration=new m.NamedError("StopIteration");
}
this.iteratorRegistry=new m.AdapterRegistry();
this.registerIteratorFactory("arrayLike",m.isArrayLike,this.arrayLikeIter);
this.registerIteratorFactory("iterateNext",this.hasIterateNext,this.iterateNextIter);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
MochiKit.Iter.__new__();
if(MochiKit.__export__){
reduce=MochiKit.Iter.reduce;
}
MochiKit.Base._exportSymbols(this,MochiKit.Iter);
MochiKit.Base._deps("Logging",["Base"]);
MochiKit.Logging.NAME="MochiKit.Logging";
MochiKit.Logging.VERSION="1.4";
MochiKit.Logging.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Logging.toString=function(){
return this.__repr__();
};
MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"];
MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"];
MochiKit.Logging.LogMessage=function(num,_1eb,info){
this.num=num;
this.level=_1eb;
this.info=info;
this.timestamp=new Date();
};
MochiKit.Logging.LogMessage.prototype={repr:function(){
var m=MochiKit.Base;
return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")";
},toString:MochiKit.Base.forwardCall("repr")};
MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_1ee){
var self=MochiKit.Logging;
if(typeof (_1ee)=="string"){
_1ee=self.LogLevel[_1ee];
}
return function(msg){
var _1f1=msg.level;
if(typeof (_1f1)=="string"){
_1f1=self.LogLevel[_1f1];
}
return _1f1>=_1ee;
};
},isLogMessage:function(){
var _1f2=MochiKit.Logging.LogMessage;
for(var i=0;i<arguments.length;i++){
if(!(arguments[i] instanceof _1f2)){
return false;
}
}
return true;
},compareLogMessage:function(a,b){
return MochiKit.Base.compare([a.level,a.info],[b.level,b.info]);
},alertListener:function(msg){
alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" "));
}});
MochiKit.Logging.Logger=function(_1f7){
this.counter=0;
if(typeof (_1f7)=="undefined"||_1f7===null){
_1f7=-1;
}
this.maxSize=_1f7;
this._messages=[];
this.listeners={};
this.useNativeConsole=false;
};
MochiKit.Logging.Logger.prototype={clear:function(){
this._messages.splice(0,this._messages.length);
},logToConsole:function(msg){
if(typeof (window)!="undefined"&&window.console&&window.console.log){
window.console.log(msg.replace(/%/g,"\uff05"));
}else{
if(typeof (opera)!="undefined"&&opera.postError){
opera.postError(msg);
}else{
if(typeof (printfire)=="function"){
printfire(msg);
}else{
if(typeof (Debug)!="undefined"&&Debug.writeln){
Debug.writeln(msg);
}else{
if(typeof (debug)!="undefined"&&debug.trace){
debug.trace(msg);
}
}
}
}
}
},dispatchListeners:function(msg){
for(var k in this.listeners){
var pair=this.listeners[k];
if(pair.ident!=k||(pair[0]&&!pair[0](msg))){
continue;
}
pair[1](msg);
}
},addListener:function(_1fc,_1fd,_1fe){
if(typeof (_1fd)=="string"){
_1fd=MochiKit.Logging.logLevelAtLeast(_1fd);
}
var _1ff=[_1fd,_1fe];
_1ff.ident=_1fc;
this.listeners[_1fc]=_1ff;
},removeListener:function(_200){
delete this.listeners[_200];
},baseLog:function(_201,_202){
var msg=new MochiKit.Logging.LogMessage(this.counter,_201,MochiKit.Base.extend(null,arguments,1));
this._messages.push(msg);
this.dispatchListeners(msg);
if(this.useNativeConsole){
this.logToConsole(msg.level+": "+msg.info.join(" "));
}
this.counter+=1;
while(this.maxSize>=0&&this._messages.length>this.maxSize){
this._messages.shift();
}
},getMessages:function(_204){
var _205=0;
if(!(typeof (_204)=="undefined"||_204===null)){
_205=Math.max(0,this._messages.length-_204);
}
return this._messages.slice(_205);
},getMessageText:function(_206){
if(typeof (_206)=="undefined"||_206===null){
_206=30;
}
var _207=this.getMessages(_206);
if(_207.length){
var lst=map(function(m){
return "\n  ["+m.num+"] "+m.level+": "+m.info.join(" ");
},_207);
lst.unshift("LAST "+_207.length+" MESSAGES:");
return lst.join("");
}
return "";
},debuggingBookmarklet:function(_20a){
if(typeof (MochiKit.LoggingPane)=="undefined"){
alert(this.getMessageText());
}else{
MochiKit.LoggingPane.createLoggingPane(_20a||false);
}
}};
MochiKit.Logging.__new__=function(){
this.LogLevel={ERROR:40,FATAL:50,WARNING:30,INFO:20,DEBUG:10};
var m=MochiKit.Base;
m.registerComparator("LogMessage",this.isLogMessage,this.compareLogMessage);
var _20c=m.partial;
var _20d=this.Logger;
var _20e=_20d.prototype.baseLog;
m.update(this.Logger.prototype,{debug:_20c(_20e,"DEBUG"),log:_20c(_20e,"INFO"),error:_20c(_20e,"ERROR"),fatal:_20c(_20e,"FATAL"),warning:_20c(_20e,"WARNING")});
var self=this;
var _210=function(name){
return function(){
self.logger[name].apply(self.logger,arguments);
};
};
this.log=_210("log");
this.logError=_210("error");
this.logDebug=_210("debug");
this.logFatal=_210("fatal");
this.logWarning=_210("warning");
this.logger=new _20d();
this.logger.useNativeConsole=true;
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
if(typeof (printfire)=="undefined"&&typeof (document)!="undefined"&&document.createEvent&&typeof (dispatchEvent)!="undefined"){
printfire=function(){
printfire.args=arguments;
var ev=document.createEvent("Events");
ev.initEvent("printfire",false,true);
dispatchEvent(ev);
};
}
MochiKit.Logging.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Logging);
MochiKit.Base._deps("DateTime",["Base"]);
MochiKit.DateTime.NAME="MochiKit.DateTime";
MochiKit.DateTime.VERSION="1.4";
MochiKit.DateTime.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.DateTime.toString=function(){
return this.__repr__();
};
MochiKit.DateTime.isoDate=function(str){
str=str+"";
if(typeof (str)!="string"||str.length===0){
return null;
}
var iso=str.split("-");
if(iso.length===0){
return null;
}
return new Date(iso[0],iso[1]-1,iso[2]);
};
MochiKit.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}))?)?)?)?)?/;
MochiKit.DateTime.isoTimestamp=function(str){
str=str+"";
if(typeof (str)!="string"||str.length===0){
return null;
}
var res=str.match(MochiKit.DateTime._isoRegexp);
if(typeof (res)=="undefined"||res===null){
return null;
}
var year,_218,day,hour,min,sec,msec;
year=parseInt(res[1],10);
if(typeof (res[2])=="undefined"||res[2]===""){
return new Date(year);
}
_218=parseInt(res[2],10)-1;
day=parseInt(res[3],10);
if(typeof (res[4])=="undefined"||res[4]===""){
return new Date(year,_218,day);
}
hour=parseInt(res[4],10);
min=parseInt(res[5],10);
sec=(typeof (res[6])!="undefined"&&res[6]!=="")?parseInt(res[6],10):0;
if(typeof (res[7])!="undefined"&&res[7]!==""){
msec=Math.round(1000*parseFloat("0."+res[7]));
}else{
msec=0;
}
if((typeof (res[8])=="undefined"||res[8]==="")&&(typeof (res[9])=="undefined"||res[9]==="")){
return new Date(year,_218,day,hour,min,sec,msec);
}
var ofs;
if(typeof (res[9])!="undefined"&&res[9]!==""){
ofs=parseInt(res[10],10)*3600000;
if(typeof (res[11])!="undefined"&&res[11]!==""){
ofs+=parseInt(res[11],10)*60000;
}
if(res[9]=="-"){
ofs=-ofs;
}
}else{
ofs=0;
}
return new Date(Date.UTC(year,_218,day,hour,min,sec,msec)-ofs);
};
MochiKit.DateTime.toISOTime=function(date,_220){
if(typeof (date)=="undefined"||date===null){
return null;
}
var hh=date.getHours();
var mm=date.getMinutes();
var ss=date.getSeconds();
var lst=[((_220&&(hh<10))?"0"+hh:hh),((mm<10)?"0"+mm:mm),((ss<10)?"0"+ss:ss)];
return lst.join(":");
};
MochiKit.DateTime.toISOTimestamp=function(date,_226){
if(typeof (date)=="undefined"||date===null){
return null;
}
var sep=_226?"T":" ";
var foot=_226?"Z":"";
if(_226){
date=new Date(date.getTime()+(date.getTimezoneOffset()*60000));
}
return MochiKit.DateTime.toISODate(date)+sep+MochiKit.DateTime.toISOTime(date,_226)+foot;
};
MochiKit.DateTime.toISODate=function(date){
if(typeof (date)=="undefined"||date===null){
return null;
}
var _22a=MochiKit.DateTime._padTwo;
return [date.getFullYear(),_22a(date.getMonth()+1),_22a(date.getDate())].join("-");
};
MochiKit.DateTime.americanDate=function(d){
d=d+"";
if(typeof (d)!="string"||d.length===0){
return null;
}
var a=d.split("/");
return new Date(a[2],a[0]-1,a[1]);
};
MochiKit.DateTime._padTwo=function(n){
return (n>9)?n:"0"+n;
};
MochiKit.DateTime.toPaddedAmericanDate=function(d){
if(typeof (d)=="undefined"||d===null){
return null;
}
var _22f=MochiKit.DateTime._padTwo;
return [_22f(d.getMonth()+1),_22f(d.getDate()),d.getFullYear()].join("/");
};
MochiKit.DateTime.toAmericanDate=function(d){
if(typeof (d)=="undefined"||d===null){
return null;
}
return [d.getMonth()+1,d.getDate(),d.getFullYear()].join("/");
};
MochiKit.DateTime.EXPORT=["isoDate","isoTimestamp","toISOTime","toISOTimestamp","toISODate","americanDate","toPaddedAmericanDate","toAmericanDate"];
MochiKit.DateTime.EXPORT_OK=[];
MochiKit.DateTime.EXPORT_TAGS={":common":MochiKit.DateTime.EXPORT,":all":MochiKit.DateTime.EXPORT};
MochiKit.DateTime.__new__=function(){
var base=this.NAME+".";
for(var k in this){
var o=this[k];
if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
try{
o.NAME=base+k;
}
catch(e){
}
}
}
};
MochiKit.DateTime.__new__();
if(typeof (MochiKit.Base)!="undefined"){
MochiKit.Base._exportSymbols(this,MochiKit.DateTime);
}else{
(function(_234,_235){
if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
var all=_235.EXPORT_TAGS[":all"];
for(var i=0;i<all.length;i++){
_234[all[i]]=_235[all[i]];
}
}
})(this,MochiKit.DateTime);
}
MochiKit.Base._deps("Format",["Base"]);
MochiKit.Format.NAME="MochiKit.Format";
MochiKit.Format.VERSION="1.4";
MochiKit.Format.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Format.toString=function(){
return this.__repr__();
};
MochiKit.Format._numberFormatter=function(_238,_239,_23a,_23b,_23c,_23d,_23e,_23f,_240){
return function(num){
num=parseFloat(num);
if(typeof (num)=="undefined"||num===null||isNaN(num)){
return _238;
}
var _242=_239;
var _243=_23a;
if(num<0){
num=-num;
}else{
_242=_242.replace(/-/,"");
}
var me=arguments.callee;
var fmt=MochiKit.Format.formatLocale(_23b);
if(_23c){
num=num*100;
_243=fmt.percent+_243;
}
num=MochiKit.Format.roundToFixed(num,_23d);
var _246=num.split(/\./);
var _247=_246[0];
var frac=(_246.length==1)?"":_246[1];
var res="";
while(_247.length<_23e){
_247="0"+_247;
}
if(_23f){
while(_247.length>_23f){
var i=_247.length-_23f;
res=fmt.separator+_247.substring(i,_247.length)+res;
_247=_247.substring(0,i);
}
}
res=_247+res;
if(_23d>0){
while(frac.length<_240){
frac=frac+"0";
}
res=res+fmt.decimal+frac;
}
return _242+res+_243;
};
};
MochiKit.Format.numberFormatter=function(_24b,_24c,_24d){
if(typeof (_24c)=="undefined"){
_24c="";
}
var _24e=_24b.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
if(!_24e){
throw TypeError("Invalid pattern");
}
var _24f=_24b.substr(0,_24e.index);
var _250=_24b.substr(_24e.index+_24e[0].length);
if(_24f.search(/-/)==-1){
_24f=_24f+"-";
}
var _251=_24e[1];
var frac=(typeof (_24e[2])=="string"&&_24e[2]!="")?_24e[2]:"";
var _253=(typeof (_24e[3])=="string"&&_24e[3]!="");
var tmp=_251.split(/,/);
var _255;
if(typeof (_24d)=="undefined"){
_24d="default";
}
if(tmp.length==1){
_255=null;
}else{
_255=tmp[1].length;
}
var _256=_251.length-_251.replace(/0/g,"").length;
var _257=frac.length-frac.replace(/0/g,"").length;
var _258=frac.length;
var rval=MochiKit.Format._numberFormatter(_24c,_24f,_250,_24d,_253,_258,_256,_255,_257);
var m=MochiKit.Base;
if(m){
var fn=arguments.callee;
var args=m.concat(arguments);
rval.repr=function(){
return [self.NAME,"(",map(m.repr,args).join(", "),")"].join("");
};
}
return rval;
};
MochiKit.Format.formatLocale=function(_25d){
if(typeof (_25d)=="undefined"||_25d===null){
_25d="default";
}
if(typeof (_25d)=="string"){
var rval=MochiKit.Format.LOCALE[_25d];
if(typeof (rval)=="string"){
rval=arguments.callee(rval);
MochiKit.Format.LOCALE[_25d]=rval;
}
return rval;
}else{
return _25d;
}
};
MochiKit.Format.twoDigitAverage=function(_25f,_260){
if(_260){
var res=_25f/_260;
if(!isNaN(res)){
return MochiKit.Format.twoDigitFloat(_25f/_260);
}
}
return "0";
};
MochiKit.Format.twoDigitFloat=function(_262){
var sign=(_262<0?"-":"");
var s=Math.floor(Math.abs(_262)*100).toString();
if(s=="0"){
return s;
}
if(s.length<3){
if(s.length==1){
s="0"+s;
}
while(s.charAt(s.length-1)=="0"){
s=s.substring(0,s.length-1);
}
return sign+"0."+s;
}
var head=sign+s.substring(0,s.length-2);
var tail=s.substring(s.length-2,s.length);
if(tail=="00"){
return head;
}else{
if(tail.charAt(1)=="0"){
return head+"."+tail.charAt(0);
}else{
return head+"."+tail;
}
}
};
MochiKit.Format.lstrip=function(str,_268){
str=str+"";
if(typeof (str)!="string"){
return null;
}
if(!_268){
return str.replace(/^\s+/,"");
}else{
return str.replace(new RegExp("^["+_268+"]+"),"");
}
};
MochiKit.Format.rstrip=function(str,_26a){
str=str+"";
if(typeof (str)!="string"){
return null;
}
if(!_26a){
return str.replace(/\s+$/,"");
}else{
return str.replace(new RegExp("["+_26a+"]+$"),"");
}
};
MochiKit.Format.strip=function(str,_26c){
var self=MochiKit.Format;
return self.rstrip(self.lstrip(str,_26c),_26c);
};
MochiKit.Format.truncToFixed=function(_26e,_26f){
_26e=Math.floor(_26e*Math.pow(10,_26f));
var res=(_26e*Math.pow(10,-_26f)).toFixed(_26f);
if(res.charAt(0)=="."){
res="0"+res;
}
return res;
};
MochiKit.Format.roundToFixed=function(_271,_272){
return MochiKit.Format.truncToFixed(_271+0.5*Math.pow(10,-_272),_272);
};
MochiKit.Format.percentFormat=function(_273){
return MochiKit.Format.twoDigitFloat(100*_273)+"%";
};
MochiKit.Format.EXPORT=["truncToFixed","roundToFixed","numberFormatter","formatLocale","twoDigitAverage","twoDigitFloat","percentFormat","lstrip","rstrip","strip"];
MochiKit.Format.LOCALE={en_US:{separator:",",decimal:".",percent:"%"},de_DE:{separator:".",decimal:",",percent:"%"},pt_BR:{separator:".",decimal:",",percent:"%"},fr_FR:{separator:" ",decimal:",",percent:"%"},"default":"en_US"};
MochiKit.Format.EXPORT_OK=[];
MochiKit.Format.EXPORT_TAGS={":all":MochiKit.Format.EXPORT,":common":MochiKit.Format.EXPORT};
MochiKit.Format.__new__=function(){
var base=this.NAME+".";
var k,v,o;
for(k in this.LOCALE){
o=this.LOCALE[k];
if(typeof (o)=="object"){
o.repr=function(){
return this.NAME;
};
o.NAME=base+"LOCALE."+k;
}
}
for(k in this){
o=this[k];
if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){
try{
o.NAME=base+k;
}
catch(e){
}
}
}
};
MochiKit.Format.__new__();
if(typeof (MochiKit.Base)!="undefined"){
MochiKit.Base._exportSymbols(this,MochiKit.Format);
}else{
(function(_278,_279){
if((typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")||(MochiKit.__export__===false)){
var all=_279.EXPORT_TAGS[":all"];
for(var i=0;i<all.length;i++){
_278[all[i]]=_279[all[i]];
}
}
})(this,MochiKit.Format);
}
MochiKit.Base._deps("Async",["Base"]);
MochiKit.Async.NAME="MochiKit.Async";
MochiKit.Async.VERSION="1.4";
MochiKit.Async.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Async.toString=function(){
return this.__repr__();
};
MochiKit.Async.Deferred=function(_27c){
this.chain=[];
this.id=this._nextId();
this.fired=-1;
this.paused=0;
this.results=[null,null];
this.canceller=_27c;
this.silentlyCancelled=false;
this.chained=false;
};
MochiKit.Async.Deferred.prototype={repr:function(){
var _27d;
if(this.fired==-1){
_27d="unfired";
}else{
if(this.fired===0){
_27d="success";
}else{
_27d="error";
}
}
return "Deferred("+this.id+", "+_27d+")";
},toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){
var self=MochiKit.Async;
if(this.fired==-1){
if(this.canceller){
this.canceller(this);
}else{
this.silentlyCancelled=true;
}
if(this.fired==-1){
this.errback(new self.CancelledError(this));
}
}else{
if((this.fired===0)&&(this.results[0] instanceof self.Deferred)){
this.results[0].cancel();
}
}
},_resback:function(res){
this.fired=((res instanceof Error)?1:0);
this.results[this.fired]=res;
this._fire();
},_check:function(){
if(this.fired!=-1){
if(!this.silentlyCancelled){
throw new MochiKit.Async.AlreadyCalledError(this);
}
this.silentlyCancelled=false;
return;
}
},callback:function(res){
this._check();
if(res instanceof MochiKit.Async.Deferred){
throw new Error("Deferred instances can only be chained if they are the result of a callback");
}
this._resback(res);
},errback:function(res){
this._check();
var self=MochiKit.Async;
if(res instanceof self.Deferred){
throw new Error("Deferred instances can only be chained if they are the result of a callback");
}
if(!(res instanceof Error)){
res=new self.GenericError(res);
}
this._resback(res);
},addBoth:function(fn){
if(arguments.length>1){
fn=MochiKit.Base.partial.apply(null,arguments);
}
return this.addCallbacks(fn,fn);
},addCallback:function(fn){
if(arguments.length>1){
fn=MochiKit.Base.partial.apply(null,arguments);
}
return this.addCallbacks(fn,null);
},addErrback:function(fn){
if(arguments.length>1){
fn=MochiKit.Base.partial.apply(null,arguments);
}
return this.addCallbacks(null,fn);
},addCallbacks:function(cb,eb){
if(this.chained){
throw new Error("Chained Deferreds can not be re-used");
}
this.chain.push([cb,eb]);
if(this.fired>=0){
this._fire();
}
return this;
},_fire:function(){
var _288=this.chain;
var _289=this.fired;
var res=this.results[_289];
var self=this;
var cb=null;
while(_288.length>0&&this.paused===0){
var pair=_288.shift();
var f=pair[_289];
if(f===null){
continue;
}
try{
res=f(res);
_289=((res instanceof Error)?1:0);
if(res instanceof MochiKit.Async.Deferred){
cb=function(res){
self._resback(res);
self.paused--;
if((self.paused===0)&&(self.fired>=0)){
self._fire();
}
};
this.paused++;
}
}
catch(err){
_289=1;
if(!(err instanceof Error)){
err=new MochiKit.Async.GenericError(err);
}
res=err;
}
}
this.fired=_289;
this.results[_289]=res;
if(cb&&this.paused){
res.addBoth(cb);
res.chained=true;
}
}};
MochiKit.Base.update(MochiKit.Async,{evalJSONRequest:function(req){
return MochiKit.Base.evalJSON(req.responseText);
},succeed:function(_291){
var d=new MochiKit.Async.Deferred();
d.callback.apply(d,arguments);
return d;
},fail:function(_293){
var d=new MochiKit.Async.Deferred();
d.errback.apply(d,arguments);
return d;
},getXMLHttpRequest:function(){
var self=arguments.callee;
if(!self.XMLHttpRequest){
var _296=[function(){
return new XMLHttpRequest();
},function(){
return new ActiveXObject("Msxml2.XMLHTTP");
},function(){
return new ActiveXObject("Microsoft.XMLHTTP");
},function(){
return new ActiveXObject("Msxml2.XMLHTTP.4.0");
},function(){
throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
}];
for(var i=0;i<_296.length;i++){
var func=_296[i];
try{
self.XMLHttpRequest=func;
return func();
}
catch(e){
}
}
}
return self.XMLHttpRequest();
},_xhr_onreadystatechange:function(d){
var m=MochiKit.Base;
if(this.readyState==4){
try{
this.onreadystatechange=null;
}
catch(e){
try{
this.onreadystatechange=m.noop;
}
catch(e){
}
}
var _29b=null;
try{
_29b=this.status;
if(!_29b&&m.isNotEmpty(this.responseText)){
_29b=304;
}
}
catch(e){
}
if(_29b==200||_29b==201||_29b==204||_29b==304||_29b==1223){
d.callback(this);
}else{
var err=new MochiKit.Async.XMLHttpRequestError(this,"Request failed");
if(err.number){
d.errback(err);
}else{
d.errback(err);
}
}
}
},_xhr_canceller:function(req){
try{
req.onreadystatechange=null;
}
catch(e){
try{
req.onreadystatechange=MochiKit.Base.noop;
}
catch(e){
}
}
req.abort();
},sendXMLHttpRequest:function(req,_29f){
if(typeof (_29f)=="undefined"||_29f===null){
_29f="";
}
var m=MochiKit.Base;
var self=MochiKit.Async;
var d=new self.Deferred(m.partial(self._xhr_canceller,req));
try{
req.onreadystatechange=m.bind(self._xhr_onreadystatechange,req,d);
req.send(_29f);
}
catch(e){
try{
req.onreadystatechange=null;
}
catch(ignore){
}
d.errback(e);
}
return d;
},doXHR:function(url,opts){
var self=MochiKit.Async;
return self.callLater(0,self._doXHR,url,opts);
},_doXHR:function(url,opts){
var m=MochiKit.Base;
opts=m.update({method:"GET",sendContent:""},opts);
var self=MochiKit.Async;
var req=self.getXMLHttpRequest();
if(opts.queryString){
var qs=m.queryString(opts.queryString);
if(qs){
url+="?"+qs;
}
}
if("username" in opts){
req.open(opts.method,url,true,opts.username,opts.password);
}else{
req.open(opts.method,url,true);
}
if(req.overrideMimeType&&opts.mimeType){
req.overrideMimeType(opts.mimeType);
}
req.setRequestHeader("X-Requested-With","XMLHttpRequest");
if(opts.headers){
var _2ac=opts.headers;
if(!m.isArrayLike(_2ac)){
_2ac=m.items(_2ac);
}
for(var i=0;i<_2ac.length;i++){
var _2ae=_2ac[i];
var name=_2ae[0];
var _2b0=_2ae[1];
req.setRequestHeader(name,_2b0);
}
}
return self.sendXMLHttpRequest(req,opts.sendContent);
},_buildURL:function(url){
if(arguments.length>1){
var m=MochiKit.Base;
var qs=m.queryString.apply(null,m.extend(null,arguments,1));
if(qs){
return url+"?"+qs;
}
}
return url;
},doSimpleXMLHttpRequest:function(url){
var self=MochiKit.Async;
url=self._buildURL.apply(self,arguments);
return self.doXHR(url);
},loadJSONDoc:function(url){
var self=MochiKit.Async;
url=self._buildURL.apply(self,arguments);
var d=self.doXHR(url,{"mimeType":"text/plain","headers":[["Accept","application/json"]]});
d=d.addCallback(self.evalJSONRequest);
return d;
},wait:function(_2b9,_2ba){
var d=new MochiKit.Async.Deferred();
var m=MochiKit.Base;
if(typeof (_2ba)!="undefined"){
d.addCallback(function(){
return _2ba;
});
}
var _2bd=setTimeout(m.bind("callback",d),Math.floor(_2b9*1000));
d.canceller=function(){
try{
clearTimeout(_2bd);
}
catch(e){
}
};
return d;
},callLater:function(_2be,func){
var m=MochiKit.Base;
var _2c1=m.partial.apply(m,m.extend(null,arguments,1));
return MochiKit.Async.wait(_2be).addCallback(function(res){
return _2c1();
});
}});
MochiKit.Async.DeferredLock=function(){
this.waiting=[];
this.locked=false;
this.id=this._nextId();
};
MochiKit.Async.DeferredLock.prototype={__class__:MochiKit.Async.DeferredLock,acquire:function(){
var d=new MochiKit.Async.Deferred();
if(this.locked){
this.waiting.push(d);
}else{
this.locked=true;
d.callback(this);
}
return d;
},release:function(){
if(!this.locked){
throw TypeError("Tried to release an unlocked DeferredLock");
}
this.locked=false;
if(this.waiting.length>0){
this.locked=true;
this.waiting.shift().callback(this);
}
},_nextId:MochiKit.Base.counter(),repr:function(){
var _2c4;
if(this.locked){
_2c4="locked, "+this.waiting.length+" waiting";
}else{
_2c4="unlocked";
}
return "DeferredLock("+this.id+", "+_2c4+")";
},toString:MochiKit.Base.forwardCall("repr")};
MochiKit.Async.DeferredList=function(list,_2c6,_2c7,_2c8,_2c9){
MochiKit.Async.Deferred.apply(this,[_2c9]);
this.list=list;
var _2ca=[];
this.resultList=_2ca;
this.finishedCount=0;
this.fireOnOneCallback=_2c6;
this.fireOnOneErrback=_2c7;
this.consumeErrors=_2c8;
var cb=MochiKit.Base.bind(this._cbDeferred,this);
for(var i=0;i<list.length;i++){
var d=list[i];
_2ca.push(undefined);
d.addCallback(cb,i,true);
d.addErrback(cb,i,false);
}
if(list.length===0&&!_2c6){
this.callback(this.resultList);
}
};
MochiKit.Async.DeferredList.prototype=new MochiKit.Async.Deferred();
MochiKit.Async.DeferredList.prototype._cbDeferred=function(_2ce,_2cf,_2d0){
this.resultList[_2ce]=[_2cf,_2d0];
this.finishedCount+=1;
if(this.fired==-1){
if(_2cf&&this.fireOnOneCallback){
this.callback([_2ce,_2d0]);
}else{
if(!_2cf&&this.fireOnOneErrback){
this.errback(_2d0);
}else{
if(this.finishedCount==this.list.length){
this.callback(this.resultList);
}
}
}
}
if(!_2cf&&this.consumeErrors){
_2d0=null;
}
return _2d0;
};
MochiKit.Async.gatherResults=function(_2d1){
var d=new MochiKit.Async.DeferredList(_2d1,false,true,false);
d.addCallback(function(_2d3){
var ret=[];
for(var i=0;i<_2d3.length;i++){
ret.push(_2d3[i][1]);
}
return ret;
});
return d;
};
MochiKit.Async.maybeDeferred=function(func){
var self=MochiKit.Async;
var _2d8;
try{
var r=func.apply(null,MochiKit.Base.extend([],arguments,1));
if(r instanceof self.Deferred){
_2d8=r;
}else{
if(r instanceof Error){
_2d8=self.fail(r);
}else{
_2d8=self.succeed(r);
}
}
}
catch(e){
_2d8=self.fail(e);
}
return _2d8;
};
MochiKit.Async.EXPORT=["AlreadyCalledError","CancelledError","BrowserComplianceError","GenericError","XMLHttpRequestError","Deferred","succeed","fail","getXMLHttpRequest","doSimpleXMLHttpRequest","loadJSONDoc","wait","callLater","sendXMLHttpRequest","DeferredLock","DeferredList","gatherResults","maybeDeferred","doXHR"];
MochiKit.Async.EXPORT_OK=["evalJSONRequest"];
MochiKit.Async.__new__=function(){
var m=MochiKit.Base;
var ne=m.partial(m._newNamedError,this);
ne("AlreadyCalledError",function(_2dc){
this.deferred=_2dc;
});
ne("CancelledError",function(_2dd){
this.deferred=_2dd;
});
ne("BrowserComplianceError",function(msg){
this.message=msg;
});
ne("GenericError",function(msg){
this.message=msg;
});
ne("XMLHttpRequestError",function(req,msg){
this.req=req;
this.message=msg;
try{
this.number=req.status;
}
catch(e){
}
});
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
MochiKit.Async.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Async);
MochiKit.Base._deps("DOM",["Base"]);
MochiKit.DOM.NAME="MochiKit.DOM";
MochiKit.DOM.VERSION="1.4";
MochiKit.DOM.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.DOM.toString=function(){
return this.__repr__();
};
MochiKit.DOM.EXPORT=["removeEmptyTextNodes","formContents","currentWindow","currentDocument","withWindow","withDocument","registerDOMConverter","coerceToDOM","createDOM","createDOMFunc","isChildNode","getNodeAttribute","removeNodeAttribute","setNodeAttribute","updateNodeAttributes","appendChildNodes","insertSiblingNodesAfter","insertSiblingNodesBefore","replaceChildNodes","removeElement","swapDOM","BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","DL","DT","DD","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"];
MochiKit.DOM.EXPORT_OK=["domConverters"];
MochiKit.DOM.DEPRECATED=[["computedStyle","MochiKit.Style.getStyle","1.4"],["elementDimensions","MochiKit.Style.getElementDimensions","1.4"],["elementPosition","MochiKit.Style.getElementPosition","1.4"],["hideElement","MochiKit.Style.hideElement","1.4"],["setElementDimensions","MochiKit.Style.setElementDimensions","1.4"],["setElementPosition","MochiKit.Style.setElementPosition","1.4"],["setDisplayForElement","MochiKit.Style.setDisplayForElement","1.4"],["setOpacity","MochiKit.Style.setOpacity","1.4"],["showElement","MochiKit.Style.showElement","1.4"],["Coordinates","MochiKit.Style.Coordinates","1.4"],["Dimensions","MochiKit.Style.Dimensions","1.4"]];
MochiKit.DOM.getViewportDimensions=new Function(""+"if (!MochiKit[\"Style\"]) {"+"    throw new Error(\"This function has been deprecated and depends on MochiKit.Style.\");"+"}"+"return MochiKit.Style.getViewportDimensions.apply(this, arguments);");
MochiKit.Base.update(MochiKit.DOM,{currentWindow:function(){
return MochiKit.DOM._window;
},currentDocument:function(){
return MochiKit.DOM._document;
},withWindow:function(win,func){
var self=MochiKit.DOM;
var _2e5=self._document;
var _2e6=self._window;
var rval;
try{
self._window=win;
self._document=win.document;
rval=func();
}
catch(e){
self._window=_2e6;
self._document=_2e5;
throw e;
}
self._window=_2e6;
self._document=_2e5;
return rval;
},formContents:function(elem){
var _2e9=[];
var _2ea=[];
var m=MochiKit.Base;
var self=MochiKit.DOM;
if(typeof (elem)=="undefined"||elem===null){
elem=self._document.body;
}else{
elem=self.getElement(elem);
}
m.nodeWalk(elem,function(elem){
var name=elem.name;
if(m.isNotEmpty(name)){
var _2ef=elem.tagName.toUpperCase();
if(_2ef==="INPUT"&&(elem.type=="radio"||elem.type=="checkbox")&&!elem.checked){
return null;
}
if(_2ef==="SELECT"){
if(elem.type=="select-one"){
if(elem.selectedIndex>=0){
var opt=elem.options[elem.selectedIndex];
var v=opt.value;
if(!v){
var h=opt.outerHTML;
if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
v=opt.text;
}
}
_2e9.push(name);
_2ea.push(v);
return null;
}
_2e9.push(name);
_2ea.push("");
return null;
}else{
var opts=elem.options;
if(!opts.length){
_2e9.push(name);
_2ea.push("");
return null;
}
for(var i=0;i<opts.length;i++){
var opt=opts[i];
if(!opt.selected){
continue;
}
var v=opt.value;
if(!v){
var h=opt.outerHTML;
if(h&&!h.match(/^[^>]+\svalue\s*=/i)){
v=opt.text;
}
}
_2e9.push(name);
_2ea.push(v);
}
return null;
}
}
if(_2ef==="FORM"||_2ef==="P"||_2ef==="SPAN"||_2ef==="DIV"){
return elem.childNodes;
}
_2e9.push(name);
_2ea.push(elem.value||"");
return null;
}
return elem.childNodes;
});
return [_2e9,_2ea];
},withDocument:function(doc,func){
var self=MochiKit.DOM;
var _2f8=self._document;
var rval;
try{
self._document=doc;
rval=func();
}
catch(e){
self._document=_2f8;
throw e;
}
self._document=_2f8;
return rval;
},registerDOMConverter:function(name,_2fb,wrap,_2fd){
MochiKit.DOM.domConverters.register(name,_2fb,wrap,_2fd);
},coerceToDOM:function(node,ctx){
var m=MochiKit.Base;
var im=MochiKit.Iter;
var self=MochiKit.DOM;
if(im){
var iter=im.iter;
var _304=im.repeat;
var map=m.map;
}
var _306=self.domConverters;
var _307=arguments.callee;
var _308=m.NotFound;
while(true){
if(typeof (node)=="undefined"||node===null){
return null;
}
if(typeof (node)=="function"&&typeof (node.length)=="number"&&!(node instanceof Function)){
node=im.list(node);
}
if(typeof (node.nodeType)!="undefined"&&node.nodeType>0){
return node;
}
if(typeof (node)=="number"||typeof (node)=="boolean"){
node=node.toString();
}
if(typeof (node)=="string"){
return self._document.createTextNode(node);
}
if(typeof (node.__dom__)=="function"){
node=node.__dom__(ctx);
continue;
}
if(typeof (node.dom)=="function"){
node=node.dom(ctx);
continue;
}
if(typeof (node)=="function"){
node=node.apply(ctx,[ctx]);
continue;
}
if(im){
var _309=null;
try{
_309=iter(node);
}
catch(e){
}
if(_309){
return map(_307,_309,_304(ctx));
}
}
try{
node=_306.match(node,ctx);
continue;
}
catch(e){
if(e!=_308){
throw e;
}
}
return self._document.createTextNode(node.toString());
}
return undefined;
},isChildNode:function(node,_30b){
var self=MochiKit.DOM;
if(typeof (node)=="string"){
node=self.getElement(node);
}
if(typeof (_30b)=="string"){
_30b=self.getElement(_30b);
}
if(typeof (node)=="undefined"||node===null||node===self._document){
return false;
}
do{
if(node===_30b){
return true;
}
var _30d=node.tagName;
node=node.parentNode;
if(!_30d){
break;
}
_30d=_30d.toUpperCase();
}while(_30d!="BODY"&&_30d!="HTML");
return false;
},setNodeAttribute:function(node,attr,_310){
var o={};
o[attr]=_310;
try{
return MochiKit.DOM.updateNodeAttributes(node,o);
}
catch(e){
}
return null;
},getNodeAttribute:function(node,attr){
var self=MochiKit.DOM;
var _315=self.attributeArray.renames[attr];
node=self.getElement(node);
try{
if(_315){
return node[_315];
}
return node.getAttribute(attr);
}
catch(e){
}
return null;
},removeNodeAttribute:function(node,attr){
var self=MochiKit.DOM;
var _319=self.attributeArray.renames[attr];
node=self.getElement(node);
try{
if(_319){
return node[_319];
}
return node.removeAttribute(attr);
}
catch(e){
}
return null;
},updateNodeAttributes:function(node,_31b){
var elem=node;
var self=MochiKit.DOM;
if(typeof (node)=="string"){
elem=self.getElement(node);
}
if(_31b){
var _31e=MochiKit.Base.updatetree;
if(self.attributeArray.compliant){
for(var k in _31b){
var v=_31b[k];
if(typeof (v)=="object"&&typeof (elem[k])=="object"){
if(k=="style"&&MochiKit.Style){
MochiKit.Style.setStyle(elem,v);
}else{
_31e(elem[k],v);
}
}else{
if(k.substring(0,2)=="on"){
if(typeof (v)=="string"){
v=new Function(v);
}
elem[k]=v;
}else{
elem.setAttribute(k,v);
}
}
}
}else{
var _321=self.attributeArray.renames;
for(var k in _31b){
v=_31b[k];
var _322=_321[k];
if(k=="style"&&typeof (v)=="string"){
elem.style.cssText=v;
}else{
if(typeof (_322)=="string"){
elem[_322]=v;
}else{
if(typeof (elem[k])=="object"&&typeof (v)=="object"){
if(k=="style"&&MochiKit.Style){
MochiKit.Style.setStyle(elem,v);
}else{
_31e(elem[k],v);
}
}else{
if(k.substring(0,2)=="on"){
if(typeof (v)=="string"){
v=new Function(v);
}
elem[k]=v;
}else{
elem.setAttribute(k,v);
}
}
}
}
}
}
}
return elem;
},appendChildNodes:function(node){
var elem=node;
var self=MochiKit.DOM;
if(typeof (node)=="string"){
elem=self.getElement(node);
}
var _326=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
var _327=MochiKit.Base.concat;
while(_326.length){
var n=_326.shift();
if(typeof (n)=="undefined"||n===null){
}else{
if(typeof (n.nodeType)=="number"){
elem.appendChild(n);
}else{
_326=_327(n,_326);
}
}
}
return elem;
},insertSiblingNodesBefore:function(node){
var elem=node;
var self=MochiKit.DOM;
if(typeof (node)=="string"){
elem=self.getElement(node);
}
var _32c=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
var _32d=elem.parentNode;
var _32e=MochiKit.Base.concat;
while(_32c.length){
var n=_32c.shift();
if(typeof (n)=="undefined"||n===null){
}else{
if(typeof (n.nodeType)=="number"){
_32d.insertBefore(n,elem);
}else{
_32c=_32e(n,_32c);
}
}
}
return _32d;
},insertSiblingNodesAfter:function(node){
var elem=node;
var self=MochiKit.DOM;
if(typeof (node)=="string"){
elem=self.getElement(node);
}
var _333=[self.coerceToDOM(MochiKit.Base.extend(null,arguments,1),elem)];
if(elem.nextSibling){
return self.insertSiblingNodesBefore(elem.nextSibling,_333);
}else{
return self.appendChildNodes(elem.parentNode,_333);
}
},replaceChildNodes:function(node){
var elem=node;
var self=MochiKit.DOM;
if(typeof (node)=="string"){
elem=self.getElement(node);
arguments[0]=elem;
}
var _337;
while((_337=elem.firstChild)){
elem.removeChild(_337);
}
if(arguments.length<2){
return elem;
}else{
return self.appendChildNodes.apply(this,arguments);
}
},createDOM:function(name,_339){
var elem;
var self=MochiKit.DOM;
var m=MochiKit.Base;
if(typeof (_339)=="string"||typeof (_339)=="number"){
var args=m.extend([name,null],arguments,1);
return arguments.callee.apply(this,args);
}
if(typeof (name)=="string"){
var _33e=self._xhtml;
if(_339&&!self.attributeArray.compliant){
var _33f="";
if("name" in _339){
_33f+=" name=\""+self.escapeHTML(_339.name)+"\"";
}
if(name=="input"&&"type" in _339){
_33f+=" type=\""+self.escapeHTML(_339.type)+"\"";
}
if(_33f){
name="<"+name+_33f+">";
_33e=false;
}
}
var d=self._document;
if(_33e&&d===document){
elem=d.createElementNS("http://www.w3.org/1999/xhtml",name);
}else{
elem=d.createElement(name);
}
}else{
elem=name;
}
if(_339){
self.updateNodeAttributes(elem,_339);
}
if(arguments.length<=2){
return elem;
}else{
var args=m.extend([elem],arguments,2);
return self.appendChildNodes.apply(this,args);
}
},createDOMFunc:function(){
var m=MochiKit.Base;
return m.partial.apply(this,m.extend([MochiKit.DOM.createDOM],arguments));
},removeElement:function(elem){
var e=MochiKit.DOM.getElement(elem);
e.parentNode.removeChild(e);
return e;
},swapDOM:function(dest,src){
var self=MochiKit.DOM;
dest=self.getElement(dest);
var _347=dest.parentNode;
if(src){
src=self.getElement(src);
_347.replaceChild(src,dest);
}else{
_347.removeChild(dest);
}
return src;
},getElement:function(id){
var self=MochiKit.DOM;
if(arguments.length==1){
return ((typeof (id)=="string")?self._document.getElementById(id):id);
}else{
return MochiKit.Base.map(self.getElement,arguments);
}
},getElementsByTagAndClassName:function(_34a,_34b,_34c){
var self=MochiKit.DOM;
if(typeof (_34a)=="undefined"||_34a===null){
_34a="*";
}
if(typeof (_34c)=="undefined"||_34c===null){
_34c=self._document;
}
_34c=self.getElement(_34c);
var _34e=(_34c.getElementsByTagName(_34a)||self._document.all);
if(typeof (_34b)=="undefined"||_34b===null){
return MochiKit.Base.extend(null,_34e);
}
var _34f=[];
for(var i=0;i<_34e.length;i++){
var _351=_34e[i];
var cls=_351.className;
if(!cls){
continue;
}
var _353=cls.split(" ");
for(var j=0;j<_353.length;j++){
if(_353[j]==_34b){
_34f.push(_351);
break;
}
}
}
return _34f;
},_newCallStack:function(path,once){
var rval=function(){
var _358=arguments.callee.callStack;
for(var i=0;i<_358.length;i++){
if(_358[i].apply(this,arguments)===false){
break;
}
}
if(once){
try{
this[path]=null;
}
catch(e){
}
}
};
rval.callStack=[];
return rval;
},addToCallStack:function(_35a,path,func,once){
var self=MochiKit.DOM;
var _35f=_35a[path];
var _360=_35f;
if(!(typeof (_35f)=="function"&&typeof (_35f.callStack)=="object"&&_35f.callStack!==null)){
_360=self._newCallStack(path,once);
if(typeof (_35f)=="function"){
_360.callStack.push(_35f);
}
_35a[path]=_360;
}
_360.callStack.push(func);
},addLoadEvent:function(func){
var self=MochiKit.DOM;
self.addToCallStack(self._window,"onload",func,true);
},focusOnLoad:function(_363){
var self=MochiKit.DOM;
self.addLoadEvent(function(){
_363=self.getElement(_363);
if(_363){
_363.focus();
}
});
},setElementClass:function(_365,_366){
var self=MochiKit.DOM;
var obj=self.getElement(_365);
if(self.attributeArray.compliant){
obj.setAttribute("class",_366);
}else{
obj.setAttribute("className",_366);
}
},toggleElementClass:function(_369){
var self=MochiKit.DOM;
for(var i=1;i<arguments.length;i++){
var obj=self.getElement(arguments[i]);
if(!self.addElementClass(obj,_369)){
self.removeElementClass(obj,_369);
}
}
},addElementClass:function(_36d,_36e){
var self=MochiKit.DOM;
var obj=self.getElement(_36d);
var cls=obj.className;
if(cls==undefined||cls.length===0){
self.setElementClass(obj,_36e);
return true;
}
if(cls==_36e){
return false;
}
var _372=cls.split(" ");
for(var i=0;i<_372.length;i++){
if(_372[i]==_36e){
return false;
}
}
self.setElementClass(obj,cls+" "+_36e);
return true;
},removeElementClass:function(_374,_375){
var self=MochiKit.DOM;
var obj=self.getElement(_374);
var cls=obj.className;
if(cls==undefined||cls.length===0){
return false;
}
if(cls==_375){
self.setElementClass(obj,"");
return true;
}
var _379=cls.split(" ");
for(var i=0;i<_379.length;i++){
if(_379[i]==_375){
_379.splice(i,1);
self.setElementClass(obj,_379.join(" "));
return true;
}
}
return false;
},swapElementClass:function(_37b,_37c,_37d){
var obj=MochiKit.DOM.getElement(_37b);
var res=MochiKit.DOM.removeElementClass(obj,_37c);
if(res){
MochiKit.DOM.addElementClass(obj,_37d);
}
return res;
},hasElementClass:function(_380,_381){
var obj=MochiKit.DOM.getElement(_380);
var cls=obj.className;
if(!cls){
return false;
}
var _384=cls.split(" ");
for(var i=1;i<arguments.length;i++){
var good=false;
for(var j=0;j<_384.length;j++){
if(_384[j]==arguments[i]){
good=true;
break;
}
}
if(!good){
return false;
}
}
return true;
},escapeHTML:function(s){
return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
},toHTML:function(dom){
return MochiKit.DOM.emitHTML(dom).join("");
},emitHTML:function(dom,lst){
if(typeof (lst)=="undefined"||lst===null){
lst=[];
}
var _38c=[dom];
var self=MochiKit.DOM;
var _38e=self.escapeHTML;
var _38f=self.attributeArray;
while(_38c.length){
dom=_38c.pop();
if(typeof (dom)=="string"){
lst.push(dom);
}else{
if(dom.nodeType==1){
lst.push("<"+dom.tagName.toLowerCase());
var _390=[];
var _391=_38f(dom);
for(var i=0;i<_391.length;i++){
var a=_391[i];
_390.push([" ",a.name,"=\"",_38e(a.value),"\""]);
}
_390.sort();
for(i=0;i<_390.length;i++){
var _394=_390[i];
for(var j=0;j<_394.length;j++){
lst.push(_394[j]);
}
}
if(dom.hasChildNodes()){
lst.push(">");
_38c.push("</"+dom.tagName.toLowerCase()+">");
var _396=dom.childNodes;
for(i=_396.length-1;i>=0;i--){
_38c.push(_396[i]);
}
}else{
lst.push("/>");
}
}else{
if(dom.nodeType==3){
lst.push(_38e(dom.nodeValue));
}
}
}
}
return lst;
},scrapeText:function(node,_398){
var rval=[];
(function(node){
var cn=node.childNodes;
if(cn){
for(var i=0;i<cn.length;i++){
arguments.callee.call(this,cn[i]);
}
}
var _39d=node.nodeValue;
if(typeof (_39d)=="string"){
rval.push(_39d);
}
})(MochiKit.DOM.getElement(node));
if(_398){
return rval;
}else{
return rval.join("");
}
},removeEmptyTextNodes:function(_39e){
_39e=MochiKit.DOM.getElement(_39e);
for(var i=0;i<_39e.childNodes.length;i++){
var node=_39e.childNodes[i];
if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
node.parentNode.removeChild(node);
}
}
},makeClipping:function(_3a1){
_3a1=MochiKit.DOM.getElement(_3a1);
var _3a2=_3a1.style.overflow;
if((MochiKit.Style.getStyle(_3a1,"overflow")||"visible")!="hidden"){
_3a1.style.overflow="hidden";
}
return _3a2;
},undoClipping:function(_3a3,_3a4){
_3a3=MochiKit.DOM.getElement(_3a3);
if(!_3a4){
return;
}
_3a3.style.overflow=_3a4;
},makePositioned:function(_3a5){
_3a5=MochiKit.DOM.getElement(_3a5);
var pos=MochiKit.Style.getStyle(_3a5,"position");
if(pos=="static"||!pos){
_3a5.style.position="relative";
if(/Opera/.test(navigator.userAgent)){
_3a5.style.top=0;
_3a5.style.left=0;
}
}
},undoPositioned:function(_3a7){
_3a7=MochiKit.DOM.getElement(_3a7);
if(_3a7.style.position=="relative"){
_3a7.style.position=_3a7.style.top=_3a7.style.left=_3a7.style.bottom=_3a7.style.right="";
}
},getFirstElementByTagAndClassName:function(_3a8,_3a9,_3aa){
var self=MochiKit.DOM;
if(typeof (_3a8)=="undefined"||_3a8===null){
_3a8="*";
}
if(typeof (_3aa)=="undefined"||_3aa===null){
_3aa=self._document;
}
_3aa=self.getElement(_3aa);
var _3ac=(_3aa.getElementsByTagName(_3a8)||self._document.all);
if(typeof (_3a9)=="undefined"||_3a9===null){
return _3ac[0];
}
for(var i=0;i<_3ac.length;i++){
var _3ae=_3ac[i];
var _3af=_3ae.className.split(" ");
for(var j=0;j<_3af.length;j++){
if(_3af[j]==_3a9){
return _3ae;
}
}
}
},getFirstParentByTagAndClassName:function(elem,_3b2,_3b3){
var self=MochiKit.DOM;
elem=self.getElement(elem);
if(typeof (_3b2)=="undefined"||_3b2===null){
_3b2="*";
}else{
_3b2=_3b2.toUpperCase();
}
if(typeof (_3b3)=="undefined"||_3b3===null){
_3b3=null;
}
var _3b5="";
var _3b6="";
while(elem&&elem.tagName){
elem=elem.parentNode;
if(_3b2=="*"&&_3b3===null){
return elem;
}
_3b5=elem.className.split(" ");
_3b6=elem.tagName.toUpperCase();
if(_3b3===null&&_3b2==_3b6){
return elem;
}else{
if(_3b3!==null){
for(var i=0;i<_3b5.length;i++){
if(_3b2=="*"&&_3b5[i]==_3b3){
return elem;
}else{
if(_3b2==_3b6&&_3b5[i]==_3b3){
return elem;
}
}
}
}
}
}
return elem;
},isParent:function(_3b8,_3b9){
if(!_3b8.parentNode||_3b8==_3b9){
return false;
}
if(_3b8.parentNode==_3b9){
return true;
}
return MochiKit.DOM.isParent(_3b8.parentNode,_3b9);
},__new__:function(win){
var m=MochiKit.Base;
if(typeof (document)!="undefined"){
this._document=document;
var _3bc="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
this._xhtml=(document.documentElement&&document.createElementNS&&document.documentElement.namespaceURI===_3bc);
}else{
if(MochiKit.MockDOM){
this._document=MochiKit.MockDOM.document;
}
}
this._window=win;
this.domConverters=new m.AdapterRegistry();
var _3bd=this._document.createElement("span");
var _3be;
if(_3bd&&_3bd.attributes&&_3bd.attributes.length>0){
var _3bf=m.filter;
_3be=function(node){
return _3bf(_3be.ignoreAttrFilter,node.attributes);
};
_3be.ignoreAttr={};
var _3c1=_3bd.attributes;
var _3c2=_3be.ignoreAttr;
for(var i=0;i<_3c1.length;i++){
var a=_3c1[i];
_3c2[a.name]=a.value;
}
_3be.ignoreAttrFilter=function(a){
return (_3be.ignoreAttr[a.name]!=a.value);
};
_3be.compliant=false;
_3be.renames={"class":"className","checked":"defaultChecked","usemap":"useMap","for":"htmlFor","readonly":"readOnly","colspan":"colSpan","bgcolor":"bgColor","cellspacing":"cellSpacing","cellpadding":"cellPadding"};
}else{
_3be=function(node){
return node.attributes;
};
_3be.compliant=true;
_3be.renames={};
}
this.attributeArray=_3be;
var _3c7=function(_3c8,arr){
var _3ca=arr[1].split(".");
var str="";
var obj={};
str+="if (!MochiKit."+_3ca[1]+") { throw new Error(\"";
str+="This function has been deprecated and depends on MochiKit.";
str+=_3ca[1]+".\");}";
str+="return MochiKit."+_3ca[1]+"."+arr[0];
str+=".apply(this, arguments);";
obj[_3ca[2]]=new Function(str);
MochiKit.Base.update(MochiKit[_3c8],obj);
};
for(var i;i<MochiKit.DOM.DEPRECATED.length;i++){
_3c7("DOM",MochiKit.DOM.DEPRECATED[i]);
}
var _3cd=this.createDOMFunc;
this.UL=_3cd("ul");
this.OL=_3cd("ol");
this.LI=_3cd("li");
this.DL=_3cd("dl");
this.DT=_3cd("dt");
this.DD=_3cd("dd");
this.TD=_3cd("td");
this.TR=_3cd("tr");
this.TBODY=_3cd("tbody");
this.THEAD=_3cd("thead");
this.TFOOT=_3cd("tfoot");
this.TABLE=_3cd("table");
this.TH=_3cd("th");
this.INPUT=_3cd("input");
this.SPAN=_3cd("span");
this.A=_3cd("a");
this.DIV=_3cd("div");
this.IMG=_3cd("img");
this.BUTTON=_3cd("button");
this.TT=_3cd("tt");
this.PRE=_3cd("pre");
this.H1=_3cd("h1");
this.H2=_3cd("h2");
this.H3=_3cd("h3");
this.BR=_3cd("br");
this.HR=_3cd("hr");
this.LABEL=_3cd("label");
this.TEXTAREA=_3cd("textarea");
this.FORM=_3cd("form");
this.P=_3cd("p");
this.SELECT=_3cd("select");
this.OPTION=_3cd("option");
this.OPTGROUP=_3cd("optgroup");
this.LEGEND=_3cd("legend");
this.FIELDSET=_3cd("fieldset");
this.STRONG=_3cd("strong");
this.CANVAS=_3cd("canvas");
this.$=this.getElement;
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
}});
MochiKit.DOM.__new__(((typeof (window)=="undefined")?this:window));
if(MochiKit.__export__){
withWindow=MochiKit.DOM.withWindow;
withDocument=MochiKit.DOM.withDocument;
}
MochiKit.Base._exportSymbols(this,MochiKit.DOM);
MochiKit.Base._deps("Selector",["Base","DOM","Iter"]);
MochiKit.Selector.NAME="MochiKit.Selector";
MochiKit.Selector.VERSION="1.4";
MochiKit.Selector.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Selector.toString=function(){
return this.__repr__();
};
MochiKit.Selector.EXPORT=["Selector","findChildElements","findDocElements","$$"];
MochiKit.Selector.EXPORT_OK=[];
MochiKit.Selector.Selector=function(_3ce){
this.params={classNames:[],pseudoClassNames:[]};
this.expression=_3ce.toString().replace(/(^\s+|\s+$)/g,"");
this.parseExpression();
this.compileMatcher();
};
MochiKit.Selector.Selector.prototype={__class__:MochiKit.Selector.Selector,parseExpression:function(){
function abort(_3cf){
throw "Parse error in selector: "+_3cf;
}
if(this.expression==""){
abort("empty expression");
}
var repr=MochiKit.Base.repr;
var _3d1=this.params;
var expr=this.expression;
var _3d3,_3d4,_3d5,rest;
while(_3d3=expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)){
_3d1.attributes=_3d1.attributes||[];
_3d1.attributes.push({name:_3d3[2],operator:_3d3[3],value:_3d3[4]||_3d3[5]||""});
expr=_3d3[1];
}
if(expr=="*"){
return this.params.wildcard=true;
}
while(_3d3=expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)){
_3d4=_3d3[1];
_3d5=_3d3[2];
rest=_3d3[3];
switch(_3d4){
case "#":
_3d1.id=_3d5;
break;
case ".":
_3d1.classNames.push(_3d5);
break;
case ":":
_3d1.pseudoClassNames.push(_3d5);
break;
case "":
case undefined:
_3d1.tagName=_3d5.toUpperCase();
break;
default:
abort(repr(expr));
}
expr=rest;
}
if(expr.length>0){
abort(repr(expr));
}
},buildMatchExpression:function(){
var repr=MochiKit.Base.repr;
var _3d8=this.params;
var _3d9=[];
var _3da,i;
function childElements(_3dc){
return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, "+_3dc+".childNodes)";
}
if(_3d8.wildcard){
_3d9.push("true");
}
if(_3da=_3d8.id){
_3d9.push("element.id == "+repr(_3da));
}
if(_3da=_3d8.tagName){
_3d9.push("element.tagName.toUpperCase() == "+repr(_3da));
}
if((_3da=_3d8.classNames).length>0){
for(i=0;i<_3da.length;i++){
_3d9.push("MochiKit.DOM.hasElementClass(element, "+repr(_3da[i])+")");
}
}
if((_3da=_3d8.pseudoClassNames).length>0){
for(i=0;i<_3da.length;i++){
var _3dd=_3da[i].match(/^([^(]+)(?:\((.*)\))?$/);
var _3de=_3dd[1];
var _3df=_3dd[2];
switch(_3de){
case "root":
_3d9.push("element.nodeType == 9 || element === element.ownerDocument.documentElement");
break;
case "nth-child":
case "nth-last-child":
case "nth-of-type":
case "nth-last-of-type":
_3dd=_3df.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/);
if(!_3dd){
throw "Invalid argument to pseudo element nth-child: "+_3df;
}
var a,b;
if(_3dd[0]=="odd"){
a=2;
b=1;
}else{
if(_3dd[0]=="even"){
a=2;
b=0;
}else{
a=_3dd[2]&&parseInt(_3dd)||null;
b=parseInt(_3dd[3]);
}
}
_3d9.push("this.nthChild(element,"+a+","+b+","+!!_3de.match("^nth-last")+","+!!_3de.match("of-type$")+")");
break;
case "first-child":
_3d9.push("this.nthChild(element, null, 1)");
break;
case "last-child":
_3d9.push("this.nthChild(element, null, 1, true)");
break;
case "first-of-type":
_3d9.push("this.nthChild(element, null, 1, false, true)");
break;
case "last-of-type":
_3d9.push("this.nthChild(element, null, 1, true, true)");
break;
case "only-child":
_3d9.push(childElements("element.parentNode")+".length == 1");
break;
case "only-of-type":
_3d9.push("MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, "+childElements("element.parentNode")+").length == 1");
break;
case "empty":
_3d9.push("element.childNodes.length == 0");
break;
case "enabled":
_3d9.push("(this.isUIElement(element) && element.disabled === false)");
break;
case "disabled":
_3d9.push("(this.isUIElement(element) && element.disabled === true)");
break;
case "checked":
_3d9.push("(this.isUIElement(element) && element.checked === true)");
break;
case "not":
var _3e2=new MochiKit.Selector.Selector(_3df);
_3d9.push("!( "+_3e2.buildMatchExpression()+")");
break;
}
}
}
if(_3da=_3d8.attributes){
MochiKit.Base.map(function(_3e3){
var _3e4="MochiKit.DOM.getNodeAttribute(element, "+repr(_3e3.name)+")";
var _3e5=function(_3e6){
return _3e4+".split("+repr(_3e6)+")";
};
switch(_3e3.operator){
case "=":
_3d9.push(_3e4+" == "+repr(_3e3.value));
break;
case "~=":
_3d9.push(_3e4+" && MochiKit.Base.findValue("+_3e5(" ")+", "+repr(_3e3.value)+") > -1");
break;
case "^=":
_3d9.push(_3e4+".substring(0, "+_3e3.value.length+") == "+repr(_3e3.value));
break;
case "$=":
_3d9.push(_3e4+".substring("+_3e4+".length - "+_3e3.value.length+") == "+repr(_3e3.value));
break;
case "*=":
_3d9.push(_3e4+".match("+repr(_3e3.value)+")");
break;
case "|=":
_3d9.push(_3e4+" && "+_3e5("-")+"[0].toUpperCase() == "+repr(_3e3.value.toUpperCase()));
break;
case "!=":
_3d9.push(_3e4+" != "+repr(_3e3.value));
break;
case "":
case undefined:
_3d9.push(_3e4+" != null");
break;
default:
throw "Unknown operator "+_3e3.operator+" in selector";
}
},_3da);
}
return _3d9.join(" && ");
},compileMatcher:function(){
this.match=new Function("element","if (!element.tagName) return false;                 return "+this.buildMatchExpression());
},nthChild:function(_3e7,a,b,_3ea,_3eb){
var _3ec=MochiKit.Base.filter(function(node){
return node.nodeType==1;
},_3e7.parentNode.childNodes);
if(_3eb){
_3ec=MochiKit.Base.filter(function(node){
return node.tagName==_3e7.tagName;
},_3ec);
}
if(_3ea){
_3ec=MochiKit.Iter.reversed(_3ec);
}
if(a){
var _3ef=MochiKit.Base.findIdentical(_3ec,_3e7);
return ((_3ef+1-b)/a)%1==0;
}else{
return b==MochiKit.Base.findIdentical(_3ec,_3e7)+1;
}
},isUIElement:function(_3f0){
return MochiKit.Base.findValue(["input","button","select","option","textarea","object"],_3f0.tagName.toLowerCase())>-1;
},findElements:function(_3f1,axis){
var _3f3;
if(axis==undefined){
axis="";
}
function inScope(_3f4,_3f5){
if(axis==""){
return MochiKit.DOM.isChildNode(_3f4,_3f5);
}else{
if(axis==">"){
return _3f4.parentNode==_3f5;
}else{
if(axis=="+"){
return _3f4==nextSiblingElement(_3f5);
}else{
if(axis=="~"){
var _3f6=_3f5;
while(_3f6=nextSiblingElement(_3f6)){
if(_3f4==_3f6){
return true;
}
}
return false;
}else{
throw "Invalid axis: "+axis;
}
}
}
}
}
if(_3f3=MochiKit.DOM.getElement(this.params.id)){
if(this.match(_3f3)){
if(!_3f1||inScope(_3f3,_3f1)){
return [_3f3];
}
}
}
function nextSiblingElement(node){
node=node.nextSibling;
while(node&&node.nodeType!=1){
node=node.nextSibling;
}
return node;
}
if(axis==""){
_3f1=(_3f1||MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName||"*");
}else{
if(axis==">"){
if(!_3f1){
throw "> combinator not allowed without preceeding expression";
}
_3f1=MochiKit.Base.filter(function(node){
return node.nodeType==1;
},_3f1.childNodes);
}else{
if(axis=="+"){
if(!_3f1){
throw "+ combinator not allowed without preceeding expression";
}
_3f1=nextSiblingElement(_3f1)&&[nextSiblingElement(_3f1)];
}else{
if(axis=="~"){
if(!_3f1){
throw "~ combinator not allowed without preceeding expression";
}
var _3f9=[];
while(nextSiblingElement(_3f1)){
_3f1=nextSiblingElement(_3f1);
_3f9.push(_3f1);
}
_3f1=_3f9;
}
}
}
}
if(!_3f1){
return [];
}
var _3fa=MochiKit.Base.filter(MochiKit.Base.bind(function(_3fb){
return this.match(_3fb);
},this),_3f1);
return _3fa;
},repr:function(){
return "Selector("+this.expression+")";
},toString:MochiKit.Base.forwardCall("repr")};
MochiKit.Base.update(MochiKit.Selector,{findChildElements:function(_3fc,_3fd){
return MochiKit.Base.flattenArray(MochiKit.Base.map(function(_3fe){
var _3ff="";
return MochiKit.Iter.reduce(function(_400,expr){
if(match=expr.match(/^[>+~]$/)){
_3ff=match[0];
return _400;
}else{
var _402=new MochiKit.Selector.Selector(expr);
var _403=MochiKit.Iter.reduce(function(_404,_405){
return MochiKit.Base.extend(_404,_402.findElements(_405||_3fc,_3ff));
},_400,[]);
_3ff="";
return _403;
}
},_3fe.replace(/(^\s+|\s+$)/g,"").split(/\s+/),[null]);
},_3fd));
},findDocElements:function(){
return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(),arguments);
},__new__:function(){
var m=MochiKit.Base;
this.$$=this.findDocElements;
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
}});
MochiKit.Selector.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Selector);
MochiKit.Base._deps("Style",["Base","DOM"]);
MochiKit.Style.NAME="MochiKit.Style";
MochiKit.Style.VERSION="1.4";
MochiKit.Style.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Style.toString=function(){
return this.__repr__();
};
MochiKit.Style.EXPORT_OK=[];
MochiKit.Style.EXPORT=["setStyle","setOpacity","getStyle","getElementDimensions","elementDimensions","setElementDimensions","getElementPosition","elementPosition","setElementPosition","setDisplayForElement","hideElement","showElement","getViewportDimensions","getViewportPosition","Dimensions","Coordinates"];
MochiKit.Style.Dimensions=function(w,h){
this.w=w;
this.h=h;
};
MochiKit.Style.Dimensions.prototype.__repr__=function(){
var repr=MochiKit.Base.repr;
return "{w: "+repr(this.w)+", h: "+repr(this.h)+"}";
};
MochiKit.Style.Dimensions.prototype.toString=function(){
return this.__repr__();
};
MochiKit.Style.Coordinates=function(x,y){
this.x=x;
this.y=y;
};
MochiKit.Style.Coordinates.prototype.__repr__=function(){
var repr=MochiKit.Base.repr;
return "{x: "+repr(this.x)+", y: "+repr(this.y)+"}";
};
MochiKit.Style.Coordinates.prototype.toString=function(){
return this.__repr__();
};
MochiKit.Base.update(MochiKit.Style,{getStyle:function(elem,_40e){
var dom=MochiKit.DOM;
var d=dom._document;
elem=dom.getElement(elem);
_40e=MochiKit.Base.camelize(_40e);
if(!elem||elem==d){
return undefined;
}
if(_40e=="opacity"&&elem.filters){
var _411=(MochiKit.Style.getStyle(elem,"filter")||"").match(/alpha\(opacity=(.*)\)/);
if(_411&&_411[1]){
return parseFloat(_411[1])/100;
}
return 1;
}
var _412=elem.style?elem.style[_40e]:null;
if(!_412){
if(d.defaultView&&d.defaultView.getComputedStyle){
var css=d.defaultView.getComputedStyle(elem,null);
_40e=_40e.replace(/([A-Z])/g,"-$1").toLowerCase();
_412=css?css.getPropertyValue(_40e):null;
}else{
if(elem.currentStyle){
_412=elem.currentStyle[_40e];
}
}
}
if(_40e=="opacity"){
_412=parseFloat(_412);
}
if(/Opera/.test(navigator.userAgent)&&(MochiKit.Base.find(["left","top","right","bottom"],_40e)!=-1)){
if(MochiKit.Style.getStyle(elem,"position")=="static"){
_412="auto";
}
}
return _412=="auto"?null:_412;
},setStyle:function(elem,_415){
elem=MochiKit.DOM.getElement(elem);
for(var name in _415){
if(name=="opacity"){
MochiKit.Style.setOpacity(elem,_415[name]);
}else{
elem.style[MochiKit.Base.camelize(name)]=_415[name];
}
}
},setOpacity:function(elem,o){
elem=MochiKit.DOM.getElement(elem);
var self=MochiKit.Style;
if(o==1){
var _41a=/Gecko/.test(navigator.userAgent)&&!(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent));
elem.style["opacity"]=_41a?0.999999:1;
if(/MSIE/.test(navigator.userAgent)){
elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"");
}
}else{
if(o<0.00001){
o=0;
}
elem.style["opacity"]=o;
if(/MSIE/.test(navigator.userAgent)){
elem.style["filter"]=self.getStyle(elem,"filter").replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+o*100+")";
}
}
},getElementPosition:function(elem,_41c){
var self=MochiKit.Style;
var dom=MochiKit.DOM;
elem=dom.getElement(elem);
if(!elem||(!(elem.x&&elem.y)&&(!elem.parentNode===null||self.getStyle(elem,"display")=="none"))){
return undefined;
}
var c=new self.Coordinates(0,0);
var box=null;
var _421=null;
var d=MochiKit.DOM._document;
var de=d.documentElement;
var b=d.body;
if(!elem.parentNode&&elem.x&&elem.y){
c.x+=elem.x||0;
c.y+=elem.y||0;
}else{
if(elem.getBoundingClientRect){
box=elem.getBoundingClientRect();
c.x+=box.left+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
c.y+=box.top+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
return c;
}else{
if(elem.offsetParent){
c.x+=elem.offsetLeft;
c.y+=elem.offsetTop;
_421=elem.offsetParent;
if(_421!=elem){
while(_421){
c.x+=_421.offsetLeft;
c.y+=_421.offsetTop;
_421=_421.offsetParent;
}
}
var ua=navigator.userAgent.toLowerCase();
if((typeof (opera)!="undefined"&&parseFloat(opera.version())<9)||(ua.indexOf("AppleWebKit")!=-1&&self.getStyle(elem,"position")=="absolute")){
c.x-=b.offsetLeft;
c.y-=b.offsetTop;
}
}
}
}
if(typeof (_41c)!="undefined"){
_41c=arguments.callee(_41c);
if(_41c){
c.x-=(_41c.x||0);
c.y-=(_41c.y||0);
}
}
if(elem.parentNode){
_421=elem.parentNode;
}else{
_421=null;
}
while(_421){
var _426=_421.tagName.toUpperCase();
if(_426==="BODY"||_426==="HTML"){
break;
}
var disp=self.getStyle(_421,"display");
if(disp.search(/^inline|table-row.*$/i)){
c.x-=_421.scrollLeft;
c.y-=_421.scrollTop;
}
if(_421.parentNode){
_421=_421.parentNode;
}else{
_421=null;
}
}
return c;
},setElementPosition:function(elem,_429,_42a){
elem=MochiKit.DOM.getElement(elem);
if(typeof (_42a)=="undefined"){
_42a="px";
}
var _42b={};
var _42c=MochiKit.Base.isUndefinedOrNull;
if(!_42c(_429.x)){
_42b["left"]=_429.x+_42a;
}
if(!_42c(_429.y)){
_42b["top"]=_429.y+_42a;
}
MochiKit.DOM.updateNodeAttributes(elem,{"style":_42b});
},getElementDimensions:function(elem){
var self=MochiKit.Style;
var dom=MochiKit.DOM;
if(typeof (elem.w)=="number"||typeof (elem.h)=="number"){
return new self.Dimensions(elem.w||0,elem.h||0);
}
elem=dom.getElement(elem);
if(!elem){
return undefined;
}
var disp=self.getStyle(elem,"display");
if(disp!="none"&&disp!==""&&typeof (disp)!="undefined"){
return new self.Dimensions(elem.offsetWidth||0,elem.offsetHeight||0);
}
var s=elem.style;
var _432=s.visibility;
var _433=s.position;
s.visibility="hidden";
s.position="absolute";
s.display="";
var _434=elem.offsetWidth;
var _435=elem.offsetHeight;
s.display="none";
s.position=_433;
s.visibility=_432;
return new self.Dimensions(_434,_435);
},setElementDimensions:function(elem,_437,_438){
elem=MochiKit.DOM.getElement(elem);
if(typeof (_438)=="undefined"){
_438="px";
}
var _439={};
var _43a=MochiKit.Base.isUndefinedOrNull;
if(!_43a(_437.w)){
_439["width"]=_437.w+_438;
}
if(!_43a(_437.h)){
_439["height"]=_437.h+_438;
}
MochiKit.DOM.updateNodeAttributes(elem,{"style":_439});
},setDisplayForElement:function(_43b,_43c){
var _43d=MochiKit.Base.extend(null,arguments,1);
var _43e=MochiKit.DOM.getElement;
for(var i=0;i<_43d.length;i++){
_43c=_43e(_43d[i]);
if(_43c){
_43c.style.display=_43b;
}
}
},getViewportDimensions:function(){
var d=new MochiKit.Style.Dimensions();
var w=MochiKit.DOM._window;
var b=MochiKit.DOM._document.body;
if(w.innerWidth){
d.w=w.innerWidth;
d.h=w.innerHeight;
}else{
if(b.parentElement.clientWidth){
d.w=b.parentElement.clientWidth;
d.h=b.parentElement.clientHeight;
}else{
if(b&&b.clientWidth){
d.w=b.clientWidth;
d.h=b.clientHeight;
}
}
}
return d;
},getViewportPosition:function(){
var c=new MochiKit.Style.Coordinates(0,0);
var d=MochiKit.DOM._document;
var de=d.documentElement;
var db=d.body;
if(de&&(de.scrollTop||de.scrollLeft)){
c.x=de.scrollLeft;
c.y=de.scrollTop;
}else{
if(db){
c.x=db.scrollLeft;
c.y=db.scrollTop;
}
}
return c;
},__new__:function(){
var m=MochiKit.Base;
this.elementPosition=this.getElementPosition;
this.elementDimensions=this.getElementDimensions;
this.hideElement=m.partial(this.setDisplayForElement,"none");
this.showElement=m.partial(this.setDisplayForElement,"block");
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
}});
MochiKit.Style.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Style);
MochiKit.Base._deps("LoggingPane",["Base","Logging"]);
MochiKit.LoggingPane.NAME="MochiKit.LoggingPane";
MochiKit.LoggingPane.VERSION="1.4";
MochiKit.LoggingPane.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.LoggingPane.toString=function(){
return this.__repr__();
};
MochiKit.LoggingPane.createLoggingPane=function(_448){
var m=MochiKit.LoggingPane;
_448=!(!_448);
if(m._loggingPane&&m._loggingPane.inline!=_448){
m._loggingPane.closePane();
m._loggingPane=null;
}
if(!m._loggingPane||m._loggingPane.closed){
m._loggingPane=new m.LoggingPane(_448,MochiKit.Logging.logger);
}
return m._loggingPane;
};
MochiKit.LoggingPane.LoggingPane=function(_44a,_44b){
if(typeof (_44b)=="undefined"||_44b===null){
_44b=MochiKit.Logging.logger;
}
this.logger=_44b;
var _44c=MochiKit.Base.update;
var _44d=MochiKit.Base.updatetree;
var bind=MochiKit.Base.bind;
var _44f=MochiKit.Base.clone;
var win=window;
var uid="_MochiKit_LoggingPane";
if(typeof (MochiKit.DOM)!="undefined"){
win=MochiKit.DOM.currentWindow();
}
if(!_44a){
var url=win.location.href.split("?")[0].replace(/[#:\/.>&<-]/g,"_");
var name=uid+"_"+url;
var nwin=win.open("",name,"dependent,resizable,height=200");
if(!nwin){
alert("Not able to open debugging window due to pop-up blocking.");
return undefined;
}
nwin.document.write("\x3c!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" "+"\"http://www.w3.org/TR/html4/loose.dtd\">"+"\x3chtml>\x3chead>\x3ctitle>[MochiKit.LoggingPane]\x3c/title>\x3c/head>"+"\x3cbody>\x3c/body>\x3c/html>");
nwin.document.close();
nwin.document.title+=" "+win.document.title;
win=nwin;
}
var doc=win.document;
this.doc=doc;
var _456=doc.getElementById(uid);
var _457=!!_456;
if(_456&&typeof (_456.loggingPane)!="undefined"){
_456.loggingPane.logger=this.logger;
_456.loggingPane.buildAndApplyFilter();
return _456.loggingPane;
}
if(_457){
var _458;
while((_458=_456.firstChild)){
_456.removeChild(_458);
}
}else{
_456=doc.createElement("div");
_456.id=uid;
}
_456.loggingPane=this;
var _459=doc.createElement("input");
var _45a=doc.createElement("input");
var _45b=doc.createElement("button");
var _45c=doc.createElement("button");
var _45d=doc.createElement("button");
var _45e=doc.createElement("button");
var _45f=doc.createElement("div");
var _460=doc.createElement("div");
var _461=uid+"_Listener";
this.colorTable=_44f(this.colorTable);
var _462=[];
var _463=null;
var _464=function(msg){
var _466=msg.level;
if(typeof (_466)=="number"){
_466=MochiKit.Logging.LogLevel[_466];
}
return _466;
};
var _467=function(msg){
return msg.info.join(" ");
};
var _469=bind(function(msg){
var _46b=_464(msg);
var text=_467(msg);
var c=this.colorTable[_46b];
var p=doc.createElement("span");
p.className="MochiKit-LogMessage MochiKit-LogLevel-"+_46b;
p.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;
p.appendChild(doc.createTextNode(_46b+": "+text));
_460.appendChild(p);
_460.appendChild(doc.createElement("br"));
if(_45f.offsetHeight>_45f.scrollHeight){
_45f.scrollTop=0;
}else{
_45f.scrollTop=_45f.scrollHeight;
}
},this);
var _46f=function(msg){
_462[_462.length]=msg;
_469(msg);
};
var _471=function(){
var _472,_473;
try{
_472=new RegExp(_459.value);
_473=new RegExp(_45a.value);
}
catch(e){
logDebug("Error in filter regex: "+e.message);
return null;
}
return function(msg){
return (_472.test(_464(msg))&&_473.test(_467(msg)));
};
};
var _475=function(){
while(_460.firstChild){
_460.removeChild(_460.firstChild);
}
};
var _476=function(){
_462=[];
_475();
};
var _477=bind(function(){
if(this.closed){
return;
}
this.closed=true;
if(MochiKit.LoggingPane._loggingPane==this){
MochiKit.LoggingPane._loggingPane=null;
}
this.logger.removeListener(_461);
try{
try{
_456.loggingPane=null;
}
catch(e){
logFatal("Bookmarklet was closed incorrectly.");
}
if(_44a){
_456.parentNode.removeChild(_456);
}else{
this.win.close();
}
}
catch(e){
}
},this);
var _478=function(){
_475();
for(var i=0;i<_462.length;i++){
var msg=_462[i];
if(_463===null||_463(msg)){
_469(msg);
}
}
};
this.buildAndApplyFilter=function(){
_463=_471();
_478();
this.logger.removeListener(_461);
this.logger.addListener(_461,_463,_46f);
};
var _47b=bind(function(){
_462=this.logger.getMessages();
_478();
},this);
var _47c=bind(function(_47d){
_47d=_47d||window.event;
key=_47d.which||_47d.keyCode;
if(key==13){
this.buildAndApplyFilter();
}
},this);
var _47e="display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: "+this.logFont;
if(_44a){
_47e+="; height: 10em; border-top: 2px solid black";
}else{
_47e+="; height: 100%;";
}
_456.style.cssText=_47e;
if(!_457){
doc.body.appendChild(_456);
}
_47e={"cssText":"width: 33%; display: inline; font: "+this.logFont};
_44d(_459,{"value":"FATAL|ERROR|WARNING|INFO|DEBUG","onkeypress":_47c,"style":_47e});
_456.appendChild(_459);
_44d(_45a,{"value":".*","onkeypress":_47c,"style":_47e});
_456.appendChild(_45a);
_47e="width: 8%; display:inline; font: "+this.logFont;
_45b.appendChild(doc.createTextNode("Filter"));
_45b.onclick=bind("buildAndApplyFilter",this);
_45b.style.cssText=_47e;
_456.appendChild(_45b);
_45c.appendChild(doc.createTextNode("Load"));
_45c.onclick=_47b;
_45c.style.cssText=_47e;
_456.appendChild(_45c);
_45d.appendChild(doc.createTextNode("Clear"));
_45d.onclick=_476;
_45d.style.cssText=_47e;
_456.appendChild(_45d);
_45e.appendChild(doc.createTextNode("Close"));
_45e.onclick=_477;
_45e.style.cssText=_47e;
_456.appendChild(_45e);
_45f.style.cssText="overflow: auto; width: 100%";
_460.style.cssText="width: 100%; height: "+(_44a?"8em":"100%");
_45f.appendChild(_460);
_456.appendChild(_45f);
this.buildAndApplyFilter();
_47b();
if(_44a){
this.win=undefined;
}else{
this.win=win;
}
this.inline=_44a;
this.closePane=_477;
this.closed=false;
return this;
};
MochiKit.LoggingPane.LoggingPane.prototype={"logFont":"8pt Verdana,sans-serif","colorTable":{"ERROR":"red","FATAL":"darkred","WARNING":"blue","INFO":"black","DEBUG":"green"}};
MochiKit.LoggingPane.EXPORT_OK=["LoggingPane"];
MochiKit.LoggingPane.EXPORT=["createLoggingPane"];
MochiKit.LoggingPane.__new__=function(){
this.EXPORT_TAGS={":common":this.EXPORT,":all":MochiKit.Base.concat(this.EXPORT,this.EXPORT_OK)};
MochiKit.Base.nameFunctions(this);
MochiKit.LoggingPane._loggingPane=null;
};
MochiKit.LoggingPane.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.LoggingPane);
MochiKit.Base._deps("Color",["Base","DOM","Style"]);
MochiKit.Color.NAME="MochiKit.Color";
MochiKit.Color.VERSION="1.4";
MochiKit.Color.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Color.toString=function(){
return this.__repr__();
};
MochiKit.Color.Color=function(red,_480,blue,_482){
if(typeof (_482)=="undefined"||_482===null){
_482=1;
}
this.rgb={r:red,g:_480,b:blue,a:_482};
};
MochiKit.Color.Color.prototype={__class__:MochiKit.Color.Color,colorWithAlpha:function(_483){
var rgb=this.rgb;
var m=MochiKit.Color;
return m.Color.fromRGB(rgb.r,rgb.g,rgb.b,_483);
},colorWithHue:function(hue){
var hsl=this.asHSL();
hsl.h=hue;
var m=MochiKit.Color;
return m.Color.fromHSL(hsl);
},colorWithSaturation:function(_489){
var hsl=this.asHSL();
hsl.s=_489;
var m=MochiKit.Color;
return m.Color.fromHSL(hsl);
},colorWithLightness:function(_48c){
var hsl=this.asHSL();
hsl.l=_48c;
var m=MochiKit.Color;
return m.Color.fromHSL(hsl);
},darkerColorWithLevel:function(_48f){
var hsl=this.asHSL();
hsl.l=Math.max(hsl.l-_48f,0);
var m=MochiKit.Color;
return m.Color.fromHSL(hsl);
},lighterColorWithLevel:function(_492){
var hsl=this.asHSL();
hsl.l=Math.min(hsl.l+_492,1);
var m=MochiKit.Color;
return m.Color.fromHSL(hsl);
},blendedColor:function(_495,_496){
if(typeof (_496)=="undefined"||_496===null){
_496=0.5;
}
var sf=1-_496;
var s=this.rgb;
var d=_495.rgb;
var df=_496;
return MochiKit.Color.Color.fromRGB((s.r*sf)+(d.r*df),(s.g*sf)+(d.g*df),(s.b*sf)+(d.b*df),(s.a*sf)+(d.a*df));
},compareRGB:function(_49b){
var a=this.asRGB();
var b=_49b.asRGB();
return MochiKit.Base.compare([a.r,a.g,a.b,a.a],[b.r,b.g,b.b,b.a]);
},isLight:function(){
return this.asHSL().b>0.5;
},isDark:function(){
return (!this.isLight());
},toHSLString:function(){
var c=this.asHSL();
var ccc=MochiKit.Color.clampColorComponent;
var rval=this._hslString;
if(!rval){
var mid=(ccc(c.h,360).toFixed(0)+","+ccc(c.s,100).toPrecision(4)+"%"+","+ccc(c.l,100).toPrecision(4)+"%");
var a=c.a;
if(a>=1){
a=1;
rval="hsl("+mid+")";
}else{
if(a<=0){
a=0;
}
rval="hsla("+mid+","+a+")";
}
this._hslString=rval;
}
return rval;
},toRGBString:function(){
var c=this.rgb;
var ccc=MochiKit.Color.clampColorComponent;
var rval=this._rgbString;
if(!rval){
var mid=(ccc(c.r,255).toFixed(0)+","+ccc(c.g,255).toFixed(0)+","+ccc(c.b,255).toFixed(0));
if(c.a!=1){
rval="rgba("+mid+","+c.a+")";
}else{
rval="rgb("+mid+")";
}
this._rgbString=rval;
}
return rval;
},asRGB:function(){
return MochiKit.Base.clone(this.rgb);
},toHexString:function(){
var m=MochiKit.Color;
var c=this.rgb;
var ccc=MochiKit.Color.clampColorComponent;
var rval=this._hexString;
if(!rval){
rval=("#"+m.toColorPart(ccc(c.r,255))+m.toColorPart(ccc(c.g,255))+m.toColorPart(ccc(c.b,255)));
this._hexString=rval;
}
return rval;
},asHSV:function(){
var hsv=this.hsv;
var c=this.rgb;
if(typeof (hsv)=="undefined"||hsv===null){
hsv=MochiKit.Color.rgbToHSV(this.rgb);
this.hsv=hsv;
}
return MochiKit.Base.clone(hsv);
},asHSL:function(){
var hsl=this.hsl;
var c=this.rgb;
if(typeof (hsl)=="undefined"||hsl===null){
hsl=MochiKit.Color.rgbToHSL(this.rgb);
this.hsl=hsl;
}
return MochiKit.Base.clone(hsl);
},toString:function(){
return this.toRGBString();
},repr:function(){
var c=this.rgb;
var col=[c.r,c.g,c.b,c.a];
return this.__class__.NAME+"("+col.join(", ")+")";
}};
MochiKit.Base.update(MochiKit.Color.Color,{fromRGB:function(red,_4b2,blue,_4b4){
var _4b5=MochiKit.Color.Color;
if(arguments.length==1){
var rgb=red;
red=rgb.r;
_4b2=rgb.g;
blue=rgb.b;
if(typeof (rgb.a)=="undefined"){
_4b4=undefined;
}else{
_4b4=rgb.a;
}
}
return new _4b5(red,_4b2,blue,_4b4);
},fromHSL:function(hue,_4b8,_4b9,_4ba){
var m=MochiKit.Color;
return m.Color.fromRGB(m.hslToRGB.apply(m,arguments));
},fromHSV:function(hue,_4bd,_4be,_4bf){
var m=MochiKit.Color;
return m.Color.fromRGB(m.hsvToRGB.apply(m,arguments));
},fromName:function(name){
var _4c2=MochiKit.Color.Color;
if(name.charAt(0)=="\""){
name=name.substr(1,name.length-2);
}
var _4c3=_4c2._namedColors[name.toLowerCase()];
if(typeof (_4c3)=="string"){
return _4c2.fromHexString(_4c3);
}else{
if(name=="transparent"){
return _4c2.transparentColor();
}
}
return null;
},fromString:function(_4c4){
var self=MochiKit.Color.Color;
var _4c6=_4c4.substr(0,3);
if(_4c6=="rgb"){
return self.fromRGBString(_4c4);
}else{
if(_4c6=="hsl"){
return self.fromHSLString(_4c4);
}else{
if(_4c4.charAt(0)=="#"){
return self.fromHexString(_4c4);
}
}
}
return self.fromName(_4c4);
},fromHexString:function(_4c7){
if(_4c7.charAt(0)=="#"){
_4c7=_4c7.substring(1);
}
var _4c8=[];
var i,hex;
if(_4c7.length==3){
for(i=0;i<3;i++){
hex=_4c7.substr(i,1);
_4c8.push(parseInt(hex+hex,16)/255);
}
}else{
for(i=0;i<6;i+=2){
hex=_4c7.substr(i,2);
_4c8.push(parseInt(hex,16)/255);
}
}
var _4cb=MochiKit.Color.Color;
return _4cb.fromRGB.apply(_4cb,_4c8);
},_fromColorString:function(pre,_4cd,_4ce,_4cf){
if(_4cf.indexOf(pre)===0){
_4cf=_4cf.substring(_4cf.indexOf("(",3)+1,_4cf.length-1);
}
var _4d0=_4cf.split(/\s*,\s*/);
var _4d1=[];
for(var i=0;i<_4d0.length;i++){
var c=_4d0[i];
var val;
var _4d5=c.substring(c.length-3);
if(c.charAt(c.length-1)=="%"){
val=0.01*parseFloat(c.substring(0,c.length-1));
}else{
if(_4d5=="deg"){
val=parseFloat(c)/360;
}else{
if(_4d5=="rad"){
val=parseFloat(c)/(Math.PI*2);
}else{
val=_4ce[i]*parseFloat(c);
}
}
}
_4d1.push(val);
}
return this[_4cd].apply(this,_4d1);
},fromComputedStyle:function(elem,_4d7){
var d=MochiKit.DOM;
var cls=MochiKit.Color.Color;
for(elem=d.getElement(elem);elem;elem=elem.parentNode){
var _4da=MochiKit.Style.getStyle.apply(d,arguments);
if(!_4da){
continue;
}
var _4db=cls.fromString(_4da);
if(!_4db){
break;
}
if(_4db.asRGB().a>0){
return _4db;
}
}
return null;
},fromBackground:function(elem){
var cls=MochiKit.Color.Color;
return cls.fromComputedStyle(elem,"backgroundColor","background-color")||cls.whiteColor();
},fromText:function(elem){
var cls=MochiKit.Color.Color;
return cls.fromComputedStyle(elem,"color","color")||cls.blackColor();
},namedColors:function(){
return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
}});
MochiKit.Base.update(MochiKit.Color,{clampColorComponent:function(v,_4e1){
v*=_4e1;
if(v<0){
return 0;
}else{
if(v>_4e1){
return _4e1;
}else{
return v;
}
}
},_hslValue:function(n1,n2,hue){
if(hue>6){
hue-=6;
}else{
if(hue<0){
hue+=6;
}
}
var val;
if(hue<1){
val=n1+(n2-n1)*hue;
}else{
if(hue<3){
val=n2;
}else{
if(hue<4){
val=n1+(n2-n1)*(4-hue);
}else{
val=n1;
}
}
}
return val;
},hsvToRGB:function(hue,_4e7,_4e8,_4e9){
if(arguments.length==1){
var hsv=hue;
hue=hsv.h;
_4e7=hsv.s;
_4e8=hsv.v;
_4e9=hsv.a;
}
var red;
var _4ec;
var blue;
if(_4e7===0){
red=_4e8;
_4ec=_4e8;
blue=_4e8;
}else{
var i=Math.floor(hue*6);
var f=(hue*6)-i;
var p=_4e8*(1-_4e7);
var q=_4e8*(1-(_4e7*f));
var t=_4e8*(1-(_4e7*(1-f)));
switch(i){
case 1:
red=q;
_4ec=_4e8;
blue=p;
break;
case 2:
red=p;
_4ec=_4e8;
blue=t;
break;
case 3:
red=p;
_4ec=q;
blue=_4e8;
break;
case 4:
red=t;
_4ec=p;
blue=_4e8;
break;
case 5:
red=_4e8;
_4ec=p;
blue=q;
break;
case 6:
case 0:
red=_4e8;
_4ec=t;
blue=p;
break;
}
}
return {r:red,g:_4ec,b:blue,a:_4e9};
},hslToRGB:function(hue,_4f4,_4f5,_4f6){
if(arguments.length==1){
var hsl=hue;
hue=hsl.h;
_4f4=hsl.s;
_4f5=hsl.l;
_4f6=hsl.a;
}
var red;
var _4f9;
var blue;
if(_4f4===0){
red=_4f5;
_4f9=_4f5;
blue=_4f5;
}else{
var m2;
if(_4f5<=0.5){
m2=_4f5*(1+_4f4);
}else{
m2=_4f5+_4f4-(_4f5*_4f4);
}
var m1=(2*_4f5)-m2;
var f=MochiKit.Color._hslValue;
var h6=hue*6;
red=f(m1,m2,h6+2);
_4f9=f(m1,m2,h6);
blue=f(m1,m2,h6-2);
}
return {r:red,g:_4f9,b:blue,a:_4f6};
},rgbToHSV:function(red,_500,blue,_502){
if(arguments.length==1){
var rgb=red;
red=rgb.r;
_500=rgb.g;
blue=rgb.b;
_502=rgb.a;
}
var max=Math.max(Math.max(red,_500),blue);
var min=Math.min(Math.min(red,_500),blue);
var hue;
var _507;
var _508=max;
if(min==max){
hue=0;
_507=0;
}else{
var _509=(max-min);
_507=_509/max;
if(red==max){
hue=(_500-blue)/_509;
}else{
if(_500==max){
hue=2+((blue-red)/_509);
}else{
hue=4+((red-_500)/_509);
}
}
hue/=6;
if(hue<0){
hue+=1;
}
if(hue>1){
hue-=1;
}
}
return {h:hue,s:_507,v:_508,a:_502};
},rgbToHSL:function(red,_50b,blue,_50d){
if(arguments.length==1){
var rgb=red;
red=rgb.r;
_50b=rgb.g;
blue=rgb.b;
_50d=rgb.a;
}
var max=Math.max(red,Math.max(_50b,blue));
var min=Math.min(red,Math.min(_50b,blue));
var hue;
var _512;
var _513=(max+min)/2;
var _514=max-min;
if(_514===0){
hue=0;
_512=0;
}else{
if(_513<=0.5){
_512=_514/(max+min);
}else{
_512=_514/(2-max-min);
}
if(red==max){
hue=(_50b-blue)/_514;
}else{
if(_50b==max){
hue=2+((blue-red)/_514);
}else{
hue=4+((red-_50b)/_514);
}
}
hue/=6;
if(hue<0){
hue+=1;
}
if(hue>1){
hue-=1;
}
}
return {h:hue,s:_512,l:_513,a:_50d};
},toColorPart:function(num){
num=Math.round(num);
var _516=num.toString(16);
if(num<16){
return "0"+_516;
}
return _516;
},__new__:function(){
var m=MochiKit.Base;
this.Color.fromRGBString=m.bind(this.Color._fromColorString,this.Color,"rgb","fromRGB",[1/255,1/255,1/255,1]);
this.Color.fromHSLString=m.bind(this.Color._fromColorString,this.Color,"hsl","fromHSL",[1/360,0.01,0.01,1]);
var _518=1/3;
var _519={black:[0,0,0],blue:[0,0,1],brown:[0.6,0.4,0.2],cyan:[0,1,1],darkGray:[_518,_518,_518],gray:[0.5,0.5,0.5],green:[0,1,0],lightGray:[2*_518,2*_518,2*_518],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]};
var _51a=function(name,r,g,b,a){
var rval=this.fromRGB(r,g,b,a);
this[name]=function(){
return rval;
};
return rval;
};
for(var k in _519){
var name=k+"Color";
var _523=m.concat([_51a,this.Color,name],_519[k]);
this.Color[name]=m.bind.apply(null,_523);
}
var _524=function(){
for(var i=0;i<arguments.length;i++){
if(!(arguments[i] instanceof Color)){
return false;
}
}
return true;
};
var _526=function(a,b){
return a.compareRGB(b);
};
m.nameFunctions(this);
m.registerComparator(this.Color.NAME,_524,_526);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
}});
MochiKit.Color.EXPORT=["Color"];
MochiKit.Color.EXPORT_OK=["clampColorComponent","rgbToHSL","hslToRGB","rgbToHSV","hsvToRGB","toColorPart"];
MochiKit.Color.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Color);
MochiKit.Color.Color._namedColors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};
MochiKit.Base._deps("Signal",["Base","DOM","Style"]);
MochiKit.Signal.NAME="MochiKit.Signal";
MochiKit.Signal.VERSION="1.4";
MochiKit.Signal._observers=[];
MochiKit.Signal.Event=function(src,e){
this._event=e||window.event;
this._src=src;
};
MochiKit.Base.update(MochiKit.Signal.Event.prototype,{__repr__:function(){
var repr=MochiKit.Base.repr;
var str="{event(): "+repr(this.event())+", src(): "+repr(this.src())+", type(): "+repr(this.type())+", target(): "+repr(this.target());
if(this.type()&&this.type().indexOf("key")===0||this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu"){
str+=", 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)+"}";
}
if(this.type()&&this.type().indexOf("key")===0){
str+=", key(): {code: "+repr(this.key().code)+", string: "+repr(this.key().string)+"}";
}
if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
str+=", mouse(): {page: "+repr(this.mouse().page)+", client: "+repr(this.mouse().client);
if(this.type()!="mousemove"){
str+=", button: {left: "+repr(this.mouse().button.left)+", middle: "+repr(this.mouse().button.middle)+", right: "+repr(this.mouse().button.right)+"}}";
}else{
str+="}";
}
}
if(this.type()=="mouseover"||this.type()=="mouseout"||this.type()=="mouseenter"||this.type()=="mouseleave"){
str+=", relatedTarget(): "+repr(this.relatedTarget());
}
str+="}";
return str;
},toString:function(){
return this.__repr__();
},src:function(){
return this._src;
},event:function(){
return this._event;
},type:function(){
return this._event.type||undefined;
},target:function(){
return this._event.target||this._event.srcElement;
},_relatedTarget:null,relatedTarget:function(){
if(this._relatedTarget!==null){
return this._relatedTarget;
}
var elem=null;
if(this.type()=="mouseover"||this.type()=="mouseenter"){
elem=(this._event.relatedTarget||this._event.fromElement);
}else{
if(this.type()=="mouseout"||this.type()=="mouseleave"){
elem=(this._event.relatedTarget||this._event.toElement);
}
}
if(elem!==null){
this._relatedTarget=elem;
return elem;
}
return undefined;
},_modifier:null,modifier:function(){
if(this._modifier!==null){
return this._modifier;
}
var m={};
m.alt=this._event.altKey;
m.ctrl=this._event.ctrlKey;
m.meta=this._event.metaKey||false;
m.shift=this._event.shiftKey;
m.any=m.alt||m.ctrl||m.shift||m.meta;
this._modifier=m;
return m;
},_key:null,key:function(){
if(this._key!==null){
return this._key;
}
var k={};
if(this.type()&&this.type().indexOf("key")===0){
if(this.type()=="keydown"||this.type()=="keyup"){
k.code=this._event.keyCode;
k.string=(MochiKit.Signal._specialKeys[k.code]||"KEY_UNKNOWN");
this._key=k;
return k;
}else{
if(this.type()=="keypress"){
k.code=0;
k.string="";
if(typeof (this._event.charCode)!="undefined"&&this._event.charCode!==0&&!MochiKit.Signal._specialMacKeys[this._event.charCode]){
k.code=this._event.charCode;
k.string=String.fromCharCode(k.code);
}else{
if(this._event.keyCode&&typeof (this._event.charCode)=="undefined"){
k.code=this._event.keyCode;
k.string=String.fromCharCode(k.code);
}
}
this._key=k;
return k;
}
}
}
return undefined;
},_mouse:null,mouse:function(){
if(this._mouse!==null){
return this._mouse;
}
var m={};
var e=this._event;
if(this.type()&&(this.type().indexOf("mouse")===0||this.type().indexOf("click")!=-1||this.type()=="contextmenu")){
m.client=new MochiKit.Style.Coordinates(0,0);
if(e.clientX||e.clientY){
m.client.x=(!e.clientX||e.clientX<0)?0:e.clientX;
m.client.y=(!e.clientY||e.clientY<0)?0:e.clientY;
}
m.page=new MochiKit.Style.Coordinates(0,0);
if(e.pageX||e.pageY){
m.page.x=(!e.pageX||e.pageX<0)?0:e.pageX;
m.page.y=(!e.pageY||e.pageY<0)?0:e.pageY;
}else{
var de=MochiKit.DOM._document.documentElement;
var b=MochiKit.DOM._document.body;
m.page.x=e.clientX+(de.scrollLeft||b.scrollLeft)-(de.clientLeft||0);
m.page.y=e.clientY+(de.scrollTop||b.scrollTop)-(de.clientTop||0);
}
if(this.type()!="mousemove"){
m.button={};
m.button.left=false;
m.button.right=false;
m.button.middle=false;
if(e.which){
m.button.left=(e.which==1);
m.button.middle=(e.which==2);
m.button.right=(e.which==3);
}else{
m.button.left=!!(e.button&1);
m.button.right=!!(e.button&2);
m.button.middle=!!(e.button&4);
}
}
this._mouse=m;
return m;
}
return undefined;
},stop:function(){
this.stopPropagation();
this.preventDefault();
},stopPropagation:function(){
if(this._event.stopPropagation){
this._event.stopPropagation();
}else{
this._event.cancelBubble=true;
}
},preventDefault:function(){
if(this._event.preventDefault){
this._event.preventDefault();
}else{
if(this._confirmUnload===null){
this._event.returnValue=false;
}
}
},_confirmUnload:null,confirmUnload:function(msg){
if(this.type()=="beforeunload"){
this._confirmUnload=msg;
this._event.returnValue=msg;
}
}});
MochiKit.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"};
(function(){
var _535=MochiKit.Signal._specialMacKeys;
for(i=63236;i<=63242;i++){
_535[i]="KEY_F"+(i-63236+1);
}
})();
MochiKit.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"};
(function(){
var _536=MochiKit.Signal._specialKeys;
for(var i=48;i<=57;i++){
_536[i]="KEY_"+(i-48);
}
for(i=65;i<=90;i++){
_536[i]="KEY_"+String.fromCharCode(i);
}
for(i=96;i<=105;i++){
_536[i]="KEY_NUM_PAD_"+(i-96);
}
for(i=112;i<=123;i++){
_536[i]="KEY_F"+(i-112+1);
}
})();
MochiKit.Signal.Ident=function(_538){
this.source=_538.source;
this.signal=_538.signal;
this.listener=_538.listener;
this.isDOM=_538.isDOM;
this.objOrFunc=_538.objOrFunc;
this.funcOrStr=_538.funcOrStr;
this.connected=_538.connected;
};
MochiKit.Signal.Ident.prototype={};
MochiKit.Base.update(MochiKit.Signal,{__repr__:function(){
return "["+this.NAME+" "+this.VERSION+"]";
},toString:function(){
return this.__repr__();
},_unloadCache:function(){
var self=MochiKit.Signal;
var _53a=self._observers;
for(var i=0;i<_53a.length;i++){
if(_53a[i].signal!=="onload"&&_53a[i].signal!=="onunload"){
self._disconnect(_53a[i]);
}
}
},_listener:function(src,sig,func,obj,_540){
var self=MochiKit.Signal;
var E=self.Event;
if(!_540){
if(typeof (func.im_self)=="undefined"){
return MochiKit.Base.bind(func,obj);
}else{
return func;
}
}
obj=obj||src;
if(typeof (func)=="string"){
if(sig==="onload"||sig==="onunload"){
return function(_543){
obj[func].apply(obj,[new E(src,_543)]);
var _544=new MochiKit.Signal.Ident({source:src,signal:sig,objOrFunc:obj,funcOrStr:func});
MochiKit.Signal._disconnect(_544);
};
}else{
return function(_545){
obj[func].apply(obj,[new E(src,_545)]);
};
}
}else{
if(sig==="onload"||sig==="onunload"){
return function(_546){
func.apply(obj,[new E(src,_546)]);
var _547=new MochiKit.Signal.Ident({source:src,signal:sig,objOrFunc:func});
MochiKit.Signal._disconnect(_547);
};
}else{
return function(_548){
func.apply(obj,[new E(src,_548)]);
};
}
}
},_browserAlreadyHasMouseEnterAndLeave:function(){
return /MSIE/.test(navigator.userAgent);
},_mouseEnterListener:function(src,sig,func,obj){
var E=MochiKit.Signal.Event;
return function(_54e){
var e=new E(src,_54e);
try{
e.relatedTarget().nodeName;
}
catch(err){
return;
}
e.stop();
if(MochiKit.DOM.isChildNode(e.relatedTarget(),src)){
return;
}
e.type=function(){
return sig;
};
if(typeof (func)=="string"){
return obj[func].apply(obj,[e]);
}else{
return func.apply(obj,[e]);
}
};
},_getDestPair:function(_550,_551){
var obj=null;
var func=null;
if(typeof (_551)!="undefined"){
obj=_550;
func=_551;
if(typeof (_551)=="string"){
if(typeof (_550[_551])!="function"){
throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
}
}else{
if(typeof (_551)!="function"){
throw new Error("'funcOrStr' must be a function or string");
}
}
}else{
if(typeof (_550)!="function"){
throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
}else{
func=_550;
}
}
return [obj,func];
},connect:function(src,sig,_556,_557){
src=MochiKit.DOM.getElement(src);
var self=MochiKit.Signal;
if(typeof (sig)!="string"){
throw new Error("'sig' must be a string");
}
var _559=self._getDestPair(_556,_557);
var obj=_559[0];
var func=_559[1];
if(typeof (obj)=="undefined"||obj===null){
obj=src;
}
var _55c=!!(src.addEventListener||src.attachEvent);
if(_55c&&(sig==="onmouseenter"||sig==="onmouseleave")&&!self._browserAlreadyHasMouseEnterAndLeave()){
var _55d=self._mouseEnterListener(src,sig.substr(2),func,obj);
if(sig==="onmouseenter"){
sig="onmouseover";
}else{
sig="onmouseout";
}
}else{
var _55d=self._listener(src,sig,func,obj,_55c);
}
if(src.addEventListener){
src.addEventListener(sig.substr(2),_55d,false);
}else{
if(src.attachEvent){
src.attachEvent(sig,_55d);
}
}
var _55e=new MochiKit.Signal.Ident({source:src,signal:sig,listener:_55d,isDOM:_55c,objOrFunc:_556,funcOrStr:_557,connected:true});
self._observers.push(_55e);
if(!_55c&&typeof (src.__connect__)=="function"){
var args=MochiKit.Base.extend([_55e],arguments,1);
src.__connect__.apply(src,args);
}
return _55e;
},_disconnect:function(_560){
if(!_560.connected){
return;
}
_560.connected=false;
if(!_560.isDOM){
return;
}
var src=_560.source;
var sig=_560.signal;
var _563=_560.listener;
if(src.removeEventListener){
src.removeEventListener(sig.substr(2),_563,false);
}else{
if(src.detachEvent){
src.detachEvent(sig,_563);
}else{
throw new Error("'src' must be a DOM element");
}
}
},disconnect:function(_564){
var self=MochiKit.Signal;
var _566=self._observers;
var m=MochiKit.Base;
if(arguments.length>1){
var src=MochiKit.DOM.getElement(arguments[0]);
var sig=arguments[1];
var obj=arguments[2];
var func=arguments[3];
for(var i=_566.length-1;i>=0;i--){
var o=_566[i];
if(o.source===src&&o.signal===sig&&o.objOrFunc===obj&&o.funcOrStr===func){
self._disconnect(o);
if(!self._lock){
_566.splice(i,1);
}else{
self._dirty=true;
}
return true;
}
}
}else{
var idx=m.findIdentical(_566,_564);
if(idx>=0){
self._disconnect(_564);
if(!self._lock){
_566.splice(idx,1);
}else{
self._dirty=true;
}
return true;
}
}
return false;
},disconnectAllTo:function(_56f,_570){
var self=MochiKit.Signal;
var _572=self._observers;
var _573=self._disconnect;
var _574=self._lock;
var _575=self._dirty;
if(typeof (_570)==="undefined"){
_570=null;
}
for(var i=_572.length-1;i>=0;i--){
var _577=_572[i];
if(_577.objOrFunc===_56f&&(_570===null||_577.funcOrStr===_570)){
_573(_577);
if(_574){
_575=true;
}else{
_572.splice(i,1);
}
}
}
self._dirty=_575;
},disconnectAll:function(src,sig){
src=MochiKit.DOM.getElement(src);
var m=MochiKit.Base;
var _57b=m.flattenArguments(m.extend(null,arguments,1));
var self=MochiKit.Signal;
var _57d=self._disconnect;
var _57e=self._observers;
var i,_580;
var _581=self._lock;
var _582=self._dirty;
if(_57b.length===0){
for(i=_57e.length-1;i>=0;i--){
_580=_57e[i];
if(_580.source===src){
_57d(_580);
if(!_581){
_57e.splice(i,1);
}else{
_582=true;
}
}
}
}else{
var sigs={};
for(i=0;i<_57b.length;i++){
sigs[_57b[i]]=true;
}
for(i=_57e.length-1;i>=0;i--){
_580=_57e[i];
if(_580.source===src&&_580.signal in sigs){
_57d(_580);
if(!_581){
_57e.splice(i,1);
}else{
_582=true;
}
}
}
}
self._dirty=_582;
},signal:function(src,sig){
var self=MochiKit.Signal;
var _587=self._observers;
src=MochiKit.DOM.getElement(src);
var args=MochiKit.Base.extend(null,arguments,2);
var _589=[];
self._lock=true;
for(var i=0;i<_587.length;i++){
var _58b=_587[i];
if(_58b.source===src&&_58b.signal===sig&&_58b.connected){
try{
_58b.listener.apply(src,args);
}
catch(e){
_589.push(e);
}
}
}
self._lock=false;
if(self._dirty){
self._dirty=false;
for(var i=_587.length-1;i>=0;i--){
if(!_587[i].connected){
_587.splice(i,1);
}
}
}
if(_589.length==1){
throw _589[0];
}else{
if(_589.length>1){
var e=new Error("Multiple errors thrown in handling 'sig', see errors property");
e.errors=_589;
throw e;
}
}
}});
MochiKit.Signal.EXPORT_OK=[];
MochiKit.Signal.EXPORT=["connect","disconnect","signal","disconnectAll","disconnectAllTo"];
MochiKit.Signal.__new__=function(win){
var m=MochiKit.Base;
this._document=document;
this._window=win;
this._lock=false;
this._dirty=false;
try{
this.connect(window,"onunload",this._unloadCache);
}
catch(e){
}
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
MochiKit.Signal.__new__(this);
if(MochiKit.__export__){
connect=MochiKit.Signal.connect;
disconnect=MochiKit.Signal.disconnect;
disconnectAll=MochiKit.Signal.disconnectAll;
signal=MochiKit.Signal.signal;
}
MochiKit.Base._exportSymbols(this,MochiKit.Signal);
MochiKit.Base._deps("Position",["Base","DOM","Style"]);
MochiKit.Position.NAME="MochiKit.Position";
MochiKit.Position.VERSION="1.4";
MochiKit.Position.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Position.toString=function(){
return this.__repr__();
};
MochiKit.Position.EXPORT_OK=[];
MochiKit.Position.EXPORT=[];
MochiKit.Base.update(MochiKit.Position,{includeScrollOffsets:false,prepare:function(){
var _58f=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;
var _590=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;
this.windowOffset=new MochiKit.Style.Coordinates(_58f,_590);
},cumulativeOffset:function(_591){
var _592=0;
var _593=0;
do{
_592+=_591.offsetTop||0;
_593+=_591.offsetLeft||0;
_591=_591.offsetParent;
}while(_591);
return new MochiKit.Style.Coordinates(_593,_592);
},realOffset:function(_594){
var _595=0;
var _596=0;
do{
_595+=_594.scrollTop||0;
_596+=_594.scrollLeft||0;
_594=_594.parentNode;
}while(_594);
return new MochiKit.Style.Coordinates(_596,_595);
},within:function(_597,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_597,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_597);
if(_597.style.position=="fixed"){
this.offset.x+=this.windowOffset.x;
this.offset.y+=this.windowOffset.y;
}
return (y>=this.offset.y&&y<this.offset.y+_597.offsetHeight&&x>=this.offset.x&&x<this.offset.x+_597.offsetWidth);
},withinIncludingScrolloffsets:function(_59a,x,y){
var _59d=this.realOffset(_59a);
this.xcomp=x+_59d.x-this.windowOffset.x;
this.ycomp=y+_59d.y-this.windowOffset.y;
this.offset=this.cumulativeOffset(_59a);
return (this.ycomp>=this.offset.y&&this.ycomp<this.offset.y+_59a.offsetHeight&&this.xcomp>=this.offset.x&&this.xcomp<this.offset.x+_59a.offsetWidth);
},overlap:function(mode,_59f){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset.y+_59f.offsetHeight)-this.ycomp)/_59f.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset.x+_59f.offsetWidth)-this.xcomp)/_59f.offsetWidth;
}
},absolutize:function(_5a0){
_5a0=MochiKit.DOM.getElement(_5a0);
if(_5a0.style.position=="absolute"){
return;
}
MochiKit.Position.prepare();
var _5a1=MochiKit.Position.positionedOffset(_5a0);
var _5a2=_5a0.clientWidth;
var _5a3=_5a0.clientHeight;
var _5a4={"position":_5a0.style.position,"left":_5a1.x-parseFloat(_5a0.style.left||0),"top":_5a1.y-parseFloat(_5a0.style.top||0),"width":_5a0.style.width,"height":_5a0.style.height};
_5a0.style.position="absolute";
_5a0.style.top=_5a1.y+"px";
_5a0.style.left=_5a1.x+"px";
_5a0.style.width=_5a2+"px";
_5a0.style.height=_5a3+"px";
return _5a4;
},positionedOffset:function(_5a5){
var _5a6=0,_5a7=0;
do{
_5a6+=_5a5.offsetTop||0;
_5a7+=_5a5.offsetLeft||0;
_5a5=_5a5.offsetParent;
if(_5a5){
p=MochiKit.Style.getStyle(_5a5,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_5a5);
return new MochiKit.Style.Coordinates(_5a7,_5a6);
},relativize:function(_5a8,_5a9){
_5a8=MochiKit.DOM.getElement(_5a8);
if(_5a8.style.position=="relative"){
return;
}
MochiKit.Position.prepare();
var top=parseFloat(_5a8.style.top||0)-(_5a9["top"]||0);
var left=parseFloat(_5a8.style.left||0)-(_5a9["left"]||0);
_5a8.style.position=_5a9["position"];
_5a8.style.top=top+"px";
_5a8.style.left=left+"px";
_5a8.style.width=_5a9["width"];
_5a8.style.height=_5a9["height"];
},clone:function(_5ac,_5ad){
_5ac=MochiKit.DOM.getElement(_5ac);
_5ad=MochiKit.DOM.getElement(_5ad);
_5ad.style.position="absolute";
var _5ae=this.cumulativeOffset(_5ac);
_5ad.style.top=_5ae.y+"px";
_5ad.style.left=_5ae.x+"px";
_5ad.style.width=_5ac.offsetWidth+"px";
_5ad.style.height=_5ac.offsetHeight+"px";
},page:function(_5af){
var _5b0=0;
var _5b1=0;
var _5b2=_5af;
do{
_5b0+=_5b2.offsetTop||0;
_5b1+=_5b2.offsetLeft||0;
if(_5b2.offsetParent==document.body&&MochiKit.Style.getStyle(_5b2,"position")=="absolute"){
break;
}
}while(_5b2=_5b2.offsetParent);
_5b2=_5af;
do{
_5b0-=_5b2.scrollTop||0;
_5b1-=_5b2.scrollLeft||0;
}while(_5b2=_5b2.parentNode);
return new MochiKit.Style.Coordinates(_5b1,_5b0);
}});
MochiKit.Position.__new__=function(win){
var m=MochiKit.Base;
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
m.nameFunctions(this);
};
MochiKit.Position.__new__(this);
MochiKit.Base._deps("Visual",["Base","DOM","Style","Color","Position"]);
MochiKit.Visual.NAME="MochiKit.Visual";
MochiKit.Visual.VERSION="1.4";
MochiKit.Visual.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.Visual.toString=function(){
return this.__repr__();
};
MochiKit.Visual._RoundCorners=function(e,_5b6){
e=MochiKit.DOM.getElement(e);
this._setOptions(_5b6);
if(this.options.__unstable__wrapElement){
e=this._doWrap(e);
}
var _5b7=this.options.color;
var C=MochiKit.Color.Color;
if(this.options.color==="fromElement"){
_5b7=C.fromBackground(e);
}else{
if(!(_5b7 instanceof C)){
_5b7=C.fromString(_5b7);
}
}
this.isTransparent=(_5b7.asRGB().a<=0);
var _5b9=this.options.bgColor;
if(this.options.bgColor==="fromParent"){
_5b9=C.fromBackground(e.offsetParent);
}else{
if(!(_5b9 instanceof C)){
_5b9=C.fromString(_5b9);
}
}
this._roundCornersImpl(e,_5b7,_5b9);
};
MochiKit.Visual._RoundCorners.prototype={_doWrap:function(e){
var _5bb=e.parentNode;
var doc=MochiKit.DOM.currentDocument();
if(typeof (doc.defaultView)==="undefined"||doc.defaultView===null){
return e;
}
var _5bd=doc.defaultView.getComputedStyle(e,null);
if(typeof (_5bd)==="undefined"||_5bd===null){
return e;
}
var _5be=MochiKit.DOM.DIV({"style":{display:"block",marginTop:_5bd.getPropertyValue("padding-top"),marginRight:_5bd.getPropertyValue("padding-right"),marginBottom:_5bd.getPropertyValue("padding-bottom"),marginLeft:_5bd.getPropertyValue("padding-left"),padding:"0px"}});
_5be.innerHTML=e.innerHTML;
e.innerHTML="";
e.appendChild(_5be);
return e;
},_roundCornersImpl:function(e,_5c0,_5c1){
if(this.options.border){
this._renderBorder(e,_5c1);
}
if(this._isTopRounded()){
this._roundTopCorners(e,_5c0,_5c1);
}
if(this._isBottomRounded()){
this._roundBottomCorners(e,_5c0,_5c1);
}
},_renderBorder:function(el,_5c3){
var _5c4="1px solid "+this._borderColor(_5c3);
var _5c5="border-left: "+_5c4;
var _5c6="border-right: "+_5c4;
var _5c7="style='"+_5c5+";"+_5c6+"'";
el.innerHTML="<div "+_5c7+">"+el.innerHTML+"</div>";
},_roundTopCorners:function(el,_5c9,_5ca){
var _5cb=this._createCorner(_5ca);
for(var i=0;i<this.options.numSlices;i++){
_5cb.appendChild(this._createCornerSlice(_5c9,_5ca,i,"top"));
}
el.style.paddingTop=0;
el.insertBefore(_5cb,el.firstChild);
},_roundBottomCorners:function(el,_5ce,_5cf){
var _5d0=this._createCorner(_5cf);
for(var i=(this.options.numSlices-1);i>=0;i--){
_5d0.appendChild(this._createCornerSlice(_5ce,_5cf,i,"bottom"));
}
el.style.paddingBottom=0;
el.appendChild(_5d0);
},_createCorner:function(_5d2){
var dom=MochiKit.DOM;
return dom.DIV({style:{backgroundColor:_5d2.toString()}});
},_createCornerSlice:function(_5d4,_5d5,n,_5d7){
var _5d8=MochiKit.DOM.SPAN();
var _5d9=_5d8.style;
_5d9.backgroundColor=_5d4.toString();
_5d9.display="block";
_5d9.height="1px";
_5d9.overflow="hidden";
_5d9.fontSize="1px";
var _5da=this._borderColor(_5d4,_5d5);
if(this.options.border&&n===0){
_5d9.borderTopStyle="solid";
_5d9.borderTopWidth="1px";
_5d9.borderLeftWidth="0px";
_5d9.borderRightWidth="0px";
_5d9.borderBottomWidth="0px";
_5d9.height="0px";
_5d9.borderColor=_5da.toString();
}else{
if(_5da){
_5d9.borderColor=_5da.toString();
_5d9.borderStyle="solid";
_5d9.borderWidth="0px 1px";
}
}
if(!this.options.compact&&(n==(this.options.numSlices-1))){
_5d9.height="2px";
}
this._setMargin(_5d8,n,_5d7);
this._setBorder(_5d8,n,_5d7);
return _5d8;
},_setOptions:function(_5db){
this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false,__unstable__wrapElement:false};
MochiKit.Base.update(this.options,_5db);
this.options.numSlices=(this.options.compact?2:4);
},_whichSideTop:function(){
var _5dc=this.options.corners;
if(this._hasString(_5dc,"all","top")){
return "";
}
var _5dd=(_5dc.indexOf("tl")!=-1);
var _5de=(_5dc.indexOf("tr")!=-1);
if(_5dd&&_5de){
return "";
}
if(_5dd){
return "left";
}
if(_5de){
return "right";
}
return "";
},_whichSideBottom:function(){
var _5df=this.options.corners;
if(this._hasString(_5df,"all","bottom")){
return "";
}
var _5e0=(_5df.indexOf("bl")!=-1);
var _5e1=(_5df.indexOf("br")!=-1);
if(_5e0&&_5e1){
return "";
}
if(_5e0){
return "left";
}
if(_5e1){
return "right";
}
return "";
},_borderColor:function(_5e2,_5e3){
if(_5e2=="transparent"){
return _5e3;
}else{
if(this.options.border){
return this.options.border;
}else{
if(this.options.blend){
return _5e3.blendedColor(_5e2);
}
}
}
return "";
},_setMargin:function(el,n,_5e6){
var _5e7=this._marginSize(n)+"px";
var _5e8=(_5e6=="top"?this._whichSideTop():this._whichSideBottom());
var _5e9=el.style;
if(_5e8=="left"){
_5e9.marginLeft=_5e7;
_5e9.marginRight="0px";
}else{
if(_5e8=="right"){
_5e9.marginRight=_5e7;
_5e9.marginLeft="0px";
}else{
_5e9.marginLeft=_5e7;
_5e9.marginRight=_5e7;
}
}
},_setBorder:function(el,n,_5ec){
var _5ed=this._borderSize(n)+"px";
var _5ee=(_5ec=="top"?this._whichSideTop():this._whichSideBottom());
var _5ef=el.style;
if(_5ee=="left"){
_5ef.borderLeftWidth=_5ed;
_5ef.borderRightWidth="0px";
}else{
if(_5ee=="right"){
_5ef.borderRightWidth=_5ed;
_5ef.borderLeftWidth="0px";
}else{
_5ef.borderLeftWidth=_5ed;
_5ef.borderRightWidth=_5ed;
}
}
},_marginSize:function(n){
if(this.isTransparent){
return 0;
}
var o=this.options;
if(o.compact&&o.blend){
var _5f2=[1,0];
return _5f2[n];
}else{
if(o.compact){
var _5f3=[2,1];
return _5f3[n];
}else{
if(o.blend){
var _5f4=[3,2,1,0];
return _5f4[n];
}else{
var _5f5=[5,3,2,1];
return _5f5[n];
}
}
}
},_borderSize:function(n){
var o=this.options;
var _5f8;
if(o.compact&&(o.blend||this.isTransparent)){
return 1;
}else{
if(o.compact){
_5f8=[1,0];
}else{
if(o.blend){
_5f8=[2,1,1,1];
}else{
if(o.border){
_5f8=[0,2,0,0];
}else{
if(this.isTransparent){
_5f8=[5,3,2,1];
}else{
return 0;
}
}
}
}
}
return _5f8[n];
},_hasString:function(str){
for(var i=1;i<arguments.length;i++){
if(str.indexOf(arguments[i])!=-1){
return true;
}
}
return false;
},_isTopRounded:function(){
return this._hasString(this.options.corners,"all","top","tl","tr");
},_isBottomRounded:function(){
return this._hasString(this.options.corners,"all","bottom","bl","br");
},_hasSingleTextChild:function(el){
return (el.childNodes.length==1&&el.childNodes[0].nodeType==3);
}};
MochiKit.Visual.roundElement=function(e,_5fd){
new MochiKit.Visual._RoundCorners(e,_5fd);
};
MochiKit.Visual.roundClass=function(_5fe,_5ff,_600){
var _601=MochiKit.DOM.getElementsByTagAndClassName(_5fe,_5ff);
for(var i=0;i<_601.length;i++){
MochiKit.Visual.roundElement(_601[i],_600);
}
};
MochiKit.Visual.tagifyText=function(_603,_604){
_604=_604||"position:relative";
if(/MSIE/.test(navigator.userAgent)){
_604+=";zoom:1";
}
_603=MochiKit.DOM.getElement(_603);
var ma=MochiKit.Base.map;
ma(function(_606){
if(_606.nodeType==3){
ma(function(_607){
_603.insertBefore(MochiKit.DOM.SPAN({style:_604},_607==" "?String.fromCharCode(160):_607),_606);
},_606.nodeValue.split(""));
MochiKit.DOM.removeElement(_606);
}
},_603.childNodes);
};
MochiKit.Visual.forceRerendering=function(_608){
try{
_608=MochiKit.DOM.getElement(_608);
var n=document.createTextNode(" ");
_608.appendChild(n);
_608.removeChild(n);
}
catch(e){
}
};
MochiKit.Visual.multiple=function(_60a,_60b,_60c){
_60c=MochiKit.Base.update({speed:0.1,delay:0},_60c);
var _60d=_60c.delay;
var _60e=0;
MochiKit.Base.map(function(_60f){
_60c.delay=_60e*_60c.speed+_60d;
new _60b(_60f,_60c);
_60e+=1;
},_60a);
};
MochiKit.Visual.PAIRS={"slide":["slideDown","slideUp"],"blind":["blindDown","blindUp"],"appear":["appear","fade"],"size":["grow","shrink"]};
MochiKit.Visual.toggle=function(_610,_611,_612){
_610=MochiKit.DOM.getElement(_610);
_611=(_611||"appear").toLowerCase();
_612=MochiKit.Base.update({queue:{position:"end",scope:(_610.id||"global"),limit:1}},_612);
var v=MochiKit.Visual;
v[MochiKit.Style.getStyle(_610,"display")!="none"?v.PAIRS[_611][1]:v.PAIRS[_611][0]](_610,_612);
};
MochiKit.Visual.Transitions={};
MochiKit.Visual.Transitions.linear=function(pos){
return pos;
};
MochiKit.Visual.Transitions.sinoidal=function(pos){
return (-Math.cos(pos*Math.PI)/2)+0.5;
};
MochiKit.Visual.Transitions.reverse=function(pos){
return 1-pos;
};
MochiKit.Visual.Transitions.flicker=function(pos){
return ((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;
};
MochiKit.Visual.Transitions.wobble=function(pos){
return (-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;
};
MochiKit.Visual.Transitions.pulse=function(pos,_61a){
if(!_61a){
return (Math.floor(pos*10)%2===0?(pos*10-Math.floor(pos*10)):1-(pos*10-Math.floor(pos*10)));
}
return (Math.round((pos%(1/_61a))*_61a)==0?((pos*_61a*2)-Math.floor(pos*_61a*2)):1-((pos*_61a*2)-Math.floor(pos*_61a*2)));
};
MochiKit.Visual.Transitions.none=function(pos){
return 0;
};
MochiKit.Visual.Transitions.full=function(pos){
return 1;
};
MochiKit.Visual.ScopedQueue=function(){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls();
}
this.__init__();
};
MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype,{__init__:function(){
this.effects=[];
this.interval=null;
},add:function(_61e){
var _61f=new Date().getTime();
var _620=(typeof (_61e.options.queue)=="string")?_61e.options.queue:_61e.options.queue.position;
var ma=MochiKit.Base.map;
switch(_620){
case "front":
ma(function(e){
if(e.state=="idle"){
e.startOn+=_61e.finishOn;
e.finishOn+=_61e.finishOn;
}
},this.effects);
break;
case "end":
var _623;
ma(function(e){
var i=e.finishOn;
if(i>=(_623||i)){
_623=i;
}
},this.effects);
_61f=_623||_61f;
break;
case "break":
ma(function(e){
e.finalize();
},this.effects);
break;
}
_61e.startOn+=_61f;
_61e.finishOn+=_61f;
if(!_61e.options.queue.limit||this.effects.length<_61e.options.queue.limit){
this.effects.push(_61e);
}
if(!this.interval){
this.interval=this.startLoop(MochiKit.Base.bind(this.loop,this),40);
}
},startLoop:function(func,_628){
return setInterval(func,_628);
},remove:function(_629){
this.effects=MochiKit.Base.filter(function(e){
return e!=_629;
},this.effects);
if(!this.effects.length){
this.stopLoop(this.interval);
this.interval=null;
}
},stopLoop:function(_62b){
clearInterval(_62b);
},loop:function(){
var _62c=new Date().getTime();
MochiKit.Base.map(function(_62d){
_62d.loop(_62c);
},this.effects);
}});
MochiKit.Visual.Queues={instances:{},get:function(_62e){
if(typeof (_62e)!="string"){
return _62e;
}
if(!this.instances[_62e]){
this.instances[_62e]=new MochiKit.Visual.ScopedQueue();
}
return this.instances[_62e];
}};
MochiKit.Visual.Queue=MochiKit.Visual.Queues.get("global");
MochiKit.Visual.DefaultOptions={transition:MochiKit.Visual.Transitions.sinoidal,duration:1,fps:25,sync:false,from:0,to:1,delay:0,queue:"parallel"};
MochiKit.Visual.Base=function(){
};
MochiKit.Visual.Base.prototype={__class__:MochiKit.Visual.Base,start:function(_62f){
var v=MochiKit.Visual;
this.options=MochiKit.Base.setdefault(_62f,v.DefaultOptions);
this.currentFrame=0;
this.state="idle";
this.startOn=this.options.delay*1000;
this.finishOn=this.startOn+(this.options.duration*1000);
this.event("beforeStart");
if(!this.options.sync){
v.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).add(this);
}
},loop:function(_631){
if(_631>=this.startOn){
if(_631>=this.finishOn){
return this.finalize();
}
var pos=(_631-this.startOn)/(this.finishOn-this.startOn);
var _633=Math.round(pos*this.options.fps*this.options.duration);
if(_633>this.currentFrame){
this.render(pos);
this.currentFrame=_633;
}
}
},render:function(pos){
if(this.state=="idle"){
this.state="running";
this.event("beforeSetup");
this.setup();
this.event("afterSetup");
}
if(this.state=="running"){
if(this.options.transition){
pos=this.options.transition(pos);
}
pos*=(this.options.to-this.options.from);
pos+=this.options.from;
this.event("beforeUpdate");
this.update(pos);
this.event("afterUpdate");
}
},cancel:function(){
if(!this.options.sync){
MochiKit.Visual.Queues.get(typeof (this.options.queue)=="string"?"global":this.options.queue.scope).remove(this);
}
this.state="finished";
},finalize:function(){
this.render(1);
this.cancel();
this.event("beforeFinish");
this.finish();
this.event("afterFinish");
},setup:function(){
},finish:function(){
},update:function(_635){
},event:function(_636){
if(this.options[_636+"Internal"]){
this.options[_636+"Internal"](this);
}
if(this.options[_636]){
this.options[_636](this);
}
},repr:function(){
return "["+this.__class__.NAME+", options:"+MochiKit.Base.repr(this.options)+"]";
}};
MochiKit.Visual.Parallel=function(_637,_638){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_637,_638);
}
this.__init__(_637,_638);
};
MochiKit.Visual.Parallel.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Parallel.prototype,{__class__:MochiKit.Visual.Parallel,__init__:function(_63a,_63b){
this.effects=_63a||[];
this.start(_63b);
},update:function(_63c){
MochiKit.Base.map(function(_63d){
_63d.render(_63c);
},this.effects);
},finish:function(){
MochiKit.Base.map(function(_63e){
_63e.finalize();
},this.effects);
}});
MochiKit.Visual.Opacity=function(_63f,_640){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_63f,_640);
}
this.__init__(_63f,_640);
};
MochiKit.Visual.Opacity.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Opacity.prototype,{__class__:MochiKit.Visual.Opacity,__init__:function(_642,_643){
var b=MochiKit.Base;
var s=MochiKit.Style;
this.element=MochiKit.DOM.getElement(_642);
if(this.element.currentStyle&&(!this.element.currentStyle.hasLayout)){
s.setStyle(this.element,{zoom:1});
}
_643=b.update({from:s.getStyle(this.element,"opacity")||0,to:1},_643);
this.start(_643);
},update:function(_646){
MochiKit.Style.setStyle(this.element,{"opacity":_646});
}});
MochiKit.Visual.Move=function(_647,_648){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_647,_648);
}
this.__init__(_647,_648);
};
MochiKit.Visual.Move.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Move.prototype,{__class__:MochiKit.Visual.Move,__init__:function(_64a,_64b){
this.element=MochiKit.DOM.getElement(_64a);
_64b=MochiKit.Base.update({x:0,y:0,mode:"relative"},_64b);
this.start(_64b);
},setup:function(){
MochiKit.DOM.makePositioned(this.element);
var s=this.element.style;
var _64d=s.visibility;
var _64e=s.display;
if(_64e=="none"){
s.visibility="hidden";
s.display="";
}
this.originalLeft=parseFloat(MochiKit.Style.getStyle(this.element,"left")||"0");
this.originalTop=parseFloat(MochiKit.Style.getStyle(this.element,"top")||"0");
if(this.options.mode=="absolute"){
this.options.x-=this.originalLeft;
this.options.y-=this.originalTop;
}
if(_64e=="none"){
s.visibility=_64d;
s.display=_64e;
}
},update:function(_64f){
MochiKit.Style.setStyle(this.element,{left:Math.round(this.options.x*_64f+this.originalLeft)+"px",top:Math.round(this.options.y*_64f+this.originalTop)+"px"});
}});
MochiKit.Visual.Scale=function(_650,_651,_652){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_650,_651,_652);
}
this.__init__(_650,_651,_652);
};
MochiKit.Visual.Scale.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Scale.prototype,{__class__:MochiKit.Visual.Scale,__init__:function(_654,_655,_656){
this.element=MochiKit.DOM.getElement(_654);
_656=MochiKit.Base.update({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_655},_656);
this.start(_656);
},setup:function(){
this.restoreAfterFinish=this.options.restoreAfterFinish||false;
this.elementPositioning=MochiKit.Style.getStyle(this.element,"position");
var ma=MochiKit.Base.map;
var b=MochiKit.Base.bind;
this.originalStyle={};
ma(b(function(k){
this.originalStyle[k]=this.element.style[k];
},this),["top","left","width","height","fontSize"]);
this.originalTop=this.element.offsetTop;
this.originalLeft=this.element.offsetLeft;
var _65a=MochiKit.Style.getStyle(this.element,"font-size")||"100%";
ma(b(function(_65b){
if(_65a.indexOf(_65b)>0){
this.fontSize=parseFloat(_65a);
this.fontSizeType=_65b;
}
},this),["em","px","%"]);
this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;
if(/^content/.test(this.options.scaleMode)){
this.dims=[this.element.scrollHeight,this.element.scrollWidth];
}else{
if(this.options.scaleMode=="box"){
this.dims=[this.element.offsetHeight,this.element.offsetWidth];
}else{
this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];
}
}
},update:function(_65c){
var _65d=(this.options.scaleFrom/100)+(this.factor*_65c);
if(this.options.scaleContent&&this.fontSize){
MochiKit.Style.setStyle(this.element,{fontSize:this.fontSize*_65d+this.fontSizeType});
}
this.setDimensions(this.dims[0]*_65d,this.dims[1]*_65d);
},finish:function(){
if(this.restoreAfterFinish){
MochiKit.Style.setStyle(this.element,this.originalStyle);
}
},setDimensions:function(_65e,_65f){
var d={};
var r=Math.round;
if(/MSIE/.test(navigator.userAgent)){
r=Math.ceil;
}
if(this.options.scaleX){
d.width=r(_65f)+"px";
}
if(this.options.scaleY){
d.height=r(_65e)+"px";
}
if(this.options.scaleFromCenter){
var topd=(_65e-this.dims[0])/2;
var _663=(_65f-this.dims[1])/2;
if(this.elementPositioning=="absolute"){
if(this.options.scaleY){
d.top=this.originalTop-topd+"px";
}
if(this.options.scaleX){
d.left=this.originalLeft-_663+"px";
}
}else{
if(this.options.scaleY){
d.top=-topd+"px";
}
if(this.options.scaleX){
d.left=-_663+"px";
}
}
}
MochiKit.Style.setStyle(this.element,d);
}});
MochiKit.Visual.Highlight=function(_664,_665){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_664,_665);
}
this.__init__(_664,_665);
};
MochiKit.Visual.Highlight.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Highlight.prototype,{__class__:MochiKit.Visual.Highlight,__init__:function(_667,_668){
this.element=MochiKit.DOM.getElement(_667);
_668=MochiKit.Base.update({startcolor:"#ffff99"},_668);
this.start(_668);
},setup:function(){
var b=MochiKit.Base;
var s=MochiKit.Style;
if(s.getStyle(this.element,"display")=="none"){
this.cancel();
return;
}
this.oldStyle={backgroundImage:s.getStyle(this.element,"background-image")};
s.setStyle(this.element,{backgroundImage:"none"});
if(!this.options.endcolor){
this.options.endcolor=MochiKit.Color.Color.fromBackground(this.element).toHexString();
}
if(b.isUndefinedOrNull(this.options.restorecolor)){
this.options.restorecolor=s.getStyle(this.element,"background-color");
}
this._base=b.map(b.bind(function(i){
return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);
},this),[0,1,2]);
this._delta=b.map(b.bind(function(i){
return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];
},this),[0,1,2]);
},update:function(_66d){
var m="#";
MochiKit.Base.map(MochiKit.Base.bind(function(i){
m+=MochiKit.Color.toColorPart(Math.round(this._base[i]+this._delta[i]*_66d));
},this),[0,1,2]);
MochiKit.Style.setStyle(this.element,{backgroundColor:m});
},finish:function(){
MochiKit.Style.setStyle(this.element,MochiKit.Base.update(this.oldStyle,{backgroundColor:this.options.restorecolor}));
}});
MochiKit.Visual.ScrollTo=function(_670,_671){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_670,_671);
}
this.__init__(_670,_671);
};
MochiKit.Visual.ScrollTo.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.ScrollTo.prototype,{__class__:MochiKit.Visual.ScrollTo,__init__:function(_673,_674){
this.element=MochiKit.DOM.getElement(_673);
this.start(_674);
},setup:function(){
var p=MochiKit.Position;
p.prepare();
var _676=p.cumulativeOffset(this.element);
if(this.options.offset){
_676.y+=this.options.offset;
}
var max;
if(window.innerHeight){
max=window.innerHeight-window.height;
}else{
if(document.documentElement&&document.documentElement.clientHeight){
max=document.documentElement.clientHeight-document.body.scrollHeight;
}else{
if(document.body){
max=document.body.clientHeight-document.body.scrollHeight;
}
}
}
this.scrollStart=p.windowOffset.y;
this.delta=(_676.y>max?max:_676.y)-this.scrollStart;
},update:function(_678){
var p=MochiKit.Position;
p.prepare();
window.scrollTo(p.windowOffset.x,this.scrollStart+(_678*this.delta));
}});
MochiKit.Visual.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;
MochiKit.Visual.Morph=function(_67a,_67b){
var cls=arguments.callee;
if(!(this instanceof cls)){
return new cls(_67a,_67b);
}
this.__init__(_67a,_67b);
};
MochiKit.Visual.Morph.prototype=new MochiKit.Visual.Base();
MochiKit.Base.update(MochiKit.Visual.Morph.prototype,{__class__:MochiKit.Visual.Morph,__init__:function(_67d,_67e){
this.element=MochiKit.DOM.getElement(_67d);
this.start(_67e);
},setup:function(){
var b=MochiKit.Base;
var _680=this.options.style;
this.styleStart={};
this.styleEnd={};
this.units={};
var _681,unit;
for(var s in _680){
_681=_680[s];
s=b.camelize(s);
if(MochiKit.Visual.CSS_LENGTH.test(_681)){
var _684=_681.match(/^([\+\-]?[0-9\.]+)(.*)$/);
_681=parseFloat(_684[1]);
unit=(_684.length==3)?_684[2]:null;
this.styleEnd[s]=_681;
this.units[s]=unit;
_681=MochiKit.Style.getStyle(this.element,s);
_684=_681.match(/^([\+\-]?[0-9\.]+)(.*)$/);
_681=parseFloat(_684[1]);
this.styleStart[s]=_681;
}else{
var c=MochiKit.Color.Color;
_681=c.fromString(_681);
if(_681){
this.units[s]="color";
this.styleEnd[s]=_681.toHexString();
_681=MochiKit.Style.getStyle(this.element,s);
this.styleStart[s]=c.fromString(_681).toHexString();
this.styleStart[s]=b.map(b.bind(function(i){
return parseInt(this.styleStart[s].slice(i*2+1,i*2+3),16);
},this),[0,1,2]);
this.styleEnd[s]=b.map(b.bind(function(i){
return parseInt(this.styleEnd[s].slice(i*2+1,i*2+3),16);
},this),[0,1,2]);
}
}
}
},update:function(_688){
var _689;
for(var s in this.styleStart){
if(this.units[s]=="color"){
var m="#";
var _68c=this.styleStart[s];
var end=this.styleEnd[s];
MochiKit.Base.map(MochiKit.Base.bind(function(i){
m+=MochiKit.Color.toColorPart(Math.round(_68c[i]+(end[i]-_68c[i])*_688));
},this),[0,1,2]);
this.element.style[s]=m;
}else{
_689=this.styleStart[s]+Math.round((this.styleEnd[s]-this.styleStart[s])*_688*1000)/1000+this.units[s];
this.element.style[s]=_689;
}
}
}});
MochiKit.Visual.fade=function(_68f,_690){
var s=MochiKit.Style;
var _692=s.getStyle(_68f,"opacity");
_690=MochiKit.Base.update({from:s.getStyle(_68f,"opacity")||1,to:0,afterFinishInternal:function(_693){
if(_693.options.to!==0){
return;
}
s.hideElement(_693.element);
s.setStyle(_693.element,{"opacity":_692});
}},_690);
return new MochiKit.Visual.Opacity(_68f,_690);
};
MochiKit.Visual.appear=function(_694,_695){
var s=MochiKit.Style;
var v=MochiKit.Visual;
_695=MochiKit.Base.update({from:(s.getStyle(_694,"display")=="none"?0:s.getStyle(_694,"opacity")||0),to:1,afterFinishInternal:function(_698){
v.forceRerendering(_698.element);
},beforeSetupInternal:function(_699){
s.setStyle(_699.element,{"opacity":_699.options.from});
s.showElement(_699.element);
}},_695);
return new v.Opacity(_694,_695);
};
MochiKit.Visual.puff=function(_69a,_69b){
var s=MochiKit.Style;
var v=MochiKit.Visual;
_69a=MochiKit.DOM.getElement(_69a);
var _69e={position:s.getStyle(_69a,"position"),top:_69a.style.top,left:_69a.style.left,width:_69a.style.width,height:_69a.style.height,opacity:s.getStyle(_69a,"opacity")};
_69b=MochiKit.Base.update({beforeSetupInternal:function(_69f){
MochiKit.Position.absolutize(_69f.effects[0].element);
},afterFinishInternal:function(_6a0){
s.hideElement(_6a0.effects[0].element);
s.setStyle(_6a0.effects[0].element,_69e);
},scaleContent:true,scaleFromCenter:true},_69b);
return new v.Parallel([new v.Scale(_69a,200,{sync:true,scaleFromCenter:_69b.scaleFromCenter,scaleContent:_69b.scaleContent,restoreAfterFinish:true}),new v.Opacity(_69a,{sync:true,to:0})],_69b);
};
MochiKit.Visual.blindUp=function(_6a1,_6a2){
var d=MochiKit.DOM;
_6a1=d.getElement(_6a1);
var _6a4=d.makeClipping(_6a1);
_6a2=MochiKit.Base.update({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_6a5){
MochiKit.Style.hideElement(_6a5.element);
d.undoClipping(_6a5.element,_6a4);
}},_6a2);
return new MochiKit.Visual.Scale(_6a1,0,_6a2);
};
MochiKit.Visual.blindDown=function(_6a6,_6a7){
var d=MochiKit.DOM;
var s=MochiKit.Style;
_6a6=d.getElement(_6a6);
var _6aa=s.getElementDimensions(_6a6);
var _6ab;
_6a7=MochiKit.Base.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6aa.h,originalWidth:_6aa.w},restoreAfterFinish:true,afterSetupInternal:function(_6ac){
_6ab=d.makeClipping(_6ac.element);
s.setStyle(_6ac.element,{height:"0px"});
s.showElement(_6ac.element);
},afterFinishInternal:function(_6ad){
d.undoClipping(_6ad.element,_6ab);
}},_6a7);
return new MochiKit.Visual.Scale(_6a6,100,_6a7);
};
MochiKit.Visual.switchOff=function(_6ae,_6af){
var d=MochiKit.DOM;
_6ae=d.getElement(_6ae);
var _6b1=MochiKit.Style.getStyle(_6ae,"opacity");
var _6b2;
_6af=MochiKit.Base.update({duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetupInternal:function(_6b3){
d.makePositioned(_6b3.element);
_6b2=d.makeClipping(_6b3.element);
},afterFinishInternal:function(_6b4){
MochiKit.Style.hideElement(_6b4.element);
d.undoClipping(_6b4.element,_6b2);
d.undoPositioned(_6b4.element);
MochiKit.Style.setStyle(_6b4.element,{"opacity":_6b1});
}},_6af);
var v=MochiKit.Visual;
return new v.appear(_6ae,{duration:0.4,from:0,transition:v.Transitions.flicker,afterFinishInternal:function(_6b6){
new v.Scale(_6b6.element,1,_6af);
}});
};
MochiKit.Visual.dropOut=function(_6b7,_6b8){
var d=MochiKit.DOM;
var s=MochiKit.Style;
_6b7=d.getElement(_6b7);
var _6bb={top:s.getStyle(_6b7,"top"),left:s.getStyle(_6b7,"left"),opacity:s.getStyle(_6b7,"opacity")};
_6b8=MochiKit.Base.update({duration:0.5,distance:100,beforeSetupInternal:function(_6bc){
d.makePositioned(_6bc.effects[0].element);
},afterFinishInternal:function(_6bd){
s.hideElement(_6bd.effects[0].element);
d.undoPositioned(_6bd.effects[0].element);
s.setStyle(_6bd.effects[0].element,_6bb);
}},_6b8);
var v=MochiKit.Visual;
return new v.Parallel([new v.Move(_6b7,{x:0,y:_6b8.distance,sync:true}),new v.Opacity(_6b7,{sync:true,to:0})],_6b8);
};
MochiKit.Visual.shake=function(_6bf,_6c0){
var d=MochiKit.DOM;
var v=MochiKit.Visual;
var s=MochiKit.Style;
_6bf=d.getElement(_6bf);
_6c0=MochiKit.Base.update({x:-20,y:0,duration:0.05,afterFinishInternal:function(_6c4){
d.undoPositioned(_6c4.element);
s.setStyle(_6c4.element,_6c5);
}},_6c0);
var _6c5={top:s.getStyle(_6bf,"top"),left:s.getStyle(_6bf,"left")};
return new v.Move(_6bf,{x:20,y:0,duration:0.05,afterFinishInternal:function(_6c6){
new v.Move(_6c6.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c7){
new v.Move(_6c7.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6c8){
new v.Move(_6c8.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_6c9){
new v.Move(_6c9.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_6ca){
new v.Move(_6ca.element,_6c0);
}});
}});
}});
}});
}});
};
MochiKit.Visual.slideDown=function(_6cb,_6cc){
var d=MochiKit.DOM;
var b=MochiKit.Base;
var s=MochiKit.Style;
_6cb=d.getElement(_6cb);
if(!_6cb.firstChild){
throw "MochiKit.Visual.slideDown must be used on a element with a child";
}
d.removeEmptyTextNodes(_6cb);
var _6d0=s.getStyle(_6cb.firstChild,"bottom")||0;
var _6d1=s.getElementDimensions(_6cb);
var _6d2;
_6cc=b.update({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_6d1.h,originalWidth:_6d1.w},restoreAfterFinish:true,afterSetupInternal:function(_6d3){
d.makePositioned(_6d3.element);
d.makePositioned(_6d3.element.firstChild);
if(/Opera/.test(navigator.userAgent)){
s.setStyle(_6d3.element,{top:""});
}
_6d2=d.makeClipping(_6d3.element);
s.setStyle(_6d3.element,{height:"0px"});
s.showElement(_6d3.element);
},afterUpdateInternal:function(_6d4){
s.setStyle(_6d4.element.firstChild,{bottom:(_6d4.dims[0]-_6d4.element.clientHeight)+"px"});
},afterFinishInternal:function(_6d5){
d.undoClipping(_6d5.element,_6d2);
if(/MSIE/.test(navigator.userAgent)){
d.undoPositioned(_6d5.element);
d.undoPositioned(_6d5.element.firstChild);
}else{
d.undoPositioned(_6d5.element.firstChild);
d.undoPositioned(_6d5.element);
}
s.setStyle(_6d5.element.firstChild,{bottom:_6d0});
}},_6cc);
return new MochiKit.Visual.Scale(_6cb,100,_6cc);
};
MochiKit.Visual.slideUp=function(_6d6,_6d7){
var d=MochiKit.DOM;
var b=MochiKit.Base;
var s=MochiKit.Style;
_6d6=d.getElement(_6d6);
if(!_6d6.firstChild){
throw "MochiKit.Visual.slideUp must be used on a element with a child";
}
d.removeEmptyTextNodes(_6d6);
var _6db=s.getStyle(_6d6.firstChild,"bottom");
var _6dc;
_6d7=b.update({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_6dd){
d.makePositioned(_6dd.element);
d.makePositioned(_6dd.element.firstChild);
if(/Opera/.test(navigator.userAgent)){
s.setStyle(_6dd.element,{top:""});
}
_6dc=d.makeClipping(_6dd.element);
s.showElement(_6dd.element);
},afterUpdateInternal:function(_6de){
s.setStyle(_6de.element.firstChild,{bottom:(_6de.dims[0]-_6de.element.clientHeight)+"px"});
},afterFinishInternal:function(_6df){
s.hideElement(_6df.element);
d.undoClipping(_6df.element,_6dc);
d.undoPositioned(_6df.element.firstChild);
d.undoPositioned(_6df.element);
s.setStyle(_6df.element.firstChild,{bottom:_6db});
}},_6d7);
return new MochiKit.Visual.Scale(_6d6,0,_6d7);
};
MochiKit.Visual.squish=function(_6e0,_6e1){
var d=MochiKit.DOM;
var b=MochiKit.Base;
var _6e4;
_6e1=b.update({restoreAfterFinish:true,beforeSetupInternal:function(_6e5){
_6e4=d.makeClipping(_6e5.element);
},afterFinishInternal:function(_6e6){
MochiKit.Style.hideElement(_6e6.element);
d.undoClipping(_6e6.element,_6e4);
}},_6e1);
return new MochiKit.Visual.Scale(_6e0,/Opera/.test(navigator.userAgent)?1:0,_6e1);
};
MochiKit.Visual.grow=function(_6e7,_6e8){
var d=MochiKit.DOM;
var v=MochiKit.Visual;
var s=MochiKit.Style;
_6e7=d.getElement(_6e7);
_6e8=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.full,scaleContent:true,scaleFromCenter:false},_6e8);
var _6ec={top:_6e7.style.top,left:_6e7.style.left,height:_6e7.style.height,width:_6e7.style.width,opacity:s.getStyle(_6e7,"opacity")};
var dims=s.getElementDimensions(_6e7);
var _6ee,_6ef;
var _6f0,_6f1;
switch(_6e8.direction){
case "top-left":
_6ee=_6ef=_6f0=_6f1=0;
break;
case "top-right":
_6ee=dims.w;
_6ef=_6f1=0;
_6f0=-dims.w;
break;
case "bottom-left":
_6ee=_6f0=0;
_6ef=dims.h;
_6f1=-dims.h;
break;
case "bottom-right":
_6ee=dims.w;
_6ef=dims.h;
_6f0=-dims.w;
_6f1=-dims.h;
break;
case "center":
_6ee=dims.w/2;
_6ef=dims.h/2;
_6f0=-dims.w/2;
_6f1=-dims.h/2;
break;
}
var _6f2=MochiKit.Base.update({beforeSetupInternal:function(_6f3){
s.setStyle(_6f3.effects[0].element,{height:"0px"});
s.showElement(_6f3.effects[0].element);
},afterFinishInternal:function(_6f4){
d.undoClipping(_6f4.effects[0].element);
d.undoPositioned(_6f4.effects[0].element);
s.setStyle(_6f4.effects[0].element,_6ec);
}},_6e8);
return new v.Move(_6e7,{x:_6ee,y:_6ef,duration:0.01,beforeSetupInternal:function(_6f5){
s.hideElement(_6f5.element);
d.makeClipping(_6f5.element);
d.makePositioned(_6f5.element);
},afterFinishInternal:function(_6f6){
new v.Parallel([new v.Opacity(_6f6.element,{sync:true,to:1,from:0,transition:_6e8.opacityTransition}),new v.Move(_6f6.element,{x:_6f0,y:_6f1,sync:true,transition:_6e8.moveTransition}),new v.Scale(_6f6.element,100,{scaleMode:{originalHeight:dims.h,originalWidth:dims.w},sync:true,scaleFrom:/Opera/.test(navigator.userAgent)?1:0,transition:_6e8.scaleTransition,scaleContent:_6e8.scaleContent,scaleFromCenter:_6e8.scaleFromCenter,restoreAfterFinish:true})],_6f2);
}});
};
MochiKit.Visual.shrink=function(_6f7,_6f8){
var d=MochiKit.DOM;
var v=MochiKit.Visual;
var s=MochiKit.Style;
_6f7=d.getElement(_6f7);
_6f8=MochiKit.Base.update({direction:"center",moveTransition:v.Transitions.sinoidal,scaleTransition:v.Transitions.sinoidal,opacityTransition:v.Transitions.none,scaleContent:true,scaleFromCenter:false},_6f8);
var _6fc={top:_6f7.style.top,left:_6f7.style.left,height:_6f7.style.height,width:_6f7.style.width,opacity:s.getStyle(_6f7,"opacity")};
var dims=s.getElementDimensions(_6f7);
var _6fe,_6ff;
switch(_6f8.direction){
case "top-left":
_6fe=_6ff=0;
break;
case "top-right":
_6fe=dims.w;
_6ff=0;
break;
case "bottom-left":
_6fe=0;
_6ff=dims.h;
break;
case "bottom-right":
_6fe=dims.w;
_6ff=dims.h;
break;
case "center":
_6fe=dims.w/2;
_6ff=dims.h/2;
break;
}
var _700;
var _701=MochiKit.Base.update({beforeStartInternal:function(_702){
_700=d.makePositioned(_702.effects[0].element);
d.makeClipping(_702.effects[0].element);
},afterFinishInternal:function(_703){
s.hideElement(_703.effects[0].element);
d.undoClipping(_703.effects[0].element,_700);
d.undoPositioned(_703.effects[0].element);
s.setStyle(_703.effects[0].element,_6fc);
}},_6f8);
return new v.Parallel([new v.Opacity(_6f7,{sync:true,to:0,from:1,transition:_6f8.opacityTransition}),new v.Scale(_6f7,/Opera/.test(navigator.userAgent)?1:0,{sync:true,transition:_6f8.scaleTransition,scaleContent:_6f8.scaleContent,scaleFromCenter:_6f8.scaleFromCenter,restoreAfterFinish:true}),new v.Move(_6f7,{x:_6fe,y:_6ff,sync:true,transition:_6f8.moveTransition})],_701);
};
MochiKit.Visual.pulsate=function(_704,_705){
var d=MochiKit.DOM;
var v=MochiKit.Visual;
var b=MochiKit.Base;
var _709=MochiKit.Style.getStyle(_704,"opacity");
_705=b.update({duration:3,from:0,afterFinishInternal:function(_70a){
MochiKit.Style.setStyle(_70a.element,{"opacity":_709});
}},_705);
var _70b=_705.transition||v.Transitions.sinoidal;
var _70c=b.bind(function(pos){
return _70b(1-v.Transitions.pulse(pos,_705.pulses));
},_70b);
b.bind(_70c,_70b);
return new v.Opacity(_704,b.update({transition:_70c},_705));
};
MochiKit.Visual.fold=function(_70e,_70f){
var d=MochiKit.DOM;
var v=MochiKit.Visual;
var s=MochiKit.Style;
_70e=d.getElement(_70e);
var _713={top:_70e.style.top,left:_70e.style.left,width:_70e.style.width,height:_70e.style.height};
var _714=d.makeClipping(_70e);
_70f=MochiKit.Base.update({scaleContent:false,scaleX:false,afterFinishInternal:function(_715){
new v.Scale(_70e,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_716){
s.hideElement(_716.element);
d.undoClipping(_716.element,_714);
s.setStyle(_716.element,_713);
}});
}},_70f);
return new v.Scale(_70e,5,_70f);
};
MochiKit.Visual.Color=MochiKit.Color.Color;
MochiKit.Visual.getElementsComputedStyle=MochiKit.DOM.computedStyle;
MochiKit.Visual.__new__=function(){
var m=MochiKit.Base;
m.nameFunctions(this);
this.EXPORT_TAGS={":common":this.EXPORT,":all":m.concat(this.EXPORT,this.EXPORT_OK)};
};
MochiKit.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"];
MochiKit.Visual.EXPORT_OK=["Base","PAIRS"];
MochiKit.Visual.__new__();
MochiKit.Base._exportSymbols(this,MochiKit.Visual);
if(typeof (MochiKit)=="undefined"){
MochiKit={};
}
if(typeof (MochiKit.MochiKit)=="undefined"){
MochiKit.MochiKit={};
}
MochiKit.MochiKit.NAME="MochiKit.MochiKit";
MochiKit.MochiKit.VERSION="1.4";
MochiKit.MochiKit.__repr__=function(){
return "["+this.NAME+" "+this.VERSION+"]";
};
MochiKit.MochiKit.toString=function(){
return this.__repr__();
};
MochiKit.MochiKit.SUBMODULES=["Base","Iter","Logging","DateTime","Format","Async","DOM","Selector","Style","LoggingPane","Color","Signal","Position","Visual"];
if(typeof (JSAN)!="undefined"||typeof (dojo)!="undefined"){
if(typeof (dojo)!="undefined"){
dojo.provide("MochiKit.MochiKit");
dojo.require("MochiKit.*");
}
if(typeof (JSAN)!="undefined"){
(function(lst){
for(var i=0;i<lst.length;i++){
JSAN.use("MochiKit."+lst[i],[]);
}
})(MochiKit.MochiKit.SUBMODULES);
}
(function(){
var _71a=MochiKit.Base.extend;
var self=MochiKit.MochiKit;
var _71c=self.SUBMODULES;
var _71d=[];
var _71e=[];
var _71f={};
var i,k,m,all;
for(i=0;i<_71c.length;i++){
m=MochiKit[_71c[i]];
_71a(_71d,m.EXPORT);
_71a(_71e,m.EXPORT_OK);
for(k in m.EXPORT_TAGS){
_71f[k]=_71a(_71f[k],m.EXPORT_TAGS[k]);
}
all=m.EXPORT_TAGS[":all"];
if(!all){
all=_71a(null,m.EXPORT,m.EXPORT_OK);
}
var j;
for(j=0;j<all.length;j++){
k=all[j];
self[k]=m[k];
}
}
self.EXPORT=_71d;
self.EXPORT_OK=_71e;
self.EXPORT_TAGS=_71f;
}());
}else{
if(typeof (MochiKit.__compat__)=="undefined"){
MochiKit.__compat__=true;
}
(function(){
if(typeof (document)=="undefined"){
return;
}
var _725=document.getElementsByTagName("script");
var _726="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var base=null;
var _728=null;
var _729={};
var i;
for(i=0;i<_725.length;i++){
var src=_725[i].getAttribute("src");
if(!src){
continue;
}
_729[src]=true;
if(src.match(/MochiKit.js$/)){
base=src.substring(0,src.lastIndexOf("MochiKit.js"));
_728=_725[i];
}
}
if(base===null){
return;
}
var _72c=MochiKit.MochiKit.SUBMODULES;
for(var i=0;i<_72c.length;i++){
if(MochiKit[_72c[i]]){
continue;
}
var uri=base+_72c[i]+".js";
if(uri in _729){
continue;
}
if(document.documentElement&&document.documentElement.namespaceURI==_726){
var s=document.createElementNS(_726,"script");
s.setAttribute("id","MochiKit_"+base+_72c[i]);
s.setAttribute("src",uri);
s.setAttribute("type","application/x-javascript");
_728.parentNode.appendChild(s);
}else{
document.write("\x3cscript src=\""+uri+"\" type=\"text/javascript\">\x3c/script>");
}
}
})();
}
/*
 * Timer class: Keeps a div updated with HH:MI:SS.
 *
 * The timer runs down until it hits 0.
 *
 * The principal mechanism for the timer is the interval stored in
 * this._interval_id. Whenever the interval fires, it calls this._tick(). This
 * causes the remaining time to be updated (based on how much time has passed
 * since the last update, which we remember with this._last_tick). Then it
 * updates the display.
 *
 * The users of this class may set a new remaining time by simply calling
 * this.setRemaining(). This will update the remaining time and start a new
 * timer.
 */
var Timer = Class.create();
Timer.prototype = {
    
    _interval_ms: 100,
    /*
     * timer = new Timer(timerDiv, remaining)
     *
     * - timerDiv: The div to contain the content.
     * - remaining: How many milliseconds are left.
     */
    initialize: function(timerDiv, remaining) {
        
        if (!timerDiv) {
            throw new Error("timerDiv is null!");
        }
        this._timerDiv = timerDiv;
        
        this._remaining = remaining;
        
        this._last_tick = new Date().getTime();
        
        this._last_shown = null;
        
        this._interval_id = null;
        
        
        var self = this;
        this._tickFunction = function() { self._tick(); };
        
        this._tick();
        if (this._remaining > 0) {
            this._startInterval();
        }
    },
    /*
     * _tick: This is what happens when the interval fires. It updates the
     * remaining time and then shows the time.
     */
    _tick: function() {
        this._timer_id = null;
        this._updateRemaining();
        this._showRemaining();
    },
    /*
     * _startInterval: setInterval for a periodic update of the time, if one
     * is not set already.
     */
    _startInterval: function() {
        if (!this._interval_id) {
            this._interval_id = window.setInterval(
                this._tickFunction,
                this._interval_ms);
        }
    },
    /*
     * _stopInterval: clearInterval if one is set.
     */
    _stopInterval: function() {
        if (this._interval_id) {
            window.clearInterval(this._interval_id);
            this._interval_id = null;
        }
    },
    /*
     * _updateRemaining: Change the remaining time based on how long has
     * actually passed since the last _updateRemaining call.
     */
    _updateRemaining: function() {
        var cur = new Date().getTime();
        
        this._remaining -= cur - this._last_tick;
        this._last_tick = cur;
        if (this._remaining <= 0) {
            this._remaining = 0;
            this._stopInterval();
        }
    },
    /*
     * _showRemaining: Actually show whatever is in this._remaining
     */
    _showRemaining: function() {
        
        var s = Math.ceil(this._remaining/1000);
        
        if (s == this._last_shown) {
            return;
        }
        this._last_shown = s;
        var hours   = '0';
        var minutes = '0';
        var seconds = '0';
        
        if ( s < 60 ) {
            seconds = s;
        } else if ( s >= 60 ) {
            if ( s > (60*60) ) {
                hours = Math.floor(s / (60*60));
                s     = (s % (60*60));
            }
            minutes = Math.floor(s / 60);
            seconds = s % 60;
        }
        this._timerDiv.innerHTML = ( this._padLeft( hours )
                 +":"+ this._padLeft( minutes )
                 +":"+ this._padLeft( seconds )
                 +" " );
    },
    /*
     * _padLeft: A helper function to pad the left with 0's to make 2 digits.
     */
    _padLeft: function(i)
    {
        return (( i < 10 ) ? ("0"+ i) : i);
    },
    /*
     * setRemaining: Call to set the time remaining.
     */
    setRemaining: function(remaining) {
        this._last_tick = new Date().getTime();
        this._remaining = remaining;
        this._showRemaining();
        if (this._remaining > 0) {
            this._startInterval();
        } else {
            this._stopInterval();
        }
    }
};
/* The Promo object contains a set of attributes that we are interested in for
 * updating upcoming or available deals. This includes: time to activation,
 * time to expire, percentage sold, and current deal state.
 *
 * This object is created by the Refresh object below after a call to get an
 * updated promo object. It is also created when time passes with updated
 * state and time parameters.
 */
var Promo = function(o) {
    
    this.dealState      = o.getDealState;
    
    
    this.percentageSold = o.getPercentageSold;
    
    
    
    this.msToActivation = o.getMsToActivation;
    this.msToExpiration = o.getMsToExpiration;
    
    
    
    
    this.dealTitle = o.getDealTitle;
    
    
    this.postDate       = o.getPostDate;
    this.expirationDate = o.getExpirationDate;
    
    
    this.msToAutoRefresh = o.getMsToAutoRefresh;
    
    
    this.autoRefresh    = o.getAutoRefresh;
};
Promo.prototype = {
    
    repr: function() {
        if (this.dealState == 'ComingSoon') {
            return '[Promo ComingSoon in '+
                Math.floor(this.msToActivation/1000)+'s]';
        } else if (this.dealState == 'Available') {
            return '[Promo Available for '+
                Math.floor(this.msToExpiration/1000)+
                's and '+
                this.percentageSold+
                '% sold]';
        } else if (this.dealState == 'PromotionSoldOut') {
            return '[Promo PromotionSoldOut for '+
                Math.floor(this.msToExpiration/1000)+
                's]';
        } else if (this.dealState == 'Expired') {
            return '[Promo Expired]';
        } else if (this.dealState == 'Claimed') {
            return '[Promo Claimed]';
        } else {
            return '[Promo with unidentifed state '+this.dealState+']';
        }
    },
    
    
    copy: function() {
        return new Promo({
            getDealState                : this.dealState,
            getPercentageSold           : this.percentageSold,
            getDealTitle                : this.dealTitle,
            getMsToActivation           : this.msToActivation,
            getMsToExpiration           : this.msToExpiration,
            getPostDate                 : this.postDate,
            getExpirationDate           : this.expirationDate,
            getMsToAutoRefresh          : this.msToAutoRefresh,
            getAutoRefresh              : true
        });
    },
    
    copyInFuture: function(ms) {
        var c = this.copy();
        c.msToActivation -= ms;
        c.msToExpiration -= ms;
        
        if (c.msToActivation > 0) {
            c.dealState = 'ComingSoon';
        } else if (c.msToExpiration > 0) {
            if (this.percentageSold < 100) {
                c.dealState = 'Available';
            } else {
                c.dealState = 'PromotionSoldOut';
            }
        } else {
            c.dealState = 'Expired';
        }
        return c;
    }
};
/* PromoRefresh is a class designed to fetch the first copy of the promo, and
 * then to keep it fresh. It takes a dealID, a callback, and an errback (when
 * no further updates are possible.) It respects the min refresh time given by
 * the server, as well as the autoRefresh parameter.
 */
PromoRefresh = Class.create();
PromoRefresh.prototype = {
    /* Class variables */
    
    _maxErrors: 10,
    _url: 'MUST DEFINE PromoRefresh.prototype._url',
    initialize: function(dealID, claimed, callback, errback) {
        this.className = 'Accordion.Tab.Refresh';
        if (!dealID) {
            throw new Error(
                'Mandatory argument dealID not sent to constructor');
        }
        if (!callback) {
            throw new Error(
                'Mandatory argument callback not sent to constructor');
        }
        if (!errback) {
            throw new Error(
                'Mandatory argument errback not sent to constructor');
        }
        this._dealID        = dealID;
        this._claimed       = claimed;
        this._callback      = callback;
        this._errback       = errback;
        
        
        this._callAJAX_func = bind(this._callAJAX, this);
        this._onSuccess_func = bind(this._onSuccess, this);
        this._onError_func = bind(this._onError, this);
        
        this._recentFailures = 0;
        
        this._timeout_id = null;
        
        this._promo = null;
        
        this._callAJAX_func();
        return this;
    },
    /* Record a successful event */
    _success: function() {
        if (this._recentFailures > 0) {
            this._recentFailures -= 1;
        }
    },
    /* Record a failure event */
    _failure: function() {
        this._recentFailures += 1;
    },
    /* setTimeout to _callAJAX based on state */
    _setTimeoutOnState: function() {
        
        
        if (!this._promo) {
            
            this._setTimeout(0);
            return;
        }
        if (this._promo.dealState == 'ComingSoon') {
            if (this._promo.msToActivation > 600000) {
                this._setTimeout(60000);
            } else {
                this._setTimeout(100);
            }
        } else if (this._promo.dealState == 'Available') {
            this._setTimeout(100);
        } else if (this._promo.dealState == 'Expired' ||
            this._promo.dealState == 'PromotionSoldOut' ||
            this._promo.dealState == 'Claimed') {
            this._setTimeout(60000);
        } else {
            
            this._setTimeout(60000);
        }
    },
    /* setTimeout--but adjust for errors. */
    _setTimeout: function(ms) {
        if (this._timeout_id) {
            clearTimeout(this._timeout_id);
        }
        
        if (this._promo &&
                this._promo.msToAutoRefresh)
        {
            if (ms < this._promo.msToAutoRefresh) {
                ms = this._promo.msToAutoRefresh;
            }
        }
        if (this._recentFailures >= this._maxErrors) {
            
            logError("Giving up on dealID "+this._dealID+": Too many failures.");
            try {
                this._errback();
            } catch(e) {
                logError("Error calling errback:", e);
            }
            return;
        } else if (this._recentFailures > 0) {
            
            
            
            log("Backing off due to errors on dealID "+this._dealID);
            ms += 1000*Math.pow(2, this._recentFailures)*(Math.random()+0.5);
        } else {
            
            ms *= (1.0 + 0.2*Math.random());
        }
        ms = Math.floor(ms+0.5);
        log("AJAX for promo "+this._dealID+" in "+ms+"ms");
        this._timeout_id = window.setTimeout(this._callAJAX_func, ms);
    },
    /* call AJAX */
    _callAJAX: function() {
        
        
        loadJSONDoc(this._url,
            { dealID: this._dealID, mID: marketplaceID, dontcache: new Date().getTime() }
        ).addCallbacks(this._onSuccess_func, this._onError_func);
    },
    /* handle the completion of the AJAX call */
    _onSuccess: function(promo) {
        
        
        
        
        this._success();
        if (this._claimed) {
            promo.getDealState = 'Claimed';
        }
        this._setPromo(new Promo(promo));
        if (this._promo.autoRefresh) {
            this._setTimeoutOnState();
        }
    },
    _onError: function(err) {
        this._failure();
        logError("Request failed for dealID "+this._dealID, err);
        this._setTimeoutOnState();
    },
    
    _setPromo: function(promo) {
        this._promo = promo;
        
        
        
        
        
        
        if (this._promo.msToActivation > 0) {
            if (this._stateChangeTimeoutID) {
                window.clearTimeout(this._stateChangeTimeoutID);
            }
            this._stateChangeTimeoutID = window.setTimeout(
                bind(function() {
                    this._stateChangeTimeoutID = null;
                    this._setPromo(promo.copyInFuture(promo.msToActivation));
                }, this), promo.msToActivation);
        } else if (promo.msToExpiration > 0) {
            if (this._stateChangeTimeoutID) {
                window.clearTimeout(this._stateChangeTimeoutID);
            }
            this._stateChangeTimeoutID = window.setTimeout(
                bind(function() {
                    this._stateChangeTimeoutID = null;
                    this._setPromo(promo.copyInFuture(promo.msToExpiration));
                }, this), promo.msToExpiration);
        } else {
            if (this._stateChangeTimeoutID) {
                window.clearTimeout(this._stateChangeTimeoutID);
                this._stateChangeTimeoutID = null;
            }
        }
        
        try {
            this._callback(promo);
        } catch(e) {
            logError("Error calling callback:", e);
        }
    }
};
var Accordion  = Class.create();
Accordion.prototype =
{
    initialize: function(container,tabIds,options)
    {
        this.className = 'Accordion';
        if ( !container )
            throw new Error('No Container sent to Accordion constructor');
        if ( !tabIds )
            throw new Error('No tabIds sent to Accordion constructor');
        this.container     = container;
        this.customerID    = options.customerID;
        this.onLoadShowTab = options.onLoadShowTab;
        
        this.singleTabMinHeight    = 20;
        this.singleTabMaxHeight    = 229;
        this.maxClosedViewableTabs = 12;
        
        this.maxOpenedViewableTabs = 4;
        
        this.setTabs( tabIds );
        
        if ( this.containerTabs.length > this.maxOpenedViewableTabs )
          this.scroller = new Accordion.Scroller(this);
        return this;
    },
    getTabByIdx: function(idx)
    {
        
        return ( this.containerTabs[ idx ]
                 ? this.containerTabs[ idx ]
                 : new Accordion.FakeTab(this) );
    },
    setCurrExpandedTab: function(tabObj)
    {
        this.currExpandedTab = tabObj;
    },
    getCurrExpandedTabID: function()
    {
        return ( this.currExpandedTab ? this.currExpandedTab.idx : -1 );
    },
    getCurrExpandedTab: function()
    {
        return this.getTabByIdx( this.currExpandedTab ? this.currExpandedTab.idx : '' );
    },
    aTabIsOpen: function()
    {
        return ( typeof( this.currExpandedTab ) == 'object' ? 1 : 0 );
    },
    closeCurrExpandedTab: function()
    {
        var ft = new Accordion.FakeTab(this);
        this.flipTabs( this.currExpandedTab, ft );
        this.setCurrExpandedTab( ft );
    },
    tabExpired: function(tab)
    {
        var nextTab = tab.next();
        
        
        
        if ( this.getCurrExpandedTab().idx == tab.idx ) {
            if ( this.scroller ) {
                this.scroller.focusTabToOpen( nextTab, true );
            } else {
                this.flipTabs( tab, nextTab );
            }
        }
        //gbox-la-no-more-deals
        if ( !nextTab.idx ) {
            this.showNoMoreDealsMessage();
        }
    },
    
    
    
    
    flipTabs: function( tabToCollapse, tabToExpand )
    {
        if ( !tabToCollapse || !tabToExpand )
            return;
        
        this.manageTabsDisplaySwap(tabToCollapse,tabToExpand);
        
        new Accordion.Animate(this,tabToExpand,tabToCollapse);
        
        this.setCurrExpandedTab( tabToExpand );
    },
    manageTabsDisplaySwap: function(tabToCollapse,tabToExpand)
    {
        
        
        
        if ( tabToCollapse.exists() && tabToExpand.exists() ) {
        } else if ( !tabToCollapse.exists() && tabToExpand.exists() ) {
            
            MochiKit.DOM.$('gbox-la-msgC').style.display = 'none';
        } else if ( tabToCollapse.exists() && !tabToExpand.exists() ) {
        }
    },
    setTabs: function( tabIds )
    {
        if ( !this.containerTabs )
            this.containerTabs = new Array();
        
        
        if ( this.onLoadShowTab > tabIds.length )
            this.onLoadShowTab = 0;
        this.panels = new Array();
        for ( var i = 0; i < tabIds.length ; i++ ) {
            this.panels.push( MochiKit.DOM.$( tabIds[i] ) );
            this.containerTabs.push( new Accordion.Tab(this, this.panels[i], i) );
            
            if ( this.onLoadShowTab != '' && this.onLoadShowTab == i ) {
                
                
                
                
                
                this.containerTabs[i].expand();
            } else {
                this.containerTabs[i].collapse();
            }
            
            this.containerTabs[i].attachBehaviors();
        }
        
        if ( this.aTabIsOpen() ) {
            var tab = this.getCurrExpandedTab();
            var nextTab = tab.next();
            tab.initContent();
            nextTab.initContent();
        }
    },
    showNoMoreDealsMessage: function()
    {
        MochiKit.DOM.$('gbox-la-deals-still-active').style.display = 'none';
        MochiKit.DOM.$('gbox-la-all-deals-expired').style.display  = 'block';
    }
};
Accordion.Scroller = Class.create();
Accordion.Scroller.prototype =
{
    initialize: function(accordion)
    {
        this.className = 'Accordion.Scroller';
        if ( !accordion )
            throw new Error("No Accordion object passed to Scroller");
        this.accordion  = accordion;
        
        
        this.allTabsC = MochiKit.DOM.$('gbox-la-main-body-content');
        this.allTabsC.style.position = "relative";
        
        this.totalTabs = this.accordion.containerTabs.length;
        
        this.stepsPerAnimation = 4;
        this.msDelay           = 10;
        
        
        
        this.scrollInProgress_ = false;
        
        
        this.totalOffset = 0;
        
        
        this.stopAt      = 0;
        
        
        this.scrollCount = 0;
        
        this.buttons = new Accordion.Scroller.Buttons(this);
        this.buttons.update();
        
        
        
        this.scrollToActiveDeal();
        return this;
    },
    scrollToActiveDeal: function()
    {
        var tabsToMove = (this.accordion.onLoadShowTab - 1);
        if ( tabsToMove > 0 ) {
            
            this.animate = false;
            for ( var i = 0; i < tabsToMove; i++ ) {
                this.scrollDown();
            }
        } else {
            this.buttons.update();
        }
        
        this.animate = true;
    },
    
    
    setPxToOffset: function(i)
    {
        i = (!i || i <= 0 ? 1 : i);
        this.pxToOffset = (this.accordion.singleTabMinHeight + 3) * i;
    },
    startingScroll: function()
    {
        this.scrollInProgress_ = true;
    },
    endedScroll: function()
    {
        this.scrollInProgress_ = false;
    },
    scrollInProgress: function()
    {
        return this.scrollInProgress_;
    },
    closeCurrTab: function(tabIdx)
    {
        this.accordion.closeCurrExpandedTab();
    },
    
    canScrollDown: function()
    {
        /* We can't scroll down if:
         *  1. we have not finished our last scroll
         *  2. we do not have any deals any lower than where we currently are
         *  3. there are only 4 tabs still on the page
         */
        if ( this.scrollInProgress() ||
             !this.buttons.dealsBelowFold() ||
             (this.scrollCount + this.accordion.maxOpenedViewableTabs) >= this.totalTabs
        ) {
            return false;
        } else {
            return true;
        }
    },
    
    
    
    scrollDown: function()
    {
        
        if (this.scrollInProgress()) {
            return;
        }
        
        if (!this.canScrollDown() ) {
            return;
        }
        this.startingScroll();
        
        
        if ( this.accordion.getCurrExpandedTabID() == this.scrollCount )
            this.closeCurrTab(this.accordion.getCurrExpandedTabID());
        
        
        
        this.setPxToOffset();
        this.scrollCount++;
        
        this.stopAt = (this.totalOffset - this.pxToOffset);
        
        this.pxOffsetPerCall = Math.round(this.pxToOffset / this.stepsPerAnimation );
        
        this.animateScrollDown();
    },
    
    canScrollUp: function()
    {
        /* We can't scroll up if we do not have any deals any above than where
         * we currently are
         */
        if (!this.buttons.dealsAboveFold() ) {
            return false;
        } else {
            return true;
        }
    },
    
    
    
    scrollUp: function()
    {
        
        
        
        if ( this.scrollInProgress() ) {
            return;
        } else if ( !this.canScrollUp() ) {
            return;
        }
        this.startingScroll();
        
        
        
        
        
        
        var cet = this.accordion.getCurrExpandedTabID();
        if ( (this.scrollCount + this.accordion.maxOpenedViewableTabs) == (cet + 1) )
            this.closeCurrTab(cet);
        
        
        
        
        this.scrollCount--;
        this.setPxToOffset();
        
        this.stopAt = (this.totalOffset + this.pxToOffset);
        
        this.pxOffsetPerCall = Math.round(this.pxToOffset / this.stepsPerAnimation );
        
        this.animateScrollUp();
    },
    
    animateScrollDown: function()
    {
        
        
        
        
        
        if ( !this.animate || (this.totalOffset - this.pxOffsetPerCall) <= this.stopAt ) {
            this.onComplete();
            return;
        }
        this.totalOffset       -= this.pxOffsetPerCall;
        this.allTabsC.style.top = this.totalOffset +"px";
        this.timer = window.setTimeout( bindTo(this.animateScrollDown, this), this.msDelay );
    },
    
    animateScrollUp: function( noAnimate )
    {
        if ( !this.animate || (this.totalOffset + this.pxOffsetPerCall) >= this.stopAt ) {
            this.onComplete();
            return;
        }
        this.totalOffset       += this.pxOffsetPerCall;
        this.allTabsC.style.top = this.totalOffset +"px";
        this.timer = window.setTimeout( bindTo(this.animateScrollUp, this), this.msDelay );
    },
    onComplete: function()
    {
        
        
        this.totalOffset        = this.stopAt;
        this.allTabsC.style.top = this.stopAt +"px";
        
        if ( typeof this.onCompleteF == 'function' )
            this.onCompleteF();
        
        this.buttons.update();
        
        this.endedScroll();
    },
    
    
    
    manageFlipAndFocus: function(tab,flip)
    {
        if ( tab && flip ) {
            var cet = this.accordion.getCurrExpandedTab();
            if ( cet == tab ) {
                this.accordion.flipTabs(tab, new Accordion.FakeTab( this.accordion ));
            } else {
                this.accordion.flipTabs(cet,tab);
            }
        }
        this.buttons.update();
    },
    //
    
    //
    focusTabToOpen: function(tab, showTabOnComplete)
    {
        
        
        
        
        
        var justFlip = ( (tab.idx <= 1 && this.scrollCount == 0) ||
                         (tab.idx == (this.scrollCount + 1)) );
        if ( justFlip ) {
            this.manageFlipAndFocus(tab,showTabOnComplete);
        } else if ( tab.idx > (this.scrollCount + 1)) {
            
            
            
            
            
            var fromEnd = (this.totalTabs - tab.idx) - 1;
            
            
            var scrollDownBy = (tab.idx - 2) - this.scrollCount;
            
            
            
            if ( fromEnd == 0 )
                scrollDownBy -= 1;
            
            
            if ( scrollDownBy == 0 ) {
                this.manageFlipAndFocus(tab,showTabOnComplete);
                return;
            }
            
            
            
            this.setPxToOffset( scrollDownBy );
            this.scrollCount += scrollDownBy;
            
            this.stopAt = (this.totalOffset - this.pxToOffset);
            
            this.pxOffsetPerCall = Math.round(this.pxToOffset / this.stepsPerAnimation);
            this.attachFlipOnComplete( tab, showTabOnComplete, scrollDownBy );
            this.animateScrollDown();
        } else if ( tab.idx <= this.scrollCount ) {
            
            var scrollUpBy = (tab.idx + 1) - this.scrollCount;
            this.setPxToOffset( scrollUpBy );
            this.scrollCount -= scrollUpBy;
            this.stopAt = (this.totalOffset + this.pxToOffset);
            this.pxOffsetPerCall = Math.round(this.pxToOffset / this.stepsPerAnimation);
            this.attachFlipOnComplete( tab, showTabOnComplete, scrollUpBy );
            this.animateScrollUp();
        }
    },
    attachFlipOnComplete: function(tab, showTabOnComplete, diff)
    {
        
        
        
        
        
        
        
        if ( showTabOnComplete ) {
            if ( diff < 99 || diff > 99 ) {
                this.manageFlipAndFocus(tab,showTabOnComplete);
            } else {
                this.onCompleteF = this.manageFlipAndFocus(tab,showTabOnComplete);
            }
        }
    }
};
Accordion.Scroller.Buttons = Class.create();
Accordion.Scroller.Buttons.prototype =
{
    initialize: function(p)
    {
        this.className = 'Accordion.Scroller.Buttons';
        if ( !p )
            throw new Error("No parent (Scroller) object passed to Accordion.Scroller.Buttons");
        this.scroller   = p;
        this.accordion  = p.accordion;
        
        
        MochiKit.DOM.$('gbox-la-scroll-button-upC').style.visibility   = 'visible';
        MochiKit.DOM.$('gbox-la-scroll-button-bcC').style.visibility   = 'visible';
        MochiKit.DOM.$('gbox-la-scroll-button-downC').style.visibility = 'visible';
        
        this.up   = MochiKit.DOM.$('gbox-la-scroll-button-up');
        this.down = MochiKit.DOM.$('gbox-la-scroll-button-down');
        this.upImage   = MochiKit.DOM.$('gbox-la-scroll-button-up-img');
        this.downImage = MochiKit.DOM.$('gbox-la-scroll-button-down-img');
        
        this.breadcrumbMin   = MochiKit.DOM.$('gbox-la-scroll-bc-min');
        this.breadcrumbMax   = MochiKit.DOM.$('gbox-la-scroll-bc-max');
        this.breadcrumbTotal = MochiKit.DOM.$('gbox-la-scroll-bc-total');
        
        this.breadcrumbTotal.innerHTML = this.scroller.totalTabs;
        
        this.attachBehavior();
        return this;
    },
    
    attachBehavior: function()
    {
        var p = this.scroller;
        this.up.onclick   = function(){ p.scrollUp(p)   };
        this.down.onclick = function(){ p.scrollDown(p) };
    },
    update: function()
    {
        
        
        
        this.upCount                 = this.scroller.scrollCount;
        this.breadcrumbMin.innerHTML = ' '+ (this.scroller.scrollCount + 1) +' ';
        
        
        
        
        var max = ( this.accordion.getCurrExpandedTabID() >= 0
                    ? ( this.scroller.scrollCount + this.accordion.maxOpenedViewableTabs )
                    : ( this.scroller.scrollCount + this.accordion.maxClosedViewableTabs ) );
        
        
        
        this.downCount = ( max > this.scroller.totalTabs
                           ? 0
                           : (this.scroller.totalTabs - max) );
        
        this.breadcrumbMax.innerHTML = ' '+ ( max > this.scroller.totalTabs
                                              ? this.scroller.totalTabs
                                              : max ) +' ';
        
        if ( this.scroller.canScrollUp() && hasClassName(this.upImage, 'gbox-img-fog') ) {
            rmClass(this.upImage, 'gbox-img-fog');
        } else if ( !this.scroller.canScrollUp() && !hasClassName(this.upImage, 'gbox-img-fog') ) {
            addClass(this.upImage, 'gbox-img-fog');
        }
        
        if ( this.scroller.canScrollDown() && hasClassName(this.downImage, 'gbox-img-fog') ) {
            rmClass(this.downImage, 'gbox-img-fog');
        } else if ( !this.scroller.canScrollDown() && !hasClassName(this.downImage, 'gbox-img-fog') ) {
            addClass(this.downImage, 'gbox-img-fog');
        }
    },
    dealsAboveFold: function()
    {
        return (this.upCount > 0);
    },
    dealsBelowFold: function()
    {
        return (this.downCount > 0);
    }
};
Accordion.Animate = Class.create();
Accordion.Animate.prototype =
{
 initialize: function(accordion,tabToExpand,tabToCollapse) {
    this.className = 'Accordion.Animate';
    
    if ( !accordion )
        throw new Error('Mandator argument accordion not sent to constructor');
    if ( !tabToExpand )
        throw new Error('Mandator argument tabToExpand not sent to constructor');
    if ( !tabToCollapse )
        throw new Error('Mandator argument tabToCollapse not sent to constructor');
    this.accordion         = accordion;
    this.tabToCollapse     = tabToCollapse;
    this.tabToExpand       = tabToExpand;
    this.tabToExpand.initContent();
    
    this.minTabHeight      = 20;
    this.maxTabHeight      = 190;
    this.msDelay           = 250;
    this.steps             = 10;
    this.stepsTaken        = 0;
    this.containerToCollapse = (tabToCollapse.exists() ? tabToCollapse.mainC : '');
    this.containerToExpand   = (tabToExpand.exists() ? tabToExpand.mainC : '');
    this.switchWithAnimation();
 },
 switchWithoutAnimation: function() {
   this.onComplete();
 },
 switchWithAnimation: function() {
   if ( this.timer )
     clearTimeout(this.timer);
   if ( this.steps <= 0 ) {
     this.onComplete();
     return;
   }
   if ( this.tabToExpand.exists() && this.tabToCollapse.exists() ) {
     this.tandemResize();
   } else {
     
     
     
     
     this.h = Math.round((this.maxTabHeight - this.minTabHeight)/(this.steps - 1));
    if ( this.h > this.maxTabHeight )
      this.h = this.maxTabHeight;
    if ( this.tabToExpand.exists() ) {
      this.expandSingleTab();
    } else {
      this.collapseSingleTab();
    }
   }
 },
 expandSingleTab: function() {
   if ( this.steps <= 0 ) {
     this.onComplete();
   } else {
     setHeight( this.tabToExpand.mainC, (getHeight(this.tabToExpand.mainC) + this.h) );
     this.timer = window.setTimeout( bindTo(this.expandSingleTab, this), this.getDelay() );
   }
 },
 collapseSingleTab: function() {
   if ( this.steps <= 0 ) {
     this.onComplete();
   } else {
     setHeight( this.tabToCollapse.mainC, (getHeight(this.tabToCollapse.mainC) - this.h) );
     this.timer = window.setTimeout( bindTo(this.collapseSingleTab, this), this.getDelay() );
   }
 },
 tandemResize: function() {
   if ( this.steps <= 0 ) {
     this.onComplete();
   } else {
     var coh  = this.containerToCollapse.offsetHeight;
     var eoh  = this.containerToExpand.offsetHeight;
     var diff = parseInt((coh - this.minTabHeight)/this.steps);
     
     
     setHeight( this.containerToCollapse, (coh - diff));
     
     if ( this.containerToExpand )
       this.containerToExpand.style.height = (eoh + diff) +'px';
     this.timer = window.setTimeout( bindTo(this.tandemResize, this), this.getDelay() );
   }
 },
 getDelay: function() {
   
   var thisDelay  = Math.round(this.msDelay/this.steps--) ;
   this.msDelay  -= thisDelay;
   
   this.stepsTaken++;
   return thisDelay;
 },
 onComplete: function() {
    if ( this.timer )
        clearTimeout(this.timer);
    
    
    
    
    
    
    
    
    this.tabToExpand.expand();
    if ( this.tabToCollapse.exists() ) {
        this.tabToCollapse.collapse();
    }
    
    if ( this.tabToExpand.exists() && !this.tabToCollapse.exists() ) {
        MochiKit.DOM.$('gbox-la-msgC').style.display = 'none';
    } else if ( !this.tabToExpand.exists() && this.tabToCollapse.exists() ) {
        MochiKit.DOM.$('gbox-la-msgC').style.display = 'block';
    }
    var nextTab = this.tabToExpand.next();
    if (nextTab && nextTab.exists()) {
        nextTab.initContent();
    }
 }
};
Accordion.Tab = Class.create();
Accordion.Tab.prototype =
{
    /*
    
    frameClasses: [
        'gbox-la-tab-frame-tb',
        'gbox-la-tab-frame-bb',
        'gbox-la-tab-frame-ll',
        'gbox-la-tab-frame-lr',
        'gbox-la-tab-frame-ul',
        'gbox-la-tab-frame-ur',
        'gbox-la-tab-mainC'],
    */
    initialize: function(accordion, container, idx) {
        this.className = 'Accordion.Tab';
        this.accordion = accordion;
        this.container = container;
        this.idx       = idx;
        
        this.key        = container.id;
        this.dealID     = this.key;
        
        
        
        this.mainC        = MochiKit.DOM.$('gbox-la-tab-mainC.'+ this.key);
        this.titlebarC    = MochiKit.DOM.$('gbox-la-tab-titlebarC.'+ this.key);
        this.dealDisplayC = MochiKit.DOM.$('gbox-la-tab-deal-displayC.'+ this.key);
        
        this.availDescr     = MochiKit.DOM.$('gbox-la-tab-avail-descr.'+ this.key);
        this.plusButton     = MochiKit.DOM.$('gbox-la-tab-expand-button.'+ this.key);
        this.contractButton = MochiKit.DOM.$('gbox-la-tab-contract-button.'+ this.key);
        this.dealTitle      = MochiKit.DOM.$('gbox-la-tab-deal-title.'+ this.key);
        this.claimed = (this.availDescr.innerHTML.search(new
            RegExp('^\\s*'+GBOX_AVAIL_DESCRS['Claimed']+'\\s*$')) >= 0);
        
        this.panelMinHeight    = this.accordion.singleTabMinHeight;
        this.expandedTabHeight = this.accordion.singleTabMaxHeight;
        return this;
    },
    next: function() {
        return this.accordion.getTabByIdx(this.idx+1);
    },
    setPromo: function(promo) {
        var old_promo = this.promo;
        this.promo = promo;
        
        if (this.isDisabled) {
            if (this.promo.dealState == 'Available') {
                this.enable();
            }
        } else {
            if (this.promo.dealState != 'Available') {
                this.disable();
            }
        }
        if ( null != this.promo.dealTitle )
            this.dealTitle.innerHTML = this.promo.dealTitle;
        
        this.setAvailDescr(this.promo.dealState);
        if (old_promo && old_promo.dealState != 'Expired' &&
                this.promo.dealState == 'Expired') {
            this.accordion.tabExpired(this);
        }
        
        if (this.content) {
            this.content.setPromo(promo);
        }
    },
    cantGetPromo: function() {
        logError("Can't get promotion details");
    },
    exists: function() {return true;},
    setAvailDescr: function(dealState) {
        this.availDescr.innerHTML = GBOX_AVAIL_DESCRS[dealState];
    },
    
    
    
    
    disable: function() {
        if (this.content) {
            this.content.disable();
        }
        
        this.isDisabled = true;
    },
    
    
    
    
    enable: function() {
        
        
        
        
        this.content.enable();
        
        this.isDisabled = false;
    },
    expand: function() {
        this.accordion.currExpandedTab = this;
        this.plusButton.style.display     = 'inline';
        this.contractButton.style.display = 'none';
        this.setExpanded( true );
        this.setOverflow( 'hidden' );
        setHeight( this.mainC, this.expandedTabHeight );
    },
    collapse: function() {
        this.plusButton.style.display     = 'none';
        this.contractButton.style.display = 'inline';
        this.setExpanded( false );
        this.setOverflow( 'hidden' );
        setHeight( this.mainC, this.panelMinHeight );
    },
    titleBarClicked: function() {
        
        
        if ( this.accordion.scroller ) {
            this.accordion.scroller.focusTabToOpen(this, true);
        } else {
            
            var cet = this.accordion.getCurrExpandedTab();
            if ( cet == this ) {
                this.accordion.flipTabs( this, new Accordion.FakeTab( this.accordion ) );
            } else {
                this.accordion.flipTabs(cet,this);
            }
        }
    },
    attachBehaviors: function() {
        var tmp = this;
        this.titlebarC.onclick = function(){ tmp.titleBarClicked(tmp) };
    },
    
    initContent: function() {
        if ( !this.content ) {
            this.content = new Accordion.Tab.Content(this);
            this.refresh = new PromoRefresh(
                this.dealID,
                this.claimed,
                bind(this.setPromo, this),
                bind(this.cantGetPromo, this));
        }
    },
    displayStyle: function(style) {
        this.mainC.style.display = style;
    },
    setOverflow: function(o) {
        this.container.style.overflow = o;
    },
    setExpanded: function(e) {
        this.expanded = e;
    },
    isExpanded: function() {
        return this.idx == this.accordion.currExpandedTab.idx;
    }
};
Accordion.FakeTab = Class.create();
Accordion.FakeTab.prototype =
{
    initialize      : function(accordion) {
        this.className = 'Accordion.FakeTab';
        this.accordion = accordion;
        return this;
    },
    next            : function() {},
    exists          : function() {return false},
    disable         : function() {},
    enable          : function() {},
    expand          : function() {},
    collapse        : function() {},
    titleBarClicked : function() {},
    attachBehaviors : function() {},
    initContent     : function() {},
    displayStyle    : function() {},
    setTitleColor   : function() {},
    setBgColor      : function() {},
    setOverflow     : function() {},
    setExpanded     : function() {},
    isExpanded      : function() {}
};
/*
 * Accordion.Tab.Content manages the content of the tabs. (Everything but the
 * tab title bar.) It's principal duties are:
 *      - Fetch the current deal HTML (Coming soon or the active deal)
 *      - Prefetch the active deal before it goes live
 *      - Flip the "coming soon" deal content to the active deal content
 *      - Enable/disable the content properly
 *      - Keep the timer and progressbar as accurate as possible.
 */
Accordion.Tab.Content =  function(tab) {
    this.className = 'Accordion.Tab.Content';
    if ( !tab ) {
        throw new Error('Mandatory argument tab not sent to constructor');
    }
    this.tab        = tab;
    this.customerID = tab.accordion.customerID;
    this.key        = tab.key;
    
    this._loadingDiv = MochiKit.DOM.$('gbox-la-tab-loadingC.'+this.key);
    showElement(this._loadingDiv);
    
    this._dealDiv = MochiKit.DOM.$('gbox-la-tab-deal-displayC.'+this.key);
    hideElement(this._dealDiv);
    
    this._dealDivHas = null;
    this._prefetchedDealDisplay = null;
    this._prefetchTimeoutID = null;
    this._fetchDealDisplayErrors = 0;
    
    this._nowShowing = 'loading';
    
    
    this._fetchDealDisplay();
    return this;
};
Accordion.Tab.Content.prototype = {
    
    _mayPrefetchMsBefore: 600000,
    setPromo: function(promo) {
        var old_promo = this.promo;
        this.promo = promo;
        if (!old_promo) {
            this._update();
        }
        
        if (this.timer) {
            this.timer.promoUpdated();
        }
        if (this.progressBar) {
            this.progressBar.update( this.promo );
        }
        
        
        if (this.promo.dealState == 'ComingSoon') {
            if (!this._prefetchedDealDisplay) {
                var start_prefetch = false;
                if (!this._prefetchTimeoutID) {
                    start_prefetch = true;
                } else if (old_promo.postDate != this.promo.postDate) {
                    window.clearTimeout(this._prefetchTimeoutID);
                    this._prefetchTimeoutID = null;
                    start_prefetch = true;
                }
                if (start_prefetch) {
                    /* The math here is a little complex. Let this diagram help.
                     * A = msToActivation
                     * P = mayPrefetchMsBefore
                     * |- A -----------------------------------------------------|
                     *                                         |- P -------------|
                     *                                         |- 0.75 * P --|
                     *        We should prefetch anytime here >|             |<
                     *
                     * So, time to wait is A - P + (0.75 * P * Math.random())
                     */
                    var ms = Math.floor(this.promo.msToActivation 
                        - this._mayPrefetchMsBefore
                        + 0.75*this._mayPrefetchMsBefore*Math.random()
                        + 0.5);
                    if (ms > 100) {
                        log("Prefetching deal display for "+this.key
                            +" in "+ms+"ms");
                        this._prefetchTimeoutID = window.setTimeout(
                            bind(function() {
                                this._prefetchTimeoutID = null;
                                this._prefetchDealDisplay();
                            }, this), ms);
                    } else {
                        this._prefetchDealDisplay();
                    }
                }
            }
        }
        
        if (this.promo.dealState == 'ComingSoon') {
            
            if (this._nowShowing != 'coming_soon') {
                if (!this._fetchingDealDisplay) {
                    this._fetchDealDisplay();
                }
            }
        } else  {
            
            if (this._nowShowing != 'deal') {
                if (this._prefetchedDealDisplay) {
                    log("Flipping prefetched deal display");
                    this._dealDiv.innerHTML = this._prefetchedDealDisplay;
                    this._prefetchedDealDisplay = null;
                    this._nowShowing = 'deal';
                    this._dealDivHas = 'deal';
                    this.timer = null;
                    this.progressBar = null;
                    this._update();
                } else if (this._fetchingDealDisplay) {
                    
                    if (this._nowShowing != 'loading') {
                        hideElement(this._dealDiv);
                        this._nowShowing = 'loading';
                    }
                } else {
                    this._fetchDealDisplay();
                }
            }
        }
    },
    _dealDisplayURL: 'MUST DEFINE Accordion.Tab.Content.prototype._dealDisplayURL',
    _prefetchDealDisplay: function() {
        log("Prefetching deal display");
        doSimpleXMLHttpRequest(this._dealDisplayURL, {
            dealID          : this.key,
            customerID      : this.customerID,
            getMerchantInfo : false,
            forceLive       : 1,
            dontcache       : new Date().getTime()}
        ).addCallbacks(
            bind(this._prefetchDealDisplayOnSuccess, this),
            bind(this._prefetchDealDisplayOnError, this)
        );
    },
    _prefetchDealDisplayOnSuccess: function(r) {
        try {
            if (!r.responseText.match(/gbox-la-deal-displayC/)) {
                logError("Didn't get back a deal from prefetching. Giving up.");
                this._prefetchDealDisplayOnError();
                return;
            }
            this._fetchDealDisplayErrors = 0;
            
            this._prefetchedDealDisplay = r.responseText;
            log("Prefetched deal display");
        } catch (e) {
            logError("Error in _prefetchDealDisplayOnSuccess", e);
        }
    },
    _prefetchDealDisplayOnError: function(err) {
        logError("Couldn't prefetchDealDisplay", err);
        log("Giving up on prefetchDealDisplay");
    },
    _fetchDealDisplay: function()
    {
        this._fetchingDealDisplay = true;
        doSimpleXMLHttpRequest(this._dealDisplayURL, {
            dealID          : this.key,
            customerID      : this.customerID,
            getMerchantInfo : false,
            dontcache       : new Date().getTime()}
        ).addCallbacks(
            bind(this._fetchDealDisplayOnSuccess, this),
            bind(this._fetchDealDisplayOnError, this));
    },
    _fetchDealDisplayOnSuccess: function(r) {
        try {
            this._fetchingDealDisplay = false;
            
            var got = null;
            if (r.responseText.match(/gbox-la-coming-soonC/)) {
                got = 'coming_soon';
            } else if (r.responseText.match(/gbox-la-deal-displayC/)) {
                got = 'deal';
            } else {
                logError("Didn't get something I recognized.");
                this._fetchDealDisplayOnError("Unrecognized response");
                return;
            }
            
            if (this.promo ) {
                if (this.promo.dealState == 'ComingSoon') {
                    
                    if (got != 'coming_soon') {
                        this._fetchDealDisplayOnError(
                            "Expected 'coming soon' but got something else");
                        return;
                    }
                } else {
                    if (got != 'deal') {
                        this._fetchDealDisplayOnError(
                            "Expected 'deal' but got something else");
                        return;
                    }
                }
            }
            this._fetchDealDisplayErrors = 0;
            
            this._dealDiv.innerHTML = r.responseText;
            this._dealDivHas = got;
            
            this.timer = null;
            this.progressBar = null;
            this._update();
        } catch (e) {
            logError("Error in _fetchDealDisplayOnSuccess", e);
        }
    },
    _fetchDealDisplayOnError: function(err) {
        this._fetchingDealDisplay     = true;
        this._fetchDealDisplayErrors += 1;
        if ( this._fetchDealDisplayErrors > 10 ) {
            logError("Giving up on fetchDealDisplay after "
                     + this._fetchDealDisplayErrors +" attempts");
        } else if ( this._fetchDealDisplayErrors > 0) {
            var ms = Math.floor(1000*Math.pow(2,
                this._fetchDealDisplayErrors)*(Math.random()+0.5));
            logError("fetchDealDisplay attempt number "+ this._fetchDealDisplayErrors
                     +" failed. Retrying in "+ms+"ms", err);
            this._fetchDealDisplayTimeOut = window.setTimeout(bind(this._fetchDealDisplay, this), ms);
        }
    },
    /* This is called whenever we get a promo update or when we get the deal
     * fetched.
     */
    _update: function() {
        
        if (!this.promo) {
            return;
        }
        
        if (!this._dealDivHas) {
            return;
        }
        if (!this.timer) {
            this.timer       = new Accordion.Tab.Content.Timer(this);
            this.timer.promoUpdated();
        }
        if (!this.progressBar) {
            this.progressBar = new Accordion.Tab.Content.ProgressBar(this);
            this.progressBar.update(this.promo);
        }
        
        showElement(this._dealDiv);
        this._nowShowing = this._dealDivHas;
        if (this.isDisabled) {
            this.disable();
        } else {
            this.enable();
        }
    },
    getPricingContainers: function() {
        var key = this.key;
        return map(function(id) { return MochiKit.DOM.$(id+'.'+key); }, [
            'gbox-buyable-price-title',
            'gbox-buyable-price',
            'gbox-discount-title',
            'gbox-discount-minus',
            'gbox-discount',
            'gbox-price-title',
            'gbox-price',
            'gbox-savings',
            'gbox-no-promo-savings',
        ]);
    },
    disable: function() {
        
        if (this._nowShowing == 'deal') {
            var pc = this.getPricingContainers();
            for ( var i = 0 ; i < pc.length; i++ ) {
                if ( pc[i] ) {
                    if ( pc[i].id.match(/buyable-price/) ) {
                        addClass( pc[i], 'price' );
                    } else {
                        pc[i].style.color = '#999999';
                    }
                }
            }
            var buyable_price = MochiKit.DOM.$('gbox-buyable-price.'+this.key);
            var list_price = MochiKit.DOM.$('gbox-list-price.'+this.key);
            if (list_price && !buyable_price) {
                
                
                list_price.style.textDecoration = 'none';
            }
            
            var mapA;
            if ( mapA = MochiKit.DOM.$('gbox-breaks-map-notice.'+ this.key) )
                mapA.style.display = 'none';
            
            var ourP;
            if ( ourP = MochiKit.DOM.$('gbox-buyable-price.'+ this.key) )
                ourP.style.fontWeight = 'bold';
            var gboxP;
            if ( gboxP = MochiKit.DOM.$('gbox-price.'+ this.key) )
                gboxP.style.fontWeight = 'normal';
            var nps;
            if ( nps = MochiKit.DOM.$('gbox-no-promo-savings.'+ this.key) ) {
                nps.style.color = '990000';
                nps.style.display = 'inline';
            }
            var buyButton = MochiKit.DOM.$('gbox-la-atc-buttonC.'+ this.key);
            if (buyButton) {
                buyButton.style.display    = 'block';
                buyButton.style.visibility = 'hidden';
            }
            
            if (this.timer) {
                this.timer.disable();
            }
            if (this.progressBar) {
                this.progressBar.disable();
            }
        }
        this.isDisabled = true;
    },
    enable: function() {
        if (this._nowShowing == 'deal') {
            var pc = this.getPricingContainers();
            for ( var i = 0 ; i < pc.length; i++ ) {
                if ( pc[i] ) {
                    if ( pc[i].id.match(/buyable-price/) ) {
                        rmClass( pc[i], 'price' );
                    } else {
                        pc[i].style.color = '';
                    }
                }
            }
            var buyable_price = MochiKit.DOM.$('gbox-our-price.'+this.key);
            var list_price = MochiKit.DOM.$('gbox-list-price.'+this.key);
            if (list_price && buyable_price) {
                
                list_price.style.textDecoration = 'line-through';
            }
            
            var mapA;
            if ( mapA = MochiKit.DOM.$('gbox-breaks-map-notice.'+ this.key) )
                mapA.style.display = 'inline';
            
            var ourP;
            if ( buyable_price )
                buyable_price.style.fontWeight = 'normal';
            var gboxP;
            if ( gboxP = MochiKit.DOM.$('gbox-price.'+ this.key) )
                gboxP.style.fontWeight = 'bold';
            var nps;
            if ( nps = MochiKit.DOM.$('gbox-no-promo-savings.'+ this.key) )
                nps.style.display = 'none';
            var buyButton = MochiKit.DOM.$('gbox-la-atc-buttonC.'+ this.key);
            if (buyButton) {
                buyButton.style.visibility = 'visible';
            }
            
            if (this.timer) {
                this.timer.enable();
            }
            if (this.progressBar) {
                this.progressBar.enable();
            }
        }
        this.isDisabled = false;
    }
};
/*
 * Accordion.Tab.Content.Timer: Handles the management of the timing content
 * of a lightning deal.
 *
 * This class creates a Timer object to keep the time remaining field updated.
 * Every time the content's promotion details are updated (which can be quite
 * frequent), it updates the Timer as well.
 *
 * The class also manages whether to show "starts in HH:MI:SS" or "HH:MI:SS
 * remaining" or nothing at all based on how much time is left in the deal.
 * This is updated, of course, every time the content changes.
 *
 * The promotion details are updated through the promoUpdated
 * method.
 */
Accordion.Tab.Content.Timer = Class.create();
Accordion.Tab.Content.Timer.prototype =
{
    initialize: function(content)
    {
        this.className = 'Accordion.Tab.Content.Timer';
        if ( !content ) {
            throw new Error('No content obj sent to constructor');
        }
        
        this.content          = content;
        this.key            = content.key;
        
        
        this.timerC      = MochiKit.DOM.$('gbox-la-timerC.'+ this.key);
        
        this.startInC    = MochiKit.DOM.$('gbox-la-timer-starts-in.'+ this.key);
        
        this.remainsC    = MochiKit.DOM.$('gbox-la-timer-remains.'+ this.key);
        
        this.timerTime   = MochiKit.DOM.$('gbox-la-timer-time.'+ this.key);
        this.timer = new Timer(this.timerTime, 0);
        return this;
    },
    /*
     * promoUpdated() is called everytime the promo are updated.
     */
    promoUpdated: function()
    {
        this.promo = this.content.promo;
        if (!this.promo) {
            return;
        }
        if (this.promo.dealState == 'ComingSoon') {
            this.timer.setRemaining(this.promo.msToActivation);
            this.startInC.style.display = '';
            this.timerTime.style.display = '';
            this.remainsC.style.display = 'none';
        } else if (this.promo.dealState == 'Available') {
            this.timer.setRemaining(this.promo.msToExpiration);
            this.startInC.style.display = 'none';
            this.timerTime.style.display = '';
            this.remainsC.style.display = '';
        } else {
            this.timer.setRemaining(0);
            this.startInC.style.display = 'none';
            this.timerTime.style.display = 'none';
            this.remainsC.style.display = 'none';
        }
    },
    /*
     * Show the timer as disabled (for instance, if qty runs out or the
     * customer purchased the deal), even though the timer may still be
     * counting down.
     */
    disable: function()
    {
        this.isDisabled = true;
        if ( this.timerC )
          this.timerC.style.color = '#666666';
    },
    /*
     * Show the timer as enabled (for instance, if there is still qty and the
     * customer hasn't purchased it).
     */
    enable: function()
    {
        this.isDisabled = false;
        if ( this.timerC )
          this.timerC.style.color = '#000000';
    }
};
Accordion.Tab.Content.ProgressBar = Class.create();
Accordion.Tab.Content.ProgressBar.prototype =
{
    initialize: function(content) {
        this.className = 'Accordion.Tab.Content.ProgressBar';
        if ( !content ) {
            throw new Error('No content obj sent to constructor');
        }
        this.tab        = content.tab;
        this.content    = content;
        this.dealID     = content.tab.dealID;
        this.customerID = content.tab.customerID;
        this.barC    = MochiKit.DOM.$('gbox-la-progress-barC.'+ content.tab.key);
        this.bar     = MochiKit.DOM.$('gbox-la-progress-bar.'+ content.tab.key);
        this.reportC = MochiKit.DOM.$('gbox-la-progress-bar-reportC.'+ content.tab.key);
        return this;
    },
    quantityAvailHasChanged: function() {
        return false;
    },
    disable: function() {
        if ( this.bar )
            this.bar.style.backgroundColor = '#eeeeee';
        if ( this.barC )
            this.barC.style.borderColor = '#999999';
        if ( this.reportC )
            this.reportC.style.color = '#999999';
    },
    enable: function() {
        this.bar.style.backgroundColor = '#c3ddeb';
        this.barC.style.borderColor    = '#bbccdd';
        this.reportC.style.color       = '#000000';
    },
    update: function(promotionDetails) {
        if ( !this.bar || !promotionDetails ) {
            return;
        }
        this.percentageSold = promotionDetails.percentageSold;
        if ( isUndefinedOrNull(this.percentageSold) ) {
          logError("percentageSold is undef or null. Exiting...");
          return;
        }
        if ( this.percentageSold < 0 )
            this.percentageSold = 0;
        if ( this.percentageSold > 100)
            this.percentageSold = 100;
        
        this.bar.style.width   = this.percentageSold +'%';
        this.reportC.innerHTML = this.percentageSold +'% Claimed';
    }
};
Accordion.Tab.Content.FakeProgressBar = Class.create();
Accordion.Tab.Content.FakeProgressBar.prototype =
{
 initialize: function(content) {
   this.className = 'Accordion.Tab.Content.FakeProgressBar';
 },
 quantityAvailHasChanged: function() {},
 disable                : function() {},
 enable                 : function() {},
 update                 : function() {}
};



var MKShovelerSorting = function(sorts) {
  
  var _sorting = this;
  this.ids = [];
  this.itemsById = {};
  forEach(sorts, function(s) {
    _sorting.ids.push(s[0]);
    _sorting.itemsById[s[0]] = s[1];
  });
};
MKShovelerSorting.prototype = {
  
  getIds: function() {
    return this.ids.slice(); 
  },
  
  sortItemsById: function(id, items) {
    
    var itemMap = {};
    forEach(items, function(i) { itemMap[i] = 1; });
    
    
    var sorted = filter(
      function (i) {
        if (itemMap.hasOwnProperty(i)) {
          itemMap[i]++;
          return 1;
        } else {
          return 0;
        } },
      this.itemsById[id]);
    
    
    return extend(sorted, filter(
      function (i) { return itemMap[i] == 1; },
      items));
  }
};

var MKShovelerFiltering = function(filters) {
  var _filtering = this;
  _filtering.ids = [];
  _filtering.itemsById = {};
  forEach(filters, function(f) {
    _filtering.ids.push(f[0]);
    _filtering.itemsById[f[0]] = f[1];
    //logDebug("_filtering.itemsById["+f[0]+"] = "+_filtering.itemsById[f[0]]);
  });
};
MKShovelerFiltering.prototype = {
  
  getIds: function() {
    return this.ids.slice(); 
  },
  
  getItemsById: function(id) {
    return this.itemsById[id].slice(); 
  }
};
/**
 * url - the url to load
 * test_error - A function that is called (if specified) upon succes. If this
 throws anything, then the request is interpreted as an error.
 */ 
loadJSONDoc_exp_retry = function(url, test_error) {
    var result = new Deferred();
    var timeout_base = 1000;
    var retries = 0;
    var onSuccess = function(res) {
        if (test_error) {
            try {
                test_error(res);
            } catch(error) {
                onError(error);
                return;
            }
        }
        result.callback(res);
    };
    var onError = function(error) {
        
        logError("Error loading JSON: ", error);
        if (retries > 5) {
            logError("Giving up.");
            result.errback(error);
            return;
        }
        retries++;
        var timeout = Math.floor(timeout_base * Math.pow(2, retries) * (Math.random() + 0.5));
        
        logDebug("Retrying in "+timeout+"ms");
        setTimeout(retry, timeout);
    };
    var retry = function() {
        loadJSONDoc(url).addCallbacks(onSuccess, onError);
    };
    retry();
    return result;
};
MKShovelerItemCache = function(p) {
    //logDebug("ItemCache p="+p);
    
    this.items = p.items;
    
    this.url_gen = p.url_gen;
    //logDebug("ItemCache loading_item="+p.loading_item);
    this.loading_item = p.loading_item;
    this.img_preload_div = p.img_preload_div;
    forEach(values(this.items), function(item) {
        this.preloadImage(item);
    }, this);
};
MKShovelerItemCache.prototype = {
    
    
    get: function(id) {
        //logDebug("get("+id+")");
        return this.items[id];
    },
    
    
    
    load: function(ids) {
        var self = this;
        //logDebug("load("+ids+")");
        ids = filter(function(id) {
            return !(id in self.items);
        }, ids);
        //logDebug("loading "+ids);
        if (!ids.length) {
          return;
        }
        forEach(ids, function(id) {
            //logDebug("Set "+id+" to "+self.loading_item);
            self.items[id] = self.loading_item;
        });
        var d = loadJSONDoc_exp_retry(
                self.url_gen(ids),
                function(res) {
                    if (res.error) {
                      throw(res);
                    }
                });
        d.addCallback(
            function(result) {
                //logDebug("loadJSONDoc callback result is "+result);
                //logDebug("loadJSONDoc callback ids is "+ids);
                forEach(ids, function(id) {
                    self.items[id] = result[id];
                    self.preloadImage(result[id]);
                });
                signal(self, "itemsChanged", ids);
            });
    },
    preloadImage: function(item) {
        this.img_preload_div.appendChild(
            IMG({src:item.ImageUrl}));
    }
};
/*
 * name: The name prefix for all IDs
 *
 * items: A dict/hash/map of all items.
 *
 * item_display(item, cell, sorting, filtering, page, pages): The display func. You
 * have to write this callback.
 *
 *      - item: The item to show. This is whatever was passed in via the items
 *      param in the constructor. null if we want a blank.
 *
 *      - cell: The cell number, between 0 and cells-1
 *
 *      - sorting: The sorting key
 *
 *      - filtering: The filtering key
 *
 *      - page: The page number, starting at 1
 *
 *      - pages: The total number of pages.
 *
 * sorting: A sorting object.
 *
 * filtering: A filtering object.
 */ 
var connect_if_exists = function(obj, a, b, c) {
    obj = MochiKit.DOM.$(obj);
    if (obj) { return connect(obj, a, b, c); }
    else { return null; }
};
var MKShoveler = function(p) {
  
  var _shoveler = this;
  this.name         = p.name;
  this.cells        = p.cells;
  this.items        = p.items;
  this.item_display = p.item_display;
  this.sorting      = p.sorting;
  this.filtering    = p.filtering;
  this.showing      = [];
  
  connect(this.items, 'itemsChanged', this, 'onItemsChanged');
  
  this.left_button_el = MochiKit.DOM.$(this.name + 'ShvlButtonPrev');
  connect_if_exists(this.left_button_el, 'onclick', this, this.left_button_clicked);
  
  this.right_button_el = MochiKit.DOM.$(this.name + 'ShvlButtonNext');
  connect_if_exists(this.right_button_el, 'onclick', this, this.right_button_clicked);
  
  this.pagination_el = MochiKit.DOM.$(this.name + 'ShvlPage');
  
  this.current_page_el = MochiKit.DOM.$(this.name + 'PageNumText');
  
  this.pages_el = MochiKit.DOM.$(this.name + 'PagesTotalText');
  
  this.start_over_el = MochiKit.DOM.$(this.name + 'StartOver');
  
  var sortingIds = this.sorting.getIds();
  
  var sort_select = MochiKit.DOM.$(this.name+'SortSelect');
  this.current_sorting = sort_select.value;
  connect_if_exists(sort_select, 'onchange', function(ev) {
    _shoveler.set_sorting_to(sort_select.value);
  });
  
  var filteringIds = this.filtering.getIds();
  this.current_filtering = 'all';
  addElementClass(this.name+'CloudLink'+this.current_filtering, 'active');
  
  
  forEach(filteringIds, function(id) {
    connect_if_exists(_shoveler.name+'CloudLink'+id, 'onclick', function(ev) {
        
        _shoveler.set_filtering_to(id);
      });
  });
  
  connect_if_exists(MochiKit.DOM.$(this.name+'StartOverLink'), 'onclick',
    function() { _shoveler.goto_page(1); });
  
  
  this.reset_items();
  this.update_cells();
  
  
  setDisplayForElement('none', this.name+'shvlNJS')
  
  forEach(['Shvl', 'Cloud', 'Sort'], function (i) {
    var el = MochiKit.DOM.$(_shoveler.name+i);
    if (el) {
        setDisplayForElement('', el);
    }
  });
  this.load()
};
MKShoveler.prototype = {
  load: function() {
    var self = this;
    var this_page_ids = this.current_items.slice(
      (this.page-1)*this.cells, this.page*this.cells);
    
    var next_page = this.page+1;
    if (next_page > this.pages) {
      next_page = 1;
    }
    var next_page_ids = this.current_items.slice(
      (next_page-1)*this.cells, next_page*this.cells);
    //log('next_page_ids='+next_page_ids);
    var prev_page = this.page-1;
    if (prev_page < 1) {
      prev_page = this.pages;
    }
    var prev_page_ids = this.current_items.slice(
      (prev_page-1)*this.cells, prev_page*this.cells);
    //log('prev_page_ids='+prev_page_ids);
    
    var filter_ids = [];
    /*forEach(this.filtering.getIds(), function(filter_id) {
      if (filter_id == self.current_filtering) {
        //log("skipping "+filter_id);
        return;
      }
      this_filter_ids = self.sorting.sortItemsById(
        self.current_sorting,
        self.filtering.getItemsById(filter_id));
      //log("this_filter_ids = "+this_filter_ids);
      filter_ids.append(this_filter_ids);
    });
    //log("filter_ids = "+filter_ids);
    */
    
    var sorting_ids = [];
    /*
    forEach(this.sorting.getIds(), function(sorting_id) {
      if (sorting_id == self.current_sorting) {
        //log("skipping "+sorting_id);
        return;
      }
      this_sorting_ids = self.sorting.sortItemsById(
        sorting_id,
        self.filtering.getItemsById(self.current_filtering));
      //log("this_sorting_ids = "+this_sorting_ids);
      sorting_ids.append(this_sorting_ids);
    });
    //log("sorting_ids = "+sorting_ids);
    */
    
    var ids_to_load = next_page_ids.concat(this_page_ids, prev_page_ids, filter_ids,
      sorting_ids);
    //log("ids_to_load="+ids_to_load);
    this.items.load(ids_to_load);
  },
  /* Filters the shown items to item_set. Resets the page to 1. Resets the
   * page count and may show or hide the left/right buttons.
   */
  set_filtering_to: function(id) {
    //logDebug("set_filtering_to("+id+")");
    if (id == this.current_filtering) {
      return;
    }
    if (this.current_filtering) {
      removeElementClass(this.name+'CloudLink'+this.current_filtering, 'active');
    }
    this.current_filtering = id;
    addElementClass(this.name+'CloudLink'+this.current_filtering, 'active');
    this.reset_items();
    this.update_cells();
  },
  /* Sets the sort method. This will reset the page to 1.
   */
  set_sorting_to: function(id) {
    //logDebug("set_sorting_to("+id+")");
    if (id == this.current_sorting) {
      return;
    }
    this.current_sorting = id;
    this.reset_items();
    this.update_cells();
  },
  /* Given the current sorting and filtering, set the items in
   * this.current_items to what it should be, set the page to 1.
   *
   * Do NOT redisplay the contents.
   */
  reset_items: function() {
    //logDebug("reset_items(): sorting:"+this.current_sorting+
    
    this.current_items = this.sorting.sortItemsById(
      this.current_sorting,
      this.filtering.getItemsById(this.current_filtering));
    //logDebug("current_items = "+repr(this.current_items));
    this.pages = Math.floor(1 + ((this.current_items.length-1) / this.cells));
    this.page = null;
    
    
    if (this.pages > 1) {
        this.pages_el.innerHTML = this.pages;
        setDisplayForElement('', this.pagination_el);
        this.right_button_el.style.visibility = '';
        this.left_button_el.style.visibility = '';
    } else {
        setDisplayForElement('none', this.pagination_el);
        this.right_button_el.style.visibility = 'hidden';
        this.left_button_el.style.visibility = 'hidden';
    }
    this.goto_page(1);
    this.load();
  },
  left_button_clicked: function(ev) {
    this.goto_prev_page();
  },
  right_button_clicked: function(ev) {
    this.goto_next_page();
  },
  goto_prev_page: function() {
    if (this.page <= 1) {
      this.goto_page(this.pages, 'ltr');
    } else {
      this.goto_page(this.page - 1, 'ltr');
    }
  },
  goto_next_page: function() {
    if (this.page >= this.pages) {
      this.goto_page(1, 'rtl');
    } else {
      this.goto_page(this.page + 1, 'rtl');
    }
  },
  /* Sets the page to the new page (after checking that it is within bounds.)
   * - Shows the page in the page numbers
   * - Sets the content of the new page
   * - Starts loading the next page
   */
  goto_page: function(page, update_dir) {
    if (page < 1 || page > this.pages) {
      var err = "goto_page: Invalid page '"+page+"'";
      throw(new RangeError(err));
    }
    if (page == this.page) {
      return;
    }
    this.page = page;
    this.current_page_el.innerHTML = this.page;
    
    if (this.page == 1) {
        setDisplayForElement('none', this.start_over_el);
    } else {
        setDisplayForElement('', this.start_over_el);
    }
    this.update_cells(update_dir);
    this.load();
  },
  /* Updates the actual contents on the page. */
  update_cells: function(order) {
    
    var _shoveler = this;
    
    if (this._update_cells_timer) {
      clearTimeout(this._update_cells_timer);
    }
    if (order == 'ltr' || order == 'rtl') {
      
      var cells = list(range(this.cells));
      if (order == 'rtl') {
        cells = cells.reverse();
      }
      /* This function is a bit weird, but it isn't difficult.
       *
       * Every time it is called, it will do one of two things:
       *   - Just return without doing anything
       *   - Update a cell, set the timer to itself, and return.
       *
       * The conditions it may encounter:
       *   - Empty list of cells to process. Just return.
       *   - Not an empty list, but an empty cell. Just call what would be
       *   called next, recursively. Then return.
       *   - Not an empty cell. Update the cell, and the set a timer to call
       *   itself.
       */   
      var timeout_func = function() {
        if (!cells.length) {
          
          return;
        }
        var cell = cells.shift();
        
        _shoveler.update_cell(cell);
        
        _shoveler._update_cells_timer = setTimeout(timeout_func, 50);
      };
      this._update_cells_timer = setTimeout(timeout_func, 200);
    } else {
      /* Update all of them at once, after a flash. */
      
      for (var i=0; i<this.cells; i++) {
        this.clear_cell(i);
      }
      
      this._update_cells_timer = setTimeout(function() {
        for (var i=0; i<_shoveler.cells; i++) {
          _shoveler.update_cell(i);
        }
      }, 100);
    }
  },
  onItemsChanged: function(items) {
    for (var i=0; i<this.cells; i++) {
      this.update_cell_if_showing(i);
    }
  },
  /* Grab the item that should be in the cell, or return null if it should be
   * empty.
   */
  item_at_cell: function(cell) {
    var item_index = (this.page-1)*this.cells + cell;
    if (item_index < this.current_items.length) {
      return this.items.get(this.current_items[item_index]);
    } else {
      return null;
    }
  },
  /* Updates the contents of a cell with the appropriate item. */
  update_cell: function(cell) {
    var item = this.item_at_cell(cell);
    this.item_display(
      item,
      cell,
      this.current_sorting,
      this.current_filtering,
      this.page,
      this.pages);
    this.showing[cell] = item;
  },
  update_cell_if_showing: function(cell) {
    if (this.showing[cell]) {
      this.update_cell(cell);
    }
  },
  clear_cell: function(cell) {
    this.item_display(
      null,
      cell,
      this.current_sorting,
      this.current_filtering,
      this.page,
      this.pages);
    this.showing[cell] = null;
  }
};
var BFTimer = Class.create();
BFTimer.prototype =
{
    initialize: function(seconds,containers)
    {
        this.className = 'Timer';
        try {
            
            if ( !seconds )
                throw new Error('No seconds sent to constructor. What are we suppose to count down from?');
            this.seconds = seconds;
            
            if ( !containers )
                throw new Error('No containers sent to constructor');
            this.container = containers.countdownC;
            this.activeC   = containers.activeC;
            this.daysC     = containers.daysC;
            this.hoursC    = containers.hoursC;
            this.minutesC  = containers.minutesC;
            this.secondsC  = containers.secondsC;
            this.printTime();
        } catch (e) {
            logError("Error in BFTimer constructor: "+ e.toString());
            return null;
        }
        return this;
    },
    printTime: function()
    {
        if ( this.seconds < 0 )
            return;
        this._printTimeToContainer( this.seconds-- );
        this.timer = window.setTimeout( bindTo(this.printTime, this), 1000 );
    },
    _printTimeToContainer: function(s)
    {
        var days    = '0';
        var hours   = '0';
        var minutes = '0';
        var seconds = '0';
        
        if ( s <= 0 ) {
            this.container.style.display = 'none';
            this.activeC.style.display = 'block';
            return;
        } else if ( s < 60 ) {
            seconds = s;
        } else if ( s >= 60 ) {
            if ( s > (60*60*24) ) {
                days = Math.floor(s / (60*60*24));
                s    = (s % (60*60*24));
            }
            if ( s > (60*60) ) {
                hours = Math.floor(s / (60*60));
                s     = (s % (60*60));
            }
            minutes = Math.floor(s / 60);
            seconds = s % 60;
        }
        if ( this.secondsC ) {
            if ( this.daysC )
                this.daysC.innerHTML = this.padLeft( days );
            if ( this.secondsC ) {
                this.hoursC.innerHTML   = this.padLeft( hours );
                this.minutesC.innerHTML = this.padLeft( minutes );
                this.secondsC.innerHTML = this.padLeft( seconds );
            }
        } else {
            this.container.innerHTML = ( this.padLeft( days )
                                         +":"+ this.padLeft( hours )
                                         +":"+ this.padLeft( minutes )
                                         +":"+ this.padLeft( seconds )
                                         +" " );
        }
    },
    padLeft: function(i)
    {
        return (( i < 10 ) ? ("0"+ i) : i);
    }
};
  var limit_height = function(limit_el, text_el, max_height) {
    limit_el = MochiKit.DOM.$(limit_el);
    text_el = MochiKit.DOM.$(text_el);
    if (getElementDimensions(limit_el).h > max_height) {
      var spl = text_el.innerHTML.split(/\s+/);
      while (spl.length && getElementDimensions(limit_el).h > max_height) {
        spl.pop();
        text_el.innerHTML = spl.join(' ') + '...';
      }
    }
  };
  var basis64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-!";
  var intBase64 = function(x) {
    return basis64.charAt(x%64) + 
      basis64.charAt((x/64)%64) +
      basis64.charAt((x/4096)%64) +
      basis64.charAt((x/262144)%64);
  };
  var refTagData = function(id, cell, sorting, filtering, page, pages) {
    cell = basis64.charAt(cell) || '!'
    page = basis64.charAt(page) || '!'
    pages = basis64.charAt(pages) || '!'
    id = intBase64(id);
    if (parseInt(filtering)) {
      filtering=intBase64(filtering);
    } else if (filtering.length < 4) {
      while (filtering.length < 4) {
        filtering = filtering + '-';
      }
    } else if (filtering.length > 4) {
      filtering = filtering.slice(0,4);
    }
    return [cell, sorting, page, pages, id, filtering].join('');
  };
  var bdsItemDisplay = function(item,cell,sorting,filtering,page,pages)
  {
    try {
      var prefix = 'bdsShvlCell'+cell;
      if (item == 'loading') {
        MochiKit.DOM.$(prefix+'Hiding').style.display = 'none';
        MochiKit.DOM.$(prefix+'Loading').style.display = '';
        MochiKit.DOM.$(prefix).style.display = 'none';
      } else if (!item) {
        MochiKit.DOM.$(prefix+'Hiding').style.display = '';
        MochiKit.DOM.$(prefix+'Loading').style.display = 'none';
        MochiKit.DOM.$(prefix).style.display = 'none';
      } else {
        var data = refTagData(item.decrypted_id, cell, sorting, filtering, page, pages);
        var fix_urls = function(t) {
          if ( !t ) { return t; }
          /* Fix the reftags */
          t = t.replace(/\/ref=([^\/"?']*)/g, "/ref=xs_gb_bd_"+data);
	  /* Replace pfRdReplace placeholder with the proper pf_rd params in all our links */
	  t = t.replace(/pfRdReplace\=1/g, pf_rd_stuff);
          return t;
        }
        bdsPopoverDataArray[prefix+'Popover'] = fix_urls(item.PopoverContent);
        MochiKit.DOM.$(prefix+'ImageLink').innerHTML       = fix_urls(item.ImageLink);
        MochiKit.DOM.$(prefix+'NewImg').innerHTML          = item.NewImg || '';
        MochiKit.DOM.$(prefix+'Title').href                = fix_urls(item.TitleHref);
        MochiKit.DOM.$(prefix+'TitleText').innerHTML       = item.TitleText;
        MochiKit.DOM.$(prefix+'Popover').innerHTML = fix_urls(item.PopoverContent);
        
        if (!item.PriceLine) {
          setStyle(prefix+'PriceLine', {'display':'none'});
        } else {
          setStyle(prefix+'PriceLine', {'display':'block'});
          MochiKit.DOM.$(prefix+'PriceLine').innerHTML       = fix_urls(item.PriceLine);
        }
        MochiKit.DOM.$(prefix+'Hiding').style.display = 'none';
        MochiKit.DOM.$(prefix+'Loading').style.display = 'none';
        MochiKit.DOM.$(prefix).style.display = '';
        
        
        
        setStyle(prefix, {
          'position':'absolute',
          'height':'auto',
          'overflow-y':'auto'});
        limit_height(prefix, prefix+'TitleText', 190);
        setStyle(prefix, {
          'position':'static',
          'height':'190px',
          'overflow-y':'hidden'});
      }
    } catch(e) {
      logError("Exception in bdsItemDisplay:", e);
    }
  };
