PopupHandler = function(door,popup,steps,time)
{
  var doorobject = document.getElementById(door);
  this._startw = this._currentw = doorobject.childNodes[0].offsetWidth;
  this._starth = this._currenth = doorobject.childNodes[0].offsetHeight;
  this._popupobject = document.getElementById(popup);
  this._stopw = this._popupobject.offsetWidth;
  this._stoph = this._popupobject.offsetHeight;
  this._deltaw = (this._stopw - this._startw)/steps;
  this._deltah = (this._stoph - this._starth)/steps;
  this._interval = time/steps;
  this._timerId = null;
  if( window.getComputedStyle ) {borderwidth = parseInt(window.getComputedStyle(doorobject,null).borderLeftWidth); }
  else if(doorobject.currentStyle) { borderwidth = parseInt(doorobject.currentStyle.borderWidth); }
  else { borderwidth = 0; }
  this._popupobject.style.left = Math.floor(doorobject.offsetLeft + (this._startw/2) + borderwidth - (this._stopw/2)) + "px";
  this._popupobject.style.top = Math.floor(doorobject.offsetTop + (this._starth/2) + borderwidth - (this._stoph/2)) + "px";
  this._blowUp = this.Delegate(this, this.BlowUp);
  this._takeDown = this.Delegate(this, this.TakeDown);
}
PopupHandler$BlowUp = function()
{
  this._currentw += this._deltaw;
  this._currenth += this._deltah;
  if(this._currentw>=this._stopw || this._currenth>=this._stoph) 
  {
    this._currentw = this._stopw;
    this._currenth = this._stoph;
    window.clearInterval(this._timerId);
    this._timerId = null;
    this._popupobject.style.clip="rect(auto, auto, auto, auto)";
    return;
  }
  this.ShowIt();
}
PopupHandler$TakeDown = function()
{
  this._currentw -= this._deltaw;
  this._currenth -= this._deltah;
  if(this._currentw<this._startw || this._currenth<this._starth) 
  {
    this._currentw = this._startw;
    this._currenth = this._starth;
    window.clearInterval(this._timerId);
    this._timerId = null;
    this._popupobject.style.visibility="hidden"; 
  }
  this.ShowIt();
}
PopupHandler$ShowIt = function()
{
  var left = (this._stopw - this._currentw)/2;
  var top = (this._stoph - this._currenth)/2;
  var rect = "rect(" + top + "px, " + (left + this._currentw) + "px, " + (top + this._currenth) + "px, " + left + "px)";
  this._popupobject.style.clip=rect;
}
PopupHandler$PopItUp = function()
{
  if(this._timerId != null) window.clearInterval(this._timerId);
  this.ShowIt();
  this._popupobject.style.visibility="visible";
  this._timerId = window.setInterval(this._blowUp, this._interval);
}
PopupHandler$PopItDown = function()
{
  if(this._timerId != null) window.clearInterval(this._timerId);
  this._timerId = window.setInterval(this._takeDown, this._interval);
}
PopupHandler$createDelegate=function(a,b)
{
  return function(){return b.apply(a,arguments);};
}
PopupHandler.prototype =
{
  PopItUp : PopupHandler$PopItUp,
  PopItDown : PopupHandler$PopItDown,
  BlowUp : PopupHandler$BlowUp,
  TakeDown : PopupHandler$TakeDown,
  ShowIt : PopupHandler$ShowIt,
  Delegate : PopupHandler$createDelegate
}
