/* ****************************************************
#kesrequire(share/webwidgets/ui/popup/Popup.js)
#kesrequire(share/webwidgets/ui/core/MImageHandling.js)
#kesrequire(share/media/MediaShow.js)
**************************************************** */

/**
 * Allgemeines Popup im Larenzo-Stil.
 */
qx.Class.define("nx4.cmslarenzo.ui.popup.Popup",
{
  extend : nx4.webwidgets.ui.popup.Popup,
  include : nx4.webwidgets.ui.core.MImageHandling,

  properties :
  {
    title :
    {
      init  : null,
      nullable : true,
      apply : "_applyTitle"
    },

    content :
    {
      init  : "",
      apply : "_applyContent"
    }
  },

  members :
  {
    _createContainerElement : function()
    {
      var el = this.base(arguments);
      el.setAttribute("class", "popup");
      return el;
    },

    _createContentElement : function()
    {
      var el = this.base(arguments);

      var t = new qx.html.Element("div");
      t.setAttribute("class", "top");
      var a = new qx.html.Element("a");
      a.setAttribute("class", "popup_closebox");
      var i = new qx.html.Image();
      i.setStyle("position", "relative");
      i.setScale(true);
      i.setStyle("width", "99px");
      i.setStyle("height", "29px");
      this._styleImageSource(i, nx4.media.MediaShow.getInstance().showResource("share/cmslarenzo/button_fenster_schliessen.gif"));
      i.addListener("click", this.exclude, this);
      i.setStyle("cursor", "pointer");
      a.add(i);      
      t.add(a);
      el.add(t);

      this._main = new qx.html.Element("div");
      this._main.setAttribute("class", "main");

      this._title = new qx.html.Element("div");
      this._title.setAttribute("class", "title");
      this._main.add(this._title);

      this._content = new qx.html.Element("div");
      this._content.setAttribute("class", "content");
      this._main.add(this._content);

      el.add(this._main);
      return el;      
    },

    _applyTitle : function(n, o)
    {
      if(!n)
        this._title.hide();
      else
      {
        this._title.setAttribute("html", n);
        this._title.show();
      }
    },

    _applyContent : function(n, o)
    {
      this._content.setAttribute("html", n);
    }
  }

});

