/*
 game
 
 This function will help the user to search through the games and list the screenshots.
*/


function searchGameList(buttonToSearch,objectForm,divObject)
{
	passThroughValue = new Array();
	passThroughValue[0] = buttonToSearch;
	passThroughValue[1] = divObject;
	
	document.getElementById(''+ buttonToSearch).disabled = true;
	ajaxSubmitFormPOST('commonAjax.php?script=searchGameList',objectForm,'procesGameList',passThroughValue);
}

function switchGameListOptions(buttonToSearch,stringToSubmit,divObject)
{
	passThroughValue = new Array();
	passThroughValue[0] = buttonToSearch;
	passThroughValue[1] = divObject;
	
	document.getElementById(''+ buttonToSearch).disabled = true;
	ajaxPostData('commonAjax.php?script=searchGameList'+ stringToSubmit,'','procesGameList',passThroughValue);
}

function switchGameListOptionsAlt(stringToSubmit)
{
	var http = ajaxRequestObject();

	http.onreadystatechange = function()
	{
		if(http.readyState == 4)
		{
			document.getElementById("searchGameResults").innerHTML = http.responseText;
		}
	}

	var searchString = document.getElementById("gameListTitle").value;

    http.open("GET", "commonAjax.php?script=searchGameList" + stringToSubmit + "&gameListTitle=" + searchString, true);
    http.send(null);
}

function procesGameList(ajaxStatus,ajaxResponse,passThroughValue)
{
	if(ajaxStatus == 202)
	{
		eval(''+ajaxResponse);
	}
	else
	{
		ajaxInnerXHTML(passThroughValue[1],ajaxResponse);
	}
	
	document.getElementById('' + passThroughValue[0]).disabled = false;
}

function nextScreenshotPage(getMethodString)
{
	ajaxPostData('commonAjax.php?script=nextScreenshotPage&'+getMethodString,'','procesNextScreenshotPage','gameScreensTableDiv');
}

function procesNextScreenshotPage(ajaxStatus,ajaxResponse,passThroughValue)
{
	if(ajaxStatus == 202)
	{
		eval(''+ajaxResponse);
	}
	else
	{
		ajaxInnerXHTML(passThroughValue,ajaxResponse);
		outputResizeImages();
	}
}
