// ****************************

//	Opens a new window (popup) with a given URL

// ****************************

var NewWindow = null;
function WindowOpener(File,Wwidth,Wheight,ScrllBrs) {
  if (NewWindow != null) {NewWindow.close();}

  // Coordinates of current popup change if "toolbar", etc. is activated
  if (window.opener != null){
    var windowTop = window.screenTop-23;
    var windowLeft = window.screenLeft-4;
  } else {
    var windowTop = 0;
    var windowLeft = 0;
  }

  var screenY = screen.height;
  var screenX = screen.width;

  var widthNW  = "width=" + Wwidth, heightNW  = "height=" + Wheight;

  if (((screenX-Wwidth)/2 == windowLeft) && ((screenY-Wheight)/2 == windowTop))
  {
    var centerNW  = "left=" + (windowLeft+150), centerNH  = "top=" + (windowTop-150);
  } else {
    var centerNW  = "left=" + (screenX-Wwidth)/2, centerNH  = "top=" + (screenY-Wheight)/2;
  }

  if (navigator.appVersion.indexOf("Macintosh") != -1) { 
    var MenuBar = "menubar=1"
  } else { 
    var MenuBar = "menubar=0"
  }

  var featuresNW   = "toolbar=0,location=0,directories=0,status=0," + MenuBar + ",scrollbars=" + ScrllBrs + ",resizable=1,copyhistory=0," + widthNW + "," + heightNW + "," + centerNW  + "," + centerNH;
  NewWindow = window.open(File,'',featuresNW);

  return;	  
}



// ****************************

//	This function closes all popups opened by WindowOpener()

// ****************************

if (window.opener){
  setTimeout("ClosePopups();", 1000); 
}

function ClosePopups() {
  if (window.opener && window.opener.closed)
  {
    window.close();
  } else {
    setTimeout("ClosePopups();", 1000);
  }
}

function KillPopups() {
  if (NewWindow != null) {NewWindow.close();}
}