///////////////////////////////////////////////////////////////
// Utility Functions
///////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
//
// InitAjax()
//
// This function initializes the ajaxRequest object used by 
// nearly every other function.  It performs the appropriate 
// logic to determine the user's browser and loads the object 
// accordingly.
//
///////////////////////////////////////////////////////////////

function InitAjax()
{
	var ajaxRequest;
	
	try
	{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	}
	catch (e)
	{
	// Internet Explorer Browsers
		try
		{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	
	return ajaxRequest;
}

///////////////////////////////////////////////////////////////
//
// $(id)
//
// This is just a fast way to call document.getElementById() 
// and is more for convenience than anything else.
//
///////////////////////////////////////////////////////////////

function $(id)
{
	return document.getElementById(id);
}

///////////////////////////////////////////////////////////////
// News Page Functions
///////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
//
// ajaxLoadNews()
//
// This function loads the output of news.php into the div
// 'contentMain' and is invoked when a user clicks the news
// button on the flash navigation bar.
//
/////////////////////////////////////////////////////////////// 

function loadContent(id, page){
	var ajaxRequest = InitAjax();  // The variable that makes Ajax possible!
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4)
		{
			var mainDiv = $(id);
			if (mainDiv)
			{
				mainDiv.innerHTML = ajaxRequest.responseText;
			}
			else
			{
				alert("Failed");
			}
		}
	}
	ajaxRequest.open("GET", page, true);
	ajaxRequest.send(null);
}

