function replaceImage(image_node_name, image_name)
{
document.writeln("<p>1 replaceImage " + image_node_name + " " + image_name + "</p>");
    var image_node = document.getElementById(image_node_name);
if (image_node)
document.writeln("<p>2 replaceImage " + image_node + "</p>");

    var new_image = new Image();
document.writeln("<p>3 replaceImage " + image_name + "</p>");
    new_image.src = image_name;
document.writeln("<p>4 replaceImage " + image_name + "</p>");
    image_node.src = new_image.src;
document.writeln("<p>5 replaceImage " + image_name + "</p>");
}

function TwoImage(image_node_name, image_name1, image_name2)
{
  document.writeln("<p>111 TwoImage image node</p>");

  this.image_node = document.getElementById(image_node_name);
  document.writeln("<p>222 TwoImage image node</p>");
  /*if (this.image_node)*/
    /*document.writeln("<p>TwoImage image node " + image_node + "</p>");*/
  /*else*/
   /* document.writeln("<p>TwoImage image node NULL!!! </p>");*/

  document.writeln("<p>1 TwoImage End</p>");
  this.i = new Array();

  this.i[0] = new Image();
  this.i[0].src = image_name1;
  this.i[1] = new Image();
  this.i[1].src = image_name2;
  document.writeln("<p>6 TwoImage End</p>");

  this.idx = 0;
}

function swapImage()
{
   document.writeln("<p>1 Swap Image</p>");
   this.image_node = this.i[this.idx];
   this.idx++;
   this.idx = this.idx % 2;
   document.writeln("<p>2 Swap Image</p>");
}

/* Make swapImage() a member function for TwoImage */
TwoImage.prototype.swap = swapImage;


// Found this off the web.  Really poorly written and no comments.
// Eventually I'll figure out how the hell it works.

function MM_swapImgRestore() { //v3.0
  var i;
  var x;
  var a = document.MM_sr;

  for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
     x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d = document;
  if(d.images)
  {
    if (!d.MM_p)
      d.MM_p = new Array();
    var i;
    var j = d.MM_p.length;
    var a = MM_preloadImages.arguments;

    for(i = 0; i < a.length; i++)
    if (a[i].indexOf("#")!=0)
    {
      d.MM_p[j] = new Image;
      d.MM_p[j++].src = a[i];
    }
  }
}

function MM_findObj(n, d) { //v4.01
  var p;
  var i;
  var x;
  if (!d)
    d = document;
  if ((p = n.indexOf("?")) > 0 && parent.frames.length)
  {
    d = parent.frames[n.substring(p+1)].document;
    n = n.substring(0,p);
  }
  if (!(x=d[n])&&d.all)
    x = d.all[n];
  for (i = 0; !x && i < d.forms.length; i++)
    x = d.forms[i][n];
  for (i = 0; !x && d.layers && i < d.layers.length; i++)
    x = MM_findObj(n,d.layers[i].document);
  if (!x && d.getElementById)
    x = d.getElementById(n);
  return x;
}

function MM_swapImage() { //v3.0
  var i;
  var j = 0;
  var x;
  var a = MM_swapImage.arguments;
  document.MM_sr = new Array;
  for (i = 0; i < (a.length-2); i += 3)
    if ((x = MM_findObj(a[i])) != null)
    {
      document.MM_sr[j++]=x;
      if (!x.oSrc)
        x.oSrc = x.src;
      x.src = a[i+2];
    }
}

