// Auto compute the main section height:-)
var Layout={}
Layout.compute = function()
{
  if(!Layout.main)
    return;
  if(Layout.middleFull)
  {
    Layout.main.style.height='';
    Layout.middleFull.style.height='';
    var height=Math.max(Layout.middleFull.offsetHeight+75,350)+5;
    Layout.main.style.height=height+"px";
    Layout.middleFull.style.height=height-75+"px";
  }
  else if(Layout.middleWide)
  {
    Layout.main.style.height='';
    Layout.left.style.height='';
    var height=Math.max(Layout.left.offsetHeight+30,Layout.middleWide.offsetHeight+60,350)+5;
    Layout.main.style.height=height+"px";
    Layout.left.style.height=height-30+"px";
  }
  else if(Layout.middleHalf)
  {
    Layout.main.style.height='';
    Layout.left.style.height='';
    var height=Math.max(Layout.left.offsetHeight+30,Layout.middleHalf.offsetHeight+75,350)+5;
    Layout.main.style.height=height+"px";
    Layout.left.style.height=height-30+"px";    
  }
  else
  {
    Layout.main.style.height='';
    Layout.left.style.height='';
    Layout.news.style.height='';
    Layout.right.style.height='';
    var height=Math.max(Layout.right.offsetHeight,Layout.left.offsetHeight+30,Layout.middle.offsetHeight+24,350)+5;
    Layout.right.style.height=height+"px";
    Layout.news.style.height=height-99+"px";
    Layout.main.style.height=height+"px";
    Layout.left.style.height=height-30+"px";
  }
  imgs=document.getElementsByTagName("img");
  for(var i=0;i<imgs.length;++i)
  {
    imgs.item(i).onload=Layout.compute;
  }
}

Layout.init = function ()
{
  Layout.right=document.getElementById('right');
  Layout.middle=document.getElementById('middle');
  Layout.middleFull=document.getElementById('middleFull');
  Layout.middleHalf=document.getElementById('middleHalf');
  Layout.middleWide=document.getElementById('middleWide');
  Layout.left=document.getElementById('left');
  Layout.main=document.getElementById('main');
  Layout.news=document.getElementById('rightNews');
  Layout.autoBox=document.getElementById('autoBox');
  window.onload=Layout.compute;
}

