// Image changing delay in milliseconds
var delay = 4000
var imageList = null
var listIndex = 0
var clock = null

function setupSwapImage(iList, imageName) {
  imageList = iList.split(',')
  var runCommand = "swapImage(\"" + imageName + "\")"

  clock = self.setTimeout(runCommand, delay)
}

function swapImage(imageName) {
  listIndex = listIndex + 1
  if (listIndex >= imageList.length) {
    listIndex = 0
  }

  img = new Image()
  img.src = "include/" + imageList[listIndex]
  document.images[imageName].src = img.src  

  var runCommand = "swapImage(\"" + imageName + "\")"

  clock = self.setTimeout(runCommand, delay)
}

function hoverImage(imageName) {
  img = new Image()
  img.src = "include/" + imageName + "_over.gif"
  document.images[imageName].src = img.src
}

function unhoverImage(imageName) {
  img = new Image()
  img.src = "include/" + imageName + "_up.gif"
  document.images[imageName].src = img.src
}

function pressImage(imageName) {
  img = new Image()
  img.src = "include/" + imageName + "_down.gif"
  document.images[imageName].src = img.src
}

function unpressImage(imageName) {
  img = new Image()
  img.src = "include/" + imageName + "_over.gif"
  document.images[imageName].src = img.src
}

// Position the site content in the middle of the screen
function position() {
   var h=0
   if( typeof( window.innerWidth ) == 'number' ) {
   //Non-IE
    h = window.innerHeight;
   } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    h = document.documentElement.clientHeight;
   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
   //IE 4 compatible
    h = document.body.clientHeight;
   }
   document.write('<style type="text/css">#outercelltop { height: ' + Math.round((h-580)/2) + 'px; }</style>')
}

