var theButtonNames = new Array();
var theButtonLayers = new Array();
var theButtonObjects = new Array();
var StaticButton = "static";

function findButtonByName(name)
{
  for (i = 0; i < theButtonNames.length; i++)
  {
    if (theButtonNames[i] == name)
    {
      return theButtonObjects[i];
    }
  }
  return null;
}

function findButtonByLayer(name)
{
  for (i = 0; i < theButtonLayers.length; i++)
  {
    if (theButtonLayers[i] == name)
      return theButtonObjects[i];
  }
  return null;
}

function showButtonDown(event)
{
  var theButton;
  if (isNav4)
    theButton = findButtonByName(event.target.name);
  else
  {
    theButton = findButtonByName(self.event.srcElement.name);
    if (theButton == null)
    {
      theButton = findButtonByLayer(self.event.srcElement.id);
    }
  }
	if (theButton != null)
    theButton.buttonDown();
}

function showButtonUp(event)
{
  var theButton;
  if (isNav4)
    theButton = findButtonByName(event.target.name);
  else
  {
    theButton = findButtonByName(self.event.srcElement.name);
    if (theButton == null)
    {
      theButton = findButtonByLayer(self.event.srcElement.id);
    }
  }
	if (theButton != null)
    theButton.buttonUp();
}

function showButtonOver(event)
{
  var theButton;
  if (isNav4)
    theButton = findButtonByName(event.target.name);
  else
  {
    theButton = findButtonByName(self.event.srcElement.name);
    if (theButton == null)
    {
      theButton = findButtonByLayer(self.event.srcElement.id);
    }
  }
	if (theButton != null)
    theButton.buttonOver();
}

function showButtonClick(event)
{
  var theButton;
  if (isNav4)
    theButton = findButtonByName(event.target.name);
  else
  {
    theButton = findButtonByName(self.event.srcElement.name);
    if (theButton == null)
    {
      theButton = findButtonByLayer(self.event.srcElement.id);
    }
  }
	if (theButton != null)
    theButton.buttonClick();
}

function bphoneButton(srcUp, srcDown, srcOver, layer, image, href)
{
  this.buttonDown = buttonDown;
  this.buttonUp = buttonUp;
  this.buttonClick = buttonClick;
  this.buttonOver = buttonOver;
  this.setClickFunction = setClickFunction;
  this.imageUp = new Image();
  this.imageUp.src = srcUp;
  this.imageDown = new Image();
  this.imageDown.src = srcDown;
  this.imageOver = new Image();
  this.imageOver.src = srcOver;
  this.href = href;
  this.theImage = null;
  this.theLayer = null;
  if (isNav4)
  {
    this.theLayer = document;
    this.theImage = document.images[image];

    if (this.theImage == null)
    {
      this.theLayer = document.layers[layer].document;
      this.theImage = document.layers[layer].document.images[image];
    }

    this.theLayer.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
  }
  else
  {
    this.theLayer = document.all(layer);
    this.theImage = document.all(image);
  }
  this.theLayer.onmouseover = showButtonOver;
  this.theLayer.onmouseout = showButtonUp;
  this.theImage.onmousedown = showButtonDown;
  this.theImage.onmouseup = showButtonClick;
  this.buttonUp();
  theButtonNames[theButtonNames.length] = image;
  theButtonLayers[theButtonLayers.length] = layer;
  theButtonObjects[theButtonObjects.length] = this;
}

function buttonDown()
{
  this.theImage.src = this.imageDown.src;
}

function buttonUp()
{
  if (this.theImage.name != window.top.staticButtonName && this.theImage.name != window.top.leaveStaticButtonName)
  {
    this.theImage.src = this.imageUp.src;
  }
}

function buttonOver()
{
  if (this.theImage.name != window.top.staticButtonName && this.theImage.name != window.top.leaveStaticButtonName)
  {
    this.theImage.src = this.imageOver.src;
  }
}

function buttonClick()
{
  this.buttonUp();
  window.location.href = this.href;
}

function setClickFunction(clickFunction)
{
  this.buttonClick = clickFunction;
}
