function onLoad ()
{
	var today = new Date ();	//	Let's start off with this month's calendar
	LoadCalendar (today.getMonth()+1, today.getFullYear ());
}

function LoadCalendar (mm, yy)
{
	var	src = '/EventXml.php?Month='+mm+'&Year='+yy;
	var	xml = loadXMLDoc (src, false);	//	Load XML synchronously
	var	thumb = loadXMLDoc ('/XSL/CalThumb.xsl', false);	//	Could just keep a copy of these XSL files
	
	var	result, dest;
	
	result = XSLTransform (xml, thumb);
	dest  = document.getElementById ('thumbnail');
	if  (typeof result == 'string')
		dest.innerHTML = result;
	else
		dest.replaceChild (result, dest.firstChild);
}

function onDateChanged ()
{
	LoadCalendar (document.getElementById ('mm').value, document.getElementById ('yy').value); 
}

/*	XSL transform call */

function XSLTransform (xml, xsl)
{
	// code for IE
	if (window.ActiveXObject)
	{
		return xml.transformNode(xsl);
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		xsltProcessor=new XSLTProcessor();
		xsltProcessor.importStylesheet(xsl);
		return xsltProcessor.transformToFragment(xml,document);
	}
}

/*
	Ajax functions - use these or replace the calls with your own
*/
function Ajax ()
{
	try {return new XMLHttpRequest();} catch (e) {};		// Firefox, Opera 8.0+, Safari
	try {return new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {};	// Internet Explorer
	try {return new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {};
	return null;
}

function loadXMLDoc(dname, bAsync)
{
	var	ajax = Ajax ();
	
	if  (bAsync)
		ajax.onreadystatechange= function() {AjaxDone(ajax);};

	ajax.open("GET",dname,bAsync);
	ajax.send("");
	
	return bAsync ? true : ajax.responseXML;
}

/*
	Not used for synchronous commands but this is what the async callback looks like
*/
function AjaxDone (ajax)
{
}

