var glow = (function() {
  var C = {
    glow: true
  },
  B = /([$^\\\/()|?+*\[\]{}.-])/g,
  A = navigator.userAgent.toLowerCase();
  return {
    VERSION: "0.4.0",
    isReady: false,
    env: function() {
      var E = [0, NaN],
      D = Number((/opera[\s\/]([\d\.]+)/.exec(A) || E)[1]),
      F = D ? NaN: Number((/msie ([\d\.]+)/.exec(A) || E)[1]);
      return {
        rhino: !!window.load,
        gecko: !window.load && Number((/gecko\/(\d+)/.exec(A) || E)[1]),
        ie: F,
        opera: D,
        webkit: Number((/applewebkit\/(\d+(?:\.\d+)?)/.exec(A) || E)[1]),
        khtml: Number((/khtml\/(\d+(?:\.\d+)?)/.exec(A) || E)[1]),
        standardsMode: document.compatMode != "BackCompat" && (!F || F >= 6)
      }
    } (),
    module: function(J, G, F) {
      var H, D, E, K = window;
      if (G != this.VERSION) {
        throw new Error("Cannot register " + J + ": Version mismatch")
      }
      if (F.require) {
        if (typeof F.require == "string") {
          F.require = [F.require]
        }
        for (H = 0; F.require[H]; H++) {
          if (!C[F.require[H]]) {
            var I = F.require[H];
            this.ready(function() {
              if (C[I]) {
                throw new Error("Module " + I + " is included after modules that depend on it, include it sooner.")
              }
            });
            throw new Error("Module " + I + " required in " + J)
          }
        }
      }
      E = J.split(".");
      for (H = 0, D = E.length; H < D - 1; H++) {
        if (!K[E[H]]) {
          K[E[H]] = {}
        }
        K = K[E[H]]
      }
      K[E[H]] = F.implementation ? F.implementation() : {};
      C[J] = true;
      return this
    },
    ready: function(D) {
      if (glow.isSupported) {
        this.onDomReady(D)
      }
      return this
    },
    onDomReady: function(E) {
      if (this.isReady) {
        E()
      } else {
        var D = this._lf;
        this._lf = function() {
          D();
          E()
        }
      }
    },
    _lf: function() {},
    lang: {
      trim: function(D) {
        return D.replace(/^\s*((?:[\S\s]*\S)?)\s*$/, "$1")
      },
      toArray: function(E) {
        if (E.constructor == Array) {
          return E
        }
        var G = [],
        F = 0,
        D = E.length;
        for (; F < D; F++) {
          G[F] = E[F]
        }
        return G
      },
      apply: function(D, F) {
        for (var E in F) {
          D[E] = F[E]
        }
        return D
      },
      map: function(E, I) {
        if (Array.prototype.map) {
          return Array.prototype.map.call(E, I, arguments[2])
        }
        if (typeof I != "function") {
          throw new TypeError()
        }
        var D = E.length,
        H = new Array(D),
        G = arguments[1] || E,
        F = 0;
        for (; F < D; F++) {
          if (F in E) {
            H[F] = I.call(G, E[F], F, E)
          }
        }
        return H
      },
      replace: (function() {
        var D = "g".replace(/g/,
        function() {
          return "l"
        }) != "l",
        E = String.prototype.replace;
        return function(K, I, F) {
          var L, H, J, G;
          if (!D || typeof(F) != "function") {
            return E.call(K, I, F)
          }
          if (! (I instanceof RegExp)) {
            L = K.indexOf(I);
            return L == -1 ? K: E.call(K, I, F.call(null, I, L, K))
          }
          G = [];
          J = I.lastIndex = 0;
          while ((H = I.exec(K)) != null) {
            L = H.index;
            G[G.length] = K.slice(J, L);
            G[G.length] = F.apply(null, H);
            if (I.global) {
              J = I.lastIndex
            } else {
              J = L + H[0].length;
              break
            }
          }
          G[G.length] = K.slice(J);
          return G.join("")
        }
      })(),
      interpolate: function(E, G) {
        var F = E,
        D;
        for (D in G) {
          F = F.replace(new RegExp("\\{" + D.replace(B, "\\$1") + "\\}", "g"), G[D])
        }
        return F
      },
      hasOwnProperty: {}.hasOwnProperty ?
      function(D, E) {
        return D.hasOwnProperty(E)
      }: function(J, K) {
        var G = J[K],
        I = J.__proto__,
        F = I ? I[K] : {};
        if (G !== F) {
          return true
        }
        var E = glow.lang.hasOwnProperty(I, K),
        D = I[K] = {},
        H = (J[K] !== D);
        delete I[K];
        if (E) {
          I[name] = D
        }
        return H
      },
      extend: function(D, F) {
        var E = function() {},
        G;
        E.prototype = F.prototype;
        G = new E();
        D.prototype = G;
        G.constructor = D;
        D.base = F
      }
    }
  }
})();
(function() {
  var D = document,
  A = glow.env;
  if (A.ie) { (function() {
      try {
        D.documentElement.doScroll("left")
      } catch(F) {
        setTimeout(arguments.callee, 50);
        return
      }
      glow._lf()
    })()
  } else {
    if (typeof D.readyState != "undefined" && !(A.webkit < 312)) {
      var C = function() {
        /loaded|complete/.test(D.readyState) ? glow._lf() : setTimeout(C, 10)
      };
      C()
    } else {
      var E = function() {
        if (arguments.callee.fired) {
          return
        }
        arguments.callee.fired = true;
        glow._lf()
      };
      D.addEventListener("DOMContentLoaded", E, false);
      var B = window.onload;
      window.onload = function() {
        if (B) {
          B()
        }
        E()
      }
    }
  }
})();
glow.onDomReady(function() {
  glow.isReady = true
});
glow.isSupported =
/*@cc_on @if (@_jscript_version > 5.1)@*/
!
/*@end @*/
! 1;
/*@cc_on @*/
/*@if (@_jscript_version > 5.1)@*/
glow.module("glow.dom", "0.4.0", {
  require: [],
  implementation: function() {
    var I = glow.env,
    E = glow.lang,
    N = {
      tagName: /^(\w+|\*)/,
      combinator: /^\s*([>]?)\s*/,
      classNameOrId: (I.webkit < 417) ? new RegExp("^([\\.#])((?:(?![\\.#\\[:\\s\\\\]).|\\\\.)+)") : /^([\.#])((?:[^\.#\[:\\\s]+|\\.)+)/
    },
    U = {},
    e = {
      checked: "checked",
      "class": "className",
      disabled: "disabled",
      "for": "htmlFor",
      maxlength: "maxLength"
    },
    A = {
      checked: true,
      disabled: true
    },
    q = {
      maxlength: function(r) {
        return r.toString() == "2147483647" ? undefined: r
      }
    },
    o = 1,
    Z = {
      black: 0,
      silver: 12632256,
      gray: 8421504,
      white: 16777215,
      maroon: 8388608,
      red: 16711680,
      purple: 8388736,
      fuchsia: 16711935,
      green: 32768,
      lime: 65280,
      olive: 8421376,
      yellow: 16776960,
      navy: 128,
      blue: 255,
      teal: 32896,
      aqua: 65535,
      orange: 16753920
    },
    V = /height|top/,
    O = /^rgb\(([\d\.]+)(%?),\s*([\d\.]+)(%?),\s*([\d\.]+)(%?)/i,
    T = /^(?:(width|height)|(top|bottom|left|right)|(border-(top|bottom|left|right)-width))$/,
    h,
    B,
    P = ["Top", "Right", "Bottom", "Left"],
    f = 4,
    S = "padding",
    M = "margin",
    n = "border",
    W = "Width",
    Y,
    m = window,
    G = document,
    i,
    X;
    glow.ready(function() {
      i = G.body;
      X = G.documentElement
    });
    function Q(r) {
      return new RegExp(["\\b", r, "\\b"].join(""))
    }
    function c(u) {
      var v = document.createElement("div"),
      t = [],
      s = 0;
      v.innerHTML = u;
      while (v.childNodes[0]) {
        t[s++] = v.removeChild(v.childNodes[0])
      }
      return t
    }
    function J(u) {
      var t = [],
      s = 0;
      for (; u[s]; s++) {
        t[s] = u[s]
      }
      return t
    }
    function C(v, s) {
      for (var u = this, r = 0, t = u.length; r < t; r++) {
        s.call(u[r], v.call ? v.call(u[r], r) : v)
      }
      return u
    }
    if (document.all) {
      h = function(t, s) {
        var u = 0,
        r = t.length,
        v = s.length;
        if (typeof s.length == "number") {
          for (; u < v; u++) {
            t[r++] = s[u]
          }
        } else {
          for (; s[u]; u++) {
            t[r++] = s[u]
          }
        }
      }
    } else {
      h = function(t, s) {
        var u = 0,
        r = t.length;
        for (; s[u]; u++) {
          t[r++] = s[u]
        }
      }
    }
    function b(r) {
      return (r.ownerDocument && !r.body) || (r.documentElement && !r.body)
    }
    if (I.ie) {
      B = function(t) {
        if (t.length == 1) {
          return t
        }
        var v = [],
        s = 0,
        u = 0;
        for (; t[u]; u++) {
          if (t[u].getAttribute("_ucheck") != o && t[u].nodeType == 1) {
            v[s++] = t[u]
          }
          t[u].setAttribute("_ucheck", o)
        }
        for (u = 0; t[u]; u++) {
          t[u].removeAttribute("_ucheck")
        }
        o++;
        return v
      }
    } else {
      B = function(t) {
        if (t.length == 1) {
          return t
        }
        var v = [],
        s = 0,
        u = 0;
        for (; t[u]; u++) {
          if (t[u]._ucheck != o && t[u].nodeType == 1) {
            v[s++] = t[u]
          }
          t[u]._ucheck = o
        }
        o++;
        return v
      }
    }
    if (document.all) {
      Y = function(s, u) {
        var v = [],
        t = 0;
        for (; u[t]; t++) {
          if (s == "*" && u[t].all && !b(u[t])) {
            h(v, u[t].all)
          } else {
            h(v, u[t].getElementsByTagName(s))
          }
        }
        return v
      }
    } else {
      Y = function(t, v) {
        var w = [],
        u = 0,
        s = v.length;
        for (; u < s; u++) {
          h(w, v[u].getElementsByTagName(t))
        }
        return w
      }
    }
    function d(x) {
      var u, w = {},
      t = 0,
      s = I.standardsMode ? X: i,
      v = x.style;
      if (x.window) {
        u = (I.webkit < 522.11 && {
          width: x.innerWidth,
          height: x.innerHeight
        }) || (I.webkit && {
          width: i.clientWidth,
          height: x.innerHeight
        }) || (I.opera < 8.5 && {
          width: i.clientWidth,
          height: i.clientHeight
        }) || {
          width: s.clientWidth,
          height: s.clientHeight
        }
      } else {
        if (x.getElementById) {
          u = {
            width: Math.max(i.scrollWidth, i.offsetWidth, X.offsetWidth),
            height: Math.max(i.scrollHeight, i.offsetHeight, X.offsetHeight)
          }
        } else {
          for (; t < f; t++) {
            w[S + P[t]] = v[S + P[t]];
            w[n + P[t] + W] = v[n + P[t] + W];
            v[S + P[t]] = "0";
            v[n + P[t] + W] = "0"
          }
          u = {
            width: x.offsetWidth,
            height: x.offsetHeight
          };
          for (t = 0; t < f; t++) {
            v[S + P[t]] = w[S + P[t]];
            v[n + P[t] + W] = w[n + P[t] + W]
          }
        }
      }
      return u
    }
    function K(y, AA) {
      if (y.nodeName == "BODY" || y.nodeName == "HTML") {
        return 0
      }
      var t = {
        t: "Top",
        l: "Left"
      },
      AB = {},
      v = p(y),
      x = I.ie && I.standardsMode ? v.parentNode: v,
      s,
      AC = y.offsetParent,
      w = 0,
      u,
      z = (AC == x ? m: AC);
      for (; w < f; w++) {
        AB[M + P[w]] = y.style[M + P[w]];
        if (AC) {
          AB[n + P[w] + W] = AC.style[n + P[w] + W];
          y.style[M + P[w]] = AC.style[n + P[w] + W] = "0"
        }
      }
      if (AA == "t" || AA == "l") {
        s = y["offset" + t[AA]];
        if (I.ie) {
          u = AC.currentStyle.position;
          if (AC.offsetParent && u != "relative" && u != "absolute") {
            s += K(AC, AA)
          }
        }
      } else {
        if (AA == "r") {
          s = d(z).width - y.offsetLeft - y.offsetWidth
        } else {
          if (AA == "b") {
            s = d(z).height - y.offsetTop - y.offsetHeight
          }
        }
      }
      for (w = 0; w < f; w++) {
        y.style[M + P[w]] = AB[M + P[w]];
        if (AC) {
          AC.style[n + P[w] + W] = AB[n + P[w] + W]
        }
      }
      return s
    }
    function p(r) {
      if (I.ie < 6) {
        return r.document.body
      } else {
        return r.ownerDocument.body
      }
    }
    function F(u, v, t) {
      if (typeof v == "number" || /\d$/.test(v)) {
        v += "px"
      }
      for (var s = 0, r = u.length; s < r; s++) {
        u[s].style[t] = v
      }
    }
    function j(r) {
      if (r == "float") {
        return I.ie ? "styleFloat": "cssFloat"
      }
      return E.replace(r, /-(\w)/g,
      function(s, t) {
        return t.toUpperCase()
      })
    }
    function R(y, w) {
      var v, x = y.style,
      u = x.display,
      s = x.visibility,
      t = x.position;
      x.visibility = "hidden";
      x.position = "absolute";
      x.display = "block";
      if (!D(y)) {
        x.position = t;
        v = R(y.parentNode, w);
        x.display = u;
        x.visibility = s
      } else {
        v = w();
        x.display = u;
        x.position = t;
        x.visibility = s
      }
      return v
    }
    function D(r) {
      return r.offsetWidth || r.offsetHeight
    }
    function l(AA, u) {
      var t, AC = 0,
      y = 0,
      x = u.length,
      w = G.defaultView && (G.defaultView.getComputedStyle(AA, null) || G.defaultView.getComputedStyle),
      v = AA.currentStyle,
      AB,
      z,
      s = u.push || T.exec(u) || [];
      if (u.push) {
        for (; y < x; y++) {
          AC += parseInt(l(AA, u[y]), 10) || 0
        }
        return AC + "px"
      }
      if (s[1]) {
        if (!D(AA)) {
          return R(AA,
          function() {
            return d(AA)[u] + "px"
          })
        } else {
          return d(AA)[u] + "px"
        }
      } else {
        if (s[2] && l(AA, "position") != "relative") {
          if (!D(AA)) {
            return R(AA,
            function() {
              return K(AA, u.charAt(0)) + "px"
            })
          } else {
            return K(AA, u.charAt(0)) + "px"
          }
        } else {
          if (s[3] && glow.env.ie && l(AA, "border-" + s[4] + "-style") == "none") {
            return "0"
          } else {
            if (w) {
              if (typeof w == "function") {
                AB = AA.style.display;
                t = R(AA,
                function() {
                  if (u == "display") {
                    AA.style.display = AB;
                    if (!G.defaultView.getComputedStyle(AA, null)) {
                      return "none"
                    }
                    AA.style.display = "block"
                  }
                  return l(AA, u)
                })
              } else {
                if (glow.env.webkit >= 522 && u == "margin-right") {
                  u = "margin-left"
                }
                t = w.getPropertyValue(u)
              }
            } else {
              if (v) {
                if (u == "opacity") {
                  z = /alpha\(opacity=([^\)]+)\)/.exec(v.filter);
                  return z ? String(parseInt(z[1], 10) / 100) : "1"
                }
                t = String(v[j(u)]);
                if (/^-?\d+[a-z%]+$/i.test(t) && u != "font-size") {
                  t = a(AA, t, V.test(u)) + "px"
                }
              }
            }
          }
        }
      }
      if (u.indexOf("color") != -1) {
        t = g(t).toString()
      } else {
        if (t.indexOf("url") == 0) {
          t = t.replace(/\"/g, "")
        }
      }
      return t
    }
    function a(u, w, r) {
      if (/^-?\d+(px)?$/i.test(w)) {
        return parseInt(w)
      }
      var t = r ? "top": "left",
      v = r ? "Top": "Left",
      x = u.style,
      y = x.left,
      z = x.overflow,
      s = x.margin;
      x.position = "absolute";
      x.margin = "0";
      x[t] = w || 0;
      w = u["offset" + v];
      x.position = z;
      x[t] = y;
      x.margin = s;
      return w
    }
    function g(t) {
      if (/^(transparent|rgba\(0, ?0, ?0, ?0\))$/.test(t)) {
        return "transparent"
      }
      var x, s, y, z, u, w = Math.round,
      AA = parseInt,
      v = parseFloat;
      if (x = O.exec(t)) {
        s = x[2] ? w(((v(x[1]) / 100) * 255)) : AA(x[1]);
        y = x[4] ? w(((v(x[3]) / 100) * 255)) : AA(x[3]);
        z = x[6] ? w(((v(x[5]) / 100) * 255)) : AA(x[5])
      } else {
        if (typeof t == "number") {
          u = t
        } else {
          if (t.charAt(0) == "#") {
            if (t.length == "4") {
              t = "#" + t.charAt(1) + t.charAt(1) + t.charAt(2) + t.charAt(2) + t.charAt(3) + t.charAt(3)
            }
            u = AA(t.slice(1), 16)
          } else {
            u = Z[t]
          }
        }
        s = (u) >> 16;
        y = (u & 65280) >> 8;
        z = (u & 255)
      }
      t = new String("rgb(" + s + ", " + y + ", " + z + ")");
      t.r = s;
      t.g = y;
      t.b = z;
      return t
    }
    function H(w) {
      var v = "",
      t = w.childNodes,
      u = 0,
      s = t.length;
      for (; u < s; u++) {
        if (t[u].nodeType == 3) {
          v += t[u].nodeValue
        } else {
          if (t[u].nodeType == 1) {
            v += H(t[u])
          }
        }
      }
      return v
    }
    function L(x, u) {
      var t = [],
      s = 0,
      r,
      v = 0,
      w = x.length;
      for (; v < w; v++) {
        r = x[v];
        while (r = r[u + "Sibling"]) {
          if (r.nodeType == 1 && r.nodeName != "!") {
            t[s++] = r;
            break
          }
        }
      }
      return k.get(t)
    }
    var k = {};
    k.get = function() {
      var v = new glow.dom.NodeList(),
      u = 0,
      t = arguments,
      s = t.length;
      for (; u < s; u++) {
        if (typeof t[u] == "string") {
          v.push(new glow.dom.NodeList().push(G).get(t[u]))
        } else {
          v.push(t[u])
        }
      }
      return v
    };
    k.create = function(v) {
      var u = c(v),
      r = [],
      s = 0,
      t = 0;
      for (; u[s]; s++) {
        if (u[s].nodeType == 1 && u[s].nodeName != "!") {
          r[t++] = u[s]
        } else {
          if (u[s].nodeType == 3 && E.trim(u[s].nodeValue) !== "") {
            throw new Error("glow.dom.create - Text must be wrapped in an element")
          }
        }
      }
      return new k.NodeList().push(r)
    };
    k.parseCssColor = function(r) {
      var s = g(r);
      return {
        r: s.r,
        g: s.g,
        b: s.b
      }
    };
    k.NodeList = function() {
      this.length = 0
    };
    k.NodeList.prototype = {
      item: function(r) {
        return this[r]
      },
      push: function() {
        var t = arguments,
        s = t.length,
        u = 0,
        x, r, v = this,
        w = Array.prototype.push;
        for (; u < s; u++) {
          if (t[u].constructor == Array) {
            w.apply(v, t[u])
          } else {
            if (t[u].item && t[u][0]) {
              for (x = 0, r = t[u].length; x < r; x++) {
                w.call(v, t[u][x])
              }
            } else {
              if (t[u].nodeType == 1 || t[u].nodeType == 9 || t[u].document) {
                w.call(v, t[u])
              }
            }
          }
        }
        return v
      },
      each: function(u) {
        for (var r = 0, t = this, s = t.length; r < s; r++) {
          u.call(t[r], r, t)
        }
        return t
      },
      eq: function(u) {
        var t = this,
        r = 0,
        s = t.length;
        if (!u.push) {
          u = [u]
        }
        if (u.length != t.length) {
          return false
        }
        for (; r < s; r++) {
          if (t[r] != u[r]) {
            return false
          }
        }
        return t
      },
      isWithin: function(u) {
        if (u.push) {
          u = u[0]
        }
        var t = this,
        r = 0,
        s = t.length,
        v;
        if (u.contains && I.webkit >= 521) {
          for (; r < s; r++) {
            if (! (u.contains(t[r]) && t[r] != u)) {
              return false
            }
          }
        } else {
          if (t[0].compareDocumentPosition) {
            for (; r < s; r++) {
              if (! (t[r].compareDocumentPosition(u) & 8)) {
                return false
              }
            }
          } else {
            for (; r < s; r++) {
              v = t[r];
              while (v = v.parentNode) {
                if (v == u) {
                  break
                }
              }
              if (!v) {
                return false
              }
            }
          }
        }
        return true
      },
      attr: function(t) {
        var v = this,
        s = arguments,
        r = s.length,
        u, w;
        if (v.length === 0) {
          return r > 1 ? v: undefined
        }
        if (typeof t == "object") {
          for (u in t) {
            if (E.hasOwnProperty(t, u)) {
              v.attr(u, t[u])
            }
          }
          return v
        }
        if (I.ie && e[t]) {
          if (r > 1) {
            C.call(v, s[1],
            function(x) {
              this[e[t]] = x
            });
            return v
          }
          w = v[0][e[t]];
          if (A[t]) {
            return w ? t: undefined
          } else {
            if (q[t]) {
              return q[t](w)
            }
          }
          return w
        }
        if (r > 1) {
          C.call(v, s[1],
          function(x) {
            this.setAttribute(t, x)
          });
          return v
        }
        return b(v[0]) ? v[0].getAttribute(t) : v[0].getAttribute(t, 2)
      },
      removeAttr: function(s) {
        var r = I.ie && e[s],
        v = this,
        t = 0,
        u = v.length;
        for (; t < u; t++) {
          if (r) {
            v[t][r] = ""
          } else {
            v[t].removeAttribute(s)
          }
        }
        return v
      },
      hasAttr: function(u) {
        var w = this[0],
        t = w.attributes;
        if (b(w) && I.ie) {
          var t = w.attributes,
          v = 0,
          s = t.length;
          for (; v < s; v++) {
            if (t[v].nodeName == u) {
              return t[v].specified
            }
          }
          return false
        } else {
          if (this[0].getAttributeNode) {
            var r = this[0].getAttributeNode(u);
            return r ? r.specified: false
          }
        }
        return typeof t[r] != "undefined"
      },
      hasClass: function(r) {
        for (var s = 0, t = this.length; s < t; s++) {
          if ((" " + this[s].className + " ").indexOf(" " + r + " ") != -1) {
            return true
          }
        }
        return false
      },
      addClass: function(r) {
        for (var s = 0, t = this.length; s < t; s++) {
          if ((" " + this[s].className + " ").indexOf(" " + r + " ") == -1) {
            this[s].className += " " + r
          }
        }
        return this
      },
      removeClass: function(r) {
        var t = Q(r),
        v = this,
        s = 0,
        u = v.length;
        for (; s < u; s++) {
          v[s].className = v[s].className.replace(t, "")
        }
        return v
      },
      toggleClass: function(r) {
        for (var u = this, s = 0, t = u.length; s < t; s++) {
          if ((" " + u[s].className + " ").indexOf(" " + r + " ") != -1) {
            u[s].className = u[s].className.replace(Q(r), "")
          } else {
            u[s].className += " " + r
          }
        }
        return u
      },
      val: function() {
        function u(y) {
          var v = y.type,
          w = y.checked,
          AA = y.value,
          AB = [],
          x = 0;
          if (v == "radio") {
            return w ? AA: undefined
          } else {
            if (v == "checkbox") {
              return w ? AA: undefined
            } else {
              if (v == "select-one") {
                return y.selectedIndex > -1 ? y.options[y.selectedIndex].value: ""
              } else {
                if (v == "select-multiple") {
                  for (var z = y.options.length; x < z; x++) {
                    if (y.options[x].selected) {
                      AB[AB.length] = y.options[x].value
                    }
                  }
                  return AB
                } else {
                  return AA
                }
              }
            }
          }
        }
        function s(w) {
          var AD = {},
          AC = {},
          z = w.elements,
          AB = 0,
          y = z.length,
          v, AE, AA = 0,
          x;
          for (; AB < y; AB++) {
            AE = z[AB];
            v = AE.name;
            if (AE.type == "checkbox" && !AE.checked) {
              if (!v in AD) {
                AD[v] = undefined
              }
            } else {
              if (AE.type == "radio") {
                if (AC[v]) {
                  AC[v][AC[v].length] = AE
                } else {
                  AC[v] = [AE]
                }
              } else {
                var AF = u(AE);
                if (v in AD) {
                  if (AD[v].push) {
                    AD[v][AD[v].length] = AF
                  } else {
                    AD[v] = [AD[v], AF]
                  }
                } else {
                  AD[v] = AF
                }
              }
            }
          }
          for (AB in AC) {
            for (y = AC[AB].length; AA < y; AA++) {
              x = AC[AB][AA];
              v = x.name;
              if (x.checked) {
                AD[x.name] = x.value;
                break
              }
            }
            if (!v in AD) {
              AD[v] = undefined
            }
          }
          return AD
        }
        function r(w, AE) {
          var v, AF, AB = {},
          z, AA = 0,
          x, AC, AD, y;
          for (v in AE) {
            AF = w[v];
            if (AF && AF[0]) {
              AE[v] = AE[v] && AE[v].push ? AE[v] : [AE[v]];
              AB.radios = [];
              AB.checkboxesSelects = [];
              AB.multiSelects = [];
              AB.other = [];
              for (; AF[AA]; AA++) {
                y = AF[AA].type;
                if (y == "radio") {
                  z = "radios"
                } else {
                  if (y == "select-one" || y == "checkbox") {
                    z = "checkboxesSelects"
                  } else {
                    if (y == "select-multiple") {
                      z = "multiSelects"
                    } else {
                      z = "other"
                    }
                  }
                }
                AB[z][AB[z].length] = AF[AA]
              }
              for (AA = 0; AB.multiSelects[AA]; AA++) {
                AE[v] = t(AB.multiSelects[AA], AE[v])
              }
              for (AA = 0; AB.checkboxesSelects[AA]; AA++) {
                t(AB.checkboxesSelects[AA], "");
                for (x = 0, AC = AE[v].length; x < AC; x++) {
                  if (t(AB.checkboxesSelects[AA], AE[v][x])) {
                    AE[v].slice(x, 1);
                    break
                  }
                }
              }
              for (AA = 0; AB.radios[AA]; AA++) {
                AB.radios[AA].checked = false;
                AD = false;
                for (x = 0, AC = AE[v].length; x < AC; x++) {
                  if (t(AB.radios[AA], AE[v][x])) {
                    AE[v].slice(x, 1);
                    AD = true;
                    break
                  }
                  if (AD) {
                    break
                  }
                }
              }
              for (AA = 0; AB.other[AA] && AE[v][AA] !== undefined; AA++) {
                t(AB.other[AA], AE[v][AA])
              }
            } else {
              if (AF && AF.nodeName) {
                t(AF, AE[v])
              }
            }
          }
        }
        function t(x, z) {
          var AA = 0,
          w, y = 0,
          AD, v, AC;
          if (x.type == "select-one") {
            for (w = x.options.length; AA < w; AA++) {
              if (x.options[AA].value == z) {
                x.selectedIndex = AA;
                return true
              }
            }
            return false
          } else {
            if (x.type == "select-multiple") {
              var AB = !!z.push;
              for (AA = 0, w = x.options.length; AA < w; AA++) {
                v = x.options[AA];
                AC = v.value;
                if (AB) {
                  v.selected = false;
                  for (AD = z.length; y < AD; y++) {
                    if (AC == z[y]) {
                      v.selected = true;
                      z.splice(y, 1);
                      break
                    }
                  }
                } else {
                  return v.selected = z == AC
                }
              }
              return false
            } else {
              if (x.type == "radio" || x.type == "checkbox") {
                x.checked = z == x.value;
                return z == x.value
              } else {
                x.value = z;
                return true
              }
            }
          }
        }
        return function() {
          var v = arguments,
          z = v[0],
          y = this,
          w = 0,
          x = y.length;
          if (v.length === 0) {
            return y[0].nodeName == "FORM" ? s(y[0]) : u(y[0])
          }
          if (y[0].nodeName == "FORM") {
            if (!typeof z == "object") {
              throw "value for FORM must be object"
            }
            r(y[0], z)
          } else {
            for (; w < x; w++) {
              t(y[w], z)
            }
          }
          return y
        }
      } (),
      slice: function() {
        return new k.NodeList().push(Array.prototype.slice.apply(this, arguments))
      },
      sort: function(u) {
        var t = this,
        s = 0,
        r;
        if (!t.length) {
          return t
        }
        if (!u) {
          if (typeof t[0].sourceIndex == "number") {
            u = function(w, v) {
              return w.sourceIndex - v.sourceIndex
            }
          } else {
            if (t[0].compareDocumentPosition) {
              u = function(w, v) {
                return 3 - (w.compareDocumentPosition(v) & 6)
              }
            } else {
              r = Y("*", [G]);
              for (; r[s]; s++) {
                r[s]._sourceIndex = s
              }
              u = function(w, v) {
                return w._sourceIndex - v._sourceIndex
              }
            }
          }
        }
        return k.get([].sort.call(t, u))
      },
      filter: function(v) {
        var s = [],
        r = 0,
        t = 0,
        u = this.length;
        for (; t < u; t++) {
          if (v.apply(this[t], [t])) {
            s[r++] = this[t]
          }
        }
        return k.get(s)
      },
      children: function() {
        var s = [],
        r = 0,
        t = 0,
        w = 0,
        v = this.length,
        u;
        for (; t < v; t++) {
          u = this[t].childNodes;
          for (; u[w]; w++) {
            if (u[w].nodeType == 1 && u[w].nodeName != "!") {
              s[r++] = u[w]
            }
          }
        }
        return k.get(s)
      },
      parent: function() {
        var s = [],
        r = 0,
        t = 0,
        u = this.length;
        for (; t < u; t++) {
          s[r++] = this[t].parentNode
        }
        return k.get(B(s))
      },
      next: function() {
        return L(this, "next")
      },
      prev: function() {
        return L(this, "previous")
      },
      is: function(s) {
        var t = glow.dom.get(s),
        v = 0,
        r = this.length,
        u,
        w;
        node: for (; v < r; v++) {
          for (u = 0, w = t.length; u < w; u++) {
            if (this[v] == t[u]) {
              continue node
            }
          }
          return false
        }
        return true
      },
      text: function() {
        var r = arguments,
        s = 0,
        u = this,
        t = u.length;
        if (r.length > 0) {
          for (; s < t; s++) {
            u[s].innerHTML = "";
            u[s].appendChild(G.createTextNode(r[0]))
          }
          return u
        }
        return u[0].innerText || u[0].textContent == undefined ? H(u[0]) : u[0].textContent
      },
      empty: function() {
        for (var r = 0, s = this.length, t; r < s; r++) {
          while (t = this[r].firstChild) {
            this[r].removeChild(t)
          }
        }
        return this
      },
      remove: function() {
        for (var u = this, s = 0, t = u.length, r; s < t; s++) {
          if (r = u[s].parentNode) {
            r.removeChild(u[s])
          }
        }
        return u
      },
      clone: function() {
        var r = [],
        s = 0,
        t = this.length;
        for (; s < t; s++) {
          r[s] = this[s].cloneNode(true)
        }
        return k.get(r)
      },
      html: function() {
        var r = arguments,
        u = this,
        s = 0,
        t = u.length;
        if (r.length > 0) {
          for (; s < t; s++) {
            u[s].innerHTML = r[0]
          }
          return u
        }
        return u[0].innerHTML
      },
      width: function(r) {
        if (r == undefined) {
          return d(this[0]).width
        }
        F(this, r, "width");
        return this
      },
      height: function(r) {
        if (r == undefined) {
          return d(this[0]).height
        }
        F(this, r, "height");
        return this
      },
      css: function(w, u) {
        var t = this,
        v, s = 0,
        r = t.length;
        if (u != undefined) {
          w = j(w);
          for (; s < r; s++) {
            v = t[s].style;
            if (w == "opacity" && I.ie) {
              if (u === "") {
                v.filter = ""
              } else {
                v.filter = "alpha(opacity=" + Math.round(Number(u, 10) * 100) + ")"
              }
            } else {
              v[w] = u
            }
          }
          return t
        } else {
          if (!t.length) {
            return
          }
          return l(t[0], w)
        }
      },
      offset: function(t) {
        var s = this[0],
        r = 0,
        v = 0,
        u = true;
        if (!s) {
          return undefined
        }
        do {
          r += s.offsetLeft;
          v += s.offsetTop;
          if (!t && !u && s != X && s != i) {
            r -= s.scrollLeft;
            v -= s.scrollTop
          }
          u = false
        } while (s = s.offsetParent);
        return {
          x: r,
          y: v
        }
      },
      append: function(w) {
        var v = this,
        s = 0,
        t = 1,
        u = v.length,
        r;
        if (u == 0) {
          return v
        }
        r = typeof w == "string" ? J(c(w)) : w.nodeType ? [w] : J(w);
        for (; r[s]; s++) {
          v[0].appendChild(r[s])
        }
        for (; t < u; t++) {
          for (s = 0; r[s]; s++) {
            v[t].appendChild(r[s].cloneNode(true))
          }
        }
        return v
      },
      prepend: function(x) {
        var v = this,
        s = 0,
        t = 1,
        u = v.length,
        r, w;
        if (u == 0) {
          return v
        }
        r = typeof x == "string" ? J(c(x)) : x.nodeType ? [x] : J(x);
        w = v[0].firstChild;
        for (; r[s]; s++) {
          v[0].insertBefore(r[s], w)
        }
        for (; t < u; t++) {
          w = v[t].firstChild;
          for (s = 0; r[s]; s++) {
            v[t].insertBefore(r[s].cloneNode(true), w)
          }
        }
        return v
      },
      appendTo: function(r) {
        if (! (r instanceof k.NodeList)) {
          r = k.get(r)
        }
        r.append(this);
        return this
      },
      prependTo: function(r) {
        if (! (r instanceof k.NodeList)) {
          r = k.get(r)
        }
        r.prepend(this);
        return this
      },
      after: function(y) {
        var x = this,
        w = x.length,
        t, s, u, v = 1,
        r;
        if (w == 0) {
          return x
        }
        t = typeof y == "string" ? k.create(y) : y instanceof k.NodeList ? y: k.get(y);
        s = t.length;
        for (u = s - 1; u >= 0; u--) {
          x[0].parentNode.insertBefore(t[u], x[0].nextSibling)
        }
        for (; v < w; v++) {
          r = t.clone();
          for (u = s - 1; u >= 0; u--) {
            x[v].parentNode.insertBefore(r[u], x[v].nextSibling)
          }
        }
        return x
      },
      before: function(y) {
        var x = this,
        w = x.length,
        u = 0,
        v = 1,
        t, s, r;
        if (w == 0) {
          return x
        }
        t = typeof y == "string" ? k.create(y) : y instanceof k.NodeList ? y: k.get(y);
        s = t.length;
        for (; u < s; u++) {
          x[0].parentNode.insertBefore(t[u], x[0])
        }
        for (; v < w; v++) {
          r = t.clone();
          for (u = 0; u < s; u++) {
            x[v].parentNode.insertBefore(r[u], x[v])
          }
        }
        return x
      },
      insertAfter: function(r) {
        if (! (r instanceof k.NodeList)) {
          r = k.get(r)
        }
        r.after(this);
        return this
      },
      insertBefore: function(r) {
        if (! (r instanceof k.NodeList)) {
          r = k.get(r)
        }
        r.before(this);
        return this
      },
      replaceWith: function(y) {
        var x = this,
        w = x.length,
        t, s, u = 0,
        v = 1,
        r;
        if (w == 0) {
          return x
        }
        t = typeof y == "string" ? k.create(y) : y instanceof k.NodeList ? y: k.get(y);
        x[0].innerHTML = "";
        s = t.length;
        for (; u < s; u++) {
          x[0].appendChild(t[u])
        }
        for (; v < w; v++) {
          x[v].innerHTML = "";
          r = t.clone();
          for (u = 0; u < s; u++) {
            x[v].appendChild(r[u])
          }
        }
        return x
      },
      get: function() {
        function t(AG) {
          if (U[AG]) {
            return U[AG]
          }
          var AA = [],
          AJ = 0,
          AB,
          AH,
          AD,
          AE,
          AI,
          AF,
          AC = true;
          while (AG && AG != AF) {
            AH = "";
            AD = "";
            AF = AG;
            if (AE = N.combinator.exec(AG)) {
              AB = AE[1];
              AG = AG.slice(AE[0].length)
            }
            if (AE = N.tagName.exec(AG)) {
              AH = AE[1];
              AG = AG.slice(AE[0].length)
            }
            if (AE = N.classNameOrId.exec(AG)) {
              if (AE[1] == "#") {
                AD = AE[2];
                AG = AG.slice(AE[0].length)
              }
            }
            if (!AB) {
              if (AD && AC) {
                AA[AJ++] = [v, [AD.replace(/\\/g, ""), AH || "*", null]]
              } else {
                AA[AJ++] = [Y, [AH || "*", null]];
                if (AD) {
                  AA[AJ++] = [y, [AD.replace(/\\/g, ""), null]]
                }
              }
            } else {
              if (AB == ">") {
                AA[AJ++] = [u, [null]];
                if (AD) {
                  AA[AJ++] = [y, [AD.replace(/\\/g, ""), null]]
                }
                if (AH && AH != "*") {
                  AA[AJ++] = [z, [AH, null]]
                }
              }
            }
            AI = true;
            while (AI) {
              if (AG.charAt(0) == "#" || AG.charAt(0) == ".") {
                if (AE = N.classNameOrId.exec(AG)) {
                  if (AG.charAt(0) == "#") {
                    AA[AJ++] = [y, [AE[2].replace(/\\/g, ""), null]]
                  } else {
                    AA[AJ++] = [x, [AE[2].replace(/\\/g, ""), null]]
                  }
                  AG = AG.slice(AE[0].length)
                } else {
                  throw new Error("Invalid Selector")
                }
              } else {
                AI = false
              }
            }
            AC = false
          }
          if (AG !== "") {
            throw new Error("Invalid Selector")
          }
          return U[AG] = AA
        }
        function w(AA, AD) {
          var AC = AD;
          for (var AB = 0, AE = AA.length; AB < AE; AB++) {
            AA[AB][1][AA[AB][1].length - 1] = AC;
            AC = AA[AB][0].apply(this, AA[AB][1])
          }
          return AC
        }
        function v(AB, AF, AC) {
          var AA = [],
          AJ = 0,
          AE = [],
          AI = 0,
          AG;
          for (var AH = 0, AD = AC.length; AH < AD; AH++) {
            if (AC[AH].getElementById) {
              AG = AC[AH].getElementById(AB);
              if (AG && (AG.tagName == AF.toUpperCase() || AF == "*" || AG.tagName == AF)) {
                AA[AJ++] = AG
              }
            } else {
              AE[AI++] = AC[AH]
            }
          }
          if (AE[0]) {
            AE = Y(AF, AE);
            AE = y(AB, AE)
          }
          return AA.concat(AE)
        }
        function u(AB) {
          var AD = [];
          for (var AA = 0, AC = AB.length; AA < AC; AA++) {
            h(AD, AB[AA].childNodes)
          }
          return AD
        }
        function y(AD, AB) {
          for (var AA = 0, AC = AB.length; AA < AC; AA++) {
            if (AB[AA].id == AD) {
              return [AB[AA]]
            }
          }
          return []
        }
        function z(AD, AC) {
          var AF = [],
          AA = 0;
          for (var AB = 0, AE = AC.length; AB < AE; AB++) {
            if (AC[AB].tagName == AD.toUpperCase() || AC[AB].tagName == AD) {
              AF[AA++] = AC[AB]
            }
          }
          return AF
        }
        function x(AD, AC) {
          var AF = [],
          AA = 0;
          for (var AB = 0, AE = AC.length; AB < AE; AB++) {
            if ((" " + AC[AB].className + " ").indexOf(" " + AD + " ") != -1) {
              AF[AA++] = AC[AB]
            }
          }
          return AF
        }
        function s(AG, AC) {
          var AD;
          var AF = [];
          var AE = AG.split(",");
          for (var AB = 0, AA = AE.length; AB < AA; AB++) {
            AD = t(glow.lang.trim(AE[AB]));
            AF = AF.concat(w(AD, AC))
          }
          return AF
        }
        function r(AB, AD) {
          AB = AB.length ? AB: [AB];
          var AE = [];
          var AA;
          for (var AC = 0; AB[AC]; AC++) {
            AA = glow.dom.get(AB[AC]);
            for (var AF = 0; AD[AF]; AF++) {
              if (AA.isWithin(AD[AF])) {
                AE[AE.length] = AA[0];
                break
              }
            }
          }
          return AE
        }
        return function(AD) {
          if (!this.length) {
            return this
          }
          var AC = [];
          for (var AB = 0, AA = arguments.length; AB < AA; AB++) {
            if (typeof arguments[AB] == "string") {
              AC = AC.concat(s(arguments[AB], this))
            } else {
              AC = AC.concat(r(arguments[AB], this))
            }
          }
          return glow.dom.get(B(AC))
        }
      } ()
    };
    return k
  }
});
glow.module("glow.debug", "0.4.0", {
  require: [],
  implementation: function() {
    return {
      assert: function(B, A) {
        if (!B) {
          throw A
        }
      },
      assertParameterObject: function(E, G, A, D) {
        var B, C;
        var F = {};
        for (B = 0, C = G.length; B < C; B++) {
          F[G[B]] = 1;
          if (! (G[B] in E)) {
            throw D + ", required parameter '" + G[B] + "' not passed"
          }
        }
        for (B = 0, C = A.length; B < C; B++) {
          F[A[B]] = 1
        }
        for (B in E) {
          if (! (B in F)) {
            throw D + ", unexpected parameter '" + B + "' passed"
          }
        }
      }
    }
  }
});
glow.module("glow.data", "0.4.0", {
  require: ["glow.dom"],
  implementation: function() {
    var TYPES = {
      UNDEFINED: "undefined",
      OBJECT: "object",
      NUMBER: "number",
      BOOLEAN: "boolean",
      STRING: "string",
      ARRAY: "array",
      FUNCTION: "function",
      NULL: "null"
    };
    var TEXT = {
      AT: "@",
      EQ: "=",
      DOT: ".",
      EMPTY: "",
      AND: "&",
      OPEN: "(",
      CLOSE: ")"
    };
    var JSON = {
      HASH: {
        START: "{",
        END: "}",
        SHOW_KEYS: true
      },
      ARRAY: {
        START: "[",
        END: "]",
        SHOW_KEYS: false
      },
      DATA_SEPARATOR: ",",
      KEY_SEPARATOR: ":",
      KEY_DELIMITER: '"',
      STRING_DELIMITER: '"',
      SAFE_PT1: /^[\],:{}\s]*$/,
      SAFE_PT2: /\\./g,
      SAFE_PT3: /\"[^\"\\\n\r]*\"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g,
      SAFE_PT4: /(?:^|:|,)(?:\s*\[)+/g
    };
    var SLASHES = {
      TEST: /[\b\n\r\t\\\f\"]/g,
      B: {
        PLAIN: "\b",
        ESC: "\\b"
      },
      N: {
        PLAIN: "\n",
        ESC: "\\n"
      },
      R: {
        PLAIN: "\r",
        ESC: "\\r"
      },
      T: {
        PLAIN: "\t",
        ESC: "\\t"
      },
      F: {
        PLAIN: "\f",
        ESC: "\\f"
      },
      SL: {
        PLAIN: "\\",
        ESC: "\\\\"
      },
      QU: {
        PLAIN: '"',
        ESC: '\\"'
      }
    };
    function _replaceSlashes(s) {
      switch (s) {
      case SLASHES.B.PLAIN:
        return SLASHES.B.ESC;
      case SLASHES.N.PLAIN:
        return SLASHES.N.ESC;
      case SLASHES.R.PLAIN:
        return SLASHES.R.ESC;
      case SLASHES.T.PLAIN:
        return SLASHES.T.ESC;
      case SLASHES.F.PLAIN:
        return SLASHES.F.ESC;
      case SLASHES.SL.PLAIN:
        return SLASHES.SL.ESC;
      case SLASHES.QU.PLAIN:
        return SLASHES.QU.ESC;
      default:
        return s
      }
    }
    function _getType(object) {
      if ((typeof object) == TYPES.OBJECT) {
        if (object == null) {
          return TYPES.NULL
        } else {
          return (object instanceof Array) ? TYPES.ARRAY: TYPES.OBJECT
        }
      } else {
        return (typeof object)
      }
    }
    return {
      encodeUrl: function(object) {
        var objectType = _getType(object);
        var paramsList = [];
        var listLength = 0;
        if (objectType != TYPES.OBJECT) {
          throw new Error("glow.data.encodeUrl: cannot encode item")
        } else {
          for (var key in object) {
            switch (_getType(object[key])) {
            case TYPES.FUNCTION:
            case TYPES.OBJECT:
              throw new Error("glow.data.encodeUrl: cannot encode item");
              break;
            case TYPES.ARRAY:
              for (var i = 0, l = object[key].length; i < l; i++) {
                switch (_getType(object[key])[i]) {
                case TYPES.FUNCTION:
                case TYPES.OBJECT:
                case TYPES.ARRAY:
                  throw new Error("glow.data.encodeUrl: cannot encode item");
                  break;
                default:
                  paramsList[listLength++] = key + TEXT.EQ + encodeURIComponent(object[key][i])
                }
              }
              break;
            default:
              paramsList[listLength++] = key + TEXT.EQ + encodeURIComponent(object[key])
            }
          }
          return paramsList.join(TEXT.AND)
        }
      },
      decodeUrl: function(text) {
        if (_getType(text) != TYPES.STRING) {
          throw new Error("glow.data.decodeUrl: cannot decode item")
        } else {
          if (text === "") {
            return {}
          }
        }
        var result = {};
        var keyValues = text.split(TEXT.AND);
        var thisPair, key, value;
        for (var i = 0, l = keyValues.length; i < l; i++) {
          thisPair = keyValues[i].split(TEXT.EQ);
          if (thisPair.length != 2) {
            throw new Error("glow.data.decodeUrl: cannot decode item")
          } else {
            key = decodeURIComponent(thisPair[0]);
            value = decodeURIComponent(thisPair[1]);
            switch (_getType(result[key])) {
            case TYPES.ARRAY:
              result[key][result[key].length] = value;
              break;
            case TYPES.UNDEFINED:
              result[key] = value;
              break;
            default:
              result[key] = [result[key], value]
            }
          }
        }
        return result
      },
      encodeJson: function(object, options) {
        function _encode(object, options) {
          if (_getType(object) == TYPES.ARRAY) {
            var type = JSON.ARRAY
          } else {
            var type = JSON.HASH
          }
          var serial = [type.START];
          var len = 1;
          var dataType;
          var notFirst = false;
          for (var key in object) {
            dataType = _getType(object[key]);
            if (dataType != TYPES.UNDEFINED) {
              if (notFirst) {
                serial[len++] = JSON.DATA_SEPARATOR
              }
              notFirst = true;
              if (type.SHOW_KEYS) {
                serial[len++] = JSON.KEY_DELIMITER;
                serial[len++] = key;
                serial[len++] = JSON.KEY_DELIMITER;
                serial[len++] = JSON.KEY_SEPARATOR
              }
              switch (dataType) {
              case TYPES.FUNCTION:
                throw new Error("glow.data.encodeJson: cannot encode item");
                break;
              case TYPES.STRING:
              default:
                serial[len++] = JSON.STRING_DELIMITER;
                serial[len++] = glow.lang.replace(object[key], SLASHES.TEST, _replaceSlashes);
                serial[len++] = JSON.STRING_DELIMITER;
                break;
              case TYPES.NUMBER:
              case TYPES.BOOLEAN:
                serial[len++] = object[key];
                break;
              case TYPES.OBJECT:
              case TYPES.ARRAY:
                serial[len++] = _encode(object[key], options);
                break;
              case TYPES.NULL:
                serial[len++] = TYPES.NULL;
                break
              }
            }
          }
          serial[len++] = type.END;
          return serial.join(TEXT.EMPTY)
        }
        options = options || {};
        var type = _getType(object);
        if ((type == TYPES.OBJECT) || (type == TYPES.ARRAY)) {
          return _encode(object, options)
        } else {
          throw new Error("glow.data.encodeJson: cannot encode item")
        }
      },
      decodeJson: function(text, options) {
        if (_getType(text) != TYPES.STRING) {
          throw new Error("glow.data.decodeJson: cannot decode item")
        }
        options = options || {};
        options.safeMode = options.safeMode || false;
        var canEval = true;
        if (options.safeMode) {
          canEval = (JSON.SAFE_PT1.test(text.replace(JSON.SAFE_PT2, TEXT.AT).replace(JSON.SAFE_PT3, JSON.ARRAY.END).replace(JSON.SAFE_PT4, TEXT.EMPTY)))
        }
        if (canEval) {
          try {
            return eval(TEXT.OPEN + text + TEXT.CLOSE)
          } catch(e) {}
        }
        throw new Error("glow.data.decodeJson: cannot decode item")
      },
      escapeHTML: function(html) {
        return glow.dom.create("<div></div>").text(html).html()
      }
    }
  }
});
glow.module("glow.net", "0.4.0", {
  require: ["glow.data"],
  implementation: function() {
    var G = {
      XML_ERR: "Cannot get response as XML, check the mime type of the data",
      POST_DEFAULT_CONTENT_TYPE: "application/x-www-form-urlencoded;"
    },
    H = [];
    function D() {
      if (window.XMLHttpRequest) {
        return (D = function() {
          return new XMLHttpRequest()
        })()
      } else {
        if (glow.env.ie < 7) {
          var J = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP"];
          for (var K = 0, I = J.length; K < I; K++) {
            try {
              new ActiveXObject(J[K]);
              return (D = function() {
                return new ActiveXObject(J[K])
              })()
            } catch(L) {}
          }
        }
      }
      return null
    }
    function B(I) {
      I.load && (I.onLoad = I.load);
      I.error && (I.onError = I.error);
      return glow.lang.apply({
        onLoad: function() {},
        onError: function() {},
        addToHistory: false,
        headers: {},
        async: true,
        useCache: false,
        data: null
      },
      I)
    }
    function A(I) {
      return [I, (/\?/.test(I) ? "&": "?"), "a", new Date().getTime(), parseInt(Math.random() * 100000)].join("")
    }
    function F(P, J, M) {
      var O, L = D(),
      N = M.data && (typeof M.data == "string" ? M.data: glow.data.encodeUrl(M.data));
      if (!M.useCache) {
        J = A(J)
      }
      L.open(P, J, M.async);
      for (var K in M.headers) {
        L.setRequestHeader(K, M.headers[K])
      }
      if (M.async) {
        L.onreadystatechange = function() {
          if (L.readyState == 4) {
            var Q = new C(L);
            if (L.status == 200 || (L.status == 0 && L.responseText)) {
              M.onLoad(Q)
            } else {
              M.onError(Q)
            }
          }
        };
        H[O = H.length] = L;
        L.send(N);
        return O
      } else {
        L.send(N);
        var I = new C(L);
        if (L.status == 200 || (L.status == 0 && L.responseText)) {
          M.onLoad(I)
        } else {
          M.onError(I)
        }
        return I
      }
    }
    var E = {};
    E._jsonCbs = {
      len: 0
    };
    E.get = function(I, J) {
      J = B(J);
      return F("GET", I, J)
    };
    E.post = function(I, J, K) {
      K = B(K);
      K.data = J;
      if (!K.headers["Content-Type"]) {
        K.headers["Content-Type"] = G.POST_DEFAULT_CONTENT_TYPE
      }
      return F("POST", I, K)
    };
    E.abort = function(I) {
      if (H[I]) {
        H[I].onreadystatechange = function() {};
        H[I].abort()
      }
      return glow.net
    };
    E.loadScript = function(J, L) {
      if (L) {
        var K = "c" + E._jsonCbs.len++;
        E._jsonCbs[K] = L;
        J = glow.lang.interpolate(J, {
          callback: "glow.net._jsonCbs." + K
        })
      }
      var I = document.createElement("script");
      I.src = A(J);
      glow.ready(function() {
        document.body.appendChild(I)
      })
    };
    function C(I) {
      this.nativeResponse = I;
      this.status = I.status
    }
    C.prototype = {
      text: function() {
        return this.nativeResponse.responseText
      },
      xml: function() {
        if (!this.nativeResponse.responseXML) {
          throw new Error(G.XML_ERR)
        }
        return this.nativeResponse.responseXML
      },
      json: function(I) {
        return glow.data.decodeJson(this.text(), {
          safeMode: I
        })
      },
      header: function(I) {
        return this.nativeResponse.getResponseHeader(I)
      },
      statusText: function() {
        return this.nativeResponse.statusText
      }
    };
    return E
  }
});
glow.module("glow.events", "0.4.0", {
  require: [],
  implementation: function() {
    var V = {};
    var Q = 1;
    var I = 1;
    var J = {};
    var A = {};
    var K = {};
    var H = "__intGlowEventId" + Math.floor(Math.random() * 1337);
    var E = H + "PreventDefault";
    var O = H + "StopPropagation";
    var X = {};
    var D = 1;
    var U = {};
    var S = {};
    var Z = 1;
    var B = 2;
    var M = 4;
    var F = {
      TAB: "\t",
      SPACE: " ",
      ENTER: "\n",
      BACKTICK: "`"
    };
    var d = {
      "96": 223
    };
    var N = {
      CAPSLOCK: 20,
      NUMLOCK: 144,
      SCROLLLOCK: 145,
      BREAK: 19,
      BACKTICK: 223,
      BACKSPACE: 8,
      PRINTSCREEN: 44,
      MENU: 93,
      SPACE: 32,
      SHIFT: 16,
      CTRL: 17,
      ALT: 18,
      ESC: 27,
      TAB: 9,
      META: 91,
      RIGHTMETA: 92,
      ENTER: 13,
      F1: 112,
      F2: 113,
      F3: 114,
      F4: 115,
      F5: 116,
      F6: 117,
      F7: 118,
      F8: 119,
      F9: 120,
      F10: 121,
      F11: 122,
      F12: 123,
      INS: 45,
      HOME: 36,
      PAGEUP: 33,
      DEL: 46,
      END: 35,
      PAGEDOWN: 34,
      LEFT: 37,
      UP: 38,
      RIGHT: 39,
      DOWN: 40
    };
    var b = {};
    for (var a in N) {
      b["" + N[a]] = a
    }
    var R = "0123456789=;'\\/#,.-";
    function W(j) {
      var h = S[j];
      if (!h) {
        return false
      }
      var g = U[h];
      if (!g) {
        return false
      }
      for (var f = 0, e = g.length; f < e; f++) {
        if (g[f][0] == j) {
          g.splice(f, 1);
          return true
        }
      }
      return false
    }
    function T(e) {
      X[e] = V.addListener(document, "key" + e,
      function(m) {
        var k = 0;
        if (m.ctrlKey) {
          k += Z
        }
        if (m.altKey) {
          k += B
        }
        if (m.shiftKey) {
          k += M
        }
        var l = m.chr ? m.chr.toLowerCase() : m.key ? m.key.toLowerCase() : m.keyCode;
        var h = k + ":" + l + ":" + e;
        var j = U[h] ? U[h].slice(0) : [];
        if (m.shiftKey) {
          var n = (k & ~M) + ":" + l + ":" + e;
          if (U[n]) {
            for (var g = 0, f = U[n].length; g < f; g++) {
              j[j.length] = U[n][g]
            }
          }
        }
        if (!j) {
          return
        }
        for (var g = 0, f = j.length; g < f; g++) {
          j[g][2].call(j[g][3] || this, m)
        }
      })
    }
    function P() {
      var e;
      for (e in A) {
        V.removeListener(e)
      }
    }
    var L;
    var c, C;
    function Y(h, g) {
      var e;
      if (glow.env.opera) {
        if (g.toLowerCase() == "resize" && !c && h == window) {
          c = V.addListener(window.document.body, "resize",
          function(k) {
            V.fire(window, "resize", k)
          })
        } else {
          if (g.toLowerCase() == "scroll" && !C && h == window) {
            C = V.addListener(window.document, "scroll",
            function(k) {
              V.fire(window, "scroll", k)
            })
          }
        }
      }
      var j = function(l) {
        if (!l) {
          l = window.event
        }
        var k = new V.Event();
        k.nativeEvent = l;
        k.source = l.target || l.srcElement;
        if (k.source && k.source.nodeType != 1) {
          k.source = k.source.parentNode
        }
        k.relatedTarget = l.relatedTarget || (g.toLowerCase() == "mouseover" ? l.fromElement: l.toElement);
        k.button = glow.env.ie ? (l.button & 1 ? 0 : l.button & 2 ? 2 : 1) : l.button;
        if (l.pageX || l.pageY) {
          k.pageX = l.pageX;
          k.pageY = l.pageY
        } else {
          if (l.clientX || l.clientY) {
            k.pageX = l.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            k.pageY = l.clientY + document.body.scrollTop + document.documentElement.scrollTop
          }
        }
        if (g.toLowerCase() == "mousewheel") {
          k.wheelDelta = l.wheelDelta ? l.wheelDelta / 120 : l.detail ? -l.detail / 3 : 0;
          if (k.wheelDelta == 0) {
            return
          }
        }
        if (g.toLowerCase().indexOf("key") != -1) {
          k.altKey = !!l.altKey;
          k.ctrlKey = !!l.ctrlKey;
          k.shiftKey = !!l.shiftKey;
          if (g == "keydown") {
            L = l.keyCode
          }
          k.charCode = l.keyCode && l.charCode !== 0 ? undefined: l.charCode;
          if (g.toLowerCase() == "keypress") {
            if (typeof(k.charCode) == "undefined") {
              k.charCode = l.keyCode
            }
            if (glow.env.opera && k.charCode && k.charCode == L && R.indexOf(String.fromCharCode(k.charCode)) == -1) {
              k.charCode = undefined;
              k.keyCode = L
            }
          }
          if (k.charCode && k.charCode <= 31) {
            k.charCode = undefined
          }
          if (k.charCode) {
            k.chr = String.fromCharCode(k.charCode)
          } else {
            if (l.keyCode) {
              k.charCode = undefined;
              k.keyCode = d[l.keyCode.toString()] || l.keyCode;
              k.key = b[k.keyCode];
              if (F[k.key]) {
                k.chr = F[k.key];
                k.charCode = k.chr.charCodeAt(0)
              }
            }
          }
          if (k.chr) {
            k.capsLock = k.chr.toUpperCase() != k.chr ? k.shiftKey: k.chr.toLowerCase() != k.chr ? !k.shiftKey: undefined
          }
        }
        V.fire(this, g, k);
        if (k.defaultPrevented()) {
          return false
        }
      };
      if (h.addEventListener && (!glow.env.webkit || glow.env.webkit > 418)) {
        h.addEventListener(g.toLowerCase() == "mousewheel" && glow.env.gecko ? "DOMMouseScroll": g, j, false)
      } else {
        var f = "on" + g;
        var i = h[f];
        if (i) {
          h[f] = function() {
            i.apply(this, arguments);
            j.apply(this, arguments)
          }
        } else {
          h[f] = j
        }
      }
      h = null
    }
    V.addListener = function(l, g, m, i) {
      if (!l) {
        throw "no attachTo paramter passed to addListener"
      }
      if (typeof l == "string") {
        if (!glow.dom) {
          throw "glow.dom must be loaded to use a selector as the first argument to glow.events.addListener"
        }
        if (! (l = glow.dom.get(l)[0])) {
          return undefined
        }
      } else {
        if (glow.dom && l instanceof glow.dom.NodeList) {
          if (l.length == 0) {
            return undefined
          }
          l = l[0]
        }
      }
      var h;
      if (! (h = l[H])) {
        h = l[H] = I++
      }
      var k = Q++;
      var j = [h, g, m, i];
      A[k] = j;
      var e = J[h];
      if (!e) {
        e = J[h] = {}
      }
      var f = e[g];
      if (!f) {
        f = e[g] = []
      }
      f[f.length] = j;
      if ((l.addEventListener || l.attachEvent) && !K[h + ":" + g]) {
        Y(l, g);
        K[h + ":" + g] = true
      }
      return k
    };
    V.removeListener = function(j) {
      if (j && j.toString().indexOf("k:") != -1) {
        return W(j)
      }
      var h = A[j];
      if (!h) {
        return false
      }
      delete A[j];
      var g = J[h[0]][h[1]];
      for (var f = 0, e = g.length; f < e; f++) {
        if (g[f] == h) {
          g.splice(f, 1);
          break
        }
      }
      if (!g.length) {
        delete J[h[0]][h[1]]
      }
      var k = false;
      for (var f in J[h[0]]) {
        k = true;
        break
      }
      if (!k) {
        delete J[h[0]]
      }
      return true
    };
    V.fire = function(o, g, n) {
      if (!o) {
        throw "glow.events.fire: required parameter attachedTo not passed (name: " + g + ")"
      }
      if (!g) {
        throw "glow.events.fire: required parameter name not passed"
      }
      if (!n) {
        n = new V.Event()
      }
      n.type = g;
      n.attachedTo = o;
      if (!n.source) {
        n.source = o
      }
      var h = o[H],
      f = h && J[h],
      j = f && f[g];
      if (!j) {
        return n
      }
      var k, p;
      var q = j.slice(0);
      for (var l = 0, m = q.length; l < m; l++) {
        k = q[l];
        p = k[2].call(k[3] || o, n);
        if (typeof p == "boolean" && !p) {
          n.preventDefault()
        }
      }
      return n
    };
    var G = /^((?:(?:ctrl|alt|shift)\+)*)(?:(\w+|.)|[\n\r])$/i;
    V.addKeyListener = function(k, j, l, f) {
      j.replace(/^key/i, "");
      j = j.toLowerCase();
      if (! (j == "press" || j == "down" || j == "up")) {
        throw "event type must be press, down or up"
      }
      if (!X[j]) {
        T(j)
      }
      var h = k.match(G),
      m = 0,
      n;
      if (!h) {
        throw "key format not recognised"
      }
      if (h[1].toLowerCase().indexOf("ctrl") != -1) {
        m += Z
      }
      if (h[1].toLowerCase().indexOf("alt") != -1) {
        m += B
      }
      if (h[1].toLowerCase().indexOf("shift") != -1) {
        m += M
      }
      var e = m + ":" + (h[2] ? h[2].toLowerCase() : "\n") + ":" + j;
      var g = "k:" + D++;
      S[g] = e;
      var i = U[e];
      if (!i) {
        i = U[e] = []
      }
      i[i.length] = [g, j, l, f];
      return g
    };
    V.Event = function() {};
    V.Event.prototype.preventDefault = function() {
      if (this[E]) {
        return
      }
      this[E] = true;
      if (this.nativeEvent && this.nativeEvent.preventDefault) {
        this.nativeEvent.preventDefault();
        this.nativeEvent.returnValue = false
      }
    };
    V.Event.prototype.defaultPrevented = function() {
      return !! this[E]
    };
    V.Event.prototype.stopPropagation = function() {
      if (this[O]) {
        return
      }
      this[O] = true;
      var f = this.nativeEvent;
      if (f) {
        f.cancelBubble = true;
        if (f.stopPropagation) {
          f.stopPropagation()
        }
      }
    };
    V.Event.prototype.propagationStopped = function() {
      return !! this[O]
    };
    V.addListener(window, "unload", P);
    return V
  }
});
/*@end @*/
/*@cc_on @*/
/*@if (@_jscript_version > 5.1)@*/
glow.module("glow.tweens", "0.4.0", {
  require: [],
  implementation: function() {
    function A(B) {
      return function(C) {
        return 1 - B(1 - C)
      }
    }
    return {
      linear: function() {
        return function(B) {
          return B
        }
      },
      easeIn: function(B) {
        B = B || 2;
        return function(C) {
          return Math.pow(1, B - 1) * Math.pow(C, B)
        }
      },
      easeOut: function(B) {
        return A(this.easeIn(B))
      },
      easeBoth: function(B) {
        return this.combine(this.easeIn(B), this.easeOut(B))
      },
      overshootIn: function(B) {
        return A(this.overshootOut(B))
      },
      overshootOut: function(B) {
        B = B || 1.70158;
        return function(C) {
          if (C == 0 || C == 1) {
            return C
          }
          return ((C -= 1) * C * ((B + 1) * C + B) + 1)
        }
      },
      overshootBoth: function(B) {
        return this.combine(this.overshootIn(B), this.overshootOut(B))
      },
      bounceIn: function() {
        return A(this.bounceOut())
      },
      bounceOut: function() {
        return function(B) {
          if (B < (1 / 2.75)) {
            return 7.5625 * B * B
          } else {
            if (B < (2 / 2.75)) {
              return (7.5625 * (B -= (1.5 / 2.75)) * B + 0.75)
            } else {
              if (B < (2.5 / 2.75)) {
                return (7.5625 * (B -= (2.25 / 2.75)) * B + 0.9375)
              } else {
                return (7.5625 * (B -= (2.625 / 2.75)) * B + 0.984375)
              }
            }
          }
        }
      },
      bounceBoth: function() {
        return this.combine(this.bounceIn(), this.bounceOut())
      },
      elasticIn: function(B, C) {
        return A(this.elasticOut(B, C))
      },
      elasticOut: function(B, C) {
        return function(D) {
          if (D == 0 || D == 1) {
            return D
          }
          if (!C) {
            C = 0.3
          }
          if (!B || B < 1) {
            B = 1;
            var E = C / 4
          } else {
            var E = C / (2 * Math.PI) * Math.asin(1 / B)
          }
          return B * Math.pow(2, -10 * D) * Math.sin((D - E) * (2 * Math.PI) / C) + 1
        }
      },
      elasticBoth: function(B, C) {
        C = C || 0.45;
        return this.combine(this.elasticIn(B, C), this.elasticOut(B, C))
      },
      combine: function(C, B) {
        return function(D) {
          if (D < 0.5) {
            return C(D * 2) / 2
          } else {
            return B((D - 0.5) * 2) / 2 + 0.5
          }
        }
      }
    }
  }
});
glow.module("glow.anim", "0.4.0", {
  require: ["glow.tweens", "glow.events", "glow.dom"],
  implementation: function() {
    var manager, events = glow.events,
    dom = glow.dom,
    get = dom.get,
    debug = glow.debug,
    hasUnits = /width|height|top$|bottom$|left$|right$|spacing$|indent$|font-size/,
    noNegatives = /width|height|padding|opacity/,
    usesYAxis = /height|top/,
    getUnit = /[\d\.]+(\D+)/,
    testElement = dom.create('<div style="position:absolute;visibility:hidden"></div>');
    (function() {
      var queue = [],
      queueLen = 0,
      intervalTime = 1,
      interval;
      manager = {
        addToQueue: function(anim) {
          queue[queueLen++] = anim;
          anim._playing = true;
          anim._timeAnchor = anim._timeAnchor || new Date().valueOf();
          if (!interval) {
            this.startInterval()
          }
        },
        removeFromQueue: function(anim) {
          for (var i = 0; i < queueLen; i++) {
            if (queue[i] == anim) {
              queue.splice(i, 1);
              anim._timeAnchor = null;
              anim._playing = false;
              if (--queueLen == 0) {
                this.stopInterval()
              }
              return
            }
          }
        },
        startInterval: function() {
          interval = window.setInterval(this.processQueue, intervalTime)
        },
        stopInterval: function() {
          window.clearInterval(interval);
          interval = null
        },
        processQueue: function() {
          var anim, i, now = new Date().valueOf();
          for (i = 0; i < queueLen; i++) {
            anim = queue[i];
            if (anim.position == anim.duration) {
              manager.removeFromQueue(anim);
              i--;
              events.fire(anim, "complete");
              continue
            }
            if (anim.useSeconds) {
              anim.position = (now - anim._timeAnchor) / 1000;
              if (anim.position > anim.duration) {
                anim.position = anim.duration
              }
            } else {
              anim.position++
            }
            anim.value = anim.tween(anim.position / anim.duration);
            events.fire(anim, "frame")
          }
        }
      }
    })();
    function convertCssUnit(element, fromValue, toUnit, axis) {
      var elmStyle = testElement[0].style,
      axisProp = (axis == "x") ? "width": "height",
      startPixelValue,
      toUnitPixelValue;
      elmStyle.margin = elmStyle.padding = elmStyle.border = "0";
      startPixelValue = testElement.css(axisProp, fromValue).insertAfter(element)[axisProp]();
      toUnitPixelValue = testElement.css(axisProp, 10 + toUnit)[axisProp]() / 10;
      testElement.remove();
      return startPixelValue / toUnitPixelValue
    }
    function keepWithinRange(num, start, end) {
      if (start !== undefined && num < start) {
        return start
      }
      if (end !== undefined && num > end) {
        return end
      }
      return num
    }
    function buildAnimFunction(element, spec) {
      var cssProp, r = ["a=(function(){"],
      rLen = 1,
      fromUnit,
      unitDefault = [0, "px"],
      to,
      from,
      unit,
      a;
      for (cssProp in spec) {
        r[rLen++] = 'element.css("' + cssProp + '", ';
        to = spec[cssProp].to;
        if ((from = spec[cssProp].from) === undefined) {
          if (cssProp == "font-size" || cssProp == "background-position") {
            throw new Error("From value must be set for " + cssProp)
          }
          from = element.css(cssProp)
        }
        if (hasUnits.test(cssProp)) {
          unit = (getUnit.exec(spec[cssProp].to) || unitDefault)[1];
          fromUnit = (getUnit.exec(from) || unitDefault)[1];
          from = parseFloat(from) || 0;
          to = parseFloat(to) || 0;
          if (from && unit != fromUnit) {
            if (cssProp == "font-size") {
              throw new Error("Units must be the same for font-size")
            }
            from = convertCssUnit(element, from + fromUnit, unit, usesYAxis.test(cssProp) ? "y": "x")
          }
          if (noNegatives.test(cssProp)) {
            r[rLen++] = "keepWithinRange((" + (to - from) + " * this.value) + " + from + ', 0) + "' + unit + '"'
          } else {
            r[rLen++] = "(" + (to - from) + " * this.value) + " + from + ' + "' + unit + '"'
          }
        } else {
          if (! (isNaN(from) || isNaN(to))) {
            from = Number(from);
            to = Number(to);
            r[rLen++] = "(" + (to - from) + " * this.value) + " + from
          } else {
            if (cssProp.indexOf("color") != -1) {
              to = dom.parseCssColor(spec[cssProp].to);
              if (!glow.lang.hasOwnProperty(from, "r")) {
                from = dom.parseCssColor(from)
              }
              r[rLen++] = '"rgb(" + keepWithinRange(Math.round(' + (to.r - from.r) + " * this.value + " + from.r + '), 0, 255) + "," + keepWithinRange(Math.round(' + (to.g - from.g) + " * this.value + " + from.g + '), 0, 255) + "," + keepWithinRange(Math.round(' + (to.b - from.b) + " * this.value + " + from.b + '), 0, 255) + ")"'
            } else {
              if (cssProp == "background-position") {
                var vals = {},
                fromTo = ["from", "to"],
                unit = (getUnit.exec(from) || unitDefault)[1];
                vals.fromOrig = from.toString().split(/\s/);
                vals.toOrig = to.toString().split(/\s/);
                if (vals.fromOrig[1] === undefined) {
                  vals.fromOrig[1] = "50%"
                }
                if (vals.toOrig[1] === undefined) {
                  vals.toOrig[1] = "50%"
                }
                for (var i = 0; i < 2; i++) {
                  vals[fromTo[i] + "X"] = parseFloat(vals[fromTo[i] + "Orig"][0]);
                  vals[fromTo[i] + "Y"] = parseFloat(vals[fromTo[i] + "Orig"][1]);
                  vals[fromTo[i] + "XUnit"] = (getUnit.exec(vals[fromTo[i] + "Orig"][0]) || unitDefault)[1];
                  vals[fromTo[i] + "YUnit"] = (getUnit.exec(vals[fromTo[i] + "Orig"][1]) || unitDefault)[1]
                }
                if ((vals.fromXUnit !== vals.toXUnit) || (vals.fromYUnit !== vals.toYUnit)) {
                  throw new Error("Mismatched axis units cannot be used for " + cssProp)
                }
                r[rLen++] = "(" + (vals.toX - vals.fromX) + " * this.value + " + vals.fromX + ') + "' + vals.fromXUnit + ' " + (' + (vals.toY - vals.fromY) + " * this.value + " + vals.fromY + ') + "' + vals.fromYUnit + '"'
              }
            }
          }
        }
        r[rLen++] = ");"
      }
      r[rLen++] = "})";
      return eval(r.join(""))
    }
    var r = {};
    r.css = function(element, duration, spec, opts) {
      element = get(element);
      var anim = new r.Animation(duration, opts),
      cssProp;
      events.addListener(anim, "frame", buildAnimFunction(element, spec));
      return anim
    };
    r.Animation = function(duration, opts) {
      opts = glow.lang.apply({
        useSeconds: true,
        tween: glow.tweens.linear()
      },
      opts);
      this._playing = false;
      this._timeAnchor = null;
      this.duration = duration;
      this.useSeconds = opts.useSeconds;
      this.tween = opts.tween;
      this.position = 0;
      this.value = 0
    };
    r.Animation.prototype = {
      start: function() {
        if (this._playing) {
          this.stop()
        }
        var e = events.fire(this, "start");
        if (e.defaultPrevented()) {
          return this
        }
        this.position = 0;
        manager.addToQueue(this);
        return this
      },
      stop: function() {
        if (this._playing) {
          var e = events.fire(this, "stop");
          if (e.defaultPrevented()) {
            return this
          }
          manager.removeFromQueue(this)
        }
        return this
      },
      resume: function() {
        if (!this._playing) {
          var e = events.fire(this, "resume");
          if (e.defaultPrevented()) {
            return this
          }
          this._timeAnchor = new Date().valueOf() - (this.position * 1000);
          manager.addToQueue(this)
        }
        return this
      },
      isPlaying: function() {
        return this._playing
      },
      goTo: function(pos) {
        this._timeAnchor = new Date().valueOf() - ((this.position = pos) * 1000);
        this.value = this.tween(this.duration && this.position / this.duration);
        events.fire(this, "frame");
        return this
      }
    };
    r.Timeline = function(channels, opts) {
      this._channels = (channels[0] && channels[0].push) ? channels: [channels];
      this._channelPos = [];
      this._playing = false;
      this.loop = !!(opts && opts.loop);
      var i, j, iLen, jLen, channel, allChannels = this._channels,
      totalDuration = 0,
      channelDuration;
      for (i = 0, iLen = allChannels.length; i < iLen; i++) {
        channel = allChannels[i];
        channelDuration = 0;
        for (j = 0, jLen = channel.length; j < jLen; j++) {
          if (typeof channel[j] == "number") {
            channel[j] = new r.Animation(channel[j])
          }
          if (channel[j] instanceof r.Animation) {
            if (!channel[j].useSeconds) {
              throw new Error("Timelined animations must be timed in seconds")
            }
            channel[j]._timelineOffset = channelDuration * 1000;
            channelDuration += channel[j].duration;
            channel[j]._channelIndex = i
          }
        }
        totalDuration = Math.max(channelDuration, totalDuration)
      }
      this._controlAnim = new r.Animation(totalDuration);
      events.addListener(this._controlAnim, "frame", this._processFrame, this);
      events.addListener(this._controlAnim, "complete", this._complete, this)
    };
    r.Timeline.prototype = {
      _advanceChannel: function(i) {
        var currentAnim = this._channels[i][this._channelPos[i]],
        nextAnim = this._channels[i][++this._channelPos[i]];
        if (currentAnim && currentAnim._playing) {
          currentAnim._playing = false;
          events.fire(currentAnim, "complete")
        }
        if ((nextAnim) !== undefined) {
          if (typeof nextAnim == "function") {
            nextAnim();
            this._advanceChannel(i)
          } else {
            nextAnim.position = 0;
            nextAnim._channelIndex = i;
            events.fire(nextAnim, "start");
            nextAnim._playing = true
          }
        }
      },
      _complete: function() {
        if (this.loop) {
          this.start();
          return
        }
        events.fire(this, "complete")
      },
      _processFrame: function() {
        var i, len, anim, controlAnim = this._controlAnim,
        msFromStart = (new Date().valueOf()) - controlAnim._timeAnchor;
        for (i = 0, len = this._channels.length; i < len; i++) {
          if (! (anim = this._channels[i][this._channelPos[i]])) {
            continue
          }
          anim.position = (msFromStart - anim._timelineOffset) / 1000;
          if (anim.position > anim.duration) {
            anim.position = anim.duration
          }
          anim.value = anim.tween(anim.position / anim.duration);
          events.fire(anim, "frame");
          if (anim.position == anim.duration) {
            this._advanceChannel(i)
          }
        }
      },
      start: function() {
        var e = events.fire(this, "start");
        if (e.defaultPrevented()) {
          return this
        }
        var i, iLen, j, jLen, anim;
        this._playing = true;
        for (i = 0, iLen = this._channels.length; i < iLen; i++) {
          this._channelPos[i] = -1;
          this._advanceChannel(i);
          for (j = this._channels[i].length; j; j--) {
            anim = this._channels[i][j];
            if (anim instanceof r.Animation) {
              anim.goTo(0)
            }
          }
        }
        this._controlAnim.start()
      },
      stop: function() {
        if (this._playing) {
          var e = events.fire(this, "stop");
          if (e.defaultPrevented()) {
            return this
          }
          this._playing = false;
          var anim;
          for (var i = 0, len = this._channels.length; i < len; i++) {
            anim = this._channels[i][this._channelPos[i]];
            if (anim instanceof r.Animation && anim._playing) {
              events.fire(anim, "stop");
              anim._playing = false
            }
          }
          this._controlAnim.stop()
        }
      },
      resume: function() {
        if (!this._playing) {
          var e = events.fire(this, "resume");
          if (e.defaultPrevented()) {
            return this
          }
          this._playing = true;
          var anim;
          for (var i = 0, len = this._channels.length; i < len; i++) {
            anim = this._channels[i][this._channelPos[i]];
            if (anim instanceof r.Animation && !anim._playing) {
              events.fire(anim, "resume");
              anim._playing = true
            }
          }
          this._controlAnim.resume()
        }
      },
      isPlaying: function() {
        return this._playing
      }
    };
    return r
  }
});
glow.module("glow.dragdrop", "0.4.0", {
  require: ["glow.tweens", "glow.events", "glow.dom", "glow.anim"],
  implementation: function() {
    var C = glow.events,
    I = C.addListener,
    Q = C.fire,
    G = C.removeListener,
    O = glow.dom,
    H = O.get,
    K = O.create;
    var L = {},
    R = 1000,
    A = (document.compatMode == "CSS1Compat" && glow.env.ie >= 5) ? true: false,
    S = (document.compatMode != "CSS1Compat" && glow.env.ie >= 5) ? true: false,
    D = glow.env.ie >= 5;
    function B(T, V) {
      var W = T.prototype[V];
      var U = "cached_" + V;
      T.prototype[V] = function() {
        if (U in this) {
          return this[U]
        }
        return this[U] = W.apply(this, arguments)
      }
    }
    function F(T, U) {
      var W = T.prototype[U];
      var V = "cached_" + U;
      T.prototype[U] = function(X) {
        if (!this[V]) {
          this[V] = {}
        }
        if (X in this[V]) {
          return this[V][X]
        }
        return this[V][X] = W.apply(this, arguments)
      }
    }
    function P(W, V) {
      for (var U = 0, T = V.length; U < T; U++) {
        delete W["cached_" + V[U]]
      }
    }
    var M = function(T) {
      this.el = T
    };
    M.prototype = {
      val: function(T) {
        var U = parseInt(this.el.css(T));
        return isNaN(U) ? 0 : U
      },
      width: function() {
        return this.borderWidth() - this.val("border-left-width") - this.val("padding-left") - this.val("padding-right") - this.val("border-right-width")
      },
      height: function() {
        return this.borderHeight() - this.val("border-top-width") - this.val("padding-top") - this.val("padding-bottom") - this.val("border-bottom-width")
      },
      offsetParentPageTop: function() {
        var T = this.el[0],
        V,
        U;
        while (T = T.offsetParent) {
          V = H(T).css("position");
          if (V == "absolute" || V == "fixed" || V == "relative") {
            break
          }
        }
        if (!T) {
          return 0
        }
        U = T.offsetTop;
        while (T = T.offsetParent) {
          U += T.offsetTop
        }
        return U
      },
      offsetTop: function() {
        var U = 0,
        V = this.el[0],
        a,
        Z;
        if (glow.env.ie) {
          do {
            Z = V.offsetTop;
            if (!isNaN(Z)) {
              U += Z
            }
            V = V.offsetParent;
            if (V) {
              a = H(V).css("position")
            }
          } while (V && !(a == "absolute" || a == "fixed" || a == "relative"))
        } else {
          U = V.offsetTop
        }
        if (glow.env.opera) {
          var X = parseInt(H(V.offsetParent).css("border-top-width"));
          U -= isNaN(X) ? 0 : X
        }
        if (glow.env.gecko) {
          var Y = document,
          T = Y.defaultView && (Y.defaultView.getComputedStyle(V.offsetParent, null) || Y.defaultView.getComputedStyle),
          W;
          if (T.position == "relative" && T.overflow == "hidden" && (W = parseInt(T.borderTopWidth))) {
            U += W
          }
        }
        return U
      },
      offsetLeft: function() {
        var U = 0,
        V = this.el[0],
        a,
        Z;
        if (glow.env.ie) {
          do {
            Z = V.offsetLeft;
            if (!isNaN(Z)) {
              U += Z
            }
            V = V.offsetParent;
            if (V) {
              a = H(V).css("position")
            }
          } while (V && !(a == "absolute" || a == "fixed" || a == "relative"))
        } else {
          U = V.offsetLeft
        }
        if (glow.env.opera) {
          var X = parseInt(H(V.offsetParent).css("border-left-width"));
          U -= isNaN(X) ? 0 : X
        }
        if (glow.env.gecko) {
          var Y = document,
          T = Y.defaultView && (Y.defaultView.getComputedStyle(V.offsetParent, null) || Y.defaultView.getComputedStyle),
          W;
          if (T.position == "relative" && T.overflow == "hidden" && (W = parseInt(T.borderLeftWidth))) {
            U += W
          }
        }
        return U
      },
      borderWidth: function() {
        var T = this.el[0].offsetWidth;
        if (glow.env.khtml) {
          T -= this.val("margin-left") + this.val("margin-right") + this.val("border-left-width") + this.val("border-right-width")
        }
        return T
      },
      borderHeight: function() {
        if (this._logicalBottom) {
          return this._logicalBottom - this.offsetTop()
        }
        var T = this.el[0].offsetHeight;
        if (glow.env.khtml) {
          T -= this.val("margin-top") + this.val("margin-bottom") + this.val("border-top-width") + this.val("border-bottom-width")
        }
        return T
      },
      outerWidth: function() {
        return this.borderWidth() + this.val("margin-left") + this.val("margin-right")
      },
      outerHeight: function() {
        return this.borderHeight() + this.val("margin-top") + this.val("margin-bottom")
      },
      innerLeftPos: function() {
        return this.offsetLeft() + this.val("border-left-width") + this.val("padding-left")
      },
      innerTopPos: function() {
        return this.offsetTop() + this.val("border-top-width") + this.val("padding-top")
      },
      surroundWidth: function() {
        return this.val("margin-left") + this.val("border-left-width") + this.val("padding-left") + this.val("padding-right") + this.val("border-right-width") + this.val("margin-right")
      },
      surroundHeight: function() {
        return this.val("margin-top") + this.val("border-top-width") + this.val("padding-top") + this.val("padding-bottom") + this.val("border-bottom-width") + this.val("margin-bottom")
      },
      verticalCenter: function() {
        return this.offsetTop() + (this.outerHeight() / 2)
      },
      horizontalCenter: function() {
        return this.offsetTop() + (this.outerWidth() / 2)
      }
    };
    for (var N in M.prototype) {
      if (N == "val") {
        F(M, N)
      } else {
        B(M, N)
      }
    }
    glow.lang.apply(M.prototype, {
      resetPosition: function() {
        P(this, ["offsetTop", "offsetLeft", "borderTopPos", "borderLeftPos", "innerTopPos", "innerLeftPos", "verticalCenter", "horizontalCenter"])
      },
      setLogicalBottom: function(T) {
        this._logicalBottom = T
      },
      boundsFor: function(V) {
        var U, T, W = this.el.css("position");
        if (W == "relative" || W == "absolute" || W == "fixed") {
          U = T = 0
        } else {
          U = this.innerTopPos();
          T = this.innerLeftPos()
        }
        return [U, T + this.width() - V.outerWidth(), U + this.height() - V.outerHeight(), T]
      },
      outerBounds: function() {
        var U = this.offsetLeft(),
        T = this.offsetTop();
        return [T, U + this.borderWidth(), T + this.borderHeight(), U]
      },
      intersectSize: function(V, W) {
        var U = this.outerBounds(),
        T = V.outerBounds();
        if (W) {
          U[1]++;
          T[1]++;
          U[2]++;
          T[2]++
        }
        return (U[2] < T[0] ? 0 : T[2] < U[0] ? 0 : U[0] < T[0] ? (U[2] < T[2] ? U[2] - T[0] : T[2] - T[0]) : T[2] < U[2] ? T[2] - U[0] : U[2] - U[0]) * (U[1] < T[3] ? 0 : T[1] < U[3] ? 0 : U[3] < T[3] ? (U[1] < T[1] ? U[1] - T[3] : T[1] - T[3]) : T[1] < U[1] ? T[1] - U[3] : U[1] - U[3])
      },
      sizePlaceholder: function(Y, Z, W, U) {
        var X = new M(Y),
        V = this.el,
        T = Z || V.css("position");
        Y.css("display", "none");
        V.after(Y);
        Y.css("width", (this.outerWidth() - X.surroundWidth()) + "px");
        Y.css("height", (this.outerHeight() - X.surroundHeight()) + "px");
        Y.remove();
        Y.css("display", "block");
        if (T != "static") {
          Y.css("left", W + "px");
          Y.css("top", U + "px")
        }
        Y.css("position", T)
      },
      contains: function(U) {
        var T = this.boundsFor(U),
        W = U.offsetTop(),
        V = U.offsetLeft();
        return W >= T[0] && V <= T[1] && W <= T[2] && V >= T[3]
      },
      containsPoint: function(U) {
        var T = this.el.offset();
        return U.x >= T.x && U.y >= T.y && U.x <= T.x + this.borderWidth() && U.y <= T.y + this.borderHeight()
      },
      positionedAncestorBox: function() {
        var T = this.el.parent(),
        U;
        while (T[0]) {
          U = T.css("position") || "static";
          if (U == "relative" || U == "absolute" || U == "fixed") {
            return new M(T)
          }
          T = T.parent()
        }
        return null
      }
    });
    function E(U) {
      var T = U[0].tagName.toLowerCase() == "li" ? "li": "div";
      var V = K("<" + T + "></" + T + ">");
      if (T == "li") {
        V.css("list-style-type", "none")
      }
      return V
    }
    L.Draggable = function(W, X) {
      this.element = H(W);
      this._opts = X = glow.lang.apply({
        dragPrevention: ["input", "textarea", "button", "select", "option", "a"],
        placeholder: "spacer",
        placeholderClass: "glow-dragdrop-placeholder"
      },
      X || {});
      this._preventDrag = [];
      for (var U = 0, T = X.dragPrevention.length; U < T; U++) {
        this._preventDrag[U] = X.dragPrevention[U].toLowerCase()
      }
      if (X.container) {
        this.container = H(X.container)
      }
      this._handle = X.handle && this.element.get(X.handle) || this.element;
      if (X.dropTargets) {
        this.dropTargets = H(X.dropTargets)
      }
      var V = this._listeners = [],
      U = 0;
      if (X.onDrag) {
        V[U++] = I(this, "drag", this._opts.onDrag, this)
      }
      if (X.onEnter) {
        V[U++] = I(this, "enter", this._opts.onEnter, this)
      }
      if (X.onLeave) {
        V[U++] = I(this, "leave", this._opts.onLeave, this)
      }
      if (X.onDrop) {
        V[U++] = I(this, "drop", this._opts.onDrop, this)
      }
      this._dragListener = I(this._handle, "mousedown", this._startDragMouse, this);
      return
    };
    L.Draggable.prototype = {
      _createPlaceholder: function() {
        var T = this.element,
        V, U = this._box;
        if (this._opts.placeholder == "clone") {
          V = T.clone()
        } else {
          V = E(T)
        }
        if (this._opts.placeholderClass) {
          V.addClass(this._opts.placeholderClass)
        }
        U.sizePlaceholder(V, null, this._startLeft, this._startTop);
        T.after(V);
        this._placeholder = V
      },
      _removePlaceholder: function() {
        this._placeholder.remove()
      },
      _resetPosition: function() {
        var b = this._preDragPosition,
        T = this.element,
        V = this._box,
        W = this._startOffset,
        Y = T.css("position"),
        a,
        X;
        V.resetPosition();
        var U = {
          x: V.offsetLeft() - V.val("margin-left"),
          y: V.offsetTop() - V.val("margin-top")
        };
        if (this._placeholder || this._dropIndicator) {
          T.remove()
        }
        if (b == "static" && U.y == W.y && U.x == W.x) {
          T.css("position", "static");
          T.css("left", "");
          T.css("top", "")
        } else {
          T.css("z-index", this._preDragZIndex);
          T.css("position", b == "static" ? "relative": b);
          if (b == "static") {
            a = U.x - W.x;
            X = U.y - W.y
          } else {
            if (b == "relative" && Y != "relative") {
              a = this._startLeft + (U.x - W.x);
              X = this._startTop + (U.y - W.y)
            }
          }
          if (Y != b) {
            T.css("left", a ? a + "px": "");
            T.css("top", X ? X + "px": "")
          }
        }
        if (this._dropIndicator) {
          var Z = this._dropIndicator.parent()[0];
          if (Z) {
            Z.replaceChild(T[0], this._dropIndicator[0])
          }
          delete this._dropIndicator;
          if (this._placeholder) {
            this._placeholder.remove();
            delete this._placeholder
          }
        } else {
          if (this._placeholder) {
            var Z = this._placeholder.parent()[0];
            if (Z) {
              Z.replaceChild(T[0], this._placeholder[0])
            }
            delete this._placeholder
          }
        }
      },
      _startDragMouse: function(c) {
        var Y = this._preventDrag,
        U = c.source,
        j = U.tagName.toLowerCase();
        for (var a = 0, Z = Y.length; a < Z; a++) {
          if (Y[a] == j) {
            return
          }
        }
        if (this._dragging == 1) {
          return this.endDrag()
        } else {
          if (this._dragging) {
            return
          }
        }
        this._dragging = 1;
        var X = this.element,
        W = this.container,
        T = this._opts,
        b = this._box = new M(X);
        this._preDragPosition = X.css("position");
        if (W) {
          this._containerBox = new M(W);
          this._bounds = this._containerBox.boundsFor(b)
        } else {
          delete this._bounds
        }
        this._mouseStart = {
          x: c.pageX,
          y: c.pageY
        };
        var d = this._startOffset = {
          x: b.offsetLeft(),
          y: b.offsetTop()
        };
        this._preDragStyle = X.attr("style");
        this._preDragZIndex = X.css("z-index");
        X.css("z-index", R++);
        this._startLeft = X[0].style.left ? parseInt(X[0].style.left) : 0;
        this._startTop = X[0].style.top ? parseInt(X[0].style.top) : 0;
        if (T.placeholder && T.placeholder != "none") {
          this._createPlaceholder()
        }
        X.css("position", "absolute");
        X.css("left", d.x + "px");
        X.css("top", d.y + "px");
        if (A) {
          this._scrollY = document.documentElement.scrollTop;
          this._innerHeight = document.documentElement.clientHeight
        } else {
          if (S) {
            this._scrollY = document.body.scrollTop;
            this._innerHeight = document.body.clientHeight
          } else {
            this._scrollY = window.scrollY;
            this._innerHeight = window.innerHeight
          }
        }
        var h = H(document).height();
        this._bodyHeight = h < this._innerHeight ? this._innerHeight: h;
        Q(this, "drag");
        var f = function() {
          return false
        },
        g = document.documentElement;
        if (this.dropTargets) {
          var V = new C.Event();
          V.draggable = this;
          for (var a = 0, Z = this.dropTargets.length; a < Z; a++) {
            Q(this.dropTargets[a], "active", V)
          }
          this._mousePos = {
            x: c.pageX,
            y: c.pageY
          };
          this._testForDropTargets()
        }
        this._dragListeners = [I(g, "selectstart", f), I(g, "dragstart", f), I(g, "mousedown", f), I(g, "mousemove", this._dragMouse, this), I(g, "mouseup", this._releaseElement, this)];
        return false
      },
      _dragMouse: function(W) {
        var T = this.element,
        X = this._opts.axis == "y" ? this._startOffset.x: (this._startOffset.x + W.pageX - this._mouseStart.x),
        V = this._opts.axis == "x" ? this._startOffset.y: (this._startOffset.y + W.pageY - this._mouseStart.y),
        U = this._bounds;
        if (U) {
          X = X < U[3] ? U[3] : X > U[1] ? U[1] : X;
          V = V < U[0] ? U[0] : V > U[2] ? U[2] : V
        }
        T[0].style.left = X + "px";
        T[0].style.top = V + "px";
        if (this.dropTargets) {
          this._mousePos = {
            x: W.pageX,
            y: W.pageY
          }
        }
        if (D && W.nativeEvent.button == 0) {
          this._releaseElement(W);
          return false
        }
        return false
      },
      _testForDropTargets: function(d) {
        if (!this._lock) {
          this._lock = 0
        }
        if (d) {
          this._lock--
        } else {
          if (this.lock) {
            return
          }
        }
        if (this._dragging != 1) {
          return
        }
        var V = this.activeTarget,
        U, p = this.dropTargets,
        q, Y, b = this._box,
        g = this._mousePos;
        b.resetPosition();
        var Z = 0;
        for (var h = 0, f = p.length; h < f; h++) {
          q = p[h];
          Y = q._box;
          if (q._opts.tolerance == "contained") {
            if (Y.contains(b)) {
              U = q;
              break
            }
          } else {
            if (q._opts.tolerance == "cursor") {
              if (Y.containsPoint(g)) {
                U = q;
                break
              }
            } else {
              var j = Y.intersectSize(b, true);
              if (j > Z) {
                Z = j;
                U = q
              }
            }
          }
        }
        this.activeTarget = U;
        if (U !== V) {
          if (U) {
            var e = new C.Event();
            e.draggable = this;
            Q(U, "enter", e);
            var T = new C.Event();
            T.dropTarget = U;
            Q(this, "enter", T)
          }
          if (V) {
            var a = new C.Event();
            a.draggable = this;
            Q(V, "leave", a);
            var c = new C.Event();
            c.dropTarget = V;
            Q(this, "leave", c)
          }
        }
        if (U && U._opts.dropIndicator != "none") {
          var n, k = U._childBoxes,
          W = U._children;
          b.resetPosition();
          var o = U._box.innerTopPos();
          var r = g.y - b.offsetParentPageTop();
          var m = 0;
          for (var h = 0, f = k.length; h < f; h++) {
            if (W[h] == this.element[0]) {
              continue
            }
            n = k[h];
            o += n.outerHeight();
            if (r <= o) {
              if (U._dropIndicatorAt != h) {
                H(n.el).before(U._dropIndicator);
                U._dropIndicatorAt = h
              }
              m = 1;
              break
            }
          }
          if (!m) {
            if (n) {
              H(n.el).after(U._dropIndicator);
              U._dropIndicatorAt = h + 1
            } else {
              U.element.append(U._dropIndicator);
              U._dropIndicatorAt = 0
            }
          }
        }
        this._lock++;
        var X = this;
        setTimeout(function() {
          X._testForDropTargets(1)
        },
        100)
      },
      _releaseElement: function() {
        if (this._dragging != 1) {
          return
        }
        this._dragging = 2;
        var V, T;
        var Z = this.dropTargets,
        Y = this.activeTarget;
        if (Z) {
          for (V = 0, T = Z.length; V < T; V++) {
            var X = new C.Event();
            X.draggable = this;
            X.droppedOnThis = Y && Y == Z[V];
            Q(Z[V], "inactive", X)
          }
        }
        if (Y) {
          var X = new C.Event();
          X.draggable = this;
          Q(Y, "drop", X)
        }
        var U = this._dragListeners;
        for (V = 0, T = U.length; V < T; V++) {
          C.removeListener(U[V])
        }
        var W = Q(this, "drop");
        if (!W.defaultPrevented() && this.dropTargets) {
          this.returnHome()
        } else {
          this.endDrag()
        }
      },
      endDrag: function() {
        if (this._dragging != 2) {
          return
        }
        this._dragging = 0;
        if (this._reset) {
          this._reset();
          delete this._reset
        }
        if (this.placeholder) {
          this.placeholder.remove()
        }
        this._resetPosition();
        delete this.activeTarget;
        Q(this, "afterDrop")
      },
      returnHome: function(U) {
        var X = (U) ? U: glow.tweens.linear(),
        V = this.element,
        Z = Math.pow(Math.pow(this._startOffset.x - this._box.offsetLeft(), 2) + Math.pow(this._startOffset.y - this._box.offsetTop(), 2), 0.5),
        Y = 0.3 + (Z / 1000);
        var T = [[glow.anim.css(V, Y, {
          left: {
            from: this._box.offsetLeft(),
            to: this._startOffset.x
          },
          top: {
            from: this._box.offsetTop(),
            to: this._startOffset.y
          }
        },
        {
          tween: X
        })]];
        if (this._dropIndicator) {
          T.push([glow.anim.css(this._dropIndicator, Y - 0.1, {
            opacity: {
              to: 0
            }
          })])
        }
        var W = new glow.anim.Timeline(T);
        I(W, "complete",
        function() {
          this.endDrag()
        },
        this);
        W.start();
        return
      }
    };
    var J = 0;
    L.DropTarget = function(T, U) {
      T = this.element = H(T);
      if (!T.length) {
        throw "no element passed into DropTarget constuctor"
      }
      if (T.length > 1) {
        throw "more than one element passed into DropTarget constructor"
      }
      this._id = ++J;
      this._opts = U = glow.lang.apply({
        dropIndicator: "none",
        acceptDropOutside: false,
        dropIndicatorClass: "glow-dragdrop-dropindicator",
        tolerance: "intersect"
      },
      U || {});
      if (U.onActive) {
        I(this, "active", U.onActive)
      }
      if (U.onInactive) {
        I(this, "inactive", U.onInactive)
      }
      if (U.onEnter) {
        I(this, "enter", U.onEnter)
      }
      if (U.onLeave) {
        I(this, "leave", U.onLeave)
      }
      if (U.onDrop) {
        I(this, "drop", U.onDrop)
      }
      this._activeListener = I(this, "active", this._onActive);
      this._activeListener = I(this, "inactive", this._onInactive);
      return this
    };
    L.DropTarget.prototype = {
      setLogicalBottom: function(T) {
        this._logicalBottom = T
      },
      _onActive: function(W) {
        var U = W.draggable;
        this._box = new M(this.element);
        if (this._logicalBottom) {
          this._box.setLogicalBottom(this._logicalBottom)
        }
        if (this._opts.dropIndicator == "none") {
          return
        }
        this._onEnterListener = I(this, "enter", this._onEnter);
        this._onLeaveListener = I(this, "leave", this._onLeave);
        this._dropIndicator = E(U.element);
        if (this._opts.dropIndicatorClass) {
          this._dropIndicator.addClass(this._opts.dropIndicatorClass)
        }
        U._box.sizePlaceholder(this._dropIndicator, "relative", 0, 0);
        var V = this._children = H(this.element.children()).filter(function() {
          var X = H(this);
          return (!W.draggable._placeholder || !X.eq(W.draggable._placeholder)) && (!this._dropIndicator || !X.eq(this._dropIndicator))
        });
        var T = this._childBoxes = [];
        V.each(function(X) {
          T[X] = new M(H(V[X]))
        })
      },
      _onInactive: function(T) {
        G(this._onEnterListener);
        G(this._onLeaveListener);
        delete this._box;
        if (this._opts.dropIndicator == "none") {
          return
        }
        if (!T.droppedOnThis && this._dropIndicator) {
          this._dropIndicator.remove();
          delete this._dropIndicator
        }
        delete this._childBoxes;
        delete this._children
      },
      _onEnter: function() {
        this._dropIndicatorAt = -1
      },
      _onLeave: function() {
        this._dropIndicator.remove()
      },
      moveToPosition: function(T) {
        var X = this._dropIndicator,
        U = new M(X);
        var W = parseInt(X.css("margin-left")),
        V = parseInt(X.css("margin-top"));
        if (isNaN(W)) {
          W = 0
        }
        if (isNaN(V)) {
          V = 0
        }
        T._startOffset = {
          x: U.offsetLeft() - W,
          y: U.offsetTop() - V
        };
        T._dropIndicator = X;
        delete this._dropIndicator
      }
    };
    return L
  }
});
/*@end @*/
/*@cc_on @*/
/*@if (@_jscript_version > 5.1)@*/
glow.module("glow.widgets", "0.4.0", {
  require: ["glow.dom", "glow.events"],
  implementation: function() {
    var C, B, A = glow.env;
    glow.ready(function() {
      C = document;
      B = C.body;
      var D = glow.dom.create('<div class="glow-cssTest"></div>').appendTo(B);
      if (D.css("z-index") != "1234" || D.css("background-image").indexOf("ctr.png") == -1) {
        B.className += " glow-basic"
      }
      D.remove();
      A.ie && (B.className += " glow-ie");
      (A.ie < 7 || !A.standardsMode) && (B.className += " glow-ielt7");
      A.gecko && (B.className += " glow-gecko")
    });
    return {
      _scrollPos: function() {
        var E = window,
        D = A.standardsMode ? C.documentElement: B;
        return {
          x: D.scrollLeft || E.pageXOffset || 0,
          y: D.scrollTop || E.pageYOffset || 0
        }
      }
    }
  }
});
glow.module("glow.widgets.Mask", "0.4.0", {
  require: ["glow.dom", "glow.events", "glow.widgets"],
  implementation: function() {
    var E = glow.dom,
    F = E.get,
    I = glow.events,
    G = glow.widgets,
    C, A = '<div class="glow-noMask" style="margin:0;padding:0;position:absolute;width:100%;top:0;left:0;overflow:auto;',
    B, H = '<iframe class="glow-noMask" style="margin:0;padding:0;position:absolute;top:0;left:0;filter:alpha(opacity=0);display:none"></iframe>';
    function D(M) {
      this.opts = glow.lang.apply({
        color: "#000",
        opacity: 0.7,
        zIndex: 9900,
        disableScroll: false
      },
      M || {});
      var K = document.body,
      J = this.maskElement = E.create(A + "z-index:" + this.opts.zIndex + ";background:" + this.opts.color + ';visibility:hidden"></div>').appendTo(K),
      L = this;
      J.css("opacity", this.opts.opacity);
      if (glow.env.ie < 7) {
        this._iframe = E.create(H).css("z-index", this.opts.zIndex - 1).appendTo(K)
      }
      I.addListener(J, "click",
      function() {
        I.fire(L, "click")
      });
      if (this.opts.onClick) {
        I.addListener(this, "click", M.onClick)
      }
    }
    D.prototype = {
      add: function() {
        var T = F(document),
        M = F(document.body),
        N = F(window),
        O = this;
        if (this.opts.disableScroll && !B) {
          B = glow.dom.create(A + 'height:100%;overflow:hidden;">' + A + '"></div></div>');
          var R = G._scrollPos(),
          P = M[0].style,
          L = N.height(),
          S = N.width(),
          K = B.get("div"),
          J = M.children().filter(function() {
            return (" " + this.className + " ").indexOf("glow-noMask") == -1
          });
          C = {
            margin: [M.css("margin-top"), M.css("margin-right"), M.css("margin-bottom"), M.css("margin-left")],
            padding: [M.css("padding-top"), M.css("padding-right"), M.css("padding-bottom"), M.css("padding-left")],
            height: M.css("height")
          };
          P.margin = P.padding = 0;
          P.height = "100%";
          K[0].style.zIndex = this.opts.zIndex - 1;
          B.appendTo(M);
          K.css("margin", C.margin.join(" ")).css("padding", C.padding.join(" ")).css("top", -R.y - parseFloat(C.margin[0]) + "px").css("left", -R.x + "px").append(J)
        }
        function Q() {
          var W = M.height();
          for (var U = 0; U < 2; U++) {
            O.maskElement.css("width", "100%").css("height", (O.opts.disableScroll ? B.height() : Math.max(W, N.height())) + "px")
          }
          if (glow.env.ie < 7) {
            var V = O.maskElement[0].style;
            O._iframe.css("width", V.width).css("height", V.height)
          }
        }
        this.maskElement.css("visibility", "visible").css("display", "block");
        if (glow.env.ie < 7) {
          this._iframe.css("display", "block")
        }
        Q();
        this._resizeListener = I.addListener(window, "resize", Q)
      },
      remove: function() {
        this.maskElement.css("visibility", "hidden").css("display", "none");
        if (glow.env.ie < 7) {
          this._iframe.css("display", "none")
        }
        I.removeListener(this._resizeListener);
        if (this.opts.disableScroll) {
          var J = F(document.body),
          K = B.children();
          K.children().appendTo(J);
          window.scroll( - parseInt(K.css("left")), -parseInt(K.css("top")));
          B.remove();
          J.css("margin", C.margin.join(" ")).css("padding", C.padding.join(" ")).css("height", C.height);
          delete B;
          B = undefined
        }
      }
    };
    return D
  }
});
glow.module("glow.widgets.Overlay", "0.4.0", {
  require: ["glow.dom", "glow.events", "glow.anim", "glow.widgets", "glow.widgets.Mask"],
  implementation: function() {
    var K = glow.dom,
    D = K.get,
    A = glow.events,
    I = glow.widgets,
    L = glow.env,
    J = glow.anim,
    H = glow.tweens,
    E = '<div class="glow-overlay glow-noMask"></div>',
    N = '<iframe class="glow-noMask" style="display:none;margin:0;padding:0;position:absolute;filter:alpha(opacity=0)"></iframe>',
    Q = [],
    G = /.swf($|\?)/i,
    B = /<param\s+(?:[^>]*(?:name=["'?]\bwmode["'?][\s\/>]|\bvalue=["'?](?:opaque|transparent)["'?][\s\/>])[^>]*){2}/i;
    function C(S) {
      if (Q.length || (!S.opts.hideFlash)) {
        return
      }
      var T = 0;
      D("object, embed").each(function() {
        var U = this,
        V;
        if ((U.getAttribute("type") == "application/x-shockwave-flash" || G.test(U.getAttribute("data") || U.getAttribute("src") || "") || (U.getAttribute("classid") || "").toLowerCase() == "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000") && !D(U).isWithin(S.content)) {
          V = U.getAttribute("wmode");
          if ((U.nodeName == "OBJECT" && !B.test(U.innerHTML)) || (V != "transparent" && V != "opaque")) {
            Q[T++] = [U, U.style.visibility];
            U.style.visibility = "hidden"
          }
        }
      })
    }
    function R() {
      for (var T = 0, S = Q.length; T < S; T++) {
        Q[T][0].style.visibility = Q[T][1]
      }
      Q = []
    }
    function M(X, a) {
      var Y = [],
      Z = [],
      U = 0,
      W = 0,
      b = X.opts.anim,
      c = X.opts.mask,
      S = X.container,
      T,
      V = 0;
      if (b == "fade") {
        S.css("opacity", (a ? 0 : 1));
        Y[W++] = [J.css(S, 0.3, {
          opacity: {
            from: (a ? 0 : 1),
            to: (a ? 1 : 0)
          }
        })];
        if (a) {
          Y[W - 1][1] = function() {
            S.css("opacity", "")
          }
        }
        Y[W++] = [O(X, a)]
      } else {
        if (b == "roll") {
          if (a) {
            S.css("height", "");
            V = S.height();
            S.css("height", "0")
          }
          Y[W++] = [function() {
            if (L.webkit < 522 && a) {
              S.css("display", "none");
              setTimeout(function() {
                S.css("overflow", "hidden").css("display", "block")
              },
              0)
            } else {
              S.css("overflow", "hidden")
            }
          },
          J.css(S, 0.3, {
            height: {
              to: V
            }
          },
          {
            tween: a ? H.easeOut() : H.easeIn()
          }),
          function() {
            if (!a) {
              S.css("visibility", "hidden")
            }
            S.css("height", "");
            S.css("overflow", "")
          }];
          Y[W++] = [O(X, a)]
        }
      }
      return new J.Timeline(Y)
    }
    function O(U, T) {
      if (!U.opts.modal) {
        return 0
      }
      var S = U.opts.mask,
      W = S.opts.opacity,
      V = S.maskElement;
      V.css("opacity", (T ? 0 : W));
      return J.css(V, 0.1, {
        opacity: {
          from: (T ? 0 : W),
          to: (T ? W: 0)
        }
      })
    }
    function P(S) {
      R();
      S.container.css("visibility", "").css("display", "");
      if (S.opts.modal) {
        S.opts.mask.remove()
      } else {
        if (glow.env.ie < 7) {
          S._iframe.css("display", "none")
        }
      }
      A.removeListener(S._scrollEvt);
      A.removeListener(S._resizeEvt)
    }
    function F(X, W) {
      if (W && W.mask) {
        W.modal = true
      }
      this.opts = glow.lang.apply({
        modal: false,
        mask: new glow.widgets.Mask(W.zIndex ? {
          zIndex: W.zIndex - 1
        }: {}),
        closeOnMaskClick: true,
        zIndex: 9990,
        autoPosition: true,
        x: "50%",
        y: "50%",
        hideFlash: true
      },
      W || {});
      var S = this.content = D(X),
      V = this,
      U = this.container = K.create(E).css("z-index", this.opts.zIndex),
      T = document.body;
      this.autoPosition = this.opts.autoPosition;
      this.isShown = false;
      this._blockActions = false;
      U.appendTo(T).append(S);
      if (this.opts.closeOnMaskClick) {
        A.addListener(this.opts.mask, "click",
        function() {
          V.hide()
        })
      }
      if (glow.env.ie < 7 && !this.opts.modal) {
        this._iframe = K.create(N).css("z-index", this.opts.zIndex - 1).appendTo(T)
      }
    }
    F.prototype = {
      setPosition: function(Z, X) {
        if (!this.autoPosition) {
          return this
        }
        if (Z !== undefined && !(Z.source)) {
          this.opts.x = Z;
          this.opts.y = X
        }
        var V = D(window),
        Z = this.opts.x,
        X = this.opts.y,
        T = (!L.ie && !(L.webkit < 522)) || (L.ie > 6 && L.standardsMode),
        a = parseFloat(this.opts.x),
        W = parseFloat(this.opts.y),
        Y = (this.opts.mask.opts.disableScroll || T) ? {
          x: 0,
          y: 0
        }: I._scrollPos(),
        S = this.container;
        T && S.css("position", "fixed");
        if (typeof Z == "string" && Z.indexOf("%") != -1) {
          S.css("left", Math.max(((V.width() - S[0].offsetWidth) * (a / 100)) + Y.x, Y.x) + "px")
        } else {
          S.css("left", a + Y.x + "px")
        }
        if (typeof X == "string" && X.indexOf("%") != -1) {
          S.css("top", Math.max(((V.height() - S[0].offsetHeight) * (W / 100)) + Y.y, Y.y) + "px")
        } else {
          S.css("top", W + Y.y + "px")
        }
        if (glow.env.ie < 7 && !this.opts.modal) {
          var U = S[0].style;
          this._iframe.css("top", U.top).css("left", U.left).css("width", S[0].offsetWidth + "px").css("height", S[0].offsetHeight + "px")
        }
        return this
      },
      show: function() {
        var T = this,
        S, U = T.opts.anim;
        if (T._blockActions || T.isShown) {
          return T
        }
        if (A.fire(T, "show").defaultPrevented()) {
          return T
        }
        C(T);
        T.container.css("display", "block");
        if (T.opts.modal) {
          T.opts.mask.add()
        } else {
          if (glow.env.ie < 7) {
            T._iframe.css("display", "block")
          }
        }
        T._scrollEvt = A.addListener(window, "scroll", T.setPosition, T);
        T._resizeEvt = A.addListener(window, "resize", T.setPosition, T);
        T.setPosition();
        if (typeof U == "string") {
          S = M(T, true)
        } else {
          if (typeof U == "function") {
            S = U(T, true)
          } else {
            if (U) {
              S = U.show
            }
          }
        }
        if (S) {
          if (!S._overlayEvtAttached) {
            A.addListener(S, "complete",
            function() {
              T._blockActions = false;
              T.isShown = true;
              A.fire(T, "afterShow")
            });
            S._overlayEvtAttached = true
          }
          T._blockActions = true;
          S.start();
          T.container.css("visibility", "visible")
        } else {
          T.container.css("visibility", "visible");
          T.isShown = true;
          A.fire(T, "afterShow")
        }
        return T
      },
      hide: function() {
        var T = this,
        S, U = T.opts.anim;
        if (this._blockActions || !T.isShown) {
          return T
        }
        if (A.fire(T, "hide").defaultPrevented()) {
          return T
        }
        if (typeof U == "string") {
          S = M(T, false)
        } else {
          if (typeof U == "function") {
            S = U(T, false)
          } else {
            if (U) {
              S = U.hide
            }
          }
        }
        if (S) {
          if (!S._overlayEvtAttached) {
            A.addListener(S, "complete",
            function() {
              P(T);
              T._blockActions = false;
              T.isShown = false;
              A.fire(T, "afterHide")
            });
            S._overlayEvtAttached = true
          }
          T._blockActions = true;
          S.start()
        } else {
          P(T);
          T.isShown = false;
          A.fire(T, "afterHide")
        }
        return T
      }
    };
    return F
  }
});
glow.module("glow.widgets.Panel", "0.4.0", {
  require: ["glow.dom", "glow.events", "glow.widgets.Overlay"],
  implementation: function() {
    var E = glow.dom,
    F = E.get,
    K = glow.events,
    H = glow.widgets,
    A = H.Overlay,
    C = glow.lang,
    G = glow.env,
    B, J = {};
    function D(P) {
      var N = P ? "<div></div>": "";
      for (var M = 1, L = arguments.length, O = []; M < L; M++) {
        O[M - 1] = '<div class="' + arguments[M] + '">' + N + "</div>"
      }
      return O.join("")
    }
    B = function() {
      var M = [],
      L = 0;
      M[L++] = '<div class="glow-panel">';
      M[L++] = '<div class="glow-defaultSkin">';
      M[L++] = D(false, "glow-infoPanel-pointerT", "glow-infoPanel-pointerL", "glow-infoPanel-pointerR");
      M[L++] = '<div class="pc">';
      M[L++] = D(false, "tr", "tl");
      M[L++] = D(true, "tb");
      M[L++] = '<div class="tc">';
      M[L++] = D(false, "bars");
      M[L++] = '<div class="c">';
      M[L++] = '<a class="glow-panel-close" href="#" title="close">X</a>';
      M[L++] = D(false, "glow-panel-hd", "glow-panel-bd", "glow-panel-ft");
      M[L++] = "</div>";
      M[L++] = "</div>";
      M[L++] = D(false, "br", "bl");
      M[L++] = D(true, "bb");
      M[L++] = "</div>";
      M[L++] = D(false, "glow-infoPanel-pointerB");
      M[L++] = "</div>";
      M[L++] = "</div>";
      return M.join("")
    } ();
    function I(R, L) {
      R = F(R);
      L = L || {};
      if (typeof L.width == "number") {
        L.width += "px"
      }
      if (L.template) {
        var M = true
      }
      L = glow.lang.apply({
        template: B,
        width: "400px",
        modal: true,
        theme: "dark"
      },
      L);
      var T = E.create(L.template),
      P = R.get("> .hd"),
      N = R.get("> .ft"),
      O = document.body,
      Q = this,
      S;
      if (!M) {
        T.addClass("glow-panel-" + L.theme);
        if (!J[L.theme] && O.className.indexOf("glow-basic") == -1) {
          S = T.clone().addClass("glow-panel-preload").appendTo(O);
          J[L.theme] = true
        }
      }
      if (R.length > 1) {
        R.each(function() {
          var U = F(this);
          if (U.hasClass("hd")) {
            P = U
          } else {
            if (U.hasClass("ft")) {
              N = U
            }
          }
        })
      }
      this.header = T.get(".glow-panel-hd");
      this.footer = T.get(".glow-panel-ft");
      this.body = T.get(".glow-panel-bd");
      if (R.isWithin(O)) {
        T.insertBefore(R)
      } else {
        T.appendTo(O)
      }
      this.body.append(R);
      if (P.length) {
        this.header.append(P)
      } else {
        if (!M) {
          T.addClass("glow-panel-noHeader")
        }
      }
      if (N.length) {
        this.footer.append(N)
      }
      K.addListener(T.get(".glow-panel-close"), "click",
      function() {
        Q.hide();
        return false
      });
      A.call(this, T, L);
      this.container.css("width", L.width)
    }
    C.extend(I, A);
    return I
  }
});
glow.module("glow.widgets.Sortable", "0.4.0", {
  require: ["glow.dom", "glow.events", "glow.dragdrop"],
  implementation: function() {
    var E = glow.dom.get,
    H = glow.events,
    B = H.fire,
    A = H.addListener;
    function C(K) {
      var J = 0,
      L = K[0],
      M;
      if (glow.env.ie) {
        do {
          J += L.offsetTop;
          L = L.offsetParent;
          if (L) {
            M = E(L).css("position")
          }
        } while (L && !(M == "absolute" || M == "fixed" || M == "relative"))
      } else {
        J = L.offsetTop
      }
      return J
    }
    var D = function(K, J) {
      this._opts = J = glow.lang.apply({
        dropIndicatorClass: "glow-sortable-dropindicator",
        equaliseColumns: true,
        draggableOptions: {}
      },
      J || {});
      this.constrainDragTo = J.constrainDragTo;
      this.axis = J.axis;
      this.draggables = [];
      var K = this.containers = E(K),
      L = this.dropTargets = [];
      if (J.onSort) {
        A(this, "sort", J.onSort)
      }
      K.each(function(M) {
        L[M] = new glow.dragdrop.DropTarget(this, {
          tolerance: "intersect",
          dropIndicator: "spacer",
          dropIndicatorClass: J.dropIndicatorClass
        })
      });
      this.addItems(K.get("> *"))
    };
    function F() {
      var M = [],
      N = 0,
      K,
      O = this.dropTargets;
      this.containers.each(function(P) {
        var Q = E(this);
        M[P] = C(Q);
        K = M[P] + Q[0].offsetHeight;
        if (glow.env.khtml) {
          K -= Q.css("margin-top") + Q.css("margin-bottom")
        }
        if (K > N) {
          N = K
        }
      });
      for (var L = 0, J = this.dropTargets.length; L < J; L++) {
        this.dropTargets[L].setLogicalBottom(N)
      }
    }
    function I(M) {
      var J = M.attachedTo,
      K = J.element,
      L = J.activeTarget;
      this._previous = K.prev();
      this._parent = K.parent();
      if (L) {
        L.moveToPosition(J)
      }
    }
    function G(L) {
      var J = L.attachedTo,
      K = J.element;
      if (!K.prev().eq(this._previous || []) || !K.parent().eq(this._parent)) {
        B(this, "sort")
      }
      delete this._prev;
      delete this._parent
    }
    D.prototype = {
      addItems: function(K) {
        var L = this,
        J = this._opts.draggableOptions;
        E(K).each(function() {
          var M = new glow.dragdrop.Draggable(this, glow.lang.apply({
            placeholder: "none",
            axis: L.axis,
            container: L.constrainDragTo,
            dropTargets: L.dropTargets,
            acceptDropOutside: (L.containers.length == 1)
          },
          J));
          if (L._opts.equaliseColumns) {
            A(M, "drag", F, L)
          }
          A(M, "drop", I, L);
          A(M, "afterDrop", G, L);
          L.draggables.push(M)
        })
      }
    };
    return D
  }
});
glow.module("glow.widgets.InfoPanel", "0.4.0", {
  require: ["glow.dom", "glow.events", "glow.widgets.Panel"],
  implementation: function() {
    var C = glow.dom,
    E = C.get,
    L = glow.events,
    K = glow.widgets,
    B = glow.lang,
    H = glow.env,
    G, J = /glow\-infoPanel\-point[TRBL]/,
    F = {
      T: {
        x: "50%",
        y: "100%"
      },
      R: {
        x: 0,
        y: "50%"
      },
      B: {
        x: "50%",
        y: 0
      },
      L: {
        x: "100%",
        y: "50%"
      }
    };
    glow.ready(function() {
      G = E(window)
    });
    function D(M, O) {
      var R = [M.x, M.y],
      P = ["x", "y"],
      Q = ["Width", "Height"],
      N = 0;
      for (; N < 2; N++) {
        if (R[N].slice) {
          R[N] = parseFloat(M[P[N]]);
          if (M[P[N]].slice( - 1) == "%") {
            R[N] = O[0]["offset" + Q[N]] * (R[N] / 100)
          }
        }
      }
      return {
        x: R[0],
        y: R[1]
      }
    }
    function I(R, Q) {
      var P = K._scrollPos(),
      M = {
        x: G.width(),
        y: G.height()
      },
      O = {
        T: M.y - R.y - Q.y + P.y,
        R: R.x - P.x,
        B: R.y - P.y,
        L: M.x - R.x - Q.x + P.x
      },
      N = ["T", "R", "B", "L"];
      N.sort(function(T, S) {
        return O[S] - O[T]
      });
      return N[0]
    }
    function A(O, N) {
      N = N || {};
      if (N.template) {
        var M = true
      }
      N = glow.lang.apply({
        modal: false,
        theme: "light",
        autoPosition: !!N.context,
        pointerRegisters: {
          t: {
            x: "50%",
            y: 0
          },
          r: {
            x: "100%",
            y: "50%"
          },
          b: {
            x: "50%",
            y: "100%"
          },
          l: {
            x: 0,
            y: "50%"
          }
        }
      },
      N);
      N.context = N.context && E(N.context);
      K.Panel.call(this, O, N);
      if (!M) {
        this.content.addClass("glow-infoPanel")
      }
      this.content.addClass("glow-infoPanel-point" + (N.pointerPosition || "t").toUpperCase())
    }
    B.extend(A, K.Panel);
    B.apply(A.prototype, {
      setPosition: function(T, R) {
        var U = (T !== undefined && !(T.source));
        if (! (this.autoPosition || U)) {
          return this
        } else {
          if (U) {
            this.autoPosition = false
          }
        }
        var X = this.opts,
        O = this.content[0],
        Y = X.pointerPosition,
        M = X.context,
        W = this.container,
        N,
        S = U ? {
          x: T,
          y: R
        }: M.offset(),
        V = U ? {
          x: 0,
          y: 0
        }: {
          x: M[0].offsetWidth,
          y: M[0].offsetHeight
        },
        Z,
        a,
        Q,
        d = W.offset(),
        b,
        c;
        if (!Y) {
          Y = I(S, V);
          if (c != Y) {
            c = Y;
            O.className = O.className.replace(J, "glow-infoPanel-point" + Y);
            N = W.get(".glow-infoPanel-pointer" + Y)
          }
        } else {
          Y = Y.toUpperCase()
        }
        if (!N) {
          N = W.get(".glow-infoPanel-pointer" + Y)
        }
        Z = U ? {
          x: 0,
          y: 0
        }: D(X.offsetInContext || F[Y], M);
        Q = D(X.pointerRegisters[Y.toLowerCase()], N);
        b = N.offset();
        a = {
          x: b.x - d.x + Q.x,
          y: b.y - d.y + Q.y
        };
        W.css("left", S.x + Z.x - a.x + "px").css("top", S.y + Z.y - a.y + "px");
        if (H.ie < 7 && !X.modal) {
          var P = W[0].style;
          this._iframe.css("top", P.top).css("left", P.left).css("width", W[0].offsetWidth + "px").css("height", W[0].offsetHeight + "px")
        }
        return this
      },
      setContext: function(M) {
        this.opts.context = E(M);
        this.autoPosition = true;
        if (this.container[0].style.display == "block") {
          this.setPosition()
        }
        return this
      }
    });
    return A
  }
});
/*@end @*/
function Carousel() {
  this._init(Carousel.arguments)
}
Carousel.prototype = {
  _init: function(B) {
    this.vertical = false;
    this.loop = true;
    this.visibleItems = 5;
    this.anim = new glow.anim.Animation(0.5);
    glow.lang.apply(this, B[1]);
    this.holder = glow.dom.get(B[0]);
    this.holder.addClass("visionAppsCarousel");
    this.items = (this.itemFilter) ? this.holder.get(this.itemFilter) : this.holder.children();
    var D = this.items.slice(0, 0 + 1);
    var C = D.width() + parseInt(D.css("margin-left")) + parseInt(D.css("margin-right"));
    var A = D.height() + parseInt(D.css("margin-top")) + parseInt(D.css("margin-bottom"));
    this.axis = (this.vertical) ? "top": "left";
    this.mult = (!this.vertical) ? C: A;
    this.currentVisibleItems = [];
    if (this.anim) {
      this.distanceToMove = 0;
      glow.events.addListener(this.anim, "frame",
      function() {
        var E = Math.ceil(this.distanceToMove * this.anim.value);
        this._moveItems(E);
        this.distanceToMove = this.distanceToMove - E
      },
      this);
      glow.events.addListener(this.anim, "stop",
      function() {
        this._moveItems(this.distanceToMove);
        this.distanceToMove = 0
      },
      this)
    }
    this._setDefaultPositions();
    this._moveItems(0)
  },
  _atEndPoint: function(D) {
    if (this.loop) {
      return false
    }
    var A = this.items[0].cache[this.axis] + D;
    var B = 0;
    if (A > B) {
      glow.events.fire(this, "cantDoPrevious");
      return true
    }
    var C = this.items[this.items.length - 1].cache[this.axis] + D;
    var E = (this.visibleItems * this.mult) - this.mult;
    if (C < E) {
      glow.events.fire(this, "cantDoNext");
      return true
    }
    if (D != 0) {
      glow.events.fire(this, "canDoPrevious");
      glow.events.fire(this, "canDoNext")
    }
    return false
  },
  _checkWrap: function(A) {
    if (!this.loop) {
      return false
    }
    if (A.cache[this.axis] < (this.mult * -2)) {
      A.cache[this.axis] = A.cache[this.axis] + (this.mult * this.items.length);
      return
    }
    if (A.cache[this.axis] >= (this.mult * (this.items.length - 1))) {
      A.cache[this.axis] = A.cache[this.axis] - (this.mult * this.items.length);
      return
    }
  },
  _distanceFrom: function(B, D) {
    var A = this.items[B].cache[this.axis];
    var C = A - (D * this.mult);
    return C
  },
  _getVisibleItems: function() {
    var B = this;
    var A = this.currentVisibleItems.sort(function(D, C) {
      var D = B.items[D].cache[B.axis];
      var C = B.items[C].cache[B.axis];
      return D - C
    });
    return A
  },
  _getNonVisibleItems: function(F, D) {
    if (F > 0) {
      var B = this._getVisibleItems();
      var A = (D > 0) ? B[B.length - 1] : B[0];
      var I = [];
      for (var E = 1; E <= F; E++) {
        var G = (D > 0) ? A + E: A - E;
        var C;
        if (this.loop) {
          var J = this.items.length;
          var H = G % J;
          C = (H < 0) ? J + H: H
        } else {
          if (G >= 0 && G < this.items.length) {
            C = G
          } else {
            C = null
          }
        }
        if (C != undefined) {
          I.push(C)
        }
      }
      return I
    }
    return []
  },
  _moveItems: function(E) {
    if (this._atEndPoint(E)) {
      return
    }
    var D = this;
    var B = [];
    var C = 0;
    var A = this.mult * this.visibleItems;
    this.items.each(function(F) {
      D._updateAxis(this, this.cache[D.axis] + E);
      D._checkWrap(this);
      if (this.cache[D.axis] >= C && this.cache[D.axis] < A) {
        B.push(F)
      }
      var G = glow.dom.get(this);
      G.css("position", "absolute");
      G.css(D.axis, this.cache[D.axis] + "px")
    });
    this.currentVisibleItems = B
  },
  _setDefaultPositions: function() {
    var A = this;
    this.items.each(function(B) {
      this.cache = {};
      A._updateAxis(this, A.mult * B)
    })
  },
  _updateAxis: function(A, B) {
    A.cache[this.axis] = B
  },
  move: function(A, B) {
    var B = B || {
      anim: true
    };
    var C = (B.usePixels) ? A: A * this.mult;
    if (this.anim && B.anim) {
      this.anim.stop();
      this.distanceToMove = C;
      this.anim.start()
    } else {
      this._moveItems(C)
    }
  },
  moveTo: function(B, D, A) {
    var A = A || {
      anim: true
    };
    var C = this._distanceFrom(B, D) * -1;
    this.move(C, {
      usePixels: true,
      anim: A.anim
    })
  },
  resetPositions: function() {
    this._setDefaultPositions();
    this._moveItems(0)
  },
  getItems: function() {
    return this.items
  },
  getVisibleItemsIndexes: function() {
    return this._getVisibleItems()
  },
  getNextVisibleItemsIndexes: function(A) {
    var A = (A) ? A: this.visibleItems;
    return this._getNonVisibleItems(A, 1)
  },
  getPrevVisibleItemsIndexes: function(A) {
    var A = (A) ? A: this.visibleItems;
    return this._getNonVisibleItems(A, -1)
  },
  addClass: function(B, A) {
    if (B == "*") {
      this.items.addClass(A)
    } else {
      this.items.slice(B, B + 1).addClass(A)
    }
  },
  removeClass: function(B, A) {
    if (B == "*") {
      this.items.removeClass(A)
    } else {
      this.items.slice(B, B + 1).removeClass(A)
    }
  },
  addItem: function(B, A) {},
  removeItem: function(A) {}
};
var utils = {};
utils.cookie = (function() {
  return {
    get: function(F) {
      if (!F) {
        return F
      }
      var E = "",
      C = document.cookie,
      D = C.indexOf(F + "=");
      if (D > -1) {
        var B = D + F.length,
        A = C.indexOf(";", B);
        E = (A == -1) ? C.substring(B + 1) : C.substring(B + 1, A)
      }
      return E
    },
    set: function(G, H, A) {
      if (!G.length) {
        return false
      }
      var E = new Date();
      E.setTime(E.getTime() + ((A.expires || 100) * 24 * 60 * 60 * 1000));
      var C = E.toGMTString();
      var B = G,
      A = A || {},
      D = H || "",
      F = A.domain ? "; domain=" + A.domain: "",
      I = A.path || "/";
      document.cookie = B + "=" + D + "; expires=" + C + F + "; path=" + I;
      return true
    },
    remove: function(E, B) {
      if (!E.length) {
        return false
      }
      var A = E,
      B = B || {},
      C = B.domain ? "; domain=" + B.domain: "",
      D = B.path || "/";
      document.cookie = A + '=""; expires=Thu, 01-Jan-1970 00:00:01 GMT' + C + "; path=" + D;
      return true
    },
    assert: function(E, C, B) {
      var A = E || "CookieTest",
      D = C || "TestValue",
      B = B || {};
      this.set(A, D, B);
      if (this.get(A) != D) {
        glow.events.fire(utils.cookie, "fail");
        return false
      }
      this.remove("CookieTest", B);
      return true
    }
  }
} ());
var Homepage = function() {
  var r = {},
  $ = glow.dom.get,
  bind = glow.events.addListener;
  r.mods = {};
  r.Carousel = {};
  r.Gallery = {};
  r.ImgList = {};
  r.Tooltips = {};
  r.promoEmp = [];
  r.acceptCookies = true;
  function _MakeHomepage() {
    if (document.all) {
      var listener = bind("a.setHome", "click",
      function(event) {
        this.style.behavior = "url(#default#homepage)";
        this.setHomePage("http://www.bbc.co.uk");
        var hp_bug = new Image(1, 1);
        hp_bug.src = "/go/homepage/" + Homepage.audience + "/int/cust/sethome/-/home/release-30-0/img/custtiny.gif";
        return false
      })
    } else {
      if (glow.env.gecko) {
        var listener = bind("a.setHome", "click",
        function(event) {
          if (!$("#hpTooltip_Sethome").length) {
            glow.dom.create('<div id="hpTooltip_Sethome"><h2 class="hd">Make this page my homepage</h2><a class="parent" href="http://www.bbc.co.uk"></a><ol><li><p>Drag the BBC home icon in this panel and drop it onto the "house icon" in the tool bar for the browser</p></li><li><p>Select "Yes" from the popup window and you\'re done!</p></li></ol><p><a href="/help/web/#1">More information</a></p></div>').appendTo($("#blq-banner a.setHome"))
          }
          this.homepageTip = this.homepageTip || new glow.widgets.InfoPanel("#hpTooltip_Sethome", {
            context: "#blq-banner a.setHome",
            pointerPosition: "t",
            offsetInContext: {
              x: "20%",
              y: "90%"
            },
            width: "480px",
            hideFlash: false
          });
          var hp_bug = new Image(1, 1);
          hp_bug.src = "/go/homepage/" + Homepage.audience + "/int/cust/sethome/-/home/release-30-0/img/custtiny.gif";
          this.homepageTip.container.addClass("home-panel");
          if (this.homepageTip.isShown) {
            this.homepageTip.hide()
          } else {
            for (var j in Homepage.Tooltips) {
              if (Homepage.Tooltips[j].isShown) {
                Homepage.Tooltips[j].hide()
              }
            }
            this.homepageTip.setPosition().show()
          }
          return false
        },
        Homepage.Tooltips)
      } else {
        return true
      }
    }
  }
  function _Sortables(opts) {
    return new glow.widgets.Sortable(opts.el, {
      dropIndicatorClass: opts.helper || "hpSortHelper",
      equaliseColumns: true,
      onSort: function(e) {
        if (typeof opts.self[opts.func] == "function") {
          opts.self[opts.func]();
          glow.events.fire(Homepage.pageState, "update")
        }
      },
      draggableOptions: {
        handle: opts.handle,
        container: opts.container || "",
        onDrag: function() {
          this.element.addClass("dragState");
          for (var j in Homepage.Tooltips) {
            if (Homepage.Tooltips[j].isShown) {
              Homepage.Tooltips[j].hide()
            }
          }
        },
        onDrop: function() {
          this.element.removeClass("dragState")
        }
      }
    })
  }
  function _Customise() {
    var customisePane = $("#hpEditYourHomePage");
    $("#hpOptionsBar").after(customisePane.css("display", "none"));
    customisePane.get("ul").removeClass("static");
    var checkboxes = customisePane.get("div.feedSelection input");
    checkboxes.each(function() {
      this.value = this.value.substring(0, 1);
      if (Homepage.pageState.modules[this.value]) {
        $(this).attr("checked", "checked");
        $(this).parent().addClass("enabled")
      }
      bind($(this).next(), "click",
      function() {
        if (glow.env.webkit < 500) {
          this.checked = !this.checked
        }
        $(this).parent().toggleClass("enabled")
      },
      this)
    });
    bind("#editLink", "click",
    function() {
      $("#local").css("display") == "none" ? utils.slide.toggle(customisePane) : utils.slide.up($("#local"),
      function() {
        utils.slide.toggle(customisePane)
      });
      var hp_bug = new Image(1, 1);
      hp_bug.src = "/go/homepage/" + Homepage.audience + "/int/cust/cust/-/home/release-30-0/img/custtiny.gif";
      return false
    });
    bind("#hpEditYourHomePage form", "submit",
    function() {
      var mods = $("div.feedSelection input");
      mods.each(function() {
        var modId = this.value;
        if (this.checked && !Homepage.pageState.modules[modId]) {
          data = glow.dom.create('<div id="' + modId + '" class="hpMod blocked"></div>');
          $("#hpColOne").prepend(data);
          Homepage.pageState.modules[modId] = {
            open: true,
            val: 3,
            subfeeds: {
              serialized: []
            }
          };
          Homepage.moduleSortable.addItems(data);
          if (Homepage.Defaults[modId]) {
            for (var i = 0; i < Homepage.Defaults[modId].length; i++) {
              Homepage.pageState.modules[modId].subfeeds[Homepage.Defaults[modId][i]] = {
                val: 3
              };
              Homepage.pageState.modules[modId].subfeeds.serialized.push(Homepage.Defaults[modId][i])
            }
          }
        } else {
          if (Homepage.pageState.modules[modId] && !this.checked) {
            $("#" + modId).remove();
            delete Homepage.pageState.modules[modId]
          }
        }
      });
      Homepage.pageState.colour = $("#hpEditYourHomePage div.colourSelection input").filter(function() {
        return this.name == "colour" && this.checked
      }).val();
      delete Homepage.pageState.modules.serialized;
      glow.events.fire(Homepage.pageState, "update");
      location.reload(true);
      return false
    });
    var cancel = glow.dom.create('<input type="reset" value="Cancel" id="feedSelectionCancel" class="hpButton cancel" />').insertAfter("#feedSelectionSave");
    bind(cancel, "click",
    function() {
      $("#local").css("display") == "none" ? utils.slide.toggle(customisePane) : utils.slide.up($("#local"),
      function() {
        utils.slide.toggle(customisePane)
      })
    })
  }
  function _ColourSelection() {
    var buttons = $("#hpEditYourHomePage div.colourSelection input");
    buttons.filter(function() {
      return this.name == "colour" && this.checked
    }).parent().addClass("current");
    buttons.each(function() {
      bind($(this).next(), "click",
      function() {
        if (glow.env.webkit < 500) {
          this.checked = !this.checked
        }
        $("div.colourSelection li.current").removeClass("current");
        $(this).parent().addClass("current")
      })
    })
  }
  function _FeatureBox() {
    var featureList = $("#hpFeatureBox ul.hpFeatureList"),
    features = featureList.get("> li > a").filter(function() {
      return this == $(this).parent().children()[0]
    });
    $("#hpFeatureBox .empImg").each(function(i) {
      var img = $(this).get("a.image");
      bind(img, "click",
      function() {
        Homepage.AddEMP({
          x: 400,
          y: 260
        },
        Homepage.promoEmp[i].location, Homepage.promoEmp[i].playlist, Homepage.promoEmp[i].config || null);
        $(this).addClass("hide");
        return false
      });
      bind(img, "mouseup",
      function() {
        this.blur()
      })
    });
    features.each(function(i) {
      bind(this, "click",
      function() {
        var current = $(this);
        if (!current.next().get("img").length) {
          current.next().append('<img src="' + Homepage.ImgList.Features[i - 1].src + '" alt="' + Homepage.ImgList.Features[i - 1].alt + '" />')
        }
        featureList.get(".current").removeClass("current").get(".emp").empty().parent().get("a.image").removeClass("hide");
        current.addClass("current").parent().addClass("current");
        if (!Homepage.pageState.colour) {
          var tabClass = current.parent().attr("class").match(/hp[0-9]+/);
          $("body").attr("class", $("body").attr("class").replace(/hp[0-9]+/, tabClass))
        }
        return false
      })
    });
    for (var y in Homepage.Gallery.Features) {
      if (Homepage.Gallery.Features[y].length) {
        var dotsHolder = glow.dom.create('<ol class="galleryControls"></ol>'),
        next = glow.dom.create('<a title="next" href="#" class="galleryNext"><span>next</span></a>'),
        previous = glow.dom.create('<a title="previous" href="#" class="galleryPrevious"><span>previous</span></a>'),
        wrapper = glow.dom.create('<div class="gallerywrap"></div>');
        var Gallery = Homepage.Gallery[y] = {
          current: 0,
          images: Homepage.Gallery.Features[y],
          animating: false,
          tab: $("." + y + " .galleryHolder")
        };
        for (var x = 0; x < Homepage.Gallery.Features[y].length; x++) {
          var current = parseInt(x + 1),
          dot = glow.dom.create('<a title="Go to item ' + current + '" href="#' + y + current + '" class="' + current + '"><span>Go to item </span>' + current + "</a>");
          bind(dot, "click",
          function(e) {
            if (this.current == parseInt(e.source.className - 1) || this.animating) {
              return false
            }
            this.tab.removeClass("first").removeClass("last");
            this.current = parseInt(e.source.className - 1);
            _SwitchImage(this);
            return false
          },
          Gallery);
          var listItem = glow.dom.create('<li class="image"></li>').append(dot);
          if (!x) {
            listItem.addClass("currentImg").append(glow.dom.create('<img src="' + Gallery.images[0].src + '" alt="' + Gallery.images[0].alt + '" />'))
          }
          dotsHolder.append(listItem)
        }
        bind(next, "click",
        function() {
          if (this.current == this.images.length - 1 || this.animating) {
            return false
          }
          this.tab.removeClass("first");
          this.current++;
          _SwitchImage(this);
          return false
        },
        Gallery);
        bind(previous, "click",
        function() {
          if (this.current < 1 || this.animating) {
            return false
          }
          this.tab.removeClass("last");
          this.current--;
          _SwitchImage(this);
          return false
        },
        Gallery);
        Gallery.tab.get("span.image").remove();
        wrapper.css("width", (3.6 + 2.33 * Homepage.Gallery.Features[y].length) + "em");
        wrapper.append(previous).append(dotsHolder).append(next);
        Gallery.tab.addClass("first").append(wrapper)
      }
    }
  }
  function _SwitchImage(Gallery) {
    Gallery.animating = true;
    if (Gallery.current < 1) {
      Gallery.tab.addClass("first")
    } else {
      if (Gallery.current == Gallery.images.length - 1) {
        Gallery.tab.addClass("last")
      }
    }
    var currentImage = Gallery.tab.get("li.currentImg").removeClass("currentImg"),
    newImage = $(Gallery.tab.get("li.image").item(Gallery.current)).addClass("currentImg");
    if (!newImage.get("img").length) {
      var image = glow.dom.create('<img src="' + Gallery.images[Gallery.current].src + '" alt="' + Gallery.images[Gallery.current].alt + '" />');
      image.css("opacity", 0);
      newImage.append(image)
    }
    var fader = _CrossFade(currentImage.get("img"), newImage.get("img"), 1);
    bind(fader, "complete",
    function() {
      Gallery.animating = false
    });
    fader.start()
  }
  function _CrossFade(from, to, duration) {
    var fadeOut = glow.anim.css(from, duration, {
      opacity: {
        to: 0
      }
    });
    var fadeIn = glow.anim.css(to, duration, {
      opacity: {
        to: 1
      }
    });
    return new glow.anim.Timeline([[fadeOut], [fadeIn]])
  }
  function _AddPopup(src, width, height, scroll, resize) {
    bind(src, "click",
    function() {
      var popup = window.open(src.href, "BBCPopupWindow", "width=" + width + ",height=" + height + ",toolbar=0,location=0,status=0,menubar=0,scrollbars=" + scroll + ",resizable=" + resize + ",top=30,left=30");
      popup.focus();
      return false
    })
  }
  function _Popups() {
    $("#blq-content a").each(function() {
      if (this.rel == "external") {
        $(this).attr("target", "_blank")
      }
      if (this.className.indexOf("pop") == -1) {
        return
      }
      var cName = " " + this.className + " ";
      if (cName.indexOf(" wsradiopop ") != -1) {
        _AddPopup(this, 409, 269, 0, 0)
      } else {
        if (cName.indexOf(" radiopop ") != -1) {
          Homepage.Location ? this.href = "/radio/": _AddPopup(this, 693, 525, 0, 0)
        } else {
          if (cName.indexOf(" emppop ") != -1) {
            Homepage.Location ? this.href = "/iplayer/": _AddPopup(this, 512, 270, 0, 0)
          } else {
            if (cName.indexOf(" newspop ") != -1) {
              Homepage.Location ? this.href = "/news/1/hi/video_and_audio/default.stm": _AddPopup(this, 669, 485, 0, 0)
            } else {
              if (cName.indexOf(" pluginpop ") != -1) {
                _AddPopup(this, 620, 450, 1, 0)
              } else {
                if (cName.indexOf(" bbc2pop ") != -1) {
                  Homepage.Location ? this.href = "/bbctwo/": _AddPopup(this, 720, 464, 1, 0)
                } else {
                  if (cName.indexOf(" bbc3pop ") != -1) {
                    Homepage.Location ? this.href = "/bbcthree/": _AddPopup(this, 720, 464, 0, 0)
                  } else {
                    if (cName.indexOf(" bbc4pop ") != -1) {
                      Homepage.Location ? this.href = "/bbfour/": _AddPopup(this, 750, 535, 0, 0)
                    } else {
                      if (cName.indexOf(" mediaselpop ") != -1) {
                        _AddPopup(this, 766, 550, 0, 0)
                      } else {
                        if (cName.indexOf(" musicpop ") != -1) {
                          Homepage.Location ? this.href = "/music/": _AddPopup(this, 409, 269, 0, 0)
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    })
  }
  function _Overlays() {
    bind("#hpReset", "click",
    function() {
      if (!$("#hpPopup_Reset").length) {
        resetPopup = glow.dom.create('<div class="hpPopup" id="hpPopup_Reset"><h2 class="hd">Are you sure?</h2><p>When you reset your homepage it goes back to its original settings and any changes you\'ve made will be lost</p></div>').appendTo($(document.body))
      }
      this.resetDialog = this.resetDialog || new utils.widgets.Dialog("#hpPopup_Reset", {
        width: "320px",
        theme: "dark",
        modal: true,
        anim: "fade"
      });
      bind(this.resetDialog, "confirm",
      function() {
        window.location = $("#hpReset").attr("href")
      },
      this);
      this.resetDialog.show();
      return false
    });
    var customiseLink = glow.dom.create('<a class="question" href="?help"><span class="hide">Further information</span></a>').appendTo($("#editLink > span "));
    if (glow.env.opera && glow.env.opera < 9) {
      customiseLink.parent().css("float", "right")
    }
    bind(customiseLink, "click",
    function(e) {
      e.stopPropagation();
      if (!$("#hpTooltip_Customise").length) {
        glow.dom.create("<div id=\"hpTooltip_Customise\"><h2 class=\"hd\">Add more to this page</h2><p>Add your favourite BBC content and remove topics that don't interest you. Click here to choose anything from 'Entertainment' to 'History'.</p><p>You can move sections around the page - and open and close them - so that everything's arranged just how you like it. And look out for new topics coming soon...</p></div>").appendTo($("#hpOptionsBar a.question"))
      }
      this.customiseTip = this.customiseTip || new glow.widgets.InfoPanel("#hpTooltip_Customise", {
        context: "#hpOptionsBar a.question",
        pointerPosition: "l",
        offsetInContext: {
          x: "150%",
          y: "50%"
        },
        width: "650px",
        hideFlash: false
      });
      this.customiseTip.container.addClass("home-panel");
      if (this.customiseTip.isShown) {
        this.customiseTip.hide()
      } else {
        for (var j in Homepage.Tooltips) {
          if (Homepage.Tooltips[j].isShown) {
            Homepage.Tooltips[j].hide()
          }
        }
        this.customiseTip.setPosition().show()
      }
      return false
    },
    Homepage.Tooltips);
    var blogLink = glow.dom.create('<a class="question dy" href="?help"><span><span class="hide">Further information</span></span></a>').appendTo($("#e h2"));
    bind(blogLink, "click",
    function() {
      if (!$("#hpTooltip_Blog").length) {
        glow.dom.create('<div id="hpTooltip_Blog"><h2 class="hd">Blog</h2><p>A blog is an online journal: a collection of personal thoughts, experiences and links to other websites.</p><p>The BBC publishes a variety of blogs, written by anyone from DJs to news editors.</p><p>Use this section to see the latest updates from a range of popular BBC blogs directly on the homepage<p></div>').appendTo($("#e h2 a.question"))
      }
      this.blogTip = this.blogTip || new glow.widgets.InfoPanel("#hpTooltip_Blog", {
        context: "#e h2 a.question",
        pointerPosition: "t",
        offsetInContext: {
          x: "100%",
          y: "100%"
        },
        width: "306px",
        hideFlash: false
      });
      this.blogTip.isShown ? this.blogTip.hide() : this.blogTip.show();
      return false
    },
    Homepage.Tooltips);
    var defaultLayout = Homepage.audience == "d" ? "+acv+ba+neaj+hj+oab*+c1+g1ab+mc2+rad*+da+f1a7b7c7d7+i+kca+la": "+ac+p+f1-i*+b+v+g1*+naij5+c1";
    var currentLayout = utils.cookie.get("hp");
    if (currentLayout == defaultLayout || currentLayout == "") {
      $("p.remove").each(function(i) {
        bind(this, "click",
        function() {
          if (!$("#hpPopup_Remove").length) {
            removePopup = glow.dom.create('<div class="hpPopup" id="hpPopup_Remove"></div>').appendTo($(document.body))
          }
          removePopup.html('<h2 class="hd remove">Are you sure?</h2><p>You are about to ' + $(this).get("span.hide").html().toLowerCase() + ' from this page.</p><br /><p> You can add it again later by clicking on the \'Add more to this page\' button.</p><img src="/home/release-30-0/img/reset_dialog.png" class="resetDialog_img" />');
          this.removeDialog = new utils.widgets.Dialog("#hpPopup_Remove", {
            width: "730px",
            theme: "dark",
            modal: true,
            anim: "fade"
          });
          bind(this.removeDialog, "confirm",
          function() {
            window.location = $(this).get("a").attr("href")
          },
          this);
          this.removeDialog.show();
          return false
        })
      })
    }
  }
  function _iPhoneSetup() {
    var ua = navigator.userAgent.toLowerCase(),
    iphone = (/(iphone|ipod)/.test(ua));
    if (iphone) {
      var iPhoneButton = glow.dom.create('<li><a href="#" id="iPhoneMove"><span>Move</span></a></li>');
      $("#setloc").parent().after(iPhoneButton);
      bind(iPhoneButton.get("a"), "click",
      function() {
        $(".hpSet").css("backgroundColor", "#ccc");
        $(".hpSet *").css("visibility", "hidden");
        $("div.utils").css("visibility", "hidden");
        bind($("div.hpMod"), "touchstart",
        function(e) {});
        bind($("div.hpMod"), "touchmove",
        function(e) {
          if (e.touches.length == 1) {
            var touch = e.touches[0];
            var node = touch.target;
            node.style.position = "absolute";
            node.style.left = touch.pageX + "px";
            node.style.top = touch.pageY + "px"
          }
        });
        return false
      })
    }
  }
  function _LonelyPlanet() {
    var lpSearchForm;
    if (lpSearchForm = $("#lpSearchForm")) {
      lpSearchForm.attr("target", "_blank")
    }
  }
  function _setLocation() {
    var locationPane = $("#local");
    $("#hpOptionsBar").after(locationPane.css("display", "none"));
    bind("#setloc", "click",
    function() {
      $("#hpEditYourHomePage").css("display") == "none" ? utils.slide.toggle(locationPane) : utils.slide.up($("#hpEditYourHomePage"),
      function() {
        utils.slide.toggle(locationPane)
      });
      return false
    });
    bind("#sbox", "focus",
    function() {
      if (this.value == "Enter UK Postcode or place name") {
        this.value = "";
        $(this).css("color", "#000")
      }
    });
    bind("#sbox", "blur",
    function() {
      if (this.value == "") {
        this.value = "Enter UK Postcode or place name";
        $(this).css("color", "#888")
      }
    });
    bind("#locreset", "click",
    function() {
      utils.slide.toggle(locationPane);
      if (Homepage.Tooltips.multiResTip) {
        Homepage.Tooltips.multiResTip.hide()
      }
      $("#reslist").remove()
    });
    if (Homepage.audience != "i") {
      bind("#ukvers", "click",
      function() {
        $("#local fieldset").attr("class", "Domestic")
      });
      bind("#intvers", "click",
      function() {
        $("#local fieldset").attr("class", "International")
      })
    }
    bind("#local", "submit",
    function() {
      if ((Homepage.audience == "i" && $("#ukvers")[0].checked) || (Homepage.audience == "d" && $("#intvers")[0].checked)) {
        var location = $("#ukvers")[0].checked ? $("#ukvers").val() : $("#intvers").val();
        if (!$("#hpPopup_AudienceChange").length) {
          var versionPanel = glow.dom.create('<div class="hpPopup" id="hpPopup_AudienceChange"><h2 class="hd">Are you sure?</h2><p>If you switch to the <strong>' + location + "</strong> version, any changes you've made to your current homepage will be lost.</p></div>").appendTo($(document.body))
        }
        this.versionDialog = this.versionDialog || new utils.widgets.Dialog("#hpPopup_AudienceChange", {
          width: "320px",
          theme: "dark",
          modal: true,
          anim: "fade"
        });
        bind(this.versionDialog, "confirm",
        function() {
          utils.cookie.remove("hp", {
            domain: "bbc.co.uk"
          });
          var aud = Homepage.audience == "d" ? "i": "d",
          loc = Homepage.audience == "d" ? "International": "Domestic";
          window.location = "http://newswm.bbc.co.uk/cgi-bin/change_edition.pl?qs=http://www.bbc.co.uk/home/" + aud + "/index.shtml&content=bol&dest=" + loc;
          return false
        },
        this);
        this.versionDialog.show();
        return false
      } else {
        var locationPanel = '<div class="hpPopup" id="hpPopup_Location"><h2 class="hd">Location Change</h2><p>Do you really want to change your location to <strong>{location}</strong>? This will affect all localised modules on your page.</p></div>';
        var multiResPanel = '<div id="multmes"><h2 class="hd">Multiple Locations</h2><p id="multref">Please refine your location by choosing a place name from the list.</p></div>';
        var result = new utils.Postcoder($("#local #sbox").val(), {
          onDisambiguation: function(data) {
            $("#reslist").remove();
            data.attr("id", "reslist");
            data.insertAfter($("#myloc"));
            if (!$("#multmes").length) {
              glow.dom.create(multiResPanel).appendTo($(document.body))
            }
            Homepage.Tooltips.multiResTip = Homepage.Tooltips.multiResTip || new glow.widgets.InfoPanel("#multmes", {
              context: "#reslist",
              pointerPosition: "l",
              offsetInContext: {
                x: "105%",
                y: "50%"
              },
              width: "306px",
              zIndex: 100
            });
            Homepage.Tooltips.multiResTip.setContext("#reslist").setPosition().show()
          },
          onZeroResults: function(data) {
            $("#reslist").remove();
            data.attr("id", "reslist");
            data.insertAfter($("#myloc"))
          },
          panel: locationPanel,
          panelOpts: {
            width: "320px",
            theme: "dark",
            modal: true,
            anim: "fade"
          }
        });
        return false
      }
    })
  }
  r.ModuleSerialize = function() {
    var order = this.pageState.modules.serialized = {};
    this.moduleSortable.containers.get("> .hpMod").each(function() {
      if (!order[this.parentNode.id]) {
        order[this.parentNode.id] = []
      }
      order[this.parentNode.id].push(this.id)
    });
    return order
  };
  r.init = function() {
    this.moduleSortable = _Sortables({
      el: "div.hpCol",
      helper: "hpSortHelper",
      handle: "h2",
      func: "ModuleSerialize",
      self: this
    });
    bind(this.pageState, "update",
    function(e) {
      if (Homepage.acceptCookies && !utils.cookie.get("hp").length) {
        utils.cookie.assert()
      }
      var cookieStr = "";
      if (this.colour) {
        cookieStr += this.colour
      }
      var columns = ["hpColOne", "hpColTwo", "hpColThree"],
      j = 0,
      clen = columns.length;
      var modSerialized = this.modules.serialized || Homepage.ModuleSerialize();
      var draggableCarousels = $("#blq-content .hpSort .carousel");
      for (; j < clen; j++) {
        var curr = modSerialized[columns[j]] || [],
        k = 0,
        mlen = curr.length;
        for (; k < mlen; k++) {
          var mod = this.modules[curr[k]];
          cookieStr += mod.open ? "+": "-";
          cookieStr += mod.val == 3 ? curr[k] : curr[k] + mod.val;
          var subSerialized = mod.subfeeds.serialized || Homepage.mods[curr[k]].SubSerialize();
          var m = 0;
          slen = subSerialized.length;
          for (; m < slen; m++) {
            var currSubId = subSerialized[m];
            if (Homepage.mods[curr[k]] && Homepage.mods[curr[k]].subs[currSubId]) {
              var currSubMod = Homepage.mods[curr[k]].subs[currSubId].data[0];
              for (var i = 0; i < draggableCarousels.length; i++) {
                var draggableCarousel = $(draggableCarousels[i]);
                var draggableCarouselParent = draggableCarousel.parent()[0];
                if (draggableCarouselParent == currSubMod && draggableCarousel.hasClass(currSubId)) {
                  if ((m != slen - 1)) {
                    Homepage.mods[curr[k]].el.removeClass("hpCo")
                  } else {
                    if (!Homepage.mods[curr[k]].el.hasClass("hpCo")) {
                      Homepage.mods[curr[k]].el.addClass("hpCo")
                    }
                  }
                }
              }
            }
            if (mod.subfeeds[currSubId]) {
              cookieStr += mod.subfeeds[currSubId].val == 3 ? currSubId: currSubId + mod.subfeeds[currSubId].val;
              if (curr[k] == "f" && mod.subfeeds[currSubId].val == 3) {
                cookieStr += 3
              }
            } else {
              cookieStr += currSubId
            }
          }
        }
        if (j < clen - 1) {
          cookieStr += "*"
        }
      }
      if (Homepage.acceptCookies && Homepage.OriginalCookie != cookieStr) {
        utils.cookie.set("hp", cookieStr, {
          domain: "bbc.co.uk",
          expires: 365
        })
      }
    });
    bind(utils.cookie, "fail",
    function(e) {
      Homepage.acceptCookies = false
    });
    for (var mod in this.pageState.modules) {
      var name = this.moduleRef[mod] ? this.moduleRef[mod] : "Module";
      this.mods[mod] = new this[name](mod)
    }
    _setLocation();
    _Customise();
    _FeatureBox();
    _ColourSelection();
    _Popups();
    _Overlays();
    _LonelyPlanet();
    _MakeHomepage();
    if (this.pageState.changed) {
      glow.events.fire(Homepage.pageState, "update")
    }
  };
  r.AddEMP = function(dimensions, location, playlist, config) {
    var emp = new bbc.Emp();
    emp.setWidth(dimensions.x);
    emp.setHeight(dimensions.y);
    emp.setDomId(location);
    emp.setPlaylist(playlist);
    if (config) {
      emp.setConfig(config)
    }
    emp.set("config_settings_skin", "black");
    emp.set("config_settings_autoPlay", true);
    emp.write()
  };
  r.Module = function(el) {
    if (!$("#" + el).length) {
      return
    }
    this.el = $("#blq-content #" + el);
    this.state = Homepage.pageState.modules[el];
    this.opts = {
      id: el,
      utils: this.el.get("div.utils"),
      set: this.el.get("div.hpSet"),
      height: this.el.get("div.hpSet").height(),
      sort: this.el.get("div.hpSort")
    };
    this.subs = {};
    var sub = this.state.subfeeds;
    for (var j in sub) {
      if (this.el.get("." + j).length) {
        var data = this.el.get("." + j).parent();
        while (!data.hasClass("hpData")) {
          data = data.parent()
        }
        var options = {
          id: j,
          state: this.state.subfeeds[j]
        };
        if (Homepage.ImgList[this.opts.id]) {
          options.images = Homepage.ImgList[this.opts.id]
        }
        this.subs[j] = new Homepage.Subfeed(data, options);
        if (Homepage.autoUpdate[this.opts.id] && Homepage.autoUpdate[this.opts.id][j]) {
          this.subs[j].refreshInterval = new Homepage.Subfeed.AutoUpdate(this.opts.id, j)
        }
      }
    }
    if (this.opts.sort.length && this.opts.sort.children().length) {
      this.subSortable = _Sortables({
        el: this.opts.sort,
        helper: "hpSortHelperMini",
        handle: "h3",
        container: this.opts.sort,
        func: "SubSerialize",
        self: this
      })
    }
    this.Collapsable();
    bind(this.opts.utils.get("p.edit a"), "click",
    function() {
      var hp_bug = new Image(1, 1);
      hp_bug.src = "/go/homepage/" + Homepage.audience + "/int/cust/edit/" + this.opts.id + "/t/-/home/release-30-0/img/custtiny.gif";
      this.EditBox();
      return false
    },
    this);
    bind(this.el.get("h2"), "mouseover",
    function() {
      var self = this;
      this.Timer = setTimeout(function() {
        self.Highlighter(true)
      },
      800)
    },
    this);
    bind(this.el.get("h2"), "mouseout",
    function() {
      clearTimeout(this.Timer);
      this.Highlighter(false)
    },
    this);
    bind(this.el.get("h2"), "mousedown",
    function() {
      clearTimeout(this.Timer);
      if (!this.el.hasClass("hoverState")) {
        this.Highlighter(true)
      }
    },
    this);
    bind(this.el.get("h2"), "mouseup",
    function() {
      clearTimeout(this.Timer);
      this.Highlighter(false)
    },
    this);
    if (this.opts.set.get("div.visionCarousel").length) {
      new Homepage.Subfeed.VisionCarousel(this)
    }
    if (this.opts.set.get("div.carousel").length) {
      this.carousel = new Homepage.Subfeed.Carousel(this)
    }
    if (this.opts.set.get("blockquote").length) {
      this.quote = new Homepage.Subfeed.Quotes(this)
    }
    var ua = navigator.userAgent.toLowerCase(),
    iphone = (/(iphone|ipod)/.test(ua));
    if (iphone) {}
  };
  r.Module.prototype = {
    Collapsable: function() {
      var collapse = glow.dom.create('<p class="collapse"><a href="#" id="collapse_module_' + this.el.attr("id") + '"><span class="hide">Close the ' + this.el.get("h2 a").text() + " box</span></a></p>").appendTo(this.opts.utils);
      bind(collapse.get("a"), "click",
      function() {
        this._collapseToggle();
        $(this.el).get("p.collapse a")[0].parentNode.focus();
        return false
      },
      this);
      bind(collapse.get("a"), "mouseup",
      function() {
        this.blur()
      });
      if (!this.state.open) {
        this.el.addClass("hpCollapsed");
        this.opts.set.addClass("blocked")
      }
    },
    iPhoneButtons: function() {
      var move = glow.dom.create('<p class="move"><a href="#">Move <span class="hide">the ' + this.el.get("h2 a").text() + " box</span></a></p>").appendTo(this.opts.utils);
      bind(move.get("a"), "click",
      function() {
        var mod = this;
        $(".dragMini").removeClass("dragMini");
        $(".iPhoneShow").removeClass("iPhoneShow");
        $("div.hpMod").filter(function() {
          return ! $(this).eq(mod.el)
        }).after('<div class="dropHelper"><p><a href="#">Drop the ' + mod.el.get("h2 a").text() + " box here</a></p></div>");
        $(".hpCol").prepend('<div class="dropHelper"><p><a href="#">Drop the ' + mod.el.get("h2 a").text() + " box here</a></p></div>");
        this.el.addClass("dragMini");
        $(".dropHelper").each(function() {
          bind(this, "click",
          function() {
            mod.el.remove();
            mod.el.insertAfter(this).addClass("iPhoneShow");
            $(".dropHelper").remove();
            mod.el.removeClass("dragMini");
            delete Homepage.pageState.modules.serialized;
            glow.events.fire(Homepage.pageState, "update");
            return false
          })
        })
      },
      this)
    },
    _collapseToggle: function() {
      this.state.open = !this.state.open;
      var data = {
        action: this.state.open ? "Close": "Open",
        boxName: this.el.get("h2").text()
      };
      var template = '<span class="hide">{action} the {boxName} box</span>';
      utils.slide.toggle(this.el.get(".hpSet"));
      this.state.open ? null: this.opts.set.get("div.options").css("display", "none");
      this.el.toggleClass("hpCollapsed");
      this.el.get("p.collapse a").html(glow.lang.interpolate(template, data));
      glow.events.fire(Homepage.pageState, "update")
    },
    _setCheckboxes: function() {
      var mod = this,
      checkboxes = mod.opts.set.get("input").filter(function() {
        return this.type == "checkbox"
      });
      checkboxes.each(function() {
        if (mod.state.subfeeds[this.value] || mod.state.subfeeds[$(this).parent()[0].className]) {
          $(this).attr("checked", "checked")
        } else {
          $(this).removeAttr("checked")
        }
      })
    },
    _feedError: function(contextEl) {
      if (!Homepage.Tooltips.feedErrorTip) {
        glow.dom.create('<div id="hpTooltip_Error"><h2 class="hd">Loading Error</h2><p>Sorry, unable to load data, please try again later.<p></div>').appendTo($(document.body));
        Homepage.Tooltips.feedErrorTip = new glow.widgets.InfoPanel("#hpTooltip_Error", {
          context: contextEl,
          pointerPosition: "t",
          offsetInContext: {
            x: "100%",
            y: "100%"
          },
          width: "306px"
        }).show()
      } else {
        Homepage.Tooltips.feedErrorTip.setContext(contextEl).setPosition().show()
      }
    },
    EditBox: function() {
      var mod = this,
      path = (Homepage.audience == "i") ? "int/": "";
      glow.net.get("/home/ssi/" + path + "edit/" + mod.opts.id + ".sssi", {
        load: function(response) {
          if (!mod.state.open) {
            mod.opts.set.prepend(response.text());
            mod._collapseToggle()
          } else {
            mod.opts.set.prepend(response.text());
            mod.opts.set.get("div.options").css("display", "none");
            utils.slide.toggle(mod.opts.set.get("div.options"))
          }
          mod._setCheckboxes();
          bind(mod.opts.set.get("div.options form"), "submit",
          function() {
            mod.EditBoxSubmit();
            return false
          },
          mod);
          bind(mod.opts.set.get("div.options input.cancel"), "click",
          function() {
            mod.EditBox()
          });
          mod.EditBox = function() {
            if (!mod.state.open) {
              this._collapseToggle()
            }
            utils.slide.toggle(mod.opts.set.get("div.options"));
            mod._setCheckboxes()
          }
        },
        error: function(response) {
          mod._feedError(mod.opts.utils.get("p.edit a"))
        },
        useCache: false,
        async: false
      });
      return this.EditBox
    },
    EditBoxSubmit: function() {
      var mod = this,
      checkboxes = mod.opts.set.get("input").filter(function() {
        return this.type == "checkbox"
      });
      checkboxes.each(function() {
        if (this.checked && !mod.state.subfeeds[this.value]) {
          mod.AddSubfeed(this)
        } else {
          if (mod.state.subfeeds[this.value] && !this.checked) {
            mod.RemoveSubfeed(this)
          }
        }
      });
      delete mod.state.subfeeds.serialized;
      glow.events.fire(Homepage.pageState, "update");
      mod.EditBox()
    },
    AddSubfeed: function(sub) {
      var mod = this,
      subId = sub.value,
      path = (Homepage.audience == "i") ? "int/": "",
      subVal = sub.subVal || 3;
      glow.net.get("/home/ssi/" + path + mod.opts.id + "/" + mod.opts.id + subId + ".sssi", {
        load: function(response) {
          var box = mod.opts.sort.length ? mod.opts.sort: mod.opts.set;
          var res = glow.dom.create(response.text());
          if (res) {
            if (res.get("script").length) {
              eval(res.get("script").html())
            }
          }
          box.append(response.text());
          mod.state.subfeeds[subId] = {
            val: subVal
          };
          var data = mod.opts.set.get(".hpData ." + subId).parent();
          while (!data.hasClass("hpData") && data.length != 0) {
            data = data.parent()
          }
          var options = {
            id: subId,
            state: mod.state.subfeeds[subId]
          };
          if (Homepage.ImgList[mod.opts.id]) {
            options.images = Homepage.ImgList[mod.opts.id]
          }
          mod.subs[subId] = new Homepage.Subfeed(data, options);
          if (data.get("blockquote").length) {
            mod.quote = new Homepage.Subfeed.Quotes(mod)
          }
          if (Homepage.autoUpdate[mod.opts.id] && Homepage.autoUpdate[mod.opts.id][subId]) {
            mod.subs[subId].refreshInterval = new Homepage.Subfeed.AutoUpdate(mod.opts.id, subId)
          }
          if (mod.subSortable) {
            mod.subSortable.addItems(data)
          } else {
            if (mod.opts.sort.children().length == 1) {
              mod.subSortable = _Sortables({
                el: mod.opts.sort,
                helper: "hpSortHelperMini",
                handle: "h3",
                container: mod.opts.sort,
                func: "SubSerialize",
                self: mod
              })
            }
          }
          mod.el.removeClass("hpCo")
        },
        error: function(response) {
          mod._feedError(mod.opts.utils.get("p.edit a"))
        },
        useCache: true,
        async: false
      })
    },
    RemoveSubfeed: function(sub) {
      var mod = this,
      subId = sub.value;
      mod.opts.set.get(".hpData ." + subId).parent().remove();
      if (mod.state.subfeeds[subId].refreshInterval) {
        clearInterval(mod.state.subfeeds[subId].refreshInterval)
      }
      delete mod.state.subfeeds[subId];
      if (mod.subSortable) {
        mod.SubSerialize()
      }
      if (mod.state.subfeeds.serialized && !mod.state.subfeeds.serialized.length && !mod.el.hasClass("hpNoCo")) {
        mod.el.addClass("hpCo")
      }
    },
    Highlighter: function(highlight) {
      clearTimeout(this.Timer);
      if (highlight) {
        this.el.addClass("hoverState").prepend('<div class="hoverCorners top"></div><div class="hoverCorners bottom"></div>')
      } else {
        this.el.removeClass("hoverState");
        this.el.get("div.hoverCorners").remove()
      }
    },
    SubSerialize: function() {
      var order = this.state.subfeeds.serialized = [],
      subs = this.subs;
      if (this.subSortable) {
        this.subSortable.containers.get("> *").each(function() {
          var current = $(this);
          for (var j in subs) {
            if (subs[j].data && (current.eq(subs[j].data).length || subs[j].data.isWithin(current))) {
              order.push(j)
            }
          }
        })
      } else {
        for (var j in subs) {
          order.push(j)
        }
      }
      return order
    }
  };
  r.Tv = function(el) {
    r.Module.apply(this, arguments);
    this.TabControls()
  };
  glow.lang.extend(r.Tv, r.Module);
  r.Tv.prototype.TabControls = function() {
    var tabs = this.opts.set.get("ol > li"),
    self = this;
    if (this.state.val > 1 && tabs[this.state.val - 1]) {
      $(tabs[0]).parent().get("li.focus").removeClass("focus").get("h4.dy").removeClass("dy");
      $(tabs[this.state.val - 1]).addClass("focus").get("> h4").addClass("dy")
    }
    tabs.each(function() {
      bind(this, "click",
      function(e) {
        var tab = $(e.attachedTo);
        if (tab.hasClass("focus")) {
          return true
        }
        tab.parent().get("li.focus").removeClass("focus").get("h4.dy").removeClass("dy");
        tab.addClass("focus").get("> h4").addClass("dy");
        this.state.val = parseInt(tab.attr("class").match(/[0-9]+/)[0]);
        glow.events.fire(Homepage.pageState, "update");
        return false
      },
      self)
    })
  };
  r.Radio = function(el) {
    r.Tv.apply(this, arguments);
    this.TabControls()
  };
  glow.lang.extend(r.Radio, r.Tv);
  r.Radio.prototype.EditBoxSubmit = function() {
    var mod = this,
    checkboxes = mod.opts.set.get("input"),
    checkedCounter = 0,
    radioList = mod.opts.set.get("div.hpData ol");
    checkboxes.each(function() {
      var check = this,
      subId = $(check).parent()[0].className,
      item = $("#" + this.value);
      if (this.checked) {
        checkedCounter++
      }
      if (this.checked && !item.length) {
        var radioFile = this.value.replace(/x/, "");
        glow.net.get("/feedengine/homepage/won/" + radioFile + ".ssi", {
          load: function(response) {
            radioList.append('<li class="l' + (radioList.children().length + 1) + " " + subId + '" id="x' + radioFile + '">' + response.text() + "</li>");
            mod.state.subfeeds[subId] = {
              val: 3
            };
            delete mod.state.subfeeds.c
          },
          error: function(response) {
            mod._feedError(mod.opts.utils.get("p.edit a"))
          },
          useCache: true,
          async: false
        })
      } else {
        if (item.length && !this.checked) {
          if (item.hasClass("focus")) {
            radioList.get("li.l1").addClass("focus").get("> h4").addClass("dy")
          }
          if (item.hasClass("l12")) {
            radioList.get("li.l13").removeClass("l13").addClass("l12")
          }
          item.remove();
          delete mod.state.subfeeds[subId]
        }
      }
    });
    switch (checkedCounter) {
    case 0:
      mod.state.subfeeds.c = {
        val: 3
      };
    case 1:
      radioList.removeClass("two");
      break;
    case 2:
      radioList.addClass("two");
      break;
    default:
      break
    }
    delete mod.state.subfeeds.serialized;
    glow.events.fire(Homepage.pageState, "update");
    mod.EditBox()
  };
  r.Radio.prototype.SubSerialize = function() {
    var order = [],
    tabA = this.el.get("li.l12"),
    tabB = this.el.get("li.l13");
    if (tabA.length) {
      tabA.hasClass("a") ? order.push("a") : order.push("b");
      if (tabB.length) {
        tabB.hasClass("a") ? order.push("a") : order.push("b")
      }
    }
    return order
  };
  r.Music = function(el) {
    r.Module.apply(this, arguments);
    this.TabControls()
  };
  glow.lang.extend(r.Music, r.Module);
  r.Music.prototype.TabControls = function() {
    var mod = this;
    for (var j in mod.subs) {
      bind(mod.subs[j].data.get("p.tabLink a"), "click",
      function() {
        var add = $(this).attr("href"),
        remove = $(this).parent().prev().attr("class"),
        length = mod.subs[remove].state.val;
        add = add.charAt(add.length - 1);
        mod.AddSubfeed({
          value: add,
          replace: remove,
          subVal: length
        });
        mod.RemoveSubfeed({
          value: remove
        });
        delete mod.state.subfeeds.serialized;
        glow.events.fire(Homepage.pageState, "update");
        return false
      })
    }
  };
  r.Music.prototype.EditBoxSubmit = function() {
    var mod = this,
    checkboxes = mod.opts.set.get("input").filter(function() {
      return this.type == "checkbox"
    });
    checkboxes.each(function() {
      var altSubId = $(this).parent().attr("class");
      if (mod.state.subfeeds[altSubId] && !this.checked) {
        mod.RemoveSubfeed({
          value: altSubId
        })
      }
    });
    r.Module.prototype.EditBoxSubmit.apply(this, arguments)
  };
  r.Music.prototype.AddSubfeed = function(sub) {
    var pair = this.opts.set.get("div.options input").filter(function() {
      return this.type == "checkbox" && this.value == sub.value
    });
    if ((!sub.replace) && pair.length && this.state.subfeeds[pair.parent().attr("class")]) {
      return false
    }
    r.Module.prototype.AddSubfeed.apply(this, arguments);
    var mod = this,
    subfeed = mod.subs[sub.value].data,
    replace = sub.replace || "";
    if (replace.length) {
      subfeed.css("display", "none")
    }
    bind(subfeed.get("p.tabLink a"), "click",
    function() {
      var add = $(this).attr("href"),
      remove = $(this).parent().prev().attr("class"),
      length = mod.subs[remove].state.val;
      add = add.charAt(add.length - 1);
      mod.AddSubfeed({
        value: add,
        replace: remove,
        subVal: length
      });
      mod.RemoveSubfeed({
        value: remove
      });
      delete mod.state.subfeeds.serialized;
      glow.events.fire(Homepage.pageState, "update");
      return false
    });
    if (replace.length) {
      subfeed.remove().insertAfter(mod.subs[replace].data).css("display", "block")
    }
  };
  r.Olympics = function(el) {
    r.Module.apply(this, arguments);
    if (this.subs.a) {
      var data = this.el.get(".a").parent();
      while (!data.hasClass("hpData")) {
        data = data.parent()
      }
      var options = {
        id: "a",
        state: this.state.subfeeds.a
      };
      this.subs.a = new Homepage.Subfeed.MedalTable(data, options)
    }
  };
  glow.lang.extend(r.Olympics, r.Module);
  r.Olympics.prototype.AddSubfeed = function(sub) {
    r.Module.prototype.AddSubfeed.apply(this, arguments);
    if (sub.value == "a") {
      var data = this.el.get(".a").parent();
      while (!data.hasClass("hpData")) {
        data = data.parent()
      }
      var options = {
        id: "a",
        state: this.state.subfeeds.a
      };
      this.subs.a = new Homepage.Subfeed.MedalTable(data, options)
    }
  };
  r.Wimbledon = function(el) {
    r.Module.apply(this, arguments)
  };
  glow.lang.extend(r.Wimbledon, r.Module);
  r.Democracy = function(el) {
    r.Module.apply(this, arguments)
  };
  glow.lang.extend(r.Democracy, r.Module);
  r.Democracy.prototype.EditBoxSubmit = function() {
    var mod = this;
    if ($("#demlocation #demloc").val()) {
      var locationPanel = '<div class="hpPopup" id="hpPopup_Location"><h2 class="hd">Location Change</h2><p>Do you really want to change your location to <strong>{location}</strong>? This will affect all localised modules on your page.</p></div>';
      var result = new utils.Postcoder($("#demlocation #demloc").val(), {
        onDisambiguation: function(data) {
          $("#demmultresults").remove();
          $("#demprompt").remove();
          data.attr("id", "demmultresults");
          data.insertAfter($("#demloc"));
          if (data[0].nodeName != "P") {
            glow.dom.create('<p id="demprompt">More than one location found:</p>').insertAfter($("#demloc"))
          }
        },
        panel: locationPanel,
        panelOpts: {
          width: "320px",
          theme: "dark",
          modal: true,
          anim: "fade"
        }
      });
      mod.EditBox()
    }
    r.Module.prototype.EditBoxSubmit.apply(this);
    return false
  };
  r.Weather = function(el) {
    r.Module.apply(this, arguments);
    this._Update = function() {
      var mod = this,
      file = (Homepage.audience == "d") ? "/home/ssi/c/ca.sssi": "/home/ssi/int/c/ca.sssi";
      glow.net.get(file, {
        onLoad: function(response) {
          mod.opts.set.get("div.main").html(response.text())
        },
        onError: function(response) {
          mod._feedError(mod.opts.utils.get("p.edit a"))
        },
        useCache: false
      })
    }
  };
  glow.lang.extend(r.Weather, r.Module);
  r.Weather.prototype.EditBoxSubmit = function() {
    var mod = this,
    units = $("#weatherloc input").filter(function() {
      return this.name == "cfToggle" && this.checked
    });
    this.state.val = parseInt(units.val()) == 0 ? 0 : 1;
    glow.events.fire(Homepage.pageState, "update");
    if ($("#weatherloc #loc").length && $("#weatherloc #loc").val()) {
      var locationPanel = '<div class="hpPopup" id="hpPopup_Location"><h2 class="hd">Location Change</h2><p>Do you really want to change your location to <strong>{location}</strong>? This will affect all localised modules on your page.</p></div>';
      var result = new utils.Postcoder($("#weatherloc #loc").val(), {
        onDisambiguation: function(data) {
          $("#weamultresults").remove();
          $("#weaprompt").remove();
          data.attr("id", "weamultresults");
          data.insertAfter($("#weatherloc"));
          if (data[0].nodeName != "P") {
            glow.dom.create('<p id="weaprompt">More than one location found:</p>').insertAfter($("#weatherloc"))
          }
        },
        onZeroResults: function(data) {
          $("#weamultresults").remove();
          $("#weaprompt").remove();
          data.attr("id", "weamultresults");
          data.insertAfter($("#weatherloc"))
        },
        panel: locationPanel,
        panelOpts: {
          width: "320px",
          theme: "dark",
          modal: true,
          anim: "fade"
        }
      })
    } else {
      mod.EditBox()
    }
    this._Update();
    return false
  };
  r.LonelyPlanet = function(el) {
    r.Module.apply(this, arguments);
    if (this.state && this.state.subfeeds) {
      if (this.state.subfeeds.a) {
        var data = this.el.get(".a").parent();
        if (data.length) {
          while (!data.hasClass("hpData")) {
            data = data.parent()
          }
          var options = {
            id: "a",
            state: this.state.subfeeds.a
          };
          this.subs.a = new Homepage.Subfeed.LonelyPlanetGallery(data, options)
        }
      }
    }
  };
  glow.lang.extend(r.LonelyPlanet, r.Module);
  r.LonelyPlanet.prototype.AddSubfeed = function(sub) {
    r.Module.prototype.AddSubfeed.apply(this, arguments);
    $("#blq-content #v a").each(function() {
      var el = $(this);
      if (this.rel == "external" && !el.attr("target")) {
        el.attr("target", "_blank")
      }
    });
    switch (sub.value) {
    case "a":
      var data = this.el.get(".a").parent();
      while (!data.hasClass("hpData")) {
        data = data.parent()
      }
      var options = {
        id: "a",
        state: this.state.subfeeds.a
      };
      this.subs.a = new Homepage.Subfeed.LonelyPlanetGallery(data, options);
      break;
    case "b":
      new Homepage.Subfeed.Carousel({
        opts:
        {
          id:
          "v",
          set: glow.dom.get("#v .editorsPicks")
        }
      });
      this.el.addClass("hpCo");
      break
    }
  };
  r.Subfeed = function(el, opts) {
    this.data = el,
    this.id = opts.id,
    this.state = opts.state,
    this.images = opts.images || {};
    this.FeedControls()
  };
  r.Subfeed.prototype = {
    FeedControls: function() {
      var img = this.images[this.id],
      allItems = this.data.get("." + this.id + " > li"),
      unblocked = allItems.slice(0, this.state.val);
      unblocked.each(function(i) {
        if ($(this).hasClass("blocked") && img) {
          $(this).get("a").prepend('<span class="ly"><img width="146" height="82" src="' + img[i - 3].src + '" alt="' + img[i - 3].alt + '"/></span>')
        }
        $(this).removeClass("blocked")
      });
      allItems.slice(this.state.val, allItems.length).addClass("blocked");
      if (allItems.length && this.state.val >= allItems.length) {
        this.data.get("a.add").css("opacity", "0.4").removeAttr("href")
      }
      if (this.state.val == 1 || allItems.length == 1) {
        this.data.get("a.remove").css("opacity", "0.4").removeAttr("href")
      }
      bind(this.data.get("a.add"), "click",
      function() {
        var blocked = this.data.get("." + this.id + " > .blocked");
        if (blocked.length) {
          $(blocked[0]).removeClass("blocked");
          this.data.get("a.remove").css("opacity", "1").attr("href", "#");
          this.state.val++;
          if (this.images[this.id] && !$(blocked[0]).get("a img").length) {
            $(blocked[0]).get("a").prepend('<span class="ly"><img width="146" height="82" src="' + img[img.length - blocked.length].src + '" alt="' + img[img.length - blocked.length].alt + '"/></span>')
          }
          glow.events.fire(Homepage.pageState, "update")
        }
        if (blocked.length == 1) {
          this.data.get("a.add").css("opacity", "0.4").removeAttr("href")
        }
        return false
      },
      this);
      bind(this.data.get("a.add"), "mouseup",
      function() {
        this.blur()
      });
      bind(this.data.get("a.remove"), "click",
      function() {
        var list = this.data.get("." + this.id),
        items = list.children(),
        blocked = list.get("> .blocked");
        if (blocked.length < items.length - 1) {
          this.data.get("a.add").css("opacity", "1").attr("href", "#");
          $(items[items.length - blocked.length - 1]).addClass("blocked");
          this.state.val--;
          glow.events.fire(Homepage.pageState, "update")
        }
        if (blocked.length == items.length - 2) {
          this.data.get("a.remove").css("opacity", "0.4").removeAttr("href")
        }
        return false
      },
      this);
      bind(this.data.get("a.remove"), "mouseup",
      function() {
        this.blur()
      })
    }
  };
  r.Subfeed.MedalTable = function(el, opts) {
    r.Subfeed.apply(this, arguments)
  };
  r.Subfeed.MedalTable.prototype.FeedControls = function() {
    var allItems = this.data.get("." + this.id + " tr"),
    unblocked = allItems.slice(1, this.state.val + 1).removeClass("blocked"),
    gb = this.data.get("tr.GBR");
    allItems.slice(this.state.val + 1, allItems.length).addClass("blocked");
    if (gb.hasClass("blocked") && Homepage.audience == "d") {
      gb.addClass("extra");
      if (gb.eq(allItems.item(allItems.length - 1))) {
        gb.removeClass("blocked")
      }
    }
    $(allItems.item(this.state.val)).addClass("last");
    if (allItems.length && this.state.val >= allItems.length) {
      this.data.get("a.add").css("opacity", "0.4").removeAttr("href")
    }
    if (this.state.val == 1 || allItems.length == 1) {
      this.data.get("a.remove").css("opacity", "0.4").removeAttr("href")
    }
    bind(this.data.get("a.add"), "click",
    function() {
      var blocked = this.data.get("tr.blocked");
      if (blocked.length) {
        blockedEl = $(blocked[0]).prev().hasClass("extra") ? $(blocked[0]).prev() : $(blocked[0]);
        $(".olympicMedals tr.last").removeClass("last");
        blockedEl.removeClass("blocked").removeClass("extra").addClass("last");
        this.data.get("a.remove").css("opacity", "1").attr("href", "#");
        this.state.val++;
        glow.events.fire(Homepage.pageState, "update")
      }
      if (blocked.length < 2) {
        this.data.get("a.add").css("opacity", "0.4").removeAttr("href")
      }
      return false
    },
    this);
    bind(this.data.get("a.add"), "mouseup",
    function() {
      this.blur()
    });
    bind(this.data.get("a.remove"), "click",
    function() {
      var all = this.data.get("tr"),
      blocked = this.data.get("tr.blocked"),
      rem = $(all[all.length - blocked.length - 1]),
      remEl = rem.prev().hasClass("last") ? rem.prev() : rem;
      if (blocked.length < all.length - 2 && this.state.val > 1) {
        remEl.addClass("blocked").removeClass("last").prev().addClass("last");
        this.data.get("a.add").css("opacity", "1").attr("href", "#");
        this.state.val--;
        glow.events.fire(Homepage.pageState, "update");
        if (remEl.is(".GBR") && Homepage.audience == "d") {
          remEl.addClass("extra")
        }
      }
      if (this.state.val == 1) {
        this.data.get("a.remove").css("opacity", "0.4").removeAttr("href")
      }
      return false
    },
    this);
    bind(this.data.get("a.remove"), "mouseup",
    function() {
      this.blur()
    })
  };
  r.Subfeed.LonelyPlanetGallery = function(el, opts) {
    r.Subfeed.apply(this, arguments)
  };
  r.Subfeed.LonelyPlanetGallery.prototype.FeedControls = function() {
    bind(this.data.get("a.add"), "click",
    function(a) {
      var list = this.data.get("." + this.id),
      items = list.get("> li"),
      blocked = list.get("> .blocked");
      var nextImgLi = null;
      var i = 0;
      for (; i < items.length; i++) {
        var item = items[i];
        if (item.className && item.className.indexOf("blocked") != -1) {
          nextImgLi = glow.dom.get(item);
          break
        }
      }
      if (nextImgLi && ((i + 1) % 3 == 0)) {
        nextImgLi.removeClass("blocked");
        this.data.get("a.remove").css("opacity", "1").attr("href", "#");
        this.state.val++;
        glow.events.fire(Homepage.pageState, "update")
      }
      if (blocked.length == 1) {
        this.data.get("a.add").css("opacity", "0.4").removeAttr("href")
      }
      return false
    },
    this);
    bind(this.data.get("a.remove"), "click",
    function() {
      var list = this.data.get("." + this.id),
      items = list.get("> li"),
      blocked = list.get("> .blocked");
      var nextImgLi = null;
      var i = 0;
      for (; i < items.length; i++) {
        var item = items[i];
        if (item.className && item.className.indexOf("blocked") != -1) {
          nextImgLi = glow.dom.get(items[i - 1]);
          break
        }
      }
      if (nextImgLi && ((i + 1) % 3 == 0)) {
        nextImgLi.addClass("blocked");
        this.data.get("a.add").css("opacity", "1").attr("href", "#");
        this.state.val--;
        glow.events.fire(Homepage.pageState, "update")
      }
      if (blocked.length == items.length - 2) {
        this.data.get("a.remove").css("opacity", "0.4").removeAttr("href")
      }
      return false
    },
    this)
  };
  r.Subfeed.Carousel = function(mod) {
    var imageObj = Homepage.Carousel[mod.opts.id],
    carousel = this.el = mod.opts.set.get("div.carousel");
    this.el.get("li.one").addClass("dy");
    this.el.get("li a").each(function(index) {
      if (index) {
        $(this).prepend('<img src="' + imageObj[index - 1].src + '" height="110" width="146" alt="' + imageObj[index - 1].alt + '" />')
      }
      bind(this, "mouseover",
      function(e) {
        carousel.get("li.dy").removeClass("dy");
        $(e.attachedTo).parent().parent().addClass("dy")
      },
      carousel)
    })
  };
  r.Subfeed.VisionCarousel = function(mod) {
    var block = false;
    if (mod.opts.set.is(".blocked")) {
      mod.opts.set.removeClass("blocked");
      mod.opts.set.css("visbility", "hidden");
      block = true
    }
    mod.visionCarousel = new Carousel("#" + mod.opts.id + " .carouselHolder", {
      loop: true,
      itemFilter: "li",
      visibleItems: 1,
      anim: new glow.anim.Animation(0.6, {
        tween: glow.tweens.easeIn(4)
      })
    });
    if (block) {
      mod.opts.set.addClass("blocked");
      mod.opts.set.css("visbility", "visible")
    }
    var dotsHolder = glow.dom.create('<ol class="carouselDots dx"></ol>'),
    imageObj = Homepage.Carousel[mod.opts.id];
    this.el = mod.opts.set.get("div.visionCarousel");
    this.el.get("li span.img").each(function(index) {
      if (index > 2) {
        $(this).prepend('<img src="' + imageObj[index - 3].src + '" height="115" width="206" alt="' + imageObj[index - 3].alt + '" />')
      }
      var current = parseInt(index + 1),
      dot = glow.dom.create('<a title="Go to item ' + current + '" href="#' + mod.opts.id + current + '"><span>Go to item ' + current + "</span></a>");
      bind(dot, "click",
      function() {
        mod.visionCarousel.moveTo(index, 0);
        mod.opts.set.get(".carouselDots li.ly").removeClass("ly");
        $(mod.opts.set.get(".carouselDots li").item(index)).addClass("ly");
        return false
      });
      var listItem = glow.dom.create("<li></li>").append(dot);
      if (!index) {
        listItem.addClass("ly")
      }
      dotsHolder.append(listItem)
    });
    var next = glow.dom.create('<a title="next" href="#" class="carouselNext"><span>next</span></a>'),
    previous = glow.dom.create('<a title="previous" href="#" class="carouselPrevious"><span>previous</span></a>');
    bind(next, "click",
    function() {
      mod.visionCarousel.move( - 1);
      mod.opts.set.get(".carouselDots li.ly").removeClass("ly");
      $(mod.opts.set.get(".carouselDots li").item(mod.visionCarousel.getNextVisibleItemsIndexes()[0])).addClass("ly");
      return false
    });
    bind(previous, "click",
    function() {
      mod.visionCarousel.move(1);
      mod.opts.set.get(".carouselDots li.ly").removeClass("ly");
      $(mod.opts.set.get(".carouselDots li").item(mod.visionCarousel.getPrevVisibleItemsIndexes()[0])).addClass("ly");
      return false
    });
    mod.opts.set.get("div.controls").append(previous).append(dotsHolder).append(next)
  };
  r.Subfeed.Quotes = function(mod) {
    this.el = mod.opts.set.get("blockquote");
    this.el.prepend('<span class="hpQuoteOpen"><span>&nbsp;</span><span>&nbsp;</span></span>').append('<span class="hpQuoteClose"><span>&nbsp;</span><span>&nbsp;</span></span>')
  };
  r.Subfeed.AutoUpdate = function(mod, subfeed) {
    return window.setInterval(function() {
      var path = (Homepage.audience == "i") ? "int/": "";
      glow.net.get("/home/ssi/" + path + mod + "/" + mod + subfeed + ".sssi", {
        load: function(response) {
          var res = glow.dom.create(response.text());
          $("#" + mod + " ." + subfeed).parent().html(res.html())
        },
        error: function(response) {},
        useCache: false
      })
    },
    Homepage.autoUpdate[mod][subfeed])
  };
  r.State = function() {
    var pageState = {};
    pageState.cookie = utils.cookie.get("hp");
    pageState.modules = {};
    if (!/[+\-a-z0-9]*\*[+\-a-z0-9]*\*[+\-a-z0-9]*/.test(pageState.cookie)) {
      pageState.cookie = Homepage.audience == "d" ? "+acv+ba+neaj+hj+oab*+c1+g1ab+mc2+rad*+da+f1a7b7c7d7+i+kca+la": "+ac+p+f1-i*+b+v+g1*+naij5+c1"
    }
    var cookieVal = pageState.cookie.replace(/\*/g, ""),
    mods = cookieVal.match(/[+\-][a-z]{1}/g);
    if (mods) {
      pageState.colour = cookieVal.substring(0, cookieVal.indexOf(mods[0]))
    } else {
      pageState.colour = cookieVal
    }
    if (mods) {
      var i = 0,
      len = mods.length;
      for (; i < len; i++) {
        var id = mods[i].charAt(1) || "";
        var mod = pageState.modules[id] = {};
        mod.open = mods[i].charAt(0) === "+" ? true: false;
        var end = cookieVal.indexOf(mods[i + 1]) > 0 ? cookieVal.indexOf(mods[i + 1]) : cookieVal.length;
        var subs = cookieVal.substring(cookieVal.indexOf(mods[i]) + 2, end);
        var split = subs.match(/[a-z][0-9]*/g) || [];
        pageState.modules[id].val = parseInt(subs.match(/[0-9]*/)[0]) || 3;
        pageState.modules[id].subfeeds = {};
        var j = 0,
        length = split.length;
        for (; j < length; j++) {
          var subFeeds = pageState.modules[id].subfeeds[split[j].charAt(0) || ""] = {};
          var defVal = id == "f" ? 7 : 3;
          subFeeds.val = parseInt(split[j].charAt(1)) || defVal;
          if (split[j].charAt(2)) {
            subFeeds.val += split[j].charAt(2)
          }
        }
      }
      pageState.changed = false;
      for (var y in Homepage.Cookie[Homepage.audience].Push) {
        var z = 0,
        zlen = Homepage.Cookie[Homepage.audience].Push[y].length;
        for (; z < zlen; z++) {
          var subFeed = Homepage.Cookie[Homepage.audience].Push[y][z].charAt(0),
          subVal = Homepage.Cookie[Homepage.audience].Push[y][z].charAt(1) || 3;
          if (pageState.modules[y] && !pageState.modules[y].subfeeds[subFeed]) {
            pageState.modules[y].subfeeds[subFeed] = {
              val: subVal
            };
            pageState.changed = true
          }
        }
      }
      for (var x in Homepage.Cookie[Homepage.audience].Pull) {
        if (pageState.modules[x] && pageState.modules[x].subfeeds[Homepage.Cookie[Homepage.audience].Pull[x]]) {
          delete pageState.modules[x].subfeeds[Homepage.Cookie[Homepage.audience].Pull[x]];
          pageState.changed = true
        }
        if (pageState.modules[x] && Homepage.Cookie[Homepage.audience].Pull[x] == "all") {
          delete pageState.modules[x];
          pageState.changed = true
        }
      }
    }
    return pageState
  };
  r.VSGet = function() {
    builder = function(str, p1, p2, p3) {
      var vs = p1 + p2;
      for (var i = 0; i < p3.length; i++) {
        if (i) {
          vs += "|" + p2
        }
        vs += p3.charAt(i);
        while (p3.charAt(i + 1) && !isNaN(p3.charAt(i + 1))) {
          i++;
          vs += p3.charAt(i)
        }
      }
      return vs
    };
    var vsCookie = utils.cookie.get("hp");
    vsCookie = vsCookie.replace(/([+-])([a-z]{1})([^+\-\*]*)/g, builder);
    vsCookie = vsCookie.replace(/([a-z0-9]{1})([+\-])/g, "$1|$2");
    return vsCookie
  };
  return r
} ();
utils.slide = function() {
  var C = {},
  D = glow.dom.get,
  E = glow.events.addListener;
  C.happening = [];
  function B(G) {
    var F = utils.slide.happening,
    H = F.length,
    I = 0;
    for (I = 0; I < F.length; I++) {
      if (F[I].list.eq(G.list)) {
        F[I].anim.stop();
        F[I] = G;
        E(F[I].anim, "complete",
        function() {
          F.splice(I)
        });
        F[I].anim.start();
        return false
      }
    }
    F[H] = G;
    E(F[H].anim, "complete",
    function() {
      F.splice(H)
    });
    F[H].anim.start();
    return false
  }
  function A(H) {
    var G = H[0].style.height,
    F = H.css("visibility", "hidden").css("display", "block").css("position", "absolute").css("padding", "0").css("height", "auto")[0].offsetHeight;
    H.css("visibility", "").css("position", "").css("padding", "").css("height", G);
    return F
  }
  C.up = function(F, I) {
    if (F[0]) {
      var H = D(F);
      var G = glow.anim.css(H, 0.5, {
        height: {
          to: 0
        }
      },
      {
        tween: glow.tweens.easeOut()
      });
      E(G, "start",
      function() {
        H.css("overflow", "hidden")
      });
      E(G, "complete",
      function() {
        H.css("display", "none");
        return I ? I() : false
      });
      return B({
        list: H,
        anim: G,
        dir: "up"
      })
    }
  };
  C.down = function(G, J) {
    if (G[0]) {
      var I = D(G),
      F = A(I);
      var H = glow.anim.css(I, 0.5, {
        height: {
          to: F
        }
      },
      {
        tween: glow.tweens.easeOut()
      });
      E(H, "start",
      function() {
        I.css("height", "0").css("overflow", "hidden").css("display", "block")
      });
      E(H, "complete",
      function() {
        I.css("height", "auto");
        return J ? J() : false
      });
      return B({
        list: I,
        anim: H,
        dir: "down"
      })
    }
  };
  C.toggle = function(F, J) {
    var G = D(F);
    for (var I = 0; I < utils.slide.happening.length; I++) {
      if (utils.slide.happening[I].list.eq(F)) {
        var H = utils.slide.happening[I].dir;
        break
      }
    }
    return (H == "up" || G.css("display") == "none") ? utils.slide.down(G, J) : utils.slide.up(G, J)
  };
  return C
} ();
glow.onDomReady(function() {
  Homepage.pageState = Homepage.State();
  var A = Homepage.pageState.cookie;
  if (Homepage.OriginalCookie != A && A.charAt(A.length - 1) != "+") {
    utils.cookie.set("hp", A + "+", {
      domain: "bbc.co.uk",
      expires: 365
    });
    window.location.reload(true)
  } else {
    if (A.charAt(A.length - 1) == "+") {
      utils.cookie.set("hp", A.substring(0, A.length - 1), {
        domain: "bbc.co.uk",
        expires: 365
      })
    }
  }
});
glow.ready(function() {
  Homepage.init()
});
Homepage.moduleRef = {
  c: "Weather",
  f: "Tv",
  g: "Radio",
  m: "Music",
  q: "Democracy",
  s: "Olympics",
  v: "LonelyPlanet"
};
Homepage.Cookie = {};
Homepage.Cookie.d = {
  Push: {
    d: ["a"],
    f: ["a7", "b7", "c7", "d7"],
    v: ["a", "b"]
  },
  Pull: {
    t: "all",
    k: ["a", "b"],
    l: ["a", "b"],
    r: ["a", "d"],
    h: ["h"],
    g: ["c"]
  }
};
Homepage.Cookie.i = {
  Push: {
    d: ["a"]
  },
  Pull: {
    t: "all",
    k: ["a", "b"],
    b: ["a"],
    r: ["a", "d"],
    h: ["h"],
    g: ["c"]
  }
};
utils.Postcoder = (function() {
  var E = glow.dom.get;
  var A = {
    PST: "postcode",
    QRY: "result > name",
    LEA: "lea id",
    TVR: "bbctv id",
    WEA: "weather id",
    CCI: "county_council id",
    CON: "constituency id",
    CTY: "county id",
    DST: "district",
    EUR: "euro_region id",
    LAU: "local_authority id",
    LST: "listings id",
    NHS: "health_authority id",
    TWN: "post_town id",
    RAD: "radio id",
    WRD: "ward id",
    WIL: "wil id",
    MAT: "match_type"
  };
  function B(G) {
    var F = new glow.dom.NodeList();
    switch (G.get("result").length) {
    case 0:
      F = glow.dom.create("<p>No results found, please try again.</p>");
      break;
    case 1:
      if (G.get("wil").length > 1) {
        F = D.call(this, G, "wil")
      }
      break;
    default:
      F = D.call(this, G, "result")
    }
    return F
  }
  function D(I, G) {
    var F = glow.dom.create("<ul></ul>");
    var H = this;
    I.get(G).each(function() {
      var J = E(this).get("name").text();
      if (G == "result") {
        J += ", " + E(this).get("hint").text()
      }
      var K = glow.dom.create('<li><a href="#">' + J + "</a></li>");
      glow.events.addListener(K, "click",
      function() {
        var L = {};
        if (this.nodeName == "wil") {
          L = {
            wil: E(this).get("id").text()
          };
          id = E(this).parent().get("id").text()
        } else {
          id = E(this).get("id").text()
        }
        utils.Postcoder.call(H, id, L);
        return false
      },
      this);
      F.append(K)
    });
    return F
  }
  function C(H, K) {
    var H = H,
    K = K || {},
    G = K.wil || 0,
    J = this;
    if (K.panel) {
      this.panel = K.panel
    }
    if (K.panelOpts) {
      this.panelOpts = K.panelOpts
    }
    var I = this.makeRequest(H);
    if (G) {
      I.get("wil").each(function() {
        if (E(this).get("id").text() != G) {
          E(this).remove()
        }
      })
    }
    var F = B.call(this, I);
    if (K.onDisambiguation) {
      glow.events.addListener(J, "disambiguation", K.onDisambiguation)
    }
    if (K.onZeroResults) {
      glow.events.addListener(J, "zeroresults", K.onZeroResults)
    }
    if (K.onSuccess) {
      glow.events.addListener(J, "success", K.onSuccess)
    }
    if (F.length && F[0].nodeName != "P") {
      glow.events.fire(J, "disambiguation", F)
    } else {
      if (F.length && F[0].nodeName == "P") {
        glow.events.fire(J, "zeroresults", F)
      } else {
        glow.events.fire(J, "success");
        if (this.panel && this.panel.length) {
          K.onConfirm = K.onConfirm ||
          function() {
            J.buildCookie(I);
            window.location.reload(true)
          };
          var L = {
            location: I.get("result > name").text()
          };
          panelNode = glow.dom.create(glow.lang.interpolate(this.panel, L));
          panelNode.appendTo(E(document.body));
          this.confirmation = new utils.widgets.Dialog(panelNode, this.panelOpts);
          glow.events.addListener(this.confirmation, "confirm", K.onConfirm);
          this.confirmation.show()
        } else {
          this.buildCookie(I)
        }
      }
    }
  }
  C.prototype = {
    makeRequest: function(F) {
      var H = new glow.dom.NodeList();
      var G = "http://www.bbc.co.uk/cgi-perl/whereilive/query/place.pl?loc=" + F + "&customer=postcoder";
      glow.net.get(G, {
        load: function(I) {
          H = E(I.xml())
        },
        error: function(I) {
          alert("error: " + I.statusText())
        },
        async: false
      });
      return H
    },
    buildCookie: function(H) {
      var G = "";
      for (var F in A) {
        var I = "";
        H.get(A[F]).each(function(J) {
          if (J) {
            I += "."
          }
          I += E(this).text()
        });
        G += F + I + ":"
      }
      utils.cookie.set("BBCpostcoder", G, {
        domain: "bbc.co.uk",
        expires: 365
      })
    }
  };
  return C
} ());
utils.widgets = {};
utils.widgets.Dialog = (function() {
  var F = glow.dom,
  D = F.get,
  B = glow.events,
  C = glow.widgets,
  E = glow.lang;
  function A(K, J) {
    J = J || {};
    if (J.template) {
      var I = true
    }
    var H = this,
    G = D(K).append(F.create('<p class="ft"><a class="glow-dialog-cancel button" href="#"><span>Cancel</span></a><a class="glow-dialog-confirm button" href="#"><span>Confirm</span></a></p>'));
    J = E.apply({
      modal: false,
      theme: "dark"
    },
    J);
    B.addListener(G.get(".glow-dialog-cancel"), "click",
    function() {
      H.hide();
      return false
    });
    B.addListener(G.get(".glow-dialog-confirm"), "click",
    function() {
      B.fire(H, "confirm");
      H.hide();
      return false
    });
    C.Panel.call(this, K, J);
    if (!I) {
      this.content.addClass("glow-dialog")
    }
  }
  E.extend(A, C.Panel);
  return A
} ());