// $Id: image_changer.js,v 1.5 2003/01/31 02:27:33 wolf Exp $
function image_changer()
{
  this.version = "1.4";
  this.dirprefix = "";
  this.image_list = new Array();
  this.saved_status = "";

  // Add an image with a mouse-over handler
  this.add = function _add(name,description,normal,over)
  {
    image_normal = new Image();
    image_over = new Image();
    image_normal.src = this.dirprefix + normal;
    image_over.src = this.dirprefix + over;
    this.image_list[name] = new Array(description,image_normal,image_over);
  } // add

  // Set the directory prefix where to find the images
  this.set_directory = function _dirprefix(dirname)
  {
    if (dirname.length != "/") { dirname = dirname + "/"; }
    this.dirprefix = dirname;
  } // set_directory

  // Function for mouse over image
  this.mouse_over = function _mouse_over(name)
  {
    if (this.image_list[name])
    {
      if (this.image_list[name][0] != "")
      {
        this.saved_status = self.status;
        self.status = this.image_list[name][0];
      }
      var obj = eval("document." + name);
      obj.src = this.image_list[name][2].src;
      return true;
    }
    return false;
  } // mouse_over

  // Function for mouse out image
  this.mouse_out = function _mouse_out(name)
  {
    if (this.image_list[name])
    {
      if (this.image_list[name][0] != "")
      { self.status = this.saved_status; }
      var obj = eval("document." + name);
      obj.src = this.image_list[name][1].src;
      return true;
    }
    return false;
  } // mouse_out

  // Function to write the image in the html page
  this.img = function _write_image(name)
  {
    if (this.image_list[name])
    {
      document.write('<img name="' +name+ '" src="' +this.image_list[name][1].src+ '" alt="' +this.image_list[name][0]+ '" border="0" />');
    }
  } // img

} // image_changer
