// Yet another popup window library.

// Used by the parent window to create a child.
function STSCI_openMBrWindow(theURL,winName,features) {
  if (document.STScI_popupsState[winName]) {
    if (document.STScI_popupsState[winName] == "open") {
	  if (document.STScI_popups[winName].close)
        document.STScI_popups[winName].close();
	}
  }
  document.STScI_popups[winName] = window.open(theURL,winName,features);
  document.MM_returnValue = false;
}

// Used by the parent window to close all children.
// Typically found in the body.onUnload attribute.
function STSCI_closeMBrWindows() {
  for (var i in document.STScI_popups) {
    if (document.STScI_popupsState[i] == "open") {
      document.STScI_popups[i].close();
	}
  }
  document.MM_returnValue = false;
}

// Used by the child to let the parent know it is closing.
// Typically found in the body.onUnload attribute.
function STScI_windowClose() {
  if (window.opener)
    if (window.opener.setClose)
      window.opener.setClose(window.name);
}

// Used by the child to let the parent know it has actually opened.
// Typically found in the body.onLoad attribute.
function STScI_windowOpen() {
  if (window.opener)
    if (window.opener.setOpen)
	  window.opener.setOpen(window.name);
}

// Auxillary function called by the child in the parent.
function setOpen(winName) {
  document.STScI_popupsState[winName] = "open";
}

// Auxillary function called by the child in the parent.
function setClose(winName) {
  document.STScI_popupsState[winName] = "close";
}

// Global initialization.
document.STScI_popups = new Array;
document.STScI_popupsState = new Array;