var images;
var button_index;
var num_buttons;

function init_buttons(num)
  {
  button_index = 0;
  num_buttons = num;
  images = new Array(num*3);
  for(i=0;i<num*3;i++)
    {
    images[i] = new Image();
    } 
  }

function button_over(name, index)
  {
  document.images[name].src = images[index*3+1].src;
  }

function button_click(name, index)
  {
  document.images[name].src = images[index*3+2].src;
  }

function button_out(name, index)
  {
  document.images[name].src = images[index*3].src;
  }

function init_button(name)
  {
  var str;
  if(button_index == num_buttons)
    button_index = 0;
  }

function mk_button(name)
  {
  var str;

  str = "images/" + name + ".png";
  images[button_index*3].src = str;

  str = "images/" + name + "_hl.png";
  images[button_index*3+1].src = str;

  str = "images/" + name + "_cl.png";
  images[button_index*3+2].src = str;

  str = "<a href=\"" + name + ".html\" target=\"main\" onMouseOver=\"button_over(\'" + name + "\', " + button_index + ");\" onMouseDown=\"button_click(\'" + name + "\', " + button_index + ");\" onMouseOut=\"button_out(\'" + name + "\', " + button_index + ");\" onMouseUp=\"button_over(\'" + name + "\', " + button_index + ");\">";
  str += "<img src=\"images/" + name + ".png\" name=\"" + name + "\" NOSAVE border=0>";
//  str += "BLA";
  str += "</a>"
  document.write(str);

  button_index += 1;
  }

function mk_button_with_link(name, link)
  {
  var str;

  str = "images/" + name + ".png";
  images[button_index*3].src = str;

  str = "images/" + name + "_hl.png";
  images[button_index*3+1].src = str;

  str = "images/" + name + "_cl.png";
  images[button_index*3+2].src = str;

  str = "<a href=\"" + link + "\" target=\"_top\" onMouseOver=\"button_over(\'" + name + "\', " + button_index + ");\" onMouseDown=\"button_click(\'" + name + "\', " + button_index + ");\" onMouseOut=\"button_out(\'" + name + "\', " + button_index + ");\" onMouseUp=\"button_over(\'" + name + "\', " + button_index + ");\">";
  str += "<img src=\"images/" + name + ".png\" name=\"" + name + "\" NOSAVE border=0>";
//  str += "BLA";
  str += "</a>"
  document.write(str);

  button_index += 1;
  }
