function AvailabilityCalendarConnection(targetWidget) {
	this.ajaxChannel = null;
	this.target = targetWidget;
	this.init();
}

AvailabilityCalendarConnection.prototype.setAjaxChannel = function(newAjaxChannel) {
	this.ajaxChannel = newAjaxChannel;
}

AvailabilityCalendarConnection.prototype.getResponse = function() {
	return this.ajaxChannel.responseText;
}

AvailabilityCalendarConnection.prototype.init = function() {
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		this.setAjaxChannel(new XMLHttpRequest());
	}
	else { // IE
		try {
			this.setAjaxChannel(new ActiveXObject("Msxml2.XMLHTTP"));
		}
		catch (e) {
			try {
				this.setAjaxChannel(new ActiveXObject("Microsoft.XMLHTTP"));
			}
			catch (e2) {
			}
		}
	}
}

AvailabilityCalendarConnection.prototype.stateChangeEventListener = function() {
}

AvailabilityCalendarConnection.prototype.onReady = function(targetWidget, ajaxResponse, objectResponse) {
}

AvailabilityCalendarConnection.prototype.onError = function(targetWidget, ajaxResponse) {
	/*window.document.write('<div><h1>Error ' + ajaxResponse.status + '</h1></div>' + ajaxResponse.responseText);
	window.document.close();*/
}

AvailabilityCalendarConnection.prototype.connect = function(targetURL, methodType) {
	if (this.ajaxChannel.overrideMimeType) {
	}
	this.ajaxChannel.open(methodType, targetURL, true);
	if (methodType == 'POST') {
		this.ajaxChannel.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	}
	var thisObject = this;
	this.ajaxChannel.onreadystatechange = function() {
		if (this.readyState == 4) {
			if (this.status == 200) {
				var objectResponse = null;
				//alert(this.responseText);

				try {
					objectResponse = JSON.parse(this.responseText);
				}
				catch (e) {
				}
				thisObject.onReady(thisObject.target, this, objectResponse);
			}
			else {
				thisObject.onError(thisObject.target, this);
			}
		}
		else {
		}
	}
}

AvailabilityCalendarConnection.prototype.send = function(operation, object) {
	if (object != null) {
		var strToSend = JSON.stringify(object);
		this.ajaxChannel.send('__submited_action=' + operation + '&json=' + strToSend);
	}
	else {
		this.ajaxChannel.send(null);
	}
}