function addResizeComponent(componentName,fudgeFactor)
{
   var resizeList = window.resizeList;

   if (resizeList == null)
   {
      resizeList = new Array();
      window.resizeList = resizeList;
   }

   var c = new Object();
   c.componentName = componentName;
   c.fudgeFactor   = fudgeFactor;

   resizeList.push(c);
}

function resizeComponentsInList()
{
   var resizeList = window.resizeList;

   if (resizeList != null)
   {
      for (var i = 0; i < resizeList.length; i++)
      {
         var c = resizeList[i];

         resizeComponentToParent(c.componentName,c.fudgeFactor);
      }
   }
}

function getBodyHeight()
{
   if (navigator.userAgent.indexOf("MSIE") != -1)
      return document.body.offsetHeight;
   else
      return window.innerHeight;
}

function setComponentHeight(component,height,fudgeFactor)
{
   /*
   var bodyHeight;

   if (navigator.userAgent.indexOf("MSIE") != -1)
   {
      bodyHeight = document.body.offsetHeight;
   }
   else
   {
      bodyHeight = window.innerHeight;
   }

   if (fudgeFactor)
      component.style.height = (bodyHeight - component.offsetTop - 5 - fudgeFactor) + "px";
   else
      component.style.height = (bodyHeight - component.offsetTop - 5) + "px";

   alert(component.id + ' - ' + component.style.height + ' - ' + component.offsetTop);
   */

   if (fudgeFactor)
      component.style.height = (height - fudgeFactor) + "px";
   else
      component.style.height = height + "px";
}

function resizeComponent(componentName,fudgeFactor)
{
   var component = document.getElementById(componentName);

   if (component == null)
      return;

   var bodyHeight;

   if (navigator.userAgent.indexOf("MSIE") != -1)
   {
      bodyHeight = document.body.offsetHeight;
   }
   else
   {
      bodyHeight = window.innerHeight;
   }

   if (fudgeFactor)
      component.style.height = (bodyHeight - component.offsetTop - 5 - fudgeFactor) + "px";
   else
      component.style.height = (bodyHeight - component.offsetTop - 5) + "px";

   //alert(componentName + ' - ' + component.style.height + ' - ' + component.offsetTop);
}

function resizeComponentToParent(componentName,fudgeFactor)
{
   var component = document.getElementById(componentName);

   if (component == null)
      return;

   var parentHeight = component.parentNode.height;

   //if (component.parentNode instanceof HTMLTableCellElement)
   //   parentHeight = component.parentNode.offsetHeight;

   if (parentHeight == null || parentHeight.length == 0)
   {
      if (navigator.userAgent.indexOf("MSIE") != -1)
         parentHeight = document.body.offsetHeight;
      else
         parentHeight = window.innerHeight;
   }

   //alert(component.id + "\n" + component.parentNode + "\n" + parentHeight);

   var extraFudge = navigator.userAgent.indexOf("MSIE") != -1 ? 0 : 3;

   if (fudgeFactor)
      component.style.height = (parentHeight - component.offsetTop - extraFudge - fudgeFactor) + "px";
   else
      component.style.height = (parentHeight - component.offsetTop - extraFudge) + "px";

   //alert(componentName + '-' + component.style.height + '-' + component.offsetTop + '-' + component.parentNode + '-' + parentHeight);
}

function resizeComponentBoth(componentName,fudgeFactorHeight,fudgeFactorWidth)
{
   var component = document.getElementById(componentName);

   if (component == null)
      return;

   var bodyHeight,bodyWidth;

   if (navigator.userAgent.indexOf("MSIE") != -1)
   {
      bodyHeight = document.body.offsetHeight;
      bodyWidth  = document.body.offsetWidth;
   }
   else
   {
      bodyHeight = window.innerHeight;
      bodyWidth  = window.innerWidth;
   }

   if (fudgeFactorHeight)
      component.style.height = (bodyHeight - component.offsetTop - 5 - fudgeFactorHeight) + "px";
   else
      component.style.height = (bodyHeight - component.offsetTop - 5) + "px";

   if (fudgeFactorWidth)
      component.style.width  = (bodyWidth - component.offsetLeft - 5 - fudgeFactorWidth) + "px";
   else
      component.style.width  = (bodyWidth - component.offsetLeft - 5) + "px";
}
