if(typeof fly == "undefined")
{
	var fly = new Object();
};

fly.CFCProxyJSON = function()
{
};

fly.CFCProxyJSON.prototype = 
{
	init: function(id_str, callback_obj) 
	{
		this._initCallback = callback_obj;

		var newCallback_obj = 
		{
			success: this._settingsLoadResult,
			failure: this._settingsLoadError,
			scope: this
		};
		YAHOO.util.Connect.asyncRequest("GET", "/cfSettings.cfm?UUID=" + id_str + "&JSON", newCallback_obj);
	},
	
	_settingsLoadResult: function(o)
	{
		this._settingsLoaded(o);
		this._initCallback.success(o);
	},
	
	_settingsLoadFailure: function(o)
	{
		this._initCallback.failure(o);
	},

	_settingsLoaded: function(o)
	{
		this._settings_obj = eval("(" + o.responseText + ")");
	},
		
	getService: function(service_str)
	{
		var service = new fly.CFCProxyJSONService(service_str, this._settings_obj.cfcProxy.username, this._settings_obj.cfcProxy.password);
		
		return service;	
	}
};

fly.CFCProxyJSONService = function(service_str, username_str, password_str)
{
	this._service_str = service_str;
	this._username_str = username_str;
	this._password_str = password_str;
	
	this._arguments_str = "method=execMethod";
	this._arguments_str += "&username=" + this._username_str;
	this._arguments_str += "&password=" + this._password_str;
	this._arguments_str += "&execMethodPath=" + this._service_str;
};

fly.CFCProxyJSONService.prototype = 
{
	callMethod: function(method_str, callback, arguments_obj)
	{
		var arguments_str = this._arguments_str;
		arguments_str += "." + method_str;
		if (arguments_obj)
		{
			arguments_str += "&execMethodArguments=" + arguments_obj.toJSONString();
		};
		
		YAHOO.util.Connect.asyncRequest("POST", "/CFCProxyJSON.cfc", callback, arguments_str)
	}
};


