function popup(url, id, w, h, x, y, resize, scrollbar, menubar, status, toolbar) {
  var opt = '';
  var noDef;

  if (w != noDef) {
	opt += 'width=' + w + ',';
	if (x == noDef)
		x = (screen.width - w) / 2;
	opt += 'left=' + x  + ',';
  }

  if (h != noDef) {
	opt += 'height=' + h + ',';
	if (y == noDef)
		y = (screen.height - h) / 2;
	opt += 'top=' + y + ',';
  }

  if (resize != noDef)		opt += 'resizable=no,';
  if (scrollbar != noDef)	opt += 'scrollbars=' + scrollbar + ',';
  if (menubar != noDef)	opt += 'menubar=' + menubar + ',';
  if (status != noDef)		opt += 'status=' + status + ',';
  if (toolbar != noDef)	opt += 'toolbar=' + toolbar + ',';

  var win = window.open(url, id, opt);
  if (win)
	win.focus();
  else
	alert("Failed to open window: " + url + "\nID = " + id + "\nOpts = \n" + opt);

}
