function CenterWin(url, x, y, name)
{
  n_width  = x;
  n_height = y;
  n_top = (screen.height - n_height)/2-50;
  n_left= (screen.width - n_width)/2;
  param="resizable=yes,scrollbars=yes,status=yes,dependent=no";
  window.open(url, name, "top="+n_top+",left="+n_left+",width="+n_width+",height="+n_height+","+param+"");
  return false;
}

function resizeDialogToContent()
{
  // resize window so there are no scrollbars visible
  var dw = window.dialogWidth;
  while (isNaN(dw))
  {
    dw = dw.substr(0,dw.length-1);
  }
  difw = dw - this.document.body.clientWidth;
  window.dialogWidth = this.document.body.scrollWidth+difw+'px';

  var dh = window.dialogHeight;
  while (isNaN(dh))
  {
    dh = dh.substr(0,dh.length-1);
  }
  difh = dh - this.document.body.clientHeight;
  window.dialogHeight = this.document.body.scrollHeight+difh+'px';
}
