var _POPUP_FEATURES =
  'location=no,'+
  'menubar=no,'+
  'resizeable=yes,'+
  'scrollbars=no,'+
  'statusbar=no';

function popup(url, w, h, target, features) {
  if (isUndefined(w)) {
	w = 400;
	h = 300;
  }
  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  x = (screen.width - w) / 2;
  y = (screen.height - h) / 2;
  features = 'width='+w+
    ',height='+h+
    ',left='+x+
    ',top='+y+
    ','+features;
  //alert(features);
  var theWindow = window.open(url, target, features);
  theWindow.focus();
  return theWindow;
}

function linkPopup(src, w, h, features) {
  return popup(src.getAttribute('href'), w, h, src.getAttribute('target') || '_blank', features);
}

function isUndefined(v) {
    var undef;
    return v===undef;
}