var calendarUrl = "/log/calendar.mhtml?year=";

function getCalendar(month,year) {
	var targetUrl = calendarUrl + year + '&mon=' + month;
	http.open("GET", targetUrl, true);
	http.onreadystatechange = handleCalendarResponse;
	http.send(null);
}

function handleCalendarResponse() {
	if (http.readyState == 4 && http.responseText) {
		var newCal = http.responseText;
		updateCalendar(newCal);
	}
}

function updateCalendar(newCal) {
	document.getElementById("cal").innerHTML = newCal;
}


function getHTTPObject() {
	var xmlhttp = null;
	var success = false;
	// List of MS XMLHTTP versions - newest first
	var MSXML_XMLHTTP_PROGIDS = new Array(
						'MSXML2.XMLHTTP.5.0',
						'MSXML2.XMLHTTP.4.0',
						'MSXML2.XMLHTTP.3.0',
						'MSXML2.XMLHTTP',
						'Microsoft.XMLHTTP'
						);
	// test for IE implementations first
	for (var i = 0; i < MSXML_XMLHTTP_PROGIDS.length &&
		 !success; i++) {
		try  {
			xmlhttp = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
			success = true;
			return xmlhttp;
		}
		catch (e) {
			xmlhttp = false;
		}
	}
	
	// Now test for non-IE implementations
	if (!xmlhttp &&
		typeof XMLHttpRequest != 'undefined')  {
		try {
			xmlhttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

http = getHTTPObject(); // We create the HTTP Object

