// JSONRequest.js
//
// A helper object for creating JSON requests against thePlatform ACS Server
//
// Copyright (c) 2010 thePlatform for Media, Inc.

(function() {
    var a = false,
    b = /xyz/.test(function() {
        xyz
    }) ? /\b_super\b/: /.*/;
    this.Class = function() {};
    Class.extend = function(g) {
        var f = this.prototype;
        a = true;
        var e = new this();
        a = false;
        for (var d in g) {
            e[d] = typeof g[d] == "function" && typeof f[d] == "function" && b.test(g[d]) ? (function(h, k) {
                return function() {
                    var m = this._super;
                    this._super = f[h];
                    var l = k.apply(this, arguments);
                    this._super = m;
                    return l
                }
            })(d, g[d]) : g[d]
        }
        function c() {
            if (!a && this.init) {
                this.init.apply(this, arguments)
            }
        }
        c.prototype = e;
        c.constructor = c;
        c.extend = arguments.callee;
        return c
    }
})();

var tpJsonContexts = new Object();
function tpRegisterJsonContext(b) {
    var a = (((1 + Math.random()) * 65536) | 0).toString(16).substring(1);
    tpJsonContexts[a] = b;
    return a
}
function tpJSONLoaderCallback(b, a) {
    tpJsonContexts[a](b)
}
JSONLoader = Class.extend({
    init: function() {},
    load: function(d, h, f, g, b) {
        if (!f) {
            f = "callback"
        }
        if (!b) {
            b = "context"
        }
        if (!g) {
            g = "tpJSONLoaderCallback"
        }
        var e = tpRegisterJsonContext(function() {
            h(arguments[0])
        });
        if (d.indexOf("?") >= 0) {
            d += "&" + f + "=" + g + "&" + b + "=" + e
        } else {
            d += "?" + f + "=" + g + "&" + b + "=" + e
        }
        var a = document.getElementsByTagName("head")[0];
        var c = document.createElement("script");
        c.type = "text/javascript";
        c.src = d;
        a.appendChild(c)
    }
});

