// CodeThatMenu PRO
// Version: 1.0.1
// IT IS ILLEGAL TO USE UNREGISTERED VERSION OF THE SCRIPT. WE PERFORM
// MONITORING OF THE SITES THAT USE SCRIPT USING GOOGLE AND SPECIAL WORDS
// INCLUDED INTO THE SCRIPT. WE WILL INITIATE LEGAL ACTIONS AGAINST THE
// PARTIES THAT VIOLATE LICENSE AGREEMENT. PLEASE REGISTER THE SCRIPT.
// Copyright (c) 2003 by CodeThat.Com
// http://www.codethat.com/
var CT_IMG_BLANK = "/images/codethat/img/1x1.gif";

function CT_pre(src) {
  return CodeThat.preload(src)
};

function pI(v) {
  return parseInt(v)
};
CT_pre(CT_IMG_BLANK);

function CT_addLayer(w, h, x, y, ox, oy, z, al) {
  var i, l = new CLayer();
  l.setSize(w, h);
  l.moveTo(x + ox, y + oy);
  l.setZIndex(z);
  l.setAlpha(al);
  i = this._l.length;
  this._l[i] = {
    l: l,
    ox: ox,
    oy: oy
  };
  return i
};

function CT_Border(d, b, hor, w) {
  var bw = b.width,
    bc = b.color;
  var def = d || {},
    bsrc = '',
    sz = def.size || w;
  if (Def(def)) {
    var i, tdw, tblw, tblh, atr, add, diff = sz;
    bw = pI(def.width || bw);
    bc = def.color || bc;
    tblw = hor ? sz : bw;
    tblh = hor ? bw : sz;
    atr = hor ? ' width=' : ' height=';
    add = hor ? ' height=' + tblh : ' width=' + tblw;
    if (Def(def.el)) {
      var elw, elm = def.el;
      for (i = 0; i < elm.length; i++) {
        elw = pI(elm[i].width);
        if (!isNaN(elw)) diff -= elw
      }
      if (diff < 0) diff = 0;
      bsrc = '<table cellpadding=0 cellspacing=0 border=0 width=' + tblw + ' height=' + tblh + '>' + (hor ? '<tr>' : '');
      for (i = 0; i < elm.length; i++) {
        var imsrc = '',
          bgimg = '';
        if (!hor) bsrc += '<tr>';
        tdw = elm[i].width;
        imsrc = elm[i].src || CT_IMG_BLANK;
        if (Undef(tdw)) {
          tdw = diff;
          bgimg = imsrc;
          imsrc = CT_IMG_BLANK
        }
        tdw = atr + tdw;
        bsrc += '<td' + tdw + (Def(bgimg) ? ' background="' + bgimg + '"' : '') + (Def(elm[i].color) ? ' bgcolor="' + elm[i].color + '"' : '') + add + '>' + '<img src="' + imsrc + '"' + tdw + add + '></td>';
        if (!hor) bsrc += '</tr>';
      }
      bsrc += (hor ? '</tr>' : '') + '</table>'
    }
  }
  return [bsrc, bw, bc, pI(def.offset || (hor ? -bw : 0)), sz]
};

