var XWin = null;
Count = 0;
var Name = null;
var Rand = Math.round(Math.random() * 100);

function openXWin(URL, Width, Height, Name){
  if (Name == null) Name = "XWin" + Rand + Count++;
  closeXWin();
	if (Width == null) Width=600;
	if (Height == null) Height=400;

  var Xpos=(screen.availWidth - Width)/2;
  var Ypos=(screen.availHeight - Height)/2;

  XWin = window.open(URL, Name, "width=" + Width + ",height=" + Height +",scrollbars,left="+Xpos+",top="+Ypos+",screenX="+Xpos+",screenY="+Ypos);
  XWin.focus();
}

function openXWinRS(URL, Width, Height){
  Name = "XWin" + Count++;
  closeXWin();
	if (Width == null) Width=600;
	if (Height == null) Height=400;
  XWin = window.open(URL, Name, "width=" + Width + ",height=" + Height +",scrollbars,resizable");
  XWin.focus();
}

function closeXWin(){   
  if(XWin != null) {
    if(!XWin.closed) 
      XWin.close();
  }
}
