/**************************************************/
/* Display a popup window centered on the screen. */
/* Width and Height are supplied by the caller.   * /
/**************************************************/
var win= null;
function newWindow(mypage,myname,w,h,scroll) {
  var winl = (screen.availWidth-w)/2;
  var wint = (screen.availHeight-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=yes';
  win=window.open(mypage,myname,settings);
  if (parseInt(navigator.appVersion) >= 4) {
     win.focus();
  }
  if (!win.opener) {
    win.opener = self;
  }

  return win;
}

/*******************************************************/
/* Display a popup window centered on the screen. The  */
/* window will be half the size of a maximized browser */
/* window and centered in the middle of the screen     */
/*******************************************************/
function centerWindowScreen(mypage,myname,scroll) {
  var w = 480, h = 340;
  if (document.all || document.layers) {
    w = screen.availWidth/2;
    h = screen.availHeight/2;
  }
  newWindow(mypage,myname,w,h,scroll)
}

/***********************************************************/
/* Display a popup window centered in the current browser. */
/***********************************************************/
function centerWindowBrowser(mypage,myname,scroll) {
  var w = 480, h = 340;
  if (document.all) {
    /* the following is only available after onLoad */
    w = document.body.clientWidth/2;
    h = document.body.clientHeight/2;
  }
  else if (document.layers) {
    w = window.innerWidth/2;
    h = window.innerHeight/2;
  }
  newWindow(mypage,myname,w,h,scroll)
}

function supressError() {
    return true;
}

/*****************************************************************/
/* Load a URL into the parent window and close the popup window. */
/*****************************************************************/
function UrlLoad(url) {
    window.onerror = supressError;
    opener.location.href = url;
    setTimeout('self.close()',1000);
}

/************************************************/
/* Resize a window and center it on the screen. */
/************************************************/
function ResizeWindow(width,height)
{
  window.resizeTo(width,height)
  x = (window.screen.width - width) / 2;
  y = (window.screen.height - height) / 2;
  window.moveTo( x, y );
}
