var modal = document.getElementById("modal");
var modal_header = document.getElementById("modal-header");
var modal_content = document.getElementById("modal-content");
var modal_body = document.getElementById("modal-body");

function ModalClose(){
  modal.style.display = "none";
}

function OpenModalUrl(title, width, height, url, callback){
  modal_header.innerHTML = title;
  modal_content.style.width = width;
  modal_body.style.maxHeight = height;

var request = new XMLHttpRequest();
  request.onreadystatechange = function () {
    if (this.readyState === 4 && this.status === 200) {
	  modal_body.innerHTML="";
	  modal_body.insertAdjacentHTML('afterbegin', this.responseText);
	  modal.style.display = "block";
	  callback();
    }
  };
  request.open("GET", url, true);
  request.send(null);
}

function OpenModalHTML(title, width, height, HTML){
  modal_header.innerHTML = title;
  modal_content.style.width = width;
  modal_body.style.height = height;
  modal_body.innerHTML="";
  modal_body.insertAdjacentHTML('afterbegin', HTML);
  modal.style.display = "block";
}