//
//  Function:   Constructor for Rollover Menu
//  Parameters: div     - handle to the DIV to hold the menu
//              graphic - background graphic
//
function RolloverMenu( div, graphic )
{
  this.div = div
  this.graphic = graphic
  this.index = ROMcounter
  eval( "ROM" + ROMcounter + "= this" )
  ROMcounter++
  this.count = -1
  this.clickedEntry = 0
//  this.isN4 = (navigator.appName=="Netscape" && parseInt(navigator.appVersion)>=4)

  this.addEntry = ROMaddEntry
  this.generate = ROMgenerate
  this.setClickedEntry = ROMsetClickedEntry
}

//
//  Function:   addEntry - add an entry to the menu
//  Parameters: left       - to position the graphic
//              top        - to position the graphic
//              alt        - the alt text for the graphic
//              unselected - the unselected graphic
//              over       - the rollover graphic
//              selected   - the selected graphic
//              javascript - the code to be executed when the entry is selected
//
function ROMaddEntry( left, top, alt, unselected, over, selected, javascript )
{
  this.count++
  eval( 'this.entry' + this.count + '=new ROMEntry("'
        + left + '","'
        + top + '","'
        + alt + '","'
        + unselected + '","'
        + over + '","'
        + selected + '","'
        + javascript + '")' )
  eval( 'entry = this.entry' + this.count )
  entry.setMenu( this )
}

//
//  Function:   generate - generate the menu
//  Parameters: none
//
function ROMgenerate()
{
  var html = ""
  if ( this.graphic != null )
  {
    html += "<IMG SRC='" + this.graphic + "'>\n"
  }
  for( i=0; i<=this.count; i++ )
  {
//    if ( this.isN4 )
//    {
//      html += "<LAYER NAME='div" + i + "i" + this.index
//      html += "' LEFT="
//      eval( "html += this.entry" + i + ".left" )
//      html += " TOP="
//      eval( "html += this.entry" + i + ".top" )
//      html += "'>\n<IMG SRC='"
//      eval( "html += this.entry" + i + ".unselected" )
//      html += "' ALT='"
//      eval( "html += this.entry" + i + ".alt" )
//      html += "' NAME='graphic" + i + "i" + this.index + "'"
//      html += "'></LAYER>\n"
//    }
//    else
//    {
      html += "<DIV ID='div" + i + "i" + this.index
      html += "' STYLE='position:absolute; left:"
      eval( "html += this.entry" + i + ".left" )
      html += "; top:"
      eval( "html += this.entry" + i + ".top" )
      html += "; cursor:hand; width:"
      eval( "html += this.entry" + i + ".imageu.width" )
      html += "'>\n<IMG SRC='"
      eval( "html += this.entry" + i + ".unselected" )
      html += "' ALT='"
      eval( "html += this.entry" + i + ".alt" )
      html += "' NAME='graphic" + i + "i" + this.index + "'></DIV>\n"
//    }
  }
 // if ( this.isN4 )
 // {
  //  var d = this.div.document
 //   d.open("text/html","replace")
 //   d.write(html)
//    d.close()
 // }
//  else
 // {
    this.div.innerHTML = html
//  }
  for( i=0; i<=this.count; i++ )
  {
    var div
//    if ( this.isN4 )
//    {
//      eval( "div = this.div.document.layers['div" + i + "i" + this.index + "']")
//    }
//    else
    {
      eval( "div = document.all('div" + i + "i" + this.index + "')")
    }
    div.onmouseover = ROMmouseOver
    div.onmouseout = ROMmouseOut
//    if ( this.isN4 )
//    {
//      this.div.captureEvents( Event.MOUSEUP ) // Unable to capture on div!
//      this.div.onmouseup = ROMmouseClickNS
//    }
//    else
    {
      div.onclick = ROMmouseClickIE
    }
    eval( "div.entry = this.entry" + i )
    eval( "this.entry" + i + ".div = div" )
    eval( "this.entry" + i + ".index = " + i )
    div.index = i
  }
}

