/**
 * サーバとの通信を行うクラス
 * prototype.js 必須
 */
function Class_Communicator() {
	this.targetUrl = "";
	this.frmName   = "";
	this.callback  = null;
}

Class_Communicator.prototype.setFormName = function(frmName) {
	this.frmName = frmName;
}

Class_Communicator.prototype.setTargetUrl = function(targetUrl) {
	this.targetUrl = targetUrl;
}

Class_Communicator.prototype.setCallback = function(callback) {
	this.callback = callback;
}

Class_Communicator.prototype.exec = function(event, syncFlg) {
	asyncFlg = (syncFlg) ? false : true;

	if (this.frmName != "") {
		var ajaxReq = new Ajax.Request(
			this.targetUrl,
			{
				method: 'post',
				parameters: Form.serialize(this.frmName),
				asynchronous: asyncFlg,
				onComplete: this.callback
			}
		);
	} else {
		var ajaxReq = new Ajax.Request(
			this.targetUrl,
			{
				method: 'post',
				asynchronous: asyncFlg,
				onComplete: this.callback
			}
		);
	}
	if (syncFlg) {
		this.callback(ajaxReq.transport);
	}
	return false;
}