// get location of the page in the iframe.
function href() 
{ 
   return window.frames['display'].document.location.href; 
}

function title()
{
   return window.frames['display'].document.title;
}

// Code around Explorer non-compliance with w3c standards.
function getElement(aID)
{  var element = document.getElementById(aID);
   if (element != null) return element;
   else                 { return document.all(aID); }
} 

function showDisplay(id, value)
{  var element = document.getElementById(id).style;
   if (value) 
        element.display = "block";
   else element.display = "none";
}

function toggleDisplay(id)
{
   var element = document.getElementById(id).style;
   if (element.display=="block") showDisplay(id, false);
   else                          showDisplay(id, true);
}

function changeBackground(id, value)
{  var element = id.style;
   if (value) { element.backgroundColor = "#000000"; element.color = "#ffffff"; }
   else       { element.backgroundColor = "#b00000"; element.color = "#ffffff"; }
}

// format date as dd-mmm-yy
function formatDate(date)
{
   // Scale the year between 00 and 99.
   var year = date.getYear();
   if(year >= 2000)  year -= 2000;
   if(year >= 100)   year -= 100;
   if(year < 10)     year = "0"+year;
   else              year = "" + year;

   var monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
   var month = monthName[date.getMonth()];
         
   var day = date.getDate();
   if (day<10) day = "0"+day;
   else        day = "" + day;
   return (month + "/" + day + "/" + year);
}

// format current time
function formatTime()
{
   var today = new Date();
   var hours = today.getHours();
   var pm    = "p.m."
   if (hours < 12) pm = "a.m."
   hours = hours % 12;
   if (hours==0) hours=12;

   var minutes = today.getMinutes();
   if (minutes < 10) minutes = "0" + minutes;
   else minutes = "" + minutes;

   var seconds = today.getSeconds();
   if (seconds < 10) seconds = "0" + seconds;
   else              seconds = "" + seconds;
   
   return "" + hours + ":" + today.getMinutes() + ":" + today.getSeconds() + " " + pm;
}


// get last modified date of the current document.
function lastModified()
{
   var date = Date.parse(window.frames['display'].document.lastModified);
   //var date = Date.parse(document.lastModified);
   if (date == 0) return "unknown";
   return formatDate(new Date(date));
}

// Return hit count.
function hitCount()
{
   return 0;
}

// Change iframe contents
function newFooter() 
{ 
  try
  {
     var tag = getElement('pageTitle');
     tag.innerHTML = title();

     var tag = getElement('time');
     tag.innerHTML = formatTime(); 

     tag = getElement('modDate');
     tag.innerHTML = "Modified: " + lastModified();

     tag = getElement('pageName');
     tag.innerHTML = href();
   }
   catch (err) {setTimeout('newFooter()', 50); } // Called before page loads.
}

