var i2m_Modal_Window = function(id, title, content, postfix) {
  this.id = "i2m_Modal_Window_" + id;
  this.title = title;
  this.content = content;
  
  this.createWindow(postfix);
};

i2m_Modal_Window.prototype.id;
i2m_Modal_Window.prototype.title;
i2m_Modal_Window.prototype.content;

i2m_Modal_Window.prototype.createWindow = function(postfix) {
  var winCont = new Element("div", { id: this.id, "class": "i2m_Modal_Window_Cont" });
    var cl = "i2m_Modal_Window";
    if (postfix) cl += postfix;
  winCont.innerHTML =
    '<div class="i2m_Modal_Window_BG"></div>' +
    '<div class="' + cl + '" id="recwin">' +
      "<h2>" + this.title +
        '<div class="modalWindowClose"></div>' +
      "</h2>" +
      "<div>" + this.content + "</div>" +
    "</div>";
  
  $$("body")[0].appendChild(winCont);
  
    $$("." + cl + " h2 div")[0].onclick = this.close.bind(this);
};

i2m_Modal_Window.prototype.onClose = function() {};

i2m_Modal_Window.prototype.close = function() {
  this.onClose();
  
  $(this.id).remove();
};
