var xmlhttp = false;

function createxmlhttp() {
	xmlhttp = false;
	try
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			xmlhttp = false;
		}
	}

	if(!xmlhttp && typeof XMLHttpRequest !='undefined') {
		try
		{
			xmlhttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlhttp = false;
		}
	}

	if(!xmlhttp && window.createRequest) {
		try
		{
			xmlhttp = window.createRequest();
		}
		catch (e)
		{
			xmlhttp = false;
		}
	}

}

createxmlhttp();

var response;

function update_cal(m, y) {
	if(xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState==4) {
				response = xmlhttp.responseText;
				$("#cal_div2").slideUp(500, function() {
					document.getElementById('cal_div2').innerHTML = response;
					$("#cal_div2").slideDown(500);
				});
				xmlhttp.close;
				createxmlhttp();
			}
		}
		var params = "";
			params += "?m=" + escape(m);
			params += "&y=" + escape(y);
		xmlhttp.open("GET", '/calendar.php'+params, true);
		xmlhttp.send(null);
	}
}

function updateEvent(m, d, y) {
	if(xmlhttp) {
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState==4) {
				response = xmlhttp.responseText;
				$("#cal_event_div").slideUp(500, function() {
					document.getElementById('cal_event_div').innerHTML = response;
					$("#cal_event_div").slideDown(500);
				});
				xmlhttp.close;
				createxmlhttp();
			}
		}
		var params = "";
			params += "?m=" + escape(m);
			params += "&d=" + escape(d);
			params += "&y=" + escape(y);
		xmlhttp.open("GET", '/events.php'+params, true);
		xmlhttp.send(null);
	}
}

function closeCalEvent() {
	$("#cal_event_div").slideUp(500);
}