
function ajax_class()	// JAVASCRIPT
{
	this.loadAddresses = function()
	{
		loadAddresses();
	}

} // end of class

/*
 * Encapsulating the XMLHttpRequest within the ajax_class object 
 * causes it to throw an error that I haven't been able to resolve. 
 * Solution: Keep the class (for the sake of organization) that 
 * calls web-page level global javascript functions that are 
 * declared beneath in this file.
 */

function createRequestObject()
{
	var objAjax;

	try 
	{ objAjax = new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
	catch (e)
	{
		try
		{ objAjax = new ActiveXObject("Msxml2.XMLHTTP"); } // Internet Explorer
		catch (e)
		{ objAjax = ActiveXObject("Microsoft.XMLHTTP"); }
	}

	return objAjax;
}

function handleResponse()
{         
	if (ajax.readyState == 4)
	{
		// performs these functions once the AJAX is finished
		// REQUIRES EXTERNAL SECURITY (OUTSIDE OF THIS APPLICATION)
		// EXECUTES JAVASCRIPT CODE RETURNED FROM THE PHP FILE
		eval(ajax.responseText);  	
	}
}

var ajax = createRequestObject();

function loadAddresses()
{
	var toSend = 'act=loadAddresses&pid=x';
	ajax.open('POST', './ajax.php?' + toSend, true);
	ajax.onreadystatechange = handleResponse;
	ajax.send(null);
}


