
/* Create a new XMLHttpRequest object to talk to the Web server */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
@end @*/

if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function showEvent(divid)
{ document.getElementById(divid).style.display='block'; }

function hideEvent(divid)
{ document.getElementById(divid).style.display='none'; }

function closeAll(numevents)
{
	for (var i=0; i<=numevents; i++)
	{
		divid='event_'+i;
		//alert(divid);
		document.getElementById(divid).style.display='none';
	}
}

function pageprocess(page) {
    var response = xmlHttp.responseText;
    document.getElementById(page).innerHTML = response;
   	showEvent(page);
}

function show_events(month, day, year)
{
	var divid="event_viewer_div";
	document.getElementById(divid).innerHTML = "";	//Clear it first;
	// Build the URL to connect to
	var url = "ajax/showEvents.php?m="+escape(month)+"&d="+escape(day)+"&y="+escape(year);
	// Open a connection to the server
	xmlHttp.open("GET", url, true);
	// Setup a function for the server to run when it's done
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
		  pageprocess(divid)
		}
	}
	// Send the request
	xmlHttp.send(null);
}