var OverlayManager = {
  overlay: null,
  overlayBg: null,
  overlayContainer: null,
  
  manage: function() {
    // try {
      if((this.overlay && this.overlayBg && this.overlayContainer) ||
        (this.overlayBg = $('overlay_bg')) &&
          (this.overlayContainer = $('overlay_container')) &&
            (this.overlay = $('overlay'))
            ) {
        if(this.overlay.firstChild && (this.overlay.firstChild.nodeType != 3 || this.overlay.firstChild != this.overlay.lastChild)) {
          window.setTimeout(function() { IAFlashes.stopFlash("play-button"); Element.hide("play-button"); }, 1000);
          if(!Element.visible(this.overlayContainer)) Element.show(this.overlayContainer);
          if(this.overlayBg.offsetHeight != this.overlayContainer.offsetHeight) {
            this.overlayBg.style.height = this.overlayContainer.offsetHeight + "px"
          }
        } else {
          if(Element.visible(this.overlayContainer)) Element.hide(this.overlayContainer); 
        }
      }
    // } catch(e) { if(confirm(e.message)) return }
    window.setTimeout(OverlayManager.manage, 200);
  },
  
  clear: function() {
    var overlay = $('overlay');
    while(overlay.firstChild) overlay.removeChild(overlay.firstChild);
  }
}

OverlayManager.manage();
