(function(c, d, g, l, h, U) {
  function t(a, b) {
    var f = typeof a[b];
    return"function" == f || !!("object" == f && a[b]) || "unknown" == f
  }
  function F() {
    if(!y(navigator.plugins) && "object" == typeof navigator.plugins["Shockwave Flash"]) {
      var a = navigator.plugins["Shockwave Flash"].description;
      a && (!y(navigator.mimeTypes) && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) && (C = a.match(/\d+/g))
    }
    if(!C) {
      var b;
      try {
        b = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"), C = Array.prototype.slice.call(b.GetVariable("$version").match(/(\d+),(\d+),(\d+),(\d+)/), 1)
      }catch(f) {
      }
    }
    if(!C) {
      return!1
    }
    a = parseInt(C[0], 10);
    b = parseInt(C[1], 10);
    R = 9 < a && 0 < b;
    return!0
  }
  function A() {
    if(!D) {
      D = !0;
      for(var a = 0;a < L.length;a++) {
        L[a]()
      }
      L.length = 0
    }
  }
  function E(a, b) {
    D ? a.call(b) : L.push(function() {
      a.call(b)
    })
  }
  function aa() {
    var a = parent;
    if("" !== I) {
      for(var b = 0, f = I.split(".");b < f.length;b++) {
        a = a[f[b]]
      }
    }
    return a.easyXDM
  }
  function n(a) {
    var b = a.toLowerCase().match(M);
    a = b[2];
    var f = b[3], b = b[4] || "";
    if("http:" == a && ":80" == b || "https:" == a && ":443" == b) {
      b = ""
    }
    return a + "//" + f + b
  }
  function J(a) {
    a = a.replace(ba, "$1/");
    if(!a.match(/^(http||https):\/\//)) {
      var b = "/" === a.substring(0, 1) ? "" : g.pathname;
      "/" !== b.substring(b.length - 1) && (b = b.substring(0, b.lastIndexOf("/") + 1));
      a = g.protocol + "//" + g.host + b + a
    }
    for(;V.test(a);) {
      a = a.replace(V, "")
    }
    return a
  }
  function G(a, b) {
    var f = "", k = a.indexOf("#");
    -1 !== k && (f = a.substring(k), a = a.substring(0, k));
    var k = [], c;
    for(c in b) {
      b.hasOwnProperty(c) && k.push(c + "\x3d" + U(b[c]))
    }
    return a + (W ? "#" : -1 == a.indexOf("?") ? "?" : "\x26") + k.join("\x26") + f
  }
  function y(a) {
    return"undefined" === typeof a
  }
  function s(a, b, f) {
    var k, c;
    for(c in b) {
      b.hasOwnProperty(c) && (c in a ? (k = b[c], "object" === typeof k ? s(a[c], k, f) : f || (a[c] = b[c])) : a[c] = b[c])
    }
    return a
  }
  function B(a) {
    if(y(N)) {
      var b = d.body.appendChild(d.createElement("form")), f = b.appendChild(d.createElement("input"));
      f.name = w + "TEST" + X;
      N = f !== b.elements[f.name];
      d.body.removeChild(b)
    }
    N ? b = d.createElement('\x3ciframe name\x3d"' + a.props.name + '"/\x3e') : (b = d.createElement("IFRAME"), b.name = a.props.name);
    b.id = b.name = a.props.name;
    delete a.props.name;
    "string" == typeof a.container && (a.container = d.getElementById(a.container));
    a.container || (s(b.style, {position:"absolute", top:"-2000px", left:"0px"}), a.container = d.body);
    f = a.props.src;
    a.props.src = "javascript:false";
    s(b, a.props);
    b.border = b.frameBorder = 0;
    b.allowTransparency = !0;
    a.container.appendChild(b);
    a.onLoad && x(b, "load", a.onLoad);
    if(a.usePost) {
      var k = a.container.appendChild(d.createElement("form")), c;
      k.target = b.name;
      k.action = f;
      k.method = "POST";
      if("object" === typeof a.usePost) {
        for(var m in a.usePost) {
          a.usePost.hasOwnProperty(m) && (N ? c = d.createElement('\x3cinput name\x3d"' + m + '"/\x3e') : (c = d.createElement("INPUT"), c.name = m), c.value = a.usePost[m], k.appendChild(c))
        }
      }
      k.submit();
      k.parentNode.removeChild(k)
    }else {
      b.src = f
    }
    a.props.src = f;
    return b
  }
  function Y(a) {
    var b = a.protocol, f;
    a.isHost = a.isHost || y(u.xdm_p);
    W = a.hash || !1;
    a.props || (a.props = {});
    if(a.isHost) {
      a.remote = J(a.remote), a.channel = a.channel || "default" + X++, a.secret = Math.random().toString(16).substring(2), y(b) && (b = n(g.href) == n(a.remote) ? "4" : t(c, "postMessage") || t(d, "postMessage") ? "1" : a.swf && t(c, "ActiveXObject") && F() ? "6" : "Gecko" === navigator.product && "frameElement" in c && -1 == navigator.userAgent.indexOf("WebKit") ? "5" : a.remoteHelper ? "2" : "0")
    }else {
      a.channel = u.xdm_c.replace(/["'<>\\]/g, "");
      a.secret = u.xdm_s;
      a.remote = u.xdm_e.replace(/["'<>\\]/g, "");
      var b = u.xdm_p, k;
      if(k = a.acl) {
        a: {
          k = a.acl;
          var v = a.remote;
          "string" == typeof k && (k = [k]);
          for(var m, p = k.length;p--;) {
            if(m = k[p], m = RegExp("^" == m.substr(0, 1) ? m : "^" + m.replace(/(\*)/g, ".$1").replace(/\?/g, ".") + "$"), m.test(v)) {
              k = !0;
              break a
            }
          }
          k = !1
        }
        k = !k
      }
      if(k) {
        throw Error("Access denied for " + a.remote);
      }
    }
    a.protocol = b;
    switch(b) {
      case "0":
        s(a, {interval:100, delay:2E3, useResize:!0, useParent:!1, usePolling:!1}, !0);
        if(a.isHost) {
          if(!a.local) {
            b = g.protocol + "//" + g.host;
            f = d.body.getElementsByTagName("img");
            for(v = f.length;v--;) {
              if(k = f[v], k.src.substring(0, b.length) === b) {
                a.local = k.src;
                break
              }
            }
            a.local || (a.local = c)
          }
          b = {xdm_c:a.channel, xdm_p:0};
          a.local === c ? (a.usePolling = !0, a.useParent = !0, a.local = g.protocol + "//" + g.host + g.pathname + g.search, b.xdm_e = a.local, b.xdm_pa = 1) : b.xdm_e = J(a.local);
          a.container && (a.useResize = !1, b.xdm_po = 1);
          a.remote = G(a.remote, b)
        }else {
          s(a, {channel:u.xdm_c, remote:u.xdm_e, useParent:!y(u.xdm_pa), usePolling:!y(u.xdm_po), useResize:a.useParent ? !1 : a.useResize})
        }
        f = [new e.stack.HashTransport(a), new e.stack.ReliableBehavior({}), new e.stack.QueueBehavior({encode:!0, maxLength:4E3 - a.remote.length}), new e.stack.VerifyBehavior({initiate:a.isHost})];
        break;
      case "1":
        f = [new e.stack.PostMessageTransport(a)];
        break;
      case "2":
        a.remoteHelper = J(a.remoteHelper);
        f = [new e.stack.NameTransport(a), new e.stack.QueueBehavior, new e.stack.VerifyBehavior({initiate:a.isHost})];
        break;
      case "3":
        f = [new e.stack.NixTransport(a)];
        break;
      case "4":
        f = [new e.stack.SameOriginTransport(a)];
        break;
      case "5":
        f = [new e.stack.FrameElementTransport(a)];
        break;
      case "6":
        C || F(), f = [new e.stack.FlashTransport(a)]
    }
    f.push(new e.stack.QueueBehavior({lazy:a.lazy, remove:!0}));
    return f
  }
  function Z(a) {
    for(var b, f = {incoming:function(a, b) {
      this.up.incoming(a, b)
    }, outgoing:function(a, b) {
      this.down.outgoing(a, b)
    }, callback:function(a) {
      this.up.callback(a)
    }, init:function() {
      this.down.init()
    }, destroy:function() {
      this.down.destroy()
    }}, c = 0, d = a.length;c < d;c++) {
      b = a[c], s(b, f, !0), 0 !== c && (b.down = a[c - 1]), c !== d - 1 && (b.up = a[c + 1])
    }
    return b
  }
  function ca(a) {
    a.up.down = a.down;
    a.down.up = a.up;
    a.up = a.down = null
  }
  var O = this, X = Math.floor(1E4 * Math.random()), S = Function.prototype, M = /^((http.?:)\/\/([^:\/\s]+)(:\d+)*)/, V = /[\-\w]+\/\.\.\//, ba = /([^:])\/\//g, I = "", e = {}, da = c.easyXDM, w = "easyXDM_", N, W = !1, C, R, x, H;
  if(t(c, "addEventListener")) {
    x = function(a, b, f) {
      a.addEventListener(b, f, !1)
    }, H = function(a, b, f) {
      a.removeEventListener(b, f, !1)
    }
  }else {
    if(t(c, "attachEvent")) {
      x = function(a, b, f) {
        a.attachEvent("on" + b, f)
      }, H = function(a, b, f) {
        a.detachEvent("on" + b, f)
      }
    }else {
      throw Error("Browser not supported");
    }
  }
  var D = !1, L = [], P;
  "readyState" in d ? (P = d.readyState, D = "complete" == P || ~navigator.userAgent.indexOf("AppleWebKit/") && ("loaded" == P || "interactive" == P)) : D = !!d.body;
  if(!D) {
    if(t(c, "addEventListener")) {
      x(d, "DOMContentLoaded", A)
    }else {
      if(x(d, "readystatechange", function() {
        "complete" == d.readyState && A()
      }), d.documentElement.doScroll && c === top) {
        var $ = function() {
          if(!D) {
            try {
              d.documentElement.doScroll("left")
            }catch(a) {
              l($, 1);
              return
            }
            A()
          }
        };
        $()
      }
    }
    x(c, "load", A)
  }
  var u = function(a) {
    a = a.substring(1).split("\x26");
    for(var b = {}, f, c = a.length;c--;) {
      f = a[c].split("\x3d"), b[f[0]] = h(f[1])
    }
    return b
  }(/xdm_e=/.test(g.search) ? g.search : g.hash), T = function() {
    var a = {}, b = {a:[1, 2, 3]};
    if("undefined" != typeof JSON && "function" === typeof JSON.stringify && '{"a":[1,2,3]}' === JSON.stringify(b).replace(/\s/g, "")) {
      return JSON
    }
    Object.toJSON && '{"a":[1,2,3]}' === Object.toJSON(b).replace(/\s/g, "") && (a.stringify = Object.toJSON);
    "function" === typeof String.prototype.evalJSON && (b = '{"a":[1,2,3]}'.evalJSON(), b.a && (3 === b.a.length && 3 === b.a[2]) && (a.parse = function(a) {
      return a.evalJSON()
    }));
    return a.stringify && a.parse ? (T = function() {
      return a
    }, a) : null
  };
  s(e, {version:"2.4.17.1", query:u, stack:{}, apply:s, getJSONObject:T, whenReady:E, noConflict:function(a) {
    c.easyXDM = da;
    (I = a) && (w = "easyXDM_" + I.replace(".", "_") + "_");
    return e
  }});
  e.DomHelper = {on:x, un:H, requiresJSON:function(a) {
    "object" == typeof c.JSON && c.JSON || d.write('\x3cscript type\x3d"text/javascript" src\x3d"' + a + '"\x3e\x3c/script\x3e')
  }};
  (function() {
    var a = {};
    e.Fn = {set:function(b, f) {
      a[b] = f
    }, get:function(b, f) {
      var c = a[b];
      f && delete a[b];
      return c
    }}
  })();
  e.Socket = function(a) {
    var b = Z(Y(a).concat([{incoming:function(b, f) {
      a.onMessage(b, f)
    }, callback:function(b) {
      if(a.onReady) {
        a.onReady(b)
      }
    }}])), f = n(a.remote);
    this.origin = n(a.remote);
    this.destroy = function() {
      b.destroy()
    };
    this.postMessage = function(a) {
      b.outgoing(a, f)
    };
    b.init()
  };
  e.Rpc = function(a, b) {
    if(b.local) {
      for(var f in b.local) {
        if(b.local.hasOwnProperty(f)) {
          var c = b.local[f];
          "function" === typeof c && (b.local[f] = {method:c})
        }
      }
    }
    var d = Z(Y(a).concat([new e.stack.RpcBehavior(this, b), {callback:function(b) {
      if(a.onReady) {
        a.onReady(b)
      }
    }}]));
    this.origin = n(a.remote);
    this.destroy = function() {
      d.destroy()
    };
    d.init()
  };
  e.stack.SameOriginTransport = function(a) {
    var b, f, c, d;
    return b = {outgoing:function(a, b, f) {
      c(a);
      f && f()
    }, destroy:function() {
      f && (f.parentNode.removeChild(f), f = null)
    }, onDOMReady:function() {
      d = n(a.remote);
      a.isHost ? (s(a.props, {src:G(a.remote, {xdm_e:g.protocol + "//" + g.host + g.pathname, xdm_c:a.channel, xdm_p:4}), name:w + a.channel + "_provider"}), f = B(a), e.Fn.set(a.channel, function(a) {
        c = a;
        l(function() {
          b.up.callback(!0)
        }, 0);
        return function(a) {
          b.up.incoming(a, d)
        }
      })) : (c = aa().Fn.get(a.channel, !0)(function(a) {
        b.up.incoming(a, d)
      }), l(function() {
        b.up.callback(!0)
      }, 0))
    }, init:function() {
      E(b.onDOMReady, b)
    }}
  };
  e.stack.FlashTransport = function(a) {
    function b(a, b) {
      l(function() {
        c.up.incoming(a, m)
      }, 0)
    }
    function f(b) {
      var c = a.swf + "?host\x3d" + a.isHost, f = "easyXDM_swf_" + Math.floor(1E4 * Math.random());
      e.Fn.set("flash_loaded" + b.replace(/[\-.]/g, "_"), function() {
        e.stack.FlashTransport[b].swf = p = q.firstChild;
        for(var a = e.stack.FlashTransport[b].queue, c = 0;c < a.length;c++) {
          a[c]()
        }
        a.length = 0
      });
      a.swfContainer ? q = "string" == typeof a.swfContainer ? d.getElementById(a.swfContainer) : a.swfContainer : (q = d.createElement("div"), s(q.style, R && a.swfNoThrottle ? {height:"20px", width:"20px", position:"fixed", right:0, top:0} : {height:"1px", width:"1px", position:"absolute", overflow:"hidden", right:0, top:0}), d.body.appendChild(q));
      var k = "callback\x3dflash_loaded" + b.replace(/[\-.]/g, "_") + "\x26proto\x3d" + O.location.protocol + "\x26domain\x3d" + O.location.href.match(M)[3] + "\x26port\x3d" + (O.location.href.match(M)[4] || "") + "\x26ns\x3d" + I;
      q.innerHTML = "\x3cobject height\x3d'20' width\x3d'20' type\x3d'application/x-shockwave-flash' id\x3d'" + f + "' data\x3d'" + c + "'\x3e\x3cparam name\x3d'allowScriptAccess' value\x3d'always'\x3e\x3c/param\x3e\x3cparam name\x3d'wmode' value\x3d'transparent'\x3e\x3cparam name\x3d'movie' value\x3d'" + c + "'\x3e\x3c/param\x3e\x3cparam name\x3d'flashvars' value\x3d'" + k + "'\x3e\x3c/param\x3e\x3cembed type\x3d'application/x-shockwave-flash' FlashVars\x3d'" + k + "' allowScriptAccess\x3d'always' wmode\x3d'transparent' src\x3d'" + 
      c + "' height\x3d'1' width\x3d'1'\x3e\x3c/embed\x3e\x3c/object\x3e"
    }
    var c, v, m, p, q;
    return c = {outgoing:function(b, c, f) {
      p.postMessage(a.channel, b.toString());
      f && f()
    }, destroy:function() {
      try {
        p.destroyChannel(a.channel)
      }catch(b) {
      }
      p = null;
      v && (v.parentNode.removeChild(v), v = null)
    }, onDOMReady:function() {
      m = a.remote;
      e.Fn.set("flash_" + a.channel + "_init", function() {
        l(function() {
          c.up.callback(!0)
        })
      });
      e.Fn.set("flash_" + a.channel + "_onMessage", b);
      a.swf = J(a.swf);
      var d = a.swf.match(M)[3], q = function() {
        e.stack.FlashTransport[d].init = !0;
        p = e.stack.FlashTransport[d].swf;
        p.createChannel(a.channel, a.secret, n(a.remote), a.isHost);
        a.isHost && (R && a.swfNoThrottle && s(a.props, {position:"fixed", right:0, top:0, height:"20px", width:"20px"}), s(a.props, {src:G(a.remote, {xdm_e:n(g.href), xdm_c:a.channel, xdm_p:6, xdm_s:a.secret}), name:w + a.channel + "_provider"}), v = B(a))
      };
      e.stack.FlashTransport[d] && e.stack.FlashTransport[d].init ? q() : e.stack.FlashTransport[d] ? e.stack.FlashTransport[d].queue.push(q) : (e.stack.FlashTransport[d] = {queue:[q]}, f(d))
    }, init:function() {
      E(c.onDOMReady, c)
    }}
  };
  e.stack.PostMessageTransport = function(a) {
    function b(b) {
      var c;
      if(b.origin) {
        c = n(b.origin)
      }else {
        if(b.uri) {
          c = n(b.uri)
        }else {
          if(b.domain) {
            c = g.protocol + "//" + b.domain
          }else {
            throw"Unable to retrieve the origin of the event";
          }
        }
      }
      c == m && b.data.substring(0, a.channel.length + 1) == a.channel + " " && f.up.incoming(b.data.substring(a.channel.length + 1), c)
    }
    var f, d, e, m;
    return f = {outgoing:function(b, c, f) {
      e.postMessage(a.channel + " " + b, c || m);
      f && f()
    }, destroy:function() {
      H(c, "message", b);
      d && (e = null, d.parentNode.removeChild(d), d = null)
    }, onDOMReady:function() {
      m = n(a.remote);
      if(a.isHost) {
        var p = function(m) {
          m.data == a.channel + "-ready" && (e = "postMessage" in d.contentWindow ? d.contentWindow : d.contentWindow.document, H(c, "message", p), x(c, "message", b), l(function() {
            f.up.callback(!0)
          }, 0))
        };
        x(c, "message", p);
        s(a.props, {src:G(a.remote, {xdm_e:n(g.href), xdm_c:a.channel, xdm_p:1}), name:w + a.channel + "_provider"});
        d = B(a)
      }else {
        x(c, "message", b), e = "postMessage" in c.parent ? c.parent : c.parent.document, e.postMessage(a.channel + "-ready", m), l(function() {
          f.up.callback(!0)
        }, 0)
      }
    }, init:function() {
      E(f.onDOMReady, f)
    }}
  };
  e.stack.FrameElementTransport = function(a) {
    var b, f, k, e;
    return b = {outgoing:function(a, b, c) {
      k.call(this, a);
      c && c()
    }, destroy:function() {
      f && (f.parentNode.removeChild(f), f = null)
    }, onDOMReady:function() {
      e = n(a.remote);
      a.isHost ? (s(a.props, {src:G(a.remote, {xdm_e:n(g.href), xdm_c:a.channel, xdm_p:5}), name:w + a.channel + "_provider"}), f = B(a), f.fn = function(a) {
        delete f.fn;
        k = a;
        l(function() {
          b.up.callback(!0)
        }, 0);
        return function(a) {
          b.up.incoming(a, e)
        }
      }) : (d.referrer && n(d.referrer) != u.xdm_e && (c.top.location = u.xdm_e), k = c.frameElement.fn(function(a) {
        b.up.incoming(a, e)
      }), b.up.callback(!0))
    }, init:function() {
      E(b.onDOMReady, b)
    }}
  };
  e.stack.NameTransport = function(a) {
    function b(b) {
      q.contentWindow.sendMessage(b, a.remoteHelper + (p ? "#_3" : "#_2") + a.channel)
    }
    function c() {
      p ? (2 === ++r || !p) && m.up.callback(!0) : (b("ready"), m.up.callback(!0))
    }
    function d(a) {
      m.up.incoming(a, K)
    }
    function g() {
      z && l(function() {
        z(!0)
      }, 0)
    }
    var m, p, q, h, r, z, K, Q;
    return m = {outgoing:function(a, c, f) {
      z = f;
      b(a)
    }, destroy:function() {
      q.parentNode.removeChild(q);
      q = null;
      p && (h.parentNode.removeChild(h), h = null)
    }, onDOMReady:function() {
      p = a.isHost;
      r = 0;
      K = n(a.remote);
      a.local = J(a.local);
      p ? (e.Fn.set(a.channel, function(b) {
        p && "ready" === b && (e.Fn.set(a.channel, d), c())
      }), Q = G(a.remote, {xdm_e:a.local, xdm_c:a.channel, xdm_p:2}), s(a.props, {src:Q + "#" + a.channel, name:w + a.channel + "_provider"}), h = B(a)) : (a.remoteHelper = a.remote, e.Fn.set(a.channel, d));
      var b = function() {
        var d = q || this;
        H(d, "load", b);
        e.Fn.set(a.channel + "_load", g);
        (function ga() {
          "function" == typeof d.contentWindow.sendMessage ? c() : l(ga, 50)
        })()
      };
      q = B({props:{src:a.local + "#_4" + a.channel}, onLoad:b})
    }, init:function() {
      E(m.onDOMReady, m)
    }}
  };
  e.stack.HashTransport = function(a) {
    function b() {
      if(h) {
        var a = h.location.href, b = "", c = a.indexOf("#");
        -1 != c && (b = a.substring(c));
        b && b != g && (g = b, f.up.incoming(g.substring(g.indexOf("_") + 1), K))
      }
    }
    var f, d, e, m, g, q, h, r, z, K;
    return f = {outgoing:function(b, c) {
      if(r) {
        var f = a.remote + "#" + q++ + "_" + b;
        (d || !z ? r.contentWindow : r).location = f
      }
    }, destroy:function() {
      c.clearInterval(e);
      (d || !z) && r.parentNode.removeChild(r);
      r = null
    }, onDOMReady:function() {
      d = a.isHost;
      m = a.interval;
      g = "#" + a.channel;
      q = 0;
      z = a.useParent;
      K = n(a.remote);
      if(d) {
        s(a.props, {src:a.remote, name:w + a.channel + "_provider"});
        if(z) {
          a.onLoad = function() {
            h = c;
            e = setInterval(b, m);
            f.up.callback(!0)
          }
        }else {
          var Q = 0, ea = a.delay / 50;
          (function fa() {
            if(++Q > ea) {
              throw Error("Unable to reference listenerwindow");
            }
            try {
              h = r.contentWindow.frames[w + a.channel + "_consumer"]
            }catch(c) {
            }
            h ? (e = setInterval(b, m), f.up.callback(!0)) : l(fa, 50)
          })()
        }
        r = B(a)
      }else {
        h = c, e = setInterval(b, m), z ? (r = parent, f.up.callback(!0)) : (s(a, {props:{src:a.remote + "#" + a.channel + new Date, name:w + a.channel + "_consumer"}, onLoad:function() {
          f.up.callback(!0)
        }}), r = B(a))
      }
    }, init:function() {
      E(f.onDOMReady, f)
    }}
  };
  e.stack.ReliableBehavior = function(a) {
    var b, c, d = 0, e = 0, g = "";
    return b = {incoming:function(a, h) {
      var l = a.indexOf("_"), r = a.substring(0, l).split(",");
      a = a.substring(l + 1);
      r[0] == d && (g = "", c && (c(!0), c = null));
      0 < a.length && (b.down.outgoing(r[1] + "," + d + "_" + g, h), e != r[1] && (e = r[1], b.up.incoming(a, h)))
    }, outgoing:function(a, h, l) {
      g = a;
      c = l;
      b.down.outgoing(e + "," + ++d + "_" + a, h)
    }}
  };
  e.stack.QueueBehavior = function(a) {
    function b() {
      if(a.remove && 0 === d.length) {
        ca(c)
      }else {
        if(!e && !(0 === d.length || p)) {
          e = !0;
          var g = d.shift();
          c.down.outgoing(g.data, g.origin, function(a) {
            e = !1;
            g.callback && l(function() {
              g.callback(a)
            }, 0);
            b()
          })
        }
      }
    }
    var c, d = [], e = !0, g = "", p, q = 0, n = !1, r = !1;
    return c = {init:function() {
      y(a) && (a = {});
      a.maxLength && (q = a.maxLength, r = !0);
      a.lazy ? n = !0 : c.down.init()
    }, callback:function(a) {
      e = !1;
      var d = c.up;
      b();
      d.callback(a)
    }, incoming:function(b, d) {
      if(r) {
        var e = b.indexOf("_"), k = parseInt(b.substring(0, e), 10);
        g += b.substring(e + 1);
        0 === k && (a.encode && (g = h(g)), c.up.incoming(g, d), g = "")
      }else {
        c.up.incoming(b, d)
      }
    }, outgoing:function(g, e, h) {
      a.encode && (g = U(g));
      var m = [], l;
      if(r) {
        for(;0 !== g.length;) {
          l = g.substring(0, q), g = g.substring(l.length), m.push(l)
        }
        for(;l = m.shift();) {
          d.push({data:m.length + "_" + l, origin:e, callback:0 === m.length ? h : null})
        }
      }else {
        d.push({data:g, origin:e, callback:h})
      }
      n ? c.down.init() : b()
    }, destroy:function() {
      p = !0;
      c.down.destroy()
    }}
  };
  e.stack.VerifyBehavior = function(a) {
    function b() {
      d = Math.random().toString(16).substring(2);
      c.down.outgoing(d)
    }
    var c, d, g;
    return c = {incoming:function(e, h) {
      var l = e.indexOf("_");
      -1 === l ? e === d ? c.up.callback(!0) : g || (g = e, a.initiate || b(), c.down.outgoing(e)) : e.substring(0, l) === g && c.up.incoming(e.substring(l + 1), h)
    }, outgoing:function(a, b, g) {
      c.down.outgoing(d + "_" + a, b, g)
    }, callback:function(c) {
      a.initiate && b()
    }}
  };
  e.stack.RpcBehavior = function(a, b) {
    function c(a) {
      a.jsonrpc = "2.0";
      e.down.outgoing(h.stringify(a))
    }
    function d(a, b) {
      var g = Array.prototype.slice;
      return function() {
        var d = arguments.length, e, h = {method:b};
        0 < d && "function" === typeof arguments[d - 1] ? (1 < d && "function" === typeof arguments[d - 2] ? (e = {success:arguments[d - 2], error:arguments[d - 1]}, h.params = g.call(arguments, 0, d - 2)) : (e = {success:arguments[d - 1]}, h.params = g.call(arguments, 0, d - 1)), n["" + ++l] = e, h.id = l) : h.params = g.call(arguments, 0);
        a.namedParams && 1 === h.params.length && (h.params = h.params[0]);
        c(h)
      }
    }
    function g(a, b, d, e) {
      if(d) {
        var h, l;
        b ? (h = function(a) {
          h = S;
          c({id:b, result:a})
        }, l = function(a, d) {
          l = S;
          var e = {id:b, error:{code:-32099, message:a}};
          d && (e.error.data = d);
          c(e)
        }) : h = l = S;
        "[object Array]" !== Object.prototype.toString.call(e) && (e = [e]);
        try {
          var k = d.method.apply(d.scope, e.concat([h, l]));
          y(k) || h(k)
        }catch(m) {
          l(m.message)
        }
      }else {
        b && c({id:b, error:{code:-32601, message:"Procedure not found."}})
      }
    }
    var e, h = b.serializer || T(), l = 0, n = {};
    return e = {incoming:function(a, d) {
      var e = h.parse(a);
      if(e.method) {
        b.handle ? b.handle(e, c) : g(e.method, e.id, b.local[e.method], e.params)
      }else {
        var l = n[e.id];
        e.error ? l.error && l.error(e.error) : l.success && l.success(e.result);
        delete n[e.id]
      }
    }, init:function() {
      if(b.remote) {
        for(var c in b.remote) {
          b.remote.hasOwnProperty(c) && (a[c] = d(b.remote[c], c))
        }
      }
      e.down.init()
    }, destroy:function() {
      for(var c in b.remote) {
        b.remote.hasOwnProperty(c) && a.hasOwnProperty(c) && delete a[c]
      }
      e.down.destroy()
    }}
  };
  O.easyXDM = e
})(window, document, location, window.setTimeout, decodeURIComponent, encodeURIComponent);
var promise = function() {
};
promise.prototype = {pending:{resolve:function() {
}, reject:function() {
}}, then:function(c, d) {
  this.pending = {resolve:c, reject:d};
  return this
}, resolve:function(c) {
  this.pending.resolve(c)
}, reject:function(c) {
  this.pending.reject(c)
}};
try {
  addToNamespace("Promise", promise)
}catch(e$$13) {
  throw Error("Cannot extends 'Promise' to 'Adfab.playground.Promise'");
}
;var user = {env:{}, id:null, uid:null, data:{}, urls:{current:window.location.href, prev:null}, init:function() {
  PG.Util.GenerateUniqueId();
  PG.User.urls.prev = PG.Util.readCookie("prev-url");
  var c = PG.Util.readCookie("authent"), d = PG.Util.readCookie("last-sync"), g = (new Date).getTime(), c = null;
  if(!PG.Util.not_null(d) || parseInt(d, 10) + 86400 < g) {
    c = null
  }
  PG.Util.not_null(c) ? (PG.User.data = JSON.parse(PG.Util.readCookie("authent")), PG.User.checkUser()) : PG.User.loadAuthent().then(function() {
    PG.User.checkUser()
  })
}, isLogged:function() {
  var c;
  if("" === PG.User.id || null === PG.User.id) {
    PG.User.id = PG.Util.readCookie("login")
  }
  c = PG.Util.not_null(PG.User.id) ? !0 : !1;
  PG.Util.log("isLogged : " + c);
  return c
}, loadAuthent:function() {
  var c = new PG.Promise;
  PG.App.call(PG.Config.env[PG.Config.mode].connect).then(function(d) {
    PG.User.data = d;
    PG.Util.createCookie("last-sync", (new Date).getTime());
    PG.Util.createCookie("authent", JSON.stringify(d));
    c.resolve()
  });
  return c
}, checkUser:function() {
  PG.User.isLogged() && PG.Util.not_null(PG.Util.readCookie("logout-try")) ? PG.Util.not_null(PG.User.data.library.stories.logout_user) && (PG.Util.not_null(PG.User.data.library.stories.logout_user.events.after) && PG.User.checkStory(PG.User.data.library.stories.logout_user.events.after)) && PG.User.logout() : !PG.User.isLogged() && PG.Util.not_null(PG.Util.readCookie("login-try")) ? PG.Util.not_null(PG.User.data.library.stories.login_user) && (PG.Util.not_null(PG.User.data.library.stories.login_user.events.after) && 
  PG.User.checkStory(PG.User.data.library.stories.login_user.events.after)) && PG.User.login(PG.Util.readCookie("login-try")) : !PG.User.isLogged() && PG.Util.not_null(PG.Util.readCookie("login")) ? PG.User.login(PG.Util.readCookie("login")) : PG.User.isLogged() && PG.User.logout();
  PG.Util.eraseCookie("logout-try");
  PG.Util.eraseCookie("login-try");
  PG.App.trackAreaEvent();
  PG.App.send(window.location.href)
}, login:function(c) {
  PG.Util.log('Login "' + c + '"');
  PG.Util.not_null(c) && (PG.User.id = c, PG.Util.createCookie("login", c));
  return PG.User.data.id
}, logout:function() {
  PG.Util.log("User is out");
  PG.Util.eraseCookie("login");
  PG.User.id = null
}, checkStory:function(c) {
  var d = !1;
  PG.Util.not_null(c) && (PG.Util.not_null(c.url) && PG.Util.not_null(c.xpath) && PG.Util.matchUrl(c.url) && PG.Util.checkXpath(c.xpath) ? d = !0 : PG.Util.not_null(c.url) && PG.Util.matchUrl(c.url) && !PG.Util.not_null(c.xpath) ? d = !0 : PG.Util.not_null(c.xpath) && (PG.Util.checkXpath(c.xpath) && !PG.Util.not_null(c.url)) && (d = !0));
  return d
}, getStory:function(c, d, g, l) {
  c = {user:{anonymous:PG.User.uid}, objects:{}, action:d, url:c, apiKey:PG.Settings.apiKey};
  PG.User.isLogged() && (c.user.login = PG.User.id);
  PG.Util.not_null(g) && (c.objects = {id:g.id}, PG.Util.not_null(g.properties) && (0 < g.properties.length && PG.Util.not_null(g.properties[0].xpath) && PG.Util.not_null(g.properties[0].name) && PG.Util.not_null(PG.Util.getObjectFromXpath(g.properties[0].xpath)[0])) && (c.objects.properties = {name:g.properties[0].name, value:PG.Util.getValueFromObject(PG.Util.getObjectFromXpath(g.properties[0].xpath)[0])}));
  return c
}, quit:function() {
  var c;
  PG.Util.createCookie("prev-url", window.location.href);
  PG.User.isLogged() ? PG.Util.not_null(PG.User.data.library.stories.logout_user) && PG.Util.not_null(PG.User.data.library.stories.logout_user.events.before) && PG.User.checkStory(PG.User.data.library.stories.logout_user.events.before) && (PG.User.getStory(window.location.href, "logout_user", PG.User.data.library.stories.logout_user.objects), PG.Util.createCookie("logout-try", "true")) : PG.Util.not_null(PG.User.data.library.stories.login_user) && PG.Util.not_null(PG.User.data.library.stories.login_user.events.before) && 
  PG.User.checkStory(PG.User.data.library.stories.login_user.events.before) && (c = PG.User.getStory(window.location.href, "login_user", PG.User.data.library.stories.login_user.objects), PG.Util.not_null(c.objects.properties.value) && PG.Util.createCookie("login-try", c.objects.properties.value))
}};
try {
  addToNamespace("User", user)
}catch(e$$14) {
  throw Error("Cannot extends 'User' to 'Adfab.playground.User'");
}
;function App() {
  return this
}
App.prototype.init = function() {
  PG.Util.not_null(PG.Settings) && PG.Util.not_null(PG.Settings.apiKey) ? (PG.Util.log("APIKEY FOUND \x3d " + PG.Settings.apiKey), PG.App.easyXDM(), PG.App.bindEvent(), PG.User.init(), PG.Util.fireEvt("earsReady", window, {apiKey:PG.Settings.apiKey, uid:PG.User.uid, login:PG.User.id})) : PG.Util.log("NO APIKEY FOUND")
};
App.prototype.bindEvent = function() {
  var c, d, g;
  c = PG.Cache.xmlhttp.prototype.open;
  d = PG.Cache.xmlhttp.prototype.send;
  PG.Cache.xmlhttp.prototype.open = function(d, h) {
    d || (d = "");
    h || (h = "");
    c.apply(this, arguments);
    g = d;
    "get" == d.toLowerCase() && h.split("?")
  };
  PG.Cache.xmlhttp.prototype.send = function(c, h) {
    c || (c = "");
    h || (h = "");
    d.apply(this, arguments);
    g.toLowerCase()
  };
  PG.Cache.document.onreadystatechange = function(c) {
    PG.Util.not_null(c.data)
  };
  PG.Cache.window.onbeforeunload = function(c) {
    PG.User.quit();
    return null
  }
};
App.prototype.trackAreaEvent = function() {
  function c(c, d) {
    var g = PG.User.getStory(window.location.href, d.action, d.objects), t = PG.Util.getObjectFromXpath(d.event.area.xpath), F, A;
    if("undefined" === typeof d.event.area.width || !PG.Util.not_null(d.event.area.width)) {
      if(!PG.Util.not_null(t[0])) {
        return
      }
      d.event.area.width = t[0].offsetWidth;
      d.event.area.height = t[0].offsetHeight
    }
    if("undefined" === typeof d.event.area.x || !PG.Util.not_null(d.event.area.y)) {
      d.event.area.x = 0, d.event.area.y = 0
    }
    A = PG.Util.getOffset(t[0]);
    F = {x:d.event.area.x + A.x, y:d.event.area.y + A.y, width:d.event.area.width, height:d.event.area.height};
    "undefined" !== typeof d.event.area.debug && !0 === d.event.area.debug && PG.Util.createShape(F);
    c.addEventListener(d.event.type, function(c) {
      c.preventDefault();
      g.objects.x = c.pageX;
      g.objects.y = c.pageY;
      g.objects.text = window.getSelection().toString();
      if(!PG.Util.not_null(d.event.area.text) || !("" !== d.event.area.text && g.objects.text !== d.event.area.text)) {
        return PG.Util.not_null(t) && PG.Util.pointOnBox(g.objects, F) && PG.App.sendToEXDM({url:PG.Cache.protocol + PG.Config.env[PG.Config.mode].send, method:"POST", data:g, headers:{"Content-Type":"application/json; charset\x3dutf-8"}}), !1
      }
    })
  }
  var d, g;
  for(d in PG.User.data.library.stories) {
    g = PG.User.data.library.stories[d], PG.User.checkStory(g.conditions) && PG.Util.not_null(g.event) && c(PG.Util.getObjectFromXpath(g.event.xpath)[0], g)
  }
};
App.prototype.easyXDM = function() {
  PG.App.rpc = new easyXDM.Rpc({local:PG.Cache.protocol + PG.Config.env[PG.Config.mode].nameTransport, swf:PG.Cache.protocol + PG.Config.env[PG.Config.mode].easySwf, remote:PG.Cache.protocol + PG.Config.env[PG.Config.mode].remote}, {remote:{request:{}}})
};
App.prototype.send = function(c) {
  var d = PG.Cache.protocol + PG.Config.env[PG.Config.mode].send, g, l;
  if(!PG.Util.isUrlValid(c)) {
    return!1
  }
  for(l in PG.User.data.library.stories) {
    g = PG.User.data.library.stories[l], PG.User.checkStory(g.conditions) && "undefined" === typeof g.event && (g = PG.User.getStory(c, g.action, g.objects), PG.App.sendToEXDM({url:d, method:"POST", data:g, headers:{"Content-Type":"application/json; charset\x3dutf-8"}}))
  }
  return!0
};
App.prototype.sendToEXDM = function(c) {
  PG.App.rpc.request(c, function(c) {
  }, function(c) {
    throw"Api Error, code : " + c.code + ", msg : " + c.message;
  })
};
App.prototype.call = function(c) {
  var d = new PG.Promise;
  PG.Util.log("call service : " + PG.Cache.protocol + c + "?apiKey\x3d" + PG.Settings.apiKey);
  PG.App.rpc.request({url:PG.Cache.protocol + c + "?apiKey\x3d" + PG.Settings.apiKey}, function(c) {
    d.resolve(JSON.parse(c.data))
  }, function(c) {
    throw"Api Error, code : " + c.code + ", msg : " + c.message;
  });
  return d
};
var app = new App;
try {
  addToNamespace("App", app)
}catch(e$$18) {
  throw Error("Cannot extends 'app' to 'Adfab.playground.App'");
}
app.init();