Listen(window,'load', Load);

function Load()
{
   //stretch whole site container to window if there's room to spare
   var winHeight = measure('window').y;
   if (elemById('zero').offsetHeight < winHeight)
   {
      var headerHeight = elemById('header').offsetHeight;
      var footerHeight = elemById('footer').offsetHeight;
      elemById('center').style.height = winHeight - headerHeight - footerHeight + 'px';
   }

   if (elemById('kc_nav'))
   {
      var leftcol = elemById('col_left');

      //rootItemsCount is a variable I smuggled inbetween the menu script. It's written by navigation.asp.
      var menuRootHeight = 0;
      for (var i = 0; i < rootItemsCount; i++)
         menuRootHeight += elemById('lnk'+i).offsetHeight;

      leftcol.style.height = leftcol.offsetHeight
         + menuRootHeight
         - 15 // I have no idea where this magic number comes from.
         + 'px';

      elemById('kc_navcontainer').style.height = menuRootHeight + 'px';
   }

   if (infoForm = elemById('invulformulier'))
   {
      infoForm.style.height = elemById('center').offsetHeight - 47 + 'px';
   }

   /*
   //stretch page columns downward.
   //col_left indicates a normal page with menu and columns.
   if (elemById('col_left'))
   {
      var col_left = elemById('col_left');
      col_left.style.height = col_left.parentNode.offsetHeight - (getStyleValue(col_left,'padding-top',true) + getStyleValue(col_left,'padding-bottom',true)) + 'px';

      var col_right = elemById('col_right');
      if (col_right)
         col_right.style.height = col_right.parentNode.offsetHeight - (getStyleValue(col_right,'padding-top',true) + getStyleValue(col_right,'padding-bottom',true)) + 'px';


      //set up foldout menu
      var leftMenuNodes = _childNodes(col_left);
      var currentFoldMenu;

      for (var i = 0; i < leftMenuNodes.length; i++)
      {
         var nodeIsLink = leftMenuNodes[i].nodeName != 'DIV';
         var nodeHasChildren = (_nextSibling(leftMenuNodes[i]) && _nextSibling(leftMenuNodes[i]).className == 'submenuchilds');

         if (nodeIsLink && nodeHasChildren)
         {
            leftMenuNodes[i].className = 'submenu';

            leftMenuNodes[i].onclick = function () {

               //Toggle this
               if (this.className == 'submenu')
                  this.className = 'unfold';
               else if (this.className == 'unfold')
                  this.className = 'submenu';

               //Toggle(_nextSibling(this));

               //Toggle previous menu depending on open/closed state
               //if previous is current, then state is open and this toggle will un-toggle the previous toggle. Um. Yeah.
               if (currentFoldMenu && currentFoldMenu != this && getStyleValue(_nextSibling(currentFoldMenu),'display') == 'block')
               {
                  if (currentFoldMenu.className == 'submenu')
                     currentFoldMenu.className = 'unfold';
                  else if (currentFoldMenu.className == 'unfold')
                     currentFoldMenu.className = 'submenu';

                  //Toggle(_nextSibling(currentFoldMenu));
               }

               currentFoldMenu = this;

               //return false;
            };
         }
      }


   }
   */

   /* since bor, the columns do not need to stretch anymore.
   //'welcometext' indicates the home page
   if (elemById('welcometext'))
   {
      //stretch front columns to layout

      var welcomeText = elemById('welcometext');
      welcomeText.style.height = welcomeText.parentNode.offsetHeight - (
           getStyleValue(welcomeText,'padding-top',true)
         + getStyleValue(welcomeText,'border-top-width',true)
         + getStyleValue(welcomeText,'border-bottom-width',true)
         + getStyleValue(welcomeText,'padding-bottom',true))
         + 'px';


      var newsColumn = elemById('front_nieuws');
      newsColumn.style.height = newsColumn.parentNode.offsetHeight - (getStyleValue(newsColumn,'padding-top',true) + getStyleValue(newsColumn,'padding-bottom',true)) + 'px';

   }
   */
}

//The PNG hack for IE.
/*
if (/MSIE (\d+\.\d+)/.test(navigator.appVersion))
{
   window.attachEvent('onload',function () {
      var imgTags = elemsByTag('img');
      for (var i=0; i < imgTags.length; i++)
      {
         if (/\.png$/i.test(imgTags[i].src))
         {
            imgTags[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imgTags[i].src + "', sizingMethod='scale')";
            imgTags[i].style.width = imgTags[i].width + 'px';
            imgTags[i].style.height = imgTags[i].height + 'px';
            imgTags[i].src = '../gfx/transparent.gif';
         }

         imgTags[i].style.visibility = 'visible';
      }
   });
}
*/