function CMenu(def, id) {
  this.id = id;
  this.open = [];
  if (Undef(def)) def = {};
  if (Undef(def.style)) def.style = {};
  var o = def.style;
  o.direction = o.direction || "v";
  if (Undef(o.box)) o.box = true;
  if (Und(o.bgcolor)) o.bgcolor = 'white';
  o.z = o.z || 1;
  if (Undef(def.itemover)) def.itemover = {};
  if (Undef(def.position)) def.position = {};
  o = def.position;
  o.pos = o.pos || [0, 0];
  o.pos[0] = pI(o.pos[0]);
  o.pos[1] = pI(o.pos[1]);
  o.anchor = o.anchor || "ne";
  o.anchor_side = o.anchor_side || "nw";
  if (Undef(o.absolute)) o.absolute = true;
  if (Undef(def.type)) def.type = "bar";
  this.menu = new CPopupMenu(def, this, null);
  this.timer = def.timer || 1000;
  this.otime = def.otime || 10;
  this.defaction = def.defaction || {};
  _CT_menus[_CT_menus.length] = this;
}; {
  var CMp = CMenu.prototype;
  CMp.create = function() {
    this.menu.createTop()
  };
  CMp.Act = function(a) {
    return this.defaction[a]
  };
  CMp.topID = CMp.path = function() {
    return this.id
  };
  CMp.childPath = function() {
    return this.topID() + ".menu"
  };
  CMp.handleEvent = function(e, s1, s2, src) {
    if (!this._dis) {
      with(this) {
        clearTimer();
        if (e == 'i') {
          var o = open,
            l = o.length;
          if (Undef(s1)) hide();
          else if (Undef(s2) || (l != 0 && o[l - 1].id != s2.id)) hideAfter(s1);
          if (Def(s2)) showTimer(s2);
          if (Def(src)) src.over();
        } else if (e == 'o') {
          setTimer();
          if (Def(src)) src.out()
        }
      }
    }
  };
  CMp.clearTimer = function() {
    if (Def(this._to)) clearTimeout(this._to);
    this._to = null;
  };
  CMp.setTimer = function() {
    if (this._to) return;
    this._to = setTimeout(this.topID() + '.hide()', this.timer)
  };
  CMp.showTimer = function(m) {
    if (this._to) return;
    this._to = setTimeout(this.topID() + '.show(' + m.path() + ')', this.otime)
  };
  CMp.show = function(path) {
    path.visible(true);
    this.open[this.open.length] = path
  };
  CMp.hide = function() {
    if (this.open.length > 0) this.hideAfter({
      "id": ''
    });
  };
  CMp.hideAfter = function(path) {
    var i, l, o;
    while ((l = (o = this.open).length) > 0 && o[l - 1].id != path.id) {
      i = l - 1;
      o[i].visible(false);
      this.open = o.slice(0, i)
    }
  };
  CMp.popupAt = function(x, y) {
    this.menu.moveRel(x, y);
    this._ap = this.menu.AbsPos();
    this.popup()
  };
  CMp.popupEv = function(e) {
    this.popupAt(e.x, e.y)
  };
  CMp.popup = function() {
    this.handleEvent('i', null, this.menu)
  };
  CMp.run = function() {
    var r = arguments.length > 0;
    if (!r) this.menu.create();
    if (!(ua.ie4up && !ua.ie6 || ua.oldOpera) || r) {
      this.menu.moveLayers();
      if (this.menu.type != 'popup') this.menu.visible(true);
      this._op = 1;
      this._ap = this.menu.AbsPos();
      this.checkMove()
    } else if (!ua.oldOpera) setTimeout(this.id + '.run(1)', 1);
  };
  CMp.checkMove = function() {
    if (this.menu.AbsPos().join() != this._ap.join()) this.movePos();
    this._mv = setTimeout(this.id + '.checkMove()', 500)
  };
  CMp.movePos = function() {
    this._ap = this.menu.AbsPos();
    this.menu.Repos()
  };
  CMp.state = function(b) {
    if (b) this.checkMove();
    else if (Def(this._mv)) clearTimeout(this._mv);
    this._dis = !b
  };
  CMp.obj = function() {
    return this.menu
  };
}
function CPopupMenu(def, parent, p_lvl) {
  this.id = CodeThat.newID();
  if (Undef(def)) def = {};
  this._p = parent;
  this._p_lvl = p_lvl;
  this._top = Undef(p_lvl);
  var o = this.style = def.style || {};
  if (Def(o.itemoffset)) {
    o.itemoffset.x = pI(o.itemoffset.x || 0);
    o.itemoffset.y = pI(o.itemoffset.y || 0)
  }
  if (Def(o.size)) {
    o.size[0] = pI(o.size[0]);
    o.size[1] = pI(o.size[1])
  }
  if (Def(o.shadow)) o.shadow.width = pI(o.shadow.width || 5);
  if (Def(o.border)) o.border.width = pI(o.border.width || 1);
  this.itemover = def.itemover || {};
  this.itemon = def.itemon || {};
  o = this.position = def.position || {};
  if (Def(o.pos)) {
    o.pos[0] = pI(o.pos[0]);
    o.pos[1] = pI(o.pos[1])
  }
  if (Def(o.menuoffset)) {
    o.menuoffset.x = pI(o.menuoffset.x || 0);
    o.menuoffset.y = pI(o.menuoffset.y || 0)
  }
  this.separator = def.separator;
  this.createItems(def);
  if (this._top) {
    this.type = def.type;
    if (this.type == 'toolbar') {
      if (Undef(this.style.bar)) this.style.bar = {};
      if (Undef(this.style.bar.drag)) this.style.bar.drag = true
    }
  }
  if (Def(o = this.style.bar)) {
    if (Undef(o.size)) o.size = [10, 10];
    if (Undef(o.src) && Undef(o.bgcolor)) o.bgcolor = "blue";
    if (Undef(o.dir)) o.dir = this.St('direction');
    o.size[0] = pI(o.size[0]);
    o.size[1] = pI(o.size[1])
  }
  this._l = [];
}; {
  var CPp = CPopupMenu.prototype;
  CPp.createTop = function() {
    var mw, mh, l;
    var p = this.Pos('pos') || [0, 0],
      w = this.width(),
      h = this.height();
    if (!this.St('box')) {
      mw = pI(this.St('fixwidth')) || w;
      mh = pI(this.St('fixheight')) || h
    } else {
      mw = w;
      mh = h
    }
    l = this._l[this.addLayer(mw, mh, 0, 0, 0, 0, this.z(), this.St('opacity'))].l;
    var x = this.getAlignX();
    if (Def(x)) p[0] = x;
    l.setRel(!this.Pos('absolute'));
    l.setPos(p[0], p[1]);
    l.create()
  };
  CPp.create = function() {
    with(this) {
      var l, n, i, it = items,
        b = St('box');
      var a = Pos('absolute');
      var p = Pos('pos') || [0, 0],
        w = width(),
        h = height(),
        _z = z();
      var al = St('opacity');
      if (b) {
        var j = St('shadow');
        if (Def(j)) {
          n = addLayer(w, h, p[0], p[1], j.width, j.width, _z, al);
          _l[n].l.setBgColor(j.color)
        }
        j = St('border');
        if (Def(j)) {
          var bpr, bw = w;

          function sp(l) {
            l.setHTML(bpr[0]);
            l.setBgColor(bpr[2]);
          };
          bpr = CT_Border(j.l, j, 0, h);
          sp(_l[addLayer(bpr[1], bpr[4], p[0], p[1], -bpr[1], bpr[3], _z + 1, al)].l);
          bw += bpr[1];
          bpr = CT_Border(j.r, j, 0, h);
          sp(_l[addLayer(bpr[1], bpr[4], p[0], p[1], w, bpr[3], _z + 1, al)].l);
          bw += bpr[1];
          bpr = CT_Border(j.t, j, 1, bw);
          sp(_l[addLayer(bpr[4], bpr[1], p[0], p[1], bpr[3], -bpr[1], _z + 1, al)].l);
          bpr = CT_Border(j.b, j, 1, bw);
          sp(_l[addLayer(bpr[4], bpr[1], p[0], p[1], bpr[3], h, _z + 1, al)].l)
        }
        n = addLayer(w, h, p[0], p[1], 0, 0, _z + 2, al);
        l = _l[n].l;
        l.setBgImage(St('bgimg'));
        l.setBgColor(St('bgcolor'));
        l.addEventHandler("onMouseOver", topID() + ".clearTimer()");
        l.addEventHandler("onMouseOut", topID() + ".setTimer()");
        this._b = n;
        j = St('bar');
        if (Def(j)) {
          var o, bh = j.size[1],
            bw = j.size[0];
          if (bh < 0) bh = h;
          if (bw < 0) bw = w;
          bh = Math.min(bh, h);
          bw = Math.min(bw, w);
          n = addLayer(bw, bh, p[0], p[1], 0, 0, _z + 3, al);
          o = _l[n].l;
          CT_pre(j.src);
          o.setBgImage(j.src);
          o.setBgColor(j.bgcolor);
          o.addEventHandler("onMouseOver", topID() + ".clearTimer()");
          o.addEventHandler("onMouseOut", topID() + ".setTimer()");
          if (j.drag) this._dragbar = n;
        }
        i = _top ? 1 : 0;
        for (; i < _l.length; i++) _l[i].l.create();
        if (Def(this._dragbar)) {
          var o = _l[_dragbar].l.object();
          CodeThat.regEventHandler("mousedown", path() + ".startDrag(ev)", o);
          CodeThat.regEventHandler("mouseup", path() + ".stopDrag()", o);
          if (ua.ie4up) {
            CodeThat.regEventHandler("dragstart", "return false");
            CodeThat.regEventHandler("selectstart", "return false")
          }
        }
      }
      for (i = 0; i < it.length; i++) it[i].create()
    }
  };
  CPp.addLayer = CT_addLayer;
  CPp.St = function(a, v) {
    if (Und(v)) {
      v = this.style[a];
      if (Und(v) && !this._top) v = this._p_lvl.St(a);
    } else this.style[a] = v;
    return v
  };
  CPp.StOver = function(a, v) {
    if (Und(v)) {
      v = this.itemover[a];
      if (Und(v) && !this._top) v = this._p_lvl.StOver(a)
    } else this.itemover[a] = v;
    return v
  };
  CPp.StOn = function(a, v) {
    if (Und(v)) {
      v = this.itemon[a];
      if (Und(v) && !this._top) v = this._p_lvl.StOn(a)
    } else this.itemon[a] = v;
    return v
  };
  CPp.Pos = function(a, v) {
    if (Und(v)) {
      v = this.position[a];
      if (Und(v) && !this._top && a != 'pos') v = this._p_lvl.Pos(a);
    } else this.position[a] = v;
    return v
  };
  CPp.AbsPos = function() {
    var p;
    if (this._top) p = Def(this._l[0]) ? this._l[0].l.getAbsolutePos() : this.position.pos;
    else p = this.Pos('pos') || [0, 0];
    return [p[0], p[1]];
  };
  CPp.z = function(z) {
    if (Undef(z)) {
      z = this.style.z;
      if (Undef(z) && !this._top) z = this._p.z() + 5;
    } else this.style.z = z;
    return z
  };
  CPp.moveItems = function(ns) {
    with(this) {
      var i, ix, iy, ox, oy;
      var dh = hor(),
        it = items,
        b = St('box'),
        ioff = St('itemoffset');
      var p = (_top && !Pos('absolute') ? AbsPos() : Pos('pos')) || [0, 0];
      ox = oy = 0;
      if (b) {
        var bar = St('bar');
        ix = Def(bar) && bar.dir == 'v' ? bar.size[0] : 0;
        iy = Def(bar) && bar.dir == 'h' ? bar.size[1] : 0
      } else iy = ix = 0;
      if (Def(ioff)) {
        ox = pI(ioff.x || 0);
        oy = pI(ioff.y || 0);
        if (b) {
          ix += ox;
          iy += oy
        }
      }
      for (i = 0; i < it.length; i++) {
        if (b || !it[i].Pos()) {
          it[i].Pos([ix, iy]);
          if (dh) ix += it[i].St('size')[0] + ox;
          else iy += it[i].St('size')[1] + oy;
        }
        it[i].moveRel(p[0], p[1], ns);
      }
    }
  };
  CPp.moveSubs = function() {
    var o, p = this.AbsPos(),
      i = this._top ? 1 : 0;
    for (; i < this._l.length; i++) {
      o = this._l[i];
      o.l.moveTo(p[0] + o.ox, p[1] + o.oy)
    }
  };
  CPp.moveLayers = function(ns) {
    this.moveSubs();
    this.moveItems(ns)
  };
  CPp.Repos = function() {
    var x = this.getAlignX() || this.Pos('pos')[0],
      v = this.vis;
    if (Def(x)) {
      if (v) this.visible(false);
      this.moveTo(x, this.Pos('pos')[1]);
      if (v) this.visible(v)
    }
  };
  CPp.getAlignX = function() {
    var x, ww = CodeThat.getWinWidth(),
      al = this.Pos('align'),
      w = this.width();
    if (Def(al)) {
      if (al == 'left') x = 0;
      else if (al == 'right') x = ww - w;
      else if (al == 'center') x = (ww - w) / 2;
    }
    return x
  };
  CPp.itemsVisible = function(v) {
    var i, it = this.items;
    for (i = 0; i < it.length; i++) it[i].visible(v)
  };
  CPp.visible = function(v) {
    this.vis = v;
    if (this.St('box')) for (var i = 0; i < this._l.length; i++) this._l[i].l.setVisible(v);
    this.itemsVisible(v);
    if (Def(this._p.setOver)) this._p.setOver(v);
  };
  CPp.moveTo = function(x, y, ns) {
    var i, o, p = this.position;
    p.pos = [x, y];
    if (this._l.length > 0) this._l[0].l.moveTo(x, y);
    this.moveLayers(ns)
  };
  CPp.moveRel = function(x, y) {
    var w, h, off, x1 = x,
      y1 = y,
      a = this.Pos('anchor'),
      as = this.Pos('anchor_side');
    if (this._p.constructor == CMenuItem) {
      w = this._p.width();
      h = this._p.height();
      if (a == 'nw' || a == 'sw' || a == 'w') {} else if (a == 'ne' || a == 'se' || a == 'e') x1 += w;
      if (a == 'nw' || a == 'ne' || a == 'n') {} else if (a == 'sw' || a == 'se' || a == 's') y1 += h;
      if (a == 'n' || a == 's') x1 = Math.ceil(x1 + w / 2);
      if (a == 'e' || a == 'w') y1 = Math.ceil(y1 + h / 2);
    }
    w = this.width(),
    h = this.height();
    if (as == 'nw' || as == 'sw' || as == 'w') {} else if (as == 'ne' || as == 'se' || as == 'e') x1 -= w;
    if (as == 'nw' || as == 'ne' || as == 'n') {} else if (as == 'sw' || as == 'se' || as == 's') y1 -= h;
    if (as == 'n' || as == 's') x1 -= Math.floor(w / 2);
    if (as == 'e' || as == 'w') y1 -= Math.floor(h / 2);
    if (Def(off = this.Pos('menuoffset'))) {
      x1 += off.x;
      y1 += off.y
    }
    this.moveTo(x1, y1);
  };
  CPp.topID = function() {
    return this._p.topID()
  };
  CPp.path = function() {
    return this._p.childPath()
  };
  CPp.childPath = function(id) {
    return this.path() + ".items[" + id + "]"
  };
  CPp.hor = function() {
    return this.St('direction') == 'h'
  };
  CPp.width = function() {
    var i, obj, h, r = 0,
      l;
    with(this) {
      if (St('box')) if (Def(this._b)) r = _l[_b].l.getWidth();
      else {
        h = hor();
        l = items.length;
        for (i = 0; i < l; i++) {
          var iw = items[i].St('size')[0];
          r = h ? r + iw : Math.max(r, iw)
        }
        if (Def(obj = St('bar')) && obj.dir == 'v') r += obj.size[0];
        if (Def(obj = St('itemoffset'))) r += (h ? l + 1 : 2) * obj.x
      } else r = items[0].St('size')[0]
    }
    return r
  };
  CPp.height = function() {
    var i, h, obj, r = 0,
      l;
    with(this) {
      if (St('box')) if (Def(this._b)) r = _l[_b].l.getHeight();
      else {
        h = hor();
        l = items.length;
        for (i = 0; i < l; i++) {
          var ih = items[i].St('size')[1];
          r = h ? Math.max(r, ih) : r + ih
        }
        if (Def(obj = St('bar')) && obj.dir == 'h') r += obj.size[1];
        if (Def(obj = St('itemoffset'))) r += (h ? 2 : l + 1) * obj.y
      } else r = items[0].St('size')[1]
    }
    return r
  };
  CPp.Separator = function(v) {
    if (Undef(v)) {
      v = this.separator;
      if (Undef(v) && !this._top) v = this._p_lvl.Separator()
    } else this.separator = v;
    return v
  };
  CPp.createItems = function(def) {
    this.items = [];
    var i, it = def.items;
    if (Undef(it)) return;
    if (Undef(it.length) && Def(it.item)) it = it.item;
    if (it.constructor != Array) it = [it];
    for (i = 0; i < it.length; i++) this.addItem(it[i]);
  };
  CPp.addItem = function(def) {
    var it = this.items;
    return it[it.length] = new CMenuItem(def, this, it.length);
  };
  CPp.delItem = function(i) {
    var j, it = this.items;
    if (i < it.length && i >= 0) {
      it[i] = null;
      it = this.items = it.slice(0, i).concat(it.slice(i + 1));
      for (j = 0; j < it.length;) it[j].setID(j++);
    }
  };
  CPp.getItem = function(i) {
    return i < this.items.length ? this.items[i] : null
  };
  CPp.startDrag = function(e) {
    with(this) {
      if (!Pos('absolute')) return;
      CodeThat.regEventHandler('mousemove', path() + '.dragTo(ev)');
      var p = AbsPos();
      this._drOffsX = p[0] - e.x;
      this._drOffsY = p[1] - e.y;
      _p.hide();
      _p.state(false)
    }
  };
  CPp.stopDrag = function() {
    CodeThat.clearEventHandler('mousemove');
    this.Repos();
    this._p.state(true)
  };
  CPp.dragTo = function(e) {
    this.moveTo(e.x + this._drOffsX, e.y + this._drOffsY, true)
  };
}
function CMenuItem(def, parent, id) {
  this.id = id;
  this._p = parent;
  if (Def(def) && def.type == 'separator') {
    def = parent.Separator();
    def.type = 'separator';
  }
  this.initDef(def);
  this._l = [];
}; {
  var CMp = CMenuItem.prototype;
  CMp.create = function() {
    var l = this._l;
    if (!l.length) this.init();
    for (var i = 0; i < l.length;) l[i++].l.create();
    this.createChild();
  };
  CMp.initDef = function(def) {
    if (Undef(def)) def = {};
    this.text = def.text;
    this.textover = def.textover;
    this.texton = def.texton;
    var o = this.style = def.style || {};
    if (Def(o.size)) {
      o.size[0] = pI(o.size[0]);
      o.size[1] = pI(o.size[1])
    }
    if (Def(o.shadow)) o.shadow.width = pI(o.shadow.width || 5);
    if (Def(o.border)) o.border.width = pI(o.border.width || 1);
    this.styleover = def.styleover || {};
    this.styleon = def.styleon || {};
    if (def.menu) this.menu = new CPopupMenu(def.menu, this, this._p);
    else this.menu = null;
    this.action = def.action || {};
    var o = this.position = def.position || {};
    if (Def(o.pos)) {
      o.pos[0] = pI(o.pos[0]);
      o.pos[1] = pI(o.pos[1])
    }
    this.type = def.type;
    this.sep = def.type == 'separator';
    this.bool = def.type == 'bool';
    this.val = def.value || false;
    this.vis = false;
  };
  CMp.init = function() {
    with(this) {
      var n, p = Pos() || [0, 0],
        s = St('size'),
        _z = z();
      var op = St('opacity');
      var w = s[0],
        h = s[1],
        x = p[0],
        y = p[1],
        ox = 0,
        oy = 0;
      var tid = topID();
      var js = Act('js'),
        url = Act('url'),
        target = Act('target'),
        title = Act('title');
      var anch = !sep && (Def(js) || Def(url) || bool);
      n = addLayer(w, h, x, y, 0, 0, _z + 5);
      setProp(n, '', '', '', vis);
      _l[n].l.setHTML((anch ? '<a href="' + (url || '#') + '"' + (Def(target) ? '" target="' + target + '"' : '') + ' onClick="' + (bool ? path() + '.toggle();' : '') + (ua.nn4 ? '' : 'this.blur();') + tid + '.hide();' + (Def(js) ? js : url ? '' : 'return false') + '"' + (Def(title) ? ' title="' + title + '"' : '') + '>' : '') + '<img border=0 src="' + CT_IMG_BLANK + '" width=' + w + ' height=' + h + '>' + (anch ? '</a>' : ''));
      _l[n].l.addEventHandler("onMouseOver", tid + ".handleEvent('i'," + _p.path() + (!sep ? "," + (this.menu ? childPath() : 'null') + "," + path() : '') + ")");
      _l[n].l.addEventHandler("onMouseOut", tid + ".handleEvent('o'," + _p.path() + ",null" + (!sep ? "," + path() : '') + ")");
      var v = Box('shadow');
      if (Def(v)) {
        this._si = n = addLayer(w, h, x, y, v.width, v.width, _z, op);
        setProp(n, '', v.color, '', vis)
      }
      v = Box('border');
      var ovb = StOver('border');
      if (Def(ovb)) {
        this._ob = true;
        this._ob_t = Def(v);
        if (_ob_t) this.ob = ovb;
        else v = ovb
      }
      if (Def(v)) {
        var bw = v.width;
        this._bi = n = addLayer(w, bw, x, y, 0, 0, _z + 1, op);
        setProp(n, '', v.color, '', vis);
        n = addLayer(w, bw, x, y, 0, h - bw, _z + 1, op);
        setProp(n, '', v.color, '', vis);
        n = addLayer(bw, h - bw * 2, x, y, 0, bw, _z + 1, op);
        setProp(n, '', v.color, '', vis);
        n = addLayer(bw, h - bw * 2, x, y, w - bw, bw, _z + 1, op);
        setProp(n, '', v.color, '', vis);
        w -= bw * 2;
        h -= bw * 2;
        ox = oy = bw
      }
      this._mn = n = addLayer(w, h, x, y, ox, oy, _z + 2, op);
      var i, al, css, tcol, ei = St('imgendoff'),
        bg = Box('bgimg');
      if (this.menu) i = St('imgdir');
      else {
        i = St('imgitem');
        if (ei) ei = {
          src: CT_IMG_BLANK,
          width: ei.width,
          height: ei.height
        };
      }
      al = St('align');
      css = St('css');
      tcol = St('color');
      CT_pre(bg);
      setProp(n, tcol, Box('bgcolor'), bg, vis, css, h, al, text, i, ei);
      if (!sep && bool && Undef(this.menu)) {
        this._on = n = addLayer(w, h, x, y, ox, oy, _z + 3, op);
        i = StOn('imgitem') || i;
        bg = StOn('bgimg');
        CT_pre(bg);
        setProp(n, StOn('color') || tcol, StOn('bgcolor'), bg, false, StOn('css') || css, h, StOn('align') || al, texton || text, i, ei)
      }
      if (!sep) {
        this._mi = n = addLayer(w, h, x, y, ox, oy, _z + 4, op);
        if (this.menu) {
          i = StOver('imgdir') || St('imgdiropen') || i;
          ei = St('imgendon') || ei
        } else i = StOver('imgitem') || i;
        bg = StOver('bgimg');
        CT_pre(bg);
        setProp(n, StOver('color') || tcol, StOver('bgcolor'), bg, false, StOver('css') || css, h, StOver('align') || al, textover || text, i, ei)
      }
    }
  };
  CMp.addLayer = CT_addLayer;
  CMp.setProp = function(n, fn, col, bgimg, vis, css, h, al, txt, img, ei) {
    var spc, iw, ih, w, o = this._l[n].l;
    o.setBgColor(col);
    o.setBgImage(bgimg);
    o.setVisible(vis);
    if (txt || Def(img) || Def(ei)) {
      o.setHTML('<table border=0 cellpadding=0 cellspacing=0 width=100%><tr>');
      if (Def(img)) {
        spc = img.space || this.St('imgspace');
        spc = Def(spc) ? pI(spc) : 0;
        iw = pI(img.width);
        ih = pI(img.height);
        w = iw + spc * 2;
        CT_pre(img.src);
        o.appendHTML('<td width=' + w + ' height=' + ih + '><img src="' + img.src + '" width=' + iw + ' height=' + ih + ' hspace=' + spc + ' border=0></td>')
      }
      if (Def(txt)) o.appendHTML('<td' + (Def(al) ? ' align=' + al : '') + ' height="' + h + '"><p' + (Undef(css) ? '' : ' class="' + css + '"') + '>' + (Undef(fn) ? txt : '<font color=' + fn + '>' + txt + '</font>') + '</p></td>');
      if (Def(ei)) {
        spc = ei.space || this.St('imgspace');
        spc = Def(spc) ? pI(spc) : 0;
        iw = pI(ei.width);
        ih = pI(ei.height);
        w = iw + spc * 2;
        CT_pre(ei.src);
        o.appendHTML('<td width=' + w + ' height=' + ih + ' align=right><img src="' + ei.src + '" width=' + iw + ' height=' + ih + ' hspace=' + spc + ' border=0></td>')
      }
      o.appendHTML('</tr></table>');
    }
  };
  CMp.createChild = function() {
    if (Def(this.menu)) this.menu.create()
  };
  CMp.St = function(a, v) {
    if (Und(v)) {
      v = this.style[a];
      if (Und(v)) v = this._p.St(a)
    } else this.style[a] = v;
    return v
  };
  CMp.Box = function(a) {
    var s;
    s = this.style[a];
    if (Und(s)) if (!this._p.St('box')) s = this._p.St(a);
    return s
  };
  CMp.StOver = function(a, v) {
    if (Und(v)) {
      v = this.styleover[a];
      if (Und(v)) v = this._p.StOver(a)
    } else this.styleover[a] = v;
    return v
  };
  CMp.StOn = function(a, v) {
    if (Und(v)) {
      v = this.styleon[a];
      if (Und(v)) v = this._p.StOn(a)
    } else this.styleon[a] = v;
    return v
  };
  CMp.Pos = function(p) {
    return Def(p) ? this.position.pos = p : this.position.pos
  };
  CMp.Type = function(t) {
    if (Def(t)) {
      if (t == 'separator') {
        this.initDef(this._p.Separator());
        this.sep = true;
      }
      this.type = t;
      this.bool = t == 'bool';
    }
    return this.type
  };
  CMp.Act = function(a, v) {
    if (Und(v)) {
      v = this.action[a];
      if (Und(v)) v = eval(this.topID() + ".Act('" + a + "')")
    } else this.action[a] = v;
    return v
  };
  CMp.AbsPos = function() {
    var pos = this._p.AbsPos();
    pos[0] += this.Pos()[0];
    pos[1] += this.Pos()[1];
    return pos
  };
  CMp.z = function(z) {
    return (Def(z) ? this.style.z = z : this.style.z || (this._p.z() + 6))
  };
  CMp.width = function() {
    return this._l[0] ? this._l[0].l.getWidth() : this.St('size')[0]
  };
  CMp.height = function() {
    return this._l[0] ? this._l[0].l.getHeight() : this.St('size')[1]
  };
  CMp.moveRel = function(x, y, ns) {
    var p = this.Pos();
    this.move(x + p[0], y + p[1], ns)
  };
  CMp.move = function(x, y, ns) {
    var i, l = this._l;
    for (i = 0; i < l.length; i++) l[i].l.moveTo(x + l[i].ox, y + l[i].oy);
    if (this.menu && !ns) {
      var ap = this.AbsPos();
      this.menu.moveRel(ap[0], ap[1])
    }
  };
  CMp.visible = function(v) {
    with(this) {
      var i;
      this.vis = v;
      if (_l.length) {
        for (i = 0; i < _l.length;) _l[i++].l.setVisible(v);
        setOvBorder(false);
        if (bool) setBool(true);
        else if (Def(this._mi)) _l[_mi].l.hide();
      }
    }
  };
  CMp.topID = function() {
    return this._p.topID()
  };
  CMp.path = function() {
    return this._p.childPath(this.id)
  };
  CMp.childPath = function() {
    return this.path() + ".menu"
  };
  CMp.over = function() {
    with(this) {
      _l[_mi].l.show();
      setOvBorder(true);
      _l[_mn].l.hide();
      var scr = Act('over');
      if (Def(scr)) eval(scr);
      if (Def(this._on)) _l[_on].l.hide()
    }
  };
  CMp.out = function() {
    if (!this.menu || !this._over) {
      this.setOvBorder(false);
      this.setBool(true);
      var scr = this.Act('out');
      if (Def(scr)) eval(scr);
    }
  };
  CMp.setOvBorder = function(v) {
    if (this._ob) with(this) {
      for (var i = _bi; i < _bi + 4; i++) {
        if (_ob_t) _l[i].l.setBgColor(v ? ob.color : Box('border').color);
        else _l[i].l.setVisible(v)
      }
    }
  };
  CMp.setOver = function(v) {
    this._over = v;
    this.setOvBorder(v);
    this.setBool(!v)
  };
  CMp.setBool = function(v) {
    if (v) with(this) {
      _l[_mi].l.hide();
      if (vis) {
        if (bool) {
          _l[_mn].l.setVisible(!this.val);
          _l[_on].l.setVisible(this.val)
        } else _l[_mn].l.show()
      }
    }
  };
  CMp.toggle = function() {
    with(this) {
      this.val = !this.val;
      _l[_mn].l.setVisible(!val);
      _l[_on].l.setVisible(val);
      var code = val ? Act('on') : Act('off');
      if (Def(code)) eval(code)
    }
  };
  CMp.addPopup = function(def) {
    this.delPopup();
    return this.menu = new CPopupMenu(def, this, this._p)
  };
  CMp.delPopup = function() {
    this.menu = null
  };
  CMp.setText = function(s, t) {
    this['text' + (t || '')] = s
  };
  CMp.setID = function(id) {
    this.id = id
  };
}
var _CT_menus = [];

function CT_m_load() {
  for (var i = 0; i < _CT_menus.length;) _CT_menus[i++].run(1);
  CodeThat.setOnResize(CT_m_res, true)
};

function CT_m_res() {
  if (ua.oldOpera || ua.nn4) {
    if (Undef(window._CT_reloading)) {
      window._CT_reloading = true;
      location.reload(true)
    }
  } else for (var i = 0; i < _CT_menus.length;) _CT_menus[i++].movePos()
};
if (ua.oldOpera) CodeThat.setOnLoad(CT_m_load);
else CodeThat.setOnResize(CT_m_res);
