// Galaxies Galore library

function di(id,name){
  if (document.images) {document.images[id].src=eval(name+".src"); }
}

// function that displays status bar message
function dm(msgStr) {
  document.returnValue = false;
  if (document.images) { 
     window.status = msgStr;
     document.returnValue = true;
  }
}

var showMsg = navigator.userAgent != "Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)";

function dmim(msgStr) {
  document.returnValue = false;
  if (showMsg) { 
    window.status = msgStr;
    document.returnValue = true;
  }
}

function MM_displayStatusMsg(msgStr) { //v2.0
  status=msgStr;
  document.MM_returnValue = true;
}

// Image swapping functions.
function MM_preloadImages() { //v1.2
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    var preloadArray = new Array();
    for (var i=0; i<imgFiles.length; i++) {
      preloadArray[i] = new Image;
      preloadArray[i].src = imgFiles[i];
    }
  }
}

function MM_swapImage() { //v1.2
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}

function MM_swapImgRestore() { //v1.2
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

// Window opening/ closing operations.
function unLoad() {
  STSCI_closeMBrWindows();
  STScI_windowClose();
}

function loadInit() {
  STScI_windowOpen();
}

// Popup management.  Note: rewritten a dozen times...
function stsci_closePopups () {
  STSCI_closeMBrWindows();
}

function stsci_createPopup (theUrl, winName, features) {
  STSCI_openMBrWindow(theUrl, winName, features);
  document.MM_returnValue = false;
}

// Set the location of the home window.
function stsci_sbOpener(theURL) { 
  var exists = false;
  if (window.opener) {
    if (window.opener != null) {
      var wo = window.opener;
      if (wo.window.opener) {
        if (wo.window.opener != null) {
          wo = window.opener.window.opener;
          if (wo.top) {
            if (wo.top != null) {
              exists = true;
            }
          }
        }
      }
    }
  }
  if (exists) {
    window.opener.window.opener.top.location = theURL;
  } else {
    location = theURL;
  }
    
  document.MM_returnValue = false;
}

// Navigation functions.
function stsci_goOwner (url) {
  window.opener.top.location = url;
  close ();
}