/*
**  Program:     bln.js
**  Called from: index.php
*/
var dayName = new Array(
  "Sunday", "Monday", "Tuesday", "Wednesday", 
  "Thursday", "Friday", "Saturday");

var monName = new Array(
  "January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December");
/*
**  Once the window's onload event triggers, call the unnamed function
**
**  Note: the "var" makes the varible local.
*/
window.onload = function() {
 /*
 **  Setup rollovers
 */
 for (var i=0; i<document.images.length; i++) {
   if (document.images[i].parentNode.tagName == "A") {
    setupRollover(document.images[i]);
   }
 }
 /*
 **  Get the orginal server's time from the hidden input field
 */
 var originalServerTime = document.getElementById('serverTime').value;
 ost = new Date();
 ost.setTime(originalServerTime * 1000);  // in msecs instead of secs.
 /*
 **  Get the orginal client's time
 */
 oct = new Date();
 /*
 **  Set the orginal difference between the two
 */
 originalDiff = (originalServerTime * 1000) - oct.getTime();
 runClock();
}
function runClock() {
 var rct = new Date();  // Running Client Time
 var rst = new Date();  // Running Server Time
 rst.setTime(originalDiff + rct.getTime());
 /*
 **  Overwrite the HTML in the ID=displayTime <TD></TD> name/value pair
 */
 document.getElementById('displayTime').innerHTML = 
  /********************************************************************
  formatTime(oct).bold().fontcolor('Red')  + ' - Original Client Time<BR>' +
  formatTime(ost).bold().fontcolor('Blue') + ' - Original Server Time<BR>' +
  formatTime(rct).bold().fontcolor('Red')  + ' - Running Client Time <BR>' +
  formatTime(rst).bold().fontcolor('Blue') + ' - Running Server Time';
  ********************************************************************/
  formatTime(rst);
 /*
 **  Set timer for one second
 */
 setTimeout('runClock()', 1000);
}
function formatTime(t) {
  var ampm = t.getHours() >= 12 ? 'PM' : 'AM';
  var hour = t.getHours() >= 13 ? t.getHours() - 12 : t.getHours();
  var s = dayName[t.getDay()] + ', ' + monName[t.getMonth()] + ' ' +
    t.getDate() + ', ' + t.getFullYear() + ' ' +
    hour + ':' + twoDigits(t.getMinutes()) + ':' + twoDigits(t.getSeconds()) + 
    ' ' + ampm + ' CST';
  return s;
}
function twoDigits(i) {
  if (i <= 9) return '0'+i;
  else return i;
}
function setupRollover(thisImage) {

  if (thisImage.id == "") return true;

  thisImage.outImage = new Image();
  thisImage.outImage.src = thisImage.src;
  thisImage.onmouseout = rollOut;

  thisImage.clickImage = new Image();
  thisImage.clickImage.src = "gif/" + thisImage.id + "Click.gif";
  thisImage.onclick = rollClick;  

  thisImage.overImage = new Image();
  thisImage.overImage.src = "gif/" + thisImage.id + "Over.gif";
  thisImage.onmouseover = rollOver;  

}
function rollOver() {
  this.src = this.overImage.src;
}
function rollOut() {
  this.src = this.outImage.src;
}
function rollClick() {
  this.src = this.clickImage.src;
}
