// Type: Javascript Document
// Author: Justin DeMaris
// Purpose: Handles all of the AJAX stuff for updating different parts of the web-site dynamically.

// The handle we use for sending the request
var request = false;
try 
{
	request = new XMLHttpRequest();
} 
catch (trymicrosoft) 
{
	try 
	{
		request = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (othermicrosoft) 
	{
		try 
		{
			request = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (failed) 
		{
			request = false;
		}
	}
}

function quote()
{
	// Get the new text to put into the entry
	var url = "ajax.php?act=quote";
	request.open("GET", url, true);
	request.onreadystatechange = quoteChg;
	request.send(null);
}

function quoteChg()
{
	// If the request is completed and successful..... do stuff
	if(request.readyState == 4 && request.status == 200)
	{
		// Grab the results
		var response = request.responseText;
	
		// Get access to the text content
		var txt = document.getElementById("quotetext");
		
		// Update it to the new text
		txt.innerHTML = "'"+response+"'";
	}
}

function calendar(month, year)
{
	var url = "cal.php?month="+month+"&year="+year;
	request.open("GET", url, true);
	request.onreadystatechange = chgCalendar;
	request.send(null);
}

function chgCalendar()
{
	// If the request is completed and successful..... do stuff
	if(request.readyState == 4 && request.status == 200)
	{
		// Grab the results
		var response = request.responseXML;

		// Get access to the text content
		var txt = document.getElementById("calDiv");

		// Update it to the new text
		txt.innerHTML = request.responseText;
	}
}
