// BusyBox class constructor
// Arguments:
//
//   varName - name of the variable this instance of the busy box is assigned to.
//   This example uses the default busy box layout defined internally (in the javascript).
//
function BusyBox(varName)
{
  // Initialize object
  this.VarName = varName;

  // Get reference to the IFrame object
  this.div = document.getElementById("BusyBoxDiv");
  //this.img = document.getElementById("BusyBoxImg");

  // Hide the busy box
  this.Hide();
}

// --------------------------------
// Instance Methods
// --------------------------------


// Center:
// Centers the busy box IFrame on the page regardless of the browsers
// scroll position.  This ensures the busy box is presented to the user
// in a visible location in the window.
BusyBox.prototype.Center = function()
{
  var div = this.div;

  // Center the BusyBox in the window regardless of the scroll positions
  var objLeft = (document.body.clientWidth - div.offsetWidth) / 2;
  var objTop = (document.body.clientHeight - div.offsetHeight) / 2;
  objLeft = objLeft + document.body.scrollLeft;
  objTop = objTop + document.body.scrollTop;

  // Position object
  div.style.position = "absolute";
  div.style.top = objTop;
  div.style.left = objLeft;
}


// IsVisible:
// Returns a boolean value representing the visibility state for the busy box.
BusyBox.prototype.IsVisible = function()
{
  return this.div.style.visibility == "visible" && this.div.style.width > 0;
}


// Hide:
// Hides the busy box making it invisible to the user.
BusyBox.prototype.Hide = function()
{
  // Hide the busy box.
  this.div.style.left = "-1000px";
  this.div.style.top = "-1000px";
}


// Show:
// This function displays the busy box to the user.  This function centers the
// busy dialog box, makes it visible, and starts the animation.  This function
// will typically be called by the body event.
//
BusyBox.prototype.Show = function()
{
  if( this.IsVisible() )
    return;

  this.Center();

  // Set the busy box to be visible and make sure it is on top of all other controls.
  this.div.style.visibility = "visible";
  this.div.style.zIndex = "999999";
 }
