

function S_initScrollTable(oElement) {
	oElement.firstChild.syncTo = oElement.childNodes[1].uniqueID;
	oElement.firstChild.syncDirection = "horizontal";	
	if (typeof oElement.addEventListener != "undefined")
	{
		oElement.addEventListener("resize", function () {S_resizeScrollTable(oElement);}, false);
	}
	else if (typeof oElement.attachEvent != "undefined")		
	{
	    oElement.attachEvent("onresize", function () { S_resizeScrollTable(oElement);});
	}
};



function S_resizeScrollTable(oElement)
{
	var head = oElement.firstChild;
	var headTable = head.firstChild;
	var body = oElement.childNodes[1];
	var bodyTable = body.firstChild;
	var foot = oElement.lastChild;
	var footTable = null;
	if (foot.attributes["class"].value == "scrollTableFoot"){
		footTable = foot.firstChild;
	}		
	body.style.height = Math.max(0, oElement.clientHeight - head.offsetHeight - 11 - ((footTable != null)? foot.offsetHeight : 0)); //- ((footTable != null)? foot.offsetHeight : 0)
	var scrollBarWidth = body.offsetWidth - body.clientWidth;
	// set width of the table in the head
	headTable.style.width = Math.max(0, Math.max(bodyTable.offsetWidth + scrollBarWidth, oElement.clientWidth));
	// go through each cell in the head and resize
	var headCells = headTable.tHead.rows[0].cells;	
	for(i=0; i <bodyTable.tBodies[0].rows.length;i++)
	{
		if (bodyTable.tBodies[0].rows[i].style.display != "none")
		{
			var bodyCells = bodyTable.tBodies[0].rows[i].cells;

			for (var i = 0; i < bodyCells.length; i++)
			{
				headCells[i].style.width = bodyCells[i].offsetWidth;
			}				
			break;	
		} 
	}
	if (footTable != null)
	{
		footTable.style.width = headTable.style.width;
		var footCells = footTable.tHead.rows[0].cells;
		for (var i = 0; i < footCells.length; i++)
		{
			footCells[i].style.width = headCells[i].style.width;
		}
	}
};
