function __CustomEventHandler()
{
	this.OnLoad = null;
	this.FireOnLoad = function()
	{
		if(this.OnLoad)
			this.OnLoad();
		__UpdateFrameCells();
	}
	this.OnResize = null;
	this.FireOnResize = function()
	{
		if(this.OnResize)
			this.OnResize();
		__UpdateFrameCells();
	}
}

if(!document.getElementById && document.all)
	document.getElementById = function(id){return document.all[id];}

function __GetParent(e)
{
	return (e.parentElement) ? e.parentElement : e.parentNode;
}

function __GetChild(e, i)
{
	if(i == -1)
		return (e.children) ? e.children.length : e.childNodes.length;
	else
		return (e.children) ? e.children[i] : e.childNodes[i];
}

var __UpdatingCells = false;
function __UpdateFrameCells()
{
	var ua = navigator.userAgent.toLowerCase();
	if(__UpdatingCells)//|| (ua.indexOf("msie") > -1))
		return;
	__UpdatingCells = true;
	for(var i=0;i<_FrameCells.length;i++)
	{
		var cellid = _FrameCells[i];
		var e = document.getElementById("FrameCell_" + cellid);
		while(e.tagName != "TABLE")
			e = __GetParent(e);
		var p = __GetParent(e);
		var parentRow = __GetParent(p);
		var MaxHeight = (!parentRow.CustomOffsetHeight) ? 0 : parentRow.CustomOffsetHeight;
		if(!parentRow.CustomOffsetHeight)
		{
			var Cells = __GetChild(parentRow, -1);
			if(Cells > 1)
			{
				for(var j=0;j<__GetChild(parentRow, -1);j++)
				{
					var tmpCell = __GetChild(parentRow, j);
					if(tmpCell.rowSpan > 1)
					{
						MaxHeight = 0;
						break;
					}
					var myHeight = parseInt(tmpCell.offsetHeight);
					if(myHeight > MaxHeight)
						MaxHeight = myHeight;
				}
			}
			parentRow.CustomOffsetHeight = MaxHeight;
		}
		if(MaxHeight > 0)
			e.style.height = parentRow.CustomOffsetHeight;
		e.style.width = p.offsetWidth;
	}
	__UpdatingCells = false;
}

var __CustomEventHandler = new __CustomEventHandler();
__CustomEventHandler.OnLoad = window.onload;
window.onload = function(){__CustomEventHandler.FireOnLoad();};
__CustomEventHandler.OnResize = window.onresize;
window.onresize = function(){__CustomEventHandler.FireOnResize();};
