/*****************************************************************************
**		 __      __  ____     ____     __  __  ________   ________      	**
**		/\ \  __/\ \/\  _`\  /\  _`\  /\ \/\ \/\_____  \ /\_____  \    		**
**		\ \ \/\ \ \ \ \ \L\ \\ \ \L\ \\ \ \ \ \/____//'/'\/____//'/'   		**
**		 \ \ \ \ \ \ \ \  _ <'\ \  _ <'\ \ \ \ \   //'/'      //'/'    		**
**		  \ \ \_/ \_\ \ \ \L\ \\ \ \L\ \\ \ \_\ \ //'/'___   //'/'___  		**
**		   \ `\___x___/\ \____/ \ \____/ \ \_____\/\_______\ /\_______\		**
**			'\/__//__/  \/___/   \/___/   \/_____/\/_______/ \/_______/		**
**																			**
**	This site created by Drew Loomer for the West Bloomfield Township 		**
**	Public Library Youth Department.  										**
**	Completed on 9-14-2009													**
**	loomerdr@wblib.org														**
**	Sorry about the lame ASCII art - it was just too tempting...			**
**																			**
**	This page holds the AJAX that is used when a user mouses over a games	**
**	thumbnail.  The replaceContent function gets some information on the 	**
**	selected ID and then returns that.										**
**																			**
*****************************************************************************/


//Global Variables
var xmlhttp;
var destination;


//Replace the information in the target div with that of another
function replaceContent (source, dest)
{
	//Create the XML Object
	xmlhttp = getXmlHttpObject();

	//If the browser doesn't support XMLHTTP, tell them their browser is too old
	if (xmlhttp == null)
	{
		document.writeln("Your browser is too old to support this list.");
		return;
	}
	
	//Call our php script
	var url = "get_game.php";
	url = url + "?gid=" + source;
	url = url + "&sid=" + Math.random();
	
	
	//Global destination variable
	destination = dest;
	

	xmlhttp.onreadystatechange = stateChanged;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}



//Function to determine which XML request to use.
function getXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	return null;
}



function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		var rep = document.getElementById(destination);
		rep.innerHTML = xmlhttp.responseText;	
	}
}

