
function createajaxrequest()
{
	var req=null;
	
	try
	{
		req=new XMLHttpRequest();    
	}
	catch (e)
	{
		try
		{      
			req=new ActiveXObject("Msxml2.XMLHTTP");      
		}
		catch (e)
		{      
			try
			{        
				req=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			
			catch (e)
			{        
				alert("Your browser does not support AJAX!");
				return false;        
			}      
		}    
	}
	
	return req;
}

function calnavigate(month,year,day) 
{
	var url = "calendar.php?month="+month+"&year="+year;

	req=createajaxrequest();
	if (req==null) return false;
			
	req.open("GET", url, true);
	
	req.onreadystatechange = function()
	{
		if(req.readyState == 4) 
		{
			if(req.status == 200) 
			{
				response = req.responseText;
				document.getElementById("caldiv").innerHTML = response;
				
//				calloadevent(month,year,0);
			} 
			else 
			{
				alert("An error has occurred :\n" + req.statusText);
			}
		}
	}
	
	req.send(null);
}

function calselectday(day,month,year) 
{
	var url = "calendar.php?day="+day+"&month="+month+"&year="+year;
	
	req=createajaxrequest();
	if (req==null) return false;
			
	req.open("GET", url, true);
	
	req.onreadystatechange = function()
	{
		if(req.readyState == 4) 
		{
			if(req.status == 200) 
			{
				response = req.responseText;
				document.getElementById("caldiv").innerHTML = response;
				
//				calloadevent(day,month,year);
			} 
			else 
			{
				alert("An error has occurred :\n" + req.statusText);
			}
		}
	}
	
	req.send(null);
}

/*function calloadevent(day,month,year) 
{
	var url = "loadevent.php?day="+day+"&month="+month+"&year="+year;
	
	req=createajaxrequest();
	if (req==null) return false;
			
	req.open("GET", url, true);
	
	req.onreadystatechange = function()
	{
		if(req.readyState == 4) 
		{
			if(req.status == 200) 
			{
				response = req.responseText;
				document.getElementById("eventdiv").innerHTML = response;
			} 
			else 
			{
				alert("An error has occurred :\n" + req.statusText);
			}
		}
	}
	
	req.send(null);
}*/

