

function ResizeDataGrid(topTable,bottomTable)
{
	var topTable;
	var bottomTable ;
	var topRow;
	var bottomRow;
	var maxcols;
	var count;
	
	topTable = gE(topTable);
	bottomTable = gE(bottomTable);

	//Check if bottom table is null //
	if (bottomTable == null) return;

	bottomRow = bottomTable.rows[0];

	//Get the max columns
	maxcols = bottomRow.cells.length;

	//Get the first row of both the first and second table //
	count=topTable.rows.length;
	while(count>0)
	{
		if (topTable.rows[count-1].cells.length==maxcols)
		{
			break;
		}
		count--;
	}
	topRow = topTable.rows[count-1];

	//We should have the same number of cells //
	for (i = 0; i < topRow.cells.length; i++)
	{
		//Compare cell widths//
		var topCell;
		var bottomCell;

		topCell = topRow.cells[i];
		bottomCell = bottomRow.cells[i];
		bottomCell.style.width='';
			
		if (topCell.clientWidth == bottomCell.clientWidth)
		{
			//Do nothing
		}
		else
		{ 
			if (topCell.clientWidth > bottomCell.clientWidth)
			{
				//Set the bottom cell width attribute //
				bottomCell.width=topCell.clientWidth;
			}
			else
			{
				topCell.style.width=bottomCell.clientWidth;
			}
		}
	}
	
	//Do it again
	for (i = 0; i < topRow.cells.length; i++)
	{
		//Compare cell widths//
		var topCell;
		var bottomCell;

		topCell = topRow.cells[i];
		bottomCell = bottomRow.cells[i];
		bottomCell.style.width='';
		
		if (topCell.clientWidth == bottomCell.clientWidth)
		{
			//Do nothing
		}
		else
		{ 
			if (topCell.clientWidth > bottomCell.clientWidth)
			{
				//Set the bottom cell width attribute //
				bottomCell.width=topCell.clientWidth;
			}
			else
			{
				topCell.width=bottomCell.clientWidth;
			}
		}
	}
	
	//Check top row for correct width.
	//top row may not resize correctly
	//if width is too wide for the screen
	for (i = 0; i < topRow.cells.length; i++)
	{
		//Compare cell widths//
		var topCell;
		var bottomCell;

		topCell = topRow.cells[i];
		bottomCell = bottomRow.cells[i];
		
		if (topCell.clientWidth < bottomCell.clientWidth)
		{
			//Set the bottom cell width attribute //
			bottomCell.width=topCell.clientWidth;
		}
	}
	
}


