// 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 changeBackground(tag, value, id)
{  var element = tag.style;
   var listObject = document.getElementById(id);
   if (value) {  listObject.style.visibility = "hidden";   }
   else       {  listObject.style.visibility = "visible";  }      
}

// 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));
}

// Change iframe contents
function newFooter() 
{ 
  try
  {
     tag = getElement('time');
     tag.innerHTML = formatTime(); 

     var tag = getElement('pageTitle');
     tag.innerHTML = title();

     tag = getElement('modDate');
     tag.innerHTML = "Modified: " + lastModified();

     tag = getElement('pageName');
     tag.innerHTML = href();
   }
   catch (err) {}   // Called before page loads.
   setTimeout('newFooter()', 1000);
}

// Randomly select a picture to display.
var pictureList = ["atThreeOaks", "bigDuckWithUs", "crossingOceanToAbidjan", "familyPosingAgain"
     , "guestHut", "meAndJolie", "nyingeAtWork", "parentsDabakalaHouse", "posingBeforeTheTrip"
	 , "twoKidsAndDolls", "sellGuavas", "tireTrouble", "visitorFromHdqtrs", "weHatePics"
	 , "babyGoat", "churchAtMamou", "familyOnTheStation", "firstLizard", "kidOnCan", "myKitten"
	 , "ourTown", "pluckingTurkey", "prayerCardInfo", "poorBird", "theTwins", "twinsAtAirport"
	 , "waitingOnThePorch", "youngMissionaryStudentsHsu"];
	 
function displayPicture(id)
{
   var index = Math.floor(Math.random() * pictureList.length);
   var picture = "images/photos/" + pictureList[index] + ".jpg";
   
   var tag = document.getElementById(id);
   tag.src = picture; 
   tag.alt = pictureList[index];
}

