var mh_Modal_Window = function(id, title, content) {
  if($("#mh_Modal_Window_" + id).length == 0) {
    this.id = "mh_Modal_Window_" + id;
    this.title = title;
    this.content = content;
    
    this.createWindow();
  }
};

mh_Modal_Window.prototype.id;
mh_Modal_Window.prototype.title;
mh_Modal_Window.prototype.content;
mh_Modal_Window.prototype.confirmOnClose = false;

mh_Modal_Window.prototype.createWindow = function() {
  var winCont = new Element("div", { id: this.id, "class": "mh_Modal_Window_Cont" });
  winCont.innerHTML =
    '<div class="mh_Modal_Window_background"></div>' +
    '<div class="mh_Modal_Window">' +
      '<div class="mh_Modal_Window_dialog">' +
        "<h2>" + this.title +
          '<button type="button">x</button>' +
        "</h2>" +
        '<div class="mh_Modal_Window_content">' + this.content + "</div>" +
      "</div>"
    "</div>";
  
  
  $("body").append(winCont);
  $("body").css("overflow", "hidden");
  
  $(".mh_Modal_Window h2 button").click(this.close.bind(this));
};

mh_Modal_Window.prototype.onClose = function() {};

mh_Modal_Window.prototype.close = function() {
  if(((this.confirmOnClose) && (confirm(mh_lng.confirm_close_window))) || (!this.confirmOnClose)) {
    this.onClose();
    
    $("body").css("overflow", "auto");
    $("#" + this.id).remove();
  }
};