function FitToContent(id, maxHeight)
{
	var text = id && id.style ? id : document.getElementById(id);
	if(!text) return;
	
	var currentHeight = text.clientHeight;
	if(!maxHeight || maxHeight > currentHeight) /* if there is no max height, or the client height isn't too big yet */
	{
			adjustedHeight =  text.scrollHeight;
			if(maxHeight) adjustedHeight = Math.min(maxHeight, adjustedHeight);
			if(adjustedHeight != text.clientHeight) text.style.height = adjustedHeight + 'px';
	}
}