var lastMaxed = {};
function doFullScreen(cellId, buttonId, fullBtn, normalBtn, targetfrm, isImageButton)
{
    doFullScreenComb(cellId, buttonId, fullBtn, normalBtn, targetfrm, isImageButton, true);
}

function doFullScreen2(cellId, targetfrm)
{
    doFullScreenComb(cellId, null, null, null, targetfrm, null, false);
}

function restoreFullScreen(cellId, targetfrm)
{
    doFullScreenComb2(cellId, null, null, null, targetfrm, null, false);
}

function doFullScreenComb(cellId, buttonId, fullBtn, normalBtn, targetfrm, isImageButton, changeBtn)
{
	var table = targetfrm.document.getElementById(cellId).parentNode.parentNode.parentNode;
   	if (lastMaxed[table.id] != null)
	{
		if (changeBtn)
		{
			document.getElementById(buttonId).innerHTML = !isImageButton?
				"&nbsp;"+fullBtn+"&nbsp;" :
				"<img src=\""+fullBtn+"\"/>";
		}
		restore(table.id, targetfrm);
	}
	else
	{
		if (changeBtn)
		{
			document.getElementById(buttonId).innerHTML = !isImageButton?
				"&nbsp;"+normalBtn+"&nbsp;" :
				"<img src=\""+normalBtn+"\"/>";
		}
		maximize(table.id, cellId, targetfrm);
	}
}

function doFullScreenComb2(cellId, buttonId, fullBtn, normalBtn, targetfrm, isImageButton, changeBtn)
{
	var cell = targetfrm.document.getElementById(cellId);
	if (cell != null)
	{
		var table = cell.parentNode.parentNode.parentNode;
	   	if (lastMaxed[table.id] != null)
		{
			if (changeBtn)
			{
				document.getElementById(buttonId).innerHTML = !isImageButton?
					"&nbsp;"+fullBtn+"&nbsp;" :
					"<img src=\""+fullBtn+"\"/>";
			}
			restore(table.id, targetfrm);
		}
	}
}

function restore(tableId, targetfrm)
{
   	if (lastMaxed[tableId] != null)
   	{
   		var cell = lastMaxed[tableId][0];
   		showAllTd(tableId, cell.id, true, targetfrm);
		cell.width = lastMaxed[tableId][1];
		cell.height = lastMaxed[tableId][2];
		lastMaxed[tableId] = null;
	}
}
   	
function maximize(tableId, cellId, targetfrm)
{
   	restore(tableId);
	showAllTd(tableId, cellId, false, targetfrm);
	var cell = targetfrm.document.getElementById(cellId);
	
	lastMaxed[tableId] = [cell, cell.width, cell.height];
	cell.width = "100%";
	cell.height = "100%";
}
   	
function showAllTd(tableId, exception, show, targetfrm)
{
	var t = targetfrm.document.getElementById(tableId);
	for (var j = 0; t.rows.length > j; j++)
	{
		var row = t.rows[j];
		
		for (var i = 0; row.cells.length > i; i++)
		{
   			var cell = row.cells[i];
   			if (cell != null && exception != cell.id)
   			{
				cell.style.display = show ? "" : "none";
   			}
   		}
	}
}

