var AuctionsGrid = null;

Event.observe(window, 'load', ShowAuctionsTable, false);

function ShowAuctionsTable()
{
	var Location = window.location.href;
	
	if( Location.indexOf('#') == -1 )
	{
		var AllInputs = document.getElementsByTagName('INPUT');
		for(var i = 0, st = AllInputs.length; i < st; i++)
		{
			if((AllInputs[i].type == 'radio') && (AllInputs[i].checked == true))
			{
				var TheId = AllInputs[i].id;
				break;
			}
		}
		
		var GameId = TheId.replace('radio', '');
		window.location.href += '#' + GameId;
	}
	else
	{
		var GameId = parseInt( Location.substr( (Location.indexOf('#') + 1), Location.length) );
	}
	
	if (AuctionsGrid == null)
	{
		var Opts =
		{
			PageScript: 'Ajax/IndexGet.php?'+ '&game=' + GameId,
			RowsPerPage: 9999999999,
			HasFooter: false,
			GlobalCallBack: null,
			ColumnPrefixClass: 'Login',
			Columns: RequiredCurrencyColumns
		}
		AuctionsGrid = new AbScript.AbGridJson('AuctionGrid', Opts);
	}
	else
	{
		OtherParams = GetAllGetParams(AuctionsGrid.Options.PageScript, new Array('game'));
		AuctionsGrid.Options.PageScript = (OtherParams ? OtherParams : AuctionsGrid.Options.PageScript) + '&game=' + GameId;
		
		AuctionsGrid.Reload();
	}
}

function ActOnGameSelection(GameId)
{
	var Location = window.location.href;
	window.location.href = Location.substr( 0, (Location.indexOf('#')+1)) + GameId;
	
	ShowAuctionsTable();
}
