function getCalendar(div, ice){
	loadCalendarXMLData("_data/getCalendar.php" + (ice == true ? "?type=ice" : "?type=private"), div);
}

function getCFSCalendar(div, ice){
	loadCalendarXMLData("_data/getCFSCalendar.php" + (ice == false ? "?type=ice" : "?type=private"), div);
}

function loadCalendarXMLData(url, div) {
	new Ajax.Request(url, {
		method: 'post',
		onSuccess: function(transport) {
			if(transport.responseXML.firstChild.firstChild.nodeValue == "none"){
				$(div).innerHTML = "There are no courses scheduled at this time.";
			} else {
				//build HTML formatted output
				var calendarTable = '<table class="calendarTable" width="95%">';
				var monthCount = transport.responseXML.firstChild.childNodes.length;
				//loop through months, build month sections
				for(var i = 0; i < monthCount; ++i){
					calendarTable += '<tr class="monthRow">';
					calendarTable += '<td colspan="3">' + transport.responseXML.firstChild.childNodes[i].getAttribute('name') + '</td>';
					calendarTable += '</tr>';
					var courseCount = transport.responseXML.firstChild.childNodes[i].childNodes.length;
					var rowType = "oddRow";
					//loop through courses in current month, build course entries
					for(var j = 0; j < courseCount; ++j){
						calendarTable += '<tr class="' + rowType + '">';
						calendarTable += '<td class="leftCol">' + transport.responseXML.firstChild.childNodes[i].childNodes[j].childNodes[1].firstChild.nodeValue + '</td>';
						calendarTable += '<td><a href="javascript:getDetailsPopup(' + transport.responseXML.firstChild.childNodes[i].childNodes[j].childNodes[0].firstChild.nodeValue + ')">';
						calendarTable += transport.responseXML.firstChild.childNodes[i].childNodes[j].childNodes[2].firstChild.nodeValue + '</a></td>';
						calendarTable += '<td>'+transport.responseXML.firstChild.childNodes[i].childNodes[j].childNodes[3].firstChild.nodeValue+'</td>';
						calendarTable += '</tr>';
						if(rowType == "oddRow"){
							rowType = "evenRow";
						} else {
							rowType = "oddRow";
						}
					}
				}
				calendarTable += '</table>';
				//write formatted HTML to page
				$(div).innerHTML = calendarTable;
			}
		}
	});
}