FB_IPPU = new Class ( IPPU, {
  init: function(title) {
    if (!title)
      title = "";

    FB_IPPU.superClass.init.apply(this, []);

    this.uniqId = this.generateUniqId();
    this.cancelThisFunc = this.cancel.bind(this);

    var titlebarContent = "\
      <div style='width:100%; text-align:left; padding: 4px; border: 0px solid yellow;'><div style='float:right; padding-right: 8px'><img src='/img/CloseButton.gif' width='15' height='15' id='" + this.uniqId + "_cancel' /></div>" + title + "</div>";

    this.setTitlebar(true);
    this.setTitle(titlebarContent);
    this.setTitlebarClass("fb_ippu_titlebar");

    this.addClass("fb_ippu");

    this.setAutoCenterCallback(IPPU.center);
    this.setDimensions(400, "auto");
    this.setOverflow("hidden");

    this.setFixedPosition(true);
    this.setClickToClose(true);
    this.setAutoHideSelects(true);
  },

  generateUniqId: function() {
    var theDate = new Date();
    return "fb_ippu_" + theDate.getHours() + theDate.getMinutes() + theDate.getMilliseconds();
  },

  show: function() {
    FB_IPPU.superClass.show.apply(this);
    var setupCallback = this.setup_fb_ippu.bind(this);
    window.setTimeout(setupCallback, 300);
  },

  setup_fb_ippu: function (evt) {
    var cancelCallback = this.cancelThisFunc;
    DOM.addEventListener($(this.uniqId + "_cancel"), "click", cancelCallback, true);
  },

  hide: function() {
    DOM.removeEventListener($(this.uniqId + "_cancel"), "click", this.cancelThisFunc, true);
    FB_IPPU.superClass.hide.apply(this);
  }
} );
