

function onUnloadCloseOpenedPopups ()
{
  //try
  //{
    //window.attachEvent("onunload", mainunload);
  //}
  //catch(e)
  //{}
}

function mainunload ()
{
  var theTop = window;
  if (theTop.opener && theTop.opener.popups)
    theTop = window.opener;
    
 for (; theTop.parent != theTop && theTop.popups; theTop = theTop.parent);
    if (theTop.popups)
      theTop.closepopups();
}