// Array to hold the retunred ajax info - kind a local cache, so we dont need to look up again
var ajaxGameArray=new Array();
var ajaxMovieArray=new Array();
// the currently selected id of the mouseover
var currentId="";

// load a tooltip
// looks to see if we already have it in the cache
// if we do, just display it
// if not, call the backend through AJAX to get the html
// args
//	gid (int) = gameid
//	boxart (bool) = display the boxart or not
//	div (object) = the div that is being called for this
function LoadGameTitleMouseOver(gid,boxart, div, event)
{
	//check and see if it is already in the array
	var arrayIndex=gid + '_' + boxart;
	if(ajaxGameArray[arrayIndex]==null)
	{
		// we dont
		currentId=div.id;
		// display the basic pne
		var tipRich = '<div class="tp1">Loading Game Description.....</div>';
		doTooltip(event,tipRich);
		ajax.GetGameMouseOver(gid,boxart,currentId,CallBack_LoadGameTitleMouseOver);
	}
	else
	{
		doTooltip(event,ajaxGameArray[arrayIndex]);
		//div.innerHTML=ajaxArray[arrayIndex];
	}
}

// ajax callback function
// called when a tooltip is looked up on hte backend, and called for the return
// retunrs an object
//		public class GetGameMouseOverData
//		{
//			public int gameId=0;
//			public string html="";
//			public bool boxart=false;
//			public string div="";
//		}
function CallBack_LoadGameTitleMouseOver(response)
{
	if (response.error != null)
	{
		// not sure what to do here
		return;
	}
	
	//return;

	// add to the array cache
	var arrayIndex = response.value.gameId + '_' + response.value.boxart;
	ajaxGameArray[arrayIndex]='<div class="tp1">' + response.value.html + '</div>';
	
	// redo the ToolTip, if the same is still displayed
	if(response.value.div == currentId)
	{
		//alert(response.value.html);
		Tooltip.writeTip('<div class="tp1">' + response.value.html + '</div>');
	}
}

// load a tooltip
// looks to see if we already have it in the cache
// if we do, just display it
// if not, call the backend through AJAX to get the html
// args
//	gid (int) = gameid
//	boxart (bool) = display the boxart or not
//	div (object) = the div that is being called for this
function LoadMovieTitleMouseOver(gid,boxart, div, event1)
{
	//check and see if it is already in the array
	var arrayIndex=gid + '_' + boxart;
	if(ajaxMovieArray[arrayIndex]==null)
	{
		// we dont
		currentId=div.id;
		// display the basic pne
		var tipRich = '<div class="tp1">Loading Product Description.....</div>';
		doTooltip(event1,tipRich);
		ajax.GetMovieMouseOver(gid,boxart,currentId,CallBack_LoadMovieTitleMouseOver);
	}
	else
	{
		doTooltip(event1,ajaxMovieArray[arrayIndex]);
		//div.innerHTML=ajaxArray[arrayIndex];
	}
}

// ajax callback function
// called when a tooltip is looked up on hte backend, and called for the return
// retunrs an object
//		public class GetMovieMouseOverData
//		{
//			public int gameId=0;
//			public string html="";
//			public bool boxart=false;
//			public string div="";
//		}
function CallBack_LoadMovieTitleMouseOver(response)
{
	if (response.error != null)
	{
		// not sure what to do here
		return;
	}
	//return;

	// add to the array cache
	var arrayIndex=response.value.gameId + '_' + response.value.boxart;
	ajaxMovieArray[arrayIndex]='<div class="tp1">' + response.value.html + '</div>';
	
	// redo the ToolTip, if the same is still displayed
	if(response.value.div==currentId)
	{
	  //alert(response.value.html);
		Tooltip.writeTip('<div class="tp1">' + response.value.html + '</div>');
	}
}
