var hideOnOverlayClose = new Array();

function getOverlay() {
  var overlay = document.getElementById('overlay');
  
  if (!overlay) {
    overlay = document.createElement('div');
    overlay.id = 'overlay';
    overlay.style.display = 'none';
    
    overlay.hide = function() {
      this.style.display = 'none';
      this.style.zIndex = '-1';

      for (i = 0; i < hideOnOverlayClose.length; i++) {
        hideOnOverlayClose[i].hide();
      }
    }
    overlay.show = function() {
      this.style.display = 'block';
      this.style.zIndex = '10000';
    }
    
    overlay.onclick = function() {
      this.hide();
    }
    
    document.body.appendChild(overlay);
  }
  
  return overlay;
};