// This script will close child windows when the parent
// window is closed.
//
// Date:     12/14/1999
// Author:   David Wickersham (skeezicks@cyberdude.com)
// Version:  1.0
//
// Installation Instructions:
// 1. Copy this script into a file named popup_closer.js.
// 2. Use the script tag to incorporate popup_closer.js 
//    into the head area of the html page:
//    <script language="javascript" src="[path]popup_closer.js"></script>.
// 3. Add the onUnload event handler to the <body> tag:
//    <body onUnload="popupCloser()">.
// 4. Each time you open a new window using the window.open
//    method put the new window object into poparray:
//    poparray[popsub] = window.open("[your_popup.html]","[any_name]","[your_window_options]");
//    and then increment popsub by 1:  popsub++;.
//    
// How It Works:
// All popup window objects created during the life cycle 
// of the parent page are stored in poparray. When the page 
// is unloaded the script spins through poparray looking
// for child window objects that still exist. Any that are
// found are closed.
//
// Compatibility:
// Should run on all IE & Netscape browsers but will not 
// close the child windows for IE browsers prior to version 
// 4. Tested on IE 5 and Netscape 4.


poparray = new Array();
var popsub = 0;

function popupCloser()  {
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >= 4)  {
    for(popsub =  0; popsub < poparray.length; popsub++)  {
      if(poparray[popsub] != null)  {
        if(!poparray[popsub].closed)  {
          poparray[popsub].close();
        }
      }
    }
  }
  return true;
}
