var uWindow ="";

function openWin(URL,maxW,maxH)
 {
  // var winX=0; var winY=0;
  if (parseInt(navigator.appVersion)>3)
   {
    if (navigator.appName=="Netscape")
     {
      // position popup screen in centre of parent window
      winX=self.screenX+window.innerWidth/2-maxW/2;
      winY=self.screenY+window.innerHeight/2-maxH/2;
     }
    if (navigator.appName.indexOf("Microsoft")!=-1)
     {
      // position popup screen in centre of parent window
      winX=this.screenLeft+document.body.clientWidth/2-maxW/2;
      winY=this.screenTop+document.body.clientHeight/2-maxH/2;
     }
   }
  // if new X position doesn't give enough room for width of popup window, adjust it
  if (winX>window.screen.width-maxW-40)
   {
    winX=window.screen.width-maxW-40;
   }
  // if new Y position doesn't give enough room for height of popup window, adjust it
 if (winY>window.screen.height-maxH-80)
   {
    winY=window.screen.height-maxH-80;
   }
 if (uWindow && !uWindow.closed)
  {
   uWindow.close();
  }
  uWindow = window.open(URL,"popupwindow",
          "left="+winX+",top="+winY+",width="+maxW+",height="+maxH+","+
          "toolbar=no,status=no,scrollbars=no,resizable=no,menubar=no");
 }