function showOutdated()
  {
   var elements = document.getElementsByTagName("td");

   // Search all <td> tags
   for (var i = 0; i < elements.length; i++)
     {
      var name = elements[i].className;

      // Look for "datefield" class
      if (name != null && name.substring(0,9) == "datefield")
        {
         // This one should contain the date as text, but we check that first...
         if (elements[i].firstChild != null && elements[i].firstChild.nodeType == 3)
           {
            // Take the contents and split it apart
            var datestring = elements[i].firstChild.nodeValue;
            var dateparts = splitDate(datestring);

            // If the split was successful, check the date
            if (dateparts != null)
              {
               var date = new Date(dateparts[0],dateparts[1]-1,dateparts[2]);
               var now  = new Date();

               // If the given date has no information on the time, set the current time to 0, so that
               // the script will only show an entry as old if the full day has passed
               // Note that time support isn't implemented yet
               if (date.getHours() == 0 && date.getMinutes() == 0 && date.getSeconds() == 0)
                 {
                  now.setHours(0);
                  now.setMinutes(0);
                  now.setSeconds(0);

                  date.setSeconds(1);
                 }                 

               // Fix year entry for two-digit year dates
               if (date.getYear() < 80) date.setYear(date.getYear()+2000);
               else if (date.getYear() < 999) date.setYear(date.getYear()+1900);

               // The given date lies before the current date
               if (now > date)
                 {
                  // Get the parent table row
                  var row = elements[i].parentNode;
                  var rowspan = parseInt(elements[i].getAttribute("rowspan"));

                  if (rowspan == null) rowspan = 1;
                  
                  // Set the row to "old" style
                  // If the date field spans multiple rows, set for all rows
                  do
                    {
                     if (row.nodeType == 1) rowspan--;
                     row.className = "old";

                     row = row.nextSibling;
                    }
                  while (rowspan > 0 && row != null)
                 }
              }
           }
        }
     }
  }
  
/**
 * Returns the date split in parts, with part[0] being the year, part[1] being the month
 * and part[2] being the day.
 */

function splitDate(date)
  {
   if (isISODate(date)) return splitISO(date);
   else if (isGERDate(date)) return splitGER(date);
   else return null;
  }
  
function isISODate(date)
  {
   return (date.indexOf("-") > -1);
  }

function isGERDate(date)
  {
   return (date.indexOf(".") > -1);
  }

function splitISO(date)
  {
   return date.split("-");
  }

function splitGER(date)
  {
   return date.split(".").reverse();
  }

attachOnLoad(showOutdated);