//rollOvers.js is a small library of functions to provide up to a four state image button.
//Copyright 1997 Ryerson Polytechnic University
//Provided free - but use at your own risk - to publically funded, not for profit,
//educational institutions or people who have taken the 
//Rogers Communication Centre Hands On Internet JavaScript course.
//Written by Brian Lesser: http://www.ryerson.ca/~blesser

ver = parseInt(navigator.appVersion)

states = new Array("normal", "over", "down", "up")

rollovers = new Array()

ready = false

function flipImage(name, state)
   {
   var roll = rollovers[name]
   if (ready && roll[state]) document[name].src = roll[state].src 
   }
   
   
function rollOver(iname, normalFile, overFile, downFile, clickedFile)
   {
   var argv = rollOver.arguments
   var w
   var h
   if (document[iname])  //Trap for Explorer Problems
      {
      w = document[iname].width
      h = document[iname].height
      document[iname].onload = null //Must catch every elsewhere for Explorer
      this.normal = new Image(w, h)
      this.normal.src = document[iname].src 
      }
   else
      {
      w = -1
      h = -1
      this.normal = new Image()
      this.normal.src = normalFile
      }

   var i = 0
   var s = ""
   
   for (i=2; i < argv.length; i++)
      {
      s = states[i - 1]
      this[s] = new Image(w, h)
      this[s].src = argv[i]
      }
   for (i=argv.length; i < 5; i++)
      {
      s = states[i]
      this[s] = new Image(w, h)
      this[s].src = normal.src

      }   
   this.flip = flipImage
   }   
   
function addImage(i, n, o, d, c)
   {
   rollovers[i] = new rollOver(i, n, o, d, c)
   }
   
function initImages()
   {
   var i
   ready = true
   } 
 
  
function flip(name, state)
  {
  if (rollovers[name]) 
     {
     document[name].onload = null
     rollovers[name].flip(name,state)
     }
  }           
