function DTAjax() {
}

DTAjax.call = function(service, func, data, successCallback, errorCallback) {

    if (data == null)
        data = "{}";
    $.ajax(
            {
                type: "POST",
                url: service + "/" + func,
                data: data,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(result) {
                    successCallback(result);
                },
                error: function(error) {
                    errorCallback(errorCallback);
                }
            });
}

DTAjax.toJSONString = function(str) {
    return str.replace(/'/g, "&#039;").replace(/\\/g, "\\\\");
}
DTAjax.fromJSONString = function(str) {
    return str.replace(/&#039;/g, "'");
}

DTAjax.getContent = function(name, arguments, callback, afterJsCallback) {

    var argumentsStr = "";
    for (key in arguments) {
        argumentsStr += key + ":" + arguments[key] + ",";
    }
    if (argumentsStr.length > 0)
        argumentsStr = argumentsStr.substr(0, argumentsStr.length - 1);

    DTAjax.call("/WebServices/Content.asmx", "GetContent", "{name: '" + name + "', args: '" + argumentsStr + "'}",
                function(result) {
                    callback(result.d);
                    eval(result.d.js);
                    try {
                        afterJsCallback();
                    } catch (ex) {
                    }
                },
                function(error) {

                });
}