
function GetXmlHttpObject(handler)  
{  
	var objXMLHttp=null  
	if (window.XMLHttpRequest)  
	{  
		objXMLHttp=new XMLHttpRequest()  
	}  
	else if (window.ActiveXObject)  
	{  
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")  
	}  
	return objXMLHttp  
}  

var radiostatus = "calendar";

function toggleEvent(radio,era)
{
	//when the radio button changes to tha calendar, set it as the inline frame
	if (radio == "calendar" /*&& radiostatus != "calendar"*/)
	{
		document.getElementById("maincalendar").innerHTML = '<iframe src="event_calendar.php" style="width: 100%; height: 500px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0"/>';
		radiostatus = "calendar";
	}
	//when you choose list, go fetch a list of events.
	else if (radio == "list" /*&& radiostatus != "list" */)
	{
		xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)  {  alert ("Browser does not support HTTP Request");  return; }  
		
		if (era)
			url="ajax/eventlist.php?Era=" + era;
		else 
			url="ajax/eventlist.php";
			
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4 && xmlHttp.status==200)
			{
				//alert(xmlHttp.responseText);
				document.getElementById("maincalendar").innerHTML = xmlHttp.responseText;

			}
		} 
		
		xmlHttp.open("GET",url,true);  
		xmlHttp.send(null);
		radiostatus = "list";
	}
	
}

function fillevent(id,calledby)
{
	

	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)  {  alert ("Browser does not support HTTP Request");  return; }  
	
		url="ajax/eventinfo.php?id=" + id;


	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 && xmlHttp.status==200)
		{
			//alert(xmlHttp.responseText);
			if (calledby == "list")
				document.getElementById("maineventinfo").innerHTML = xmlHttp.responseText;
			else
				parent.document.getElementById("maineventinfo").innerHTML = xmlHttp.responseText;

		}
	} 
	
	xmlHttp.open("GET",url,true);  
	xmlHttp.send(null);

}

