if (typeof $Client == "undefined") var $Client = {
  	req: function(service, method, params, callback) {
		adata = { jsonrpc: "2.0", method: method, params: params, id: Math.floor(Math.random() * 100) };
		jdata = $.toJSON(adata);
		service = $Config.api_base_path + "s.php?service=" + service;
		$.ajax({
			url: service,
			type: "POST",
			contentType: "application/json-rpc",
			data: jdata,
			processData: false,
			success: function(data) {
                if ($Client.chkPost(data)) {
                    data = $Client.decode(data);
					callback(data.result);
				}
			},
			error: function(data) {
			}
		});
  	},

	chkPost: function(data) {
		data = $Client.decode(data);
		if (data.error) {
            alert("we're sorry, an exception was thrown");
            return false;
		}
		return true;
	},
	decode: function(jdata) {
		jdata = jdata.replace('Array{', '{'); // what's this problem about?
		data = $.evalJSON(jdata);
		return data;
	}
}

