function hideInCurrentMonth(month, from, to)
{
  dt=null;
  for(elem=month.firstChild, i=0; elem!=null; elem=elem.nextSibling)
  {
    if(elem.nodeName=="DT")
    {
      if(dt!=null) dt.style.display="none";
      dt=elem;
      if((++i>=from)&&(i<=to)) dt.style.display="none";
    }
    if(elem.nodeName=="DD")
    {
      if(elem.innerHTML.length!=0) dt=null;
      if((i>=from)&&(i<=to)) elem.style.display="none";
    }
  }
  if(dt!=null) dt.style.display="none";
}

function hideEmptyDtInMonth(month)
{
  dt=null;
  for(elem=month.firstChild; elem!=null; elem=elem.nextSibling)
  {
    if(elem.nodeName=="DT")
    {
      if(dt!=null) dt.style.display="none";
      dt=elem;
    }
    if(elem.nodeName=="DD")
      if(elem.innerHTML.length!=0) dt=null;
  }
  if(dt!=null) dt.style.display="none";
}

function hideEmptyDtInYear()
{
  var months=document.getElementsByTagName('dl');

  for(i=0; i<months.length; i++)
    hideEmptyDtInMonth(months[i]);
}


function removeOld()
{
  var months=document.getElementsByTagName('dl');
  var header=document.getElementsByTagName('h2');
  var now=new Date();
  for(i=0; i<now.getMonth(); i++)
  {
    months[i].style.display='none'
    header[i].style.display='none'
  }

  hideInCurrentMonth(months[now.getMonth()], 1, now.getDate()-1);

  for(i=now.getMonth()+1; i<12; i++)
    hideEmptyDtInMonth(months[i]);
}

function keepOld()
{
  var months=document.getElementsByTagName('dl');
  var header=document.getElementsByTagName('h2');
  var now=new Date();
  for(i=now.getMonth()+1; i<12; i++)
  {
    months[i].style.display='none'
    header[i].style.display='none'
  }

  hideInCurrentMonth(months[now.getMonth()], now.getDate(), 31);

  for(i=0; i<now.getMonth(); i++)
    hideEmptyDtInMonth(months[i]);
}