//
//  Function:   setClickedEntry
//  Parameters: entry - entry that has been clicked
//
function ROMsetClickedEntry( entry )
{
  if ( this.clickedEntry != 0 )
  {
    this.clickedEntry.mouseClickedOff()
  }
  this.clickedEntry = entry
}

//
//  Function:   mouseOver - handle mouse over for an entry
//  Parameters: none
//
function ROMmouseOver()
{
  var entry = this.entry
  if ( entry.clicked == 1 )
  {
    return
  }
  var c
//  if ( entry.menu.isN4 )
//  {
//    c = "this.document.images['graphic" + this.index + "i" + entry.menu.index + "']"
//  }
//  else
  {
    c = "document.all.graphic" + this.index + "i" + entry.menu.index
  }
  c += ".src = entry.imageo.src"
  eval( c )
}

//  Function:   mouseOut - handle mouse out for an entry
//  Parameters: none
//
function ROMmouseOut()
{
  var entry = this.entry
  if ( entry.clicked == 1 )
  {
    return
  }
  var c
//  if ( entry.menu.isN4 )
//  {
//    c = "this.document.images['graphic" + this.index + "i" + entry.menu.index + "']"
//  }
//  else
  {
    c = "document.all.graphic" + this.index + "i" + entry.menu.index
  }
  c += ".src = entry.imageu.src"
  eval( c )
}

//
//  Function:   mouseClickNS - handle mouse click on Netscape
//  Parameters: event
//
function ROMmouseClickNS( event )
{
  name = event.target.name
  if (( name != "undefined" )
     && ( name.substring( 0, 7 ) == "graphic" ))
  {
    var indexi = name.indexOf( "i", 8 )
    var index = name.substring( 7, indexi )
    var set = name.substring( indexi+1, name.length )
    eval( "ROM" + set + ".entry" + index + ".mouseClick()" )
  }
}

//
//  Function:   mouseClickIE - handle mouse click on IE
//  Parameters: none
//
function ROMmouseClickIE()
{
  this.entry.mouseClick()
}

//
//  Function:   Constructor for ROMEntry
//  Parameters: left       - to position the graphic
//              top        - to position the graphic
//              alt        - the alt text for the graphic
//              unselected - the unselected graphic
//              over       - the rollover graphic
//              selected   - the selected graphic
//              javascript - the code to be executed when the entry is selected
//
function ROMEntry( left, top, alt, unselected, over, selected, javascript )
{
  this.left = left
  this.top = top
  this.alt = alt
  this.unselected = unselected
  this.over = over
  this.selected = selected
  this.javascript = javascript
  this.clicked = 0

  this.setMenu = ROMsetMenu
  this.mouseClick = ROMmouseClick
  this.mouseClickedOff = ROMmouseClickedOff

  this.imageu = new Image
  this.imageu.src = this.unselected
  this.imageo = new Image
  this.imageo.src = this.over
  this.images = new Image
  this.images.src = this.selected
}

//
//  Function:   setMenu - set the Menu
//  Parameters: menu
//
function ROMsetMenu( menu )
{
  this.menu = menu
}

//
//  Function:   mouseClick - handle user selecting the entry
//  Parameters: none
//
function ROMmouseClick()
{
  this.clicked = 1
  this.menu.setClickedEntry( this )
  var c
//  if ( entry.menu.isN4 )
//  {
//    c = "this.div.document.images['graphic" + this.index + "i" + this.menu.index + "']"
//  }
//  else
  {
    c = "document.all.graphic" + this.index + "i" + this.menu.index
  }
  c += ".src = this.images.src"
  eval( c )
  eval( this.javascript )
}

//
//  Function:   mouseClickedOff - handle user selecting another entry
//  Parameters: none
//
function ROMmouseClickedOff()
{
  this.clicked = 0
  var c
//  if ( entry.menu.isN4 )
//  {
//    c = "this.div.document.images['graphic" + this.index + "i" + this.menu.index + "']"
//  }
//  else
  {
    c = "document.all.graphic" + this.index + "i" + this.menu.index
  }
  c += ".src = this.imageu.src"
  eval( c )
}

ROMcounter = 0 // Global variable used to differentiate multiple menus
// (c) Copyright IBM Corporation 1998