window.popup = function(lnk, attrs) {
  var newWin, popup_win;

  var href = lnk.href;

  var dict = {
    'target' : lnk.target || '_blank',
    'attrs' : {
      'height' : 400,
      'width' : 600,
      'left' : 50,
      'top' : 50,
      'resizable' : true,
      'scrollbars' : true,
      'menubar' : false,
      'toolbar' : false,
      'location' : false,
      'status' : false,
      'directories' : false
    }
  };

  for (var x in attrs) {
    dict.attrs[x] = attrs[x];
  }

  if (popup_win) {
    newWin = popup_win(lnk, dict);
  } else {
    var attr_str = '';

    for (var x in dict.attrs) {
      if (attr_str != '') {
        attr_str += ',';
      }

      attr_str += x + '=' + (typeof(dict.attrs[x]) == 'boolean' ? (dict.attrs[x] ? 1 : 0) : dict.attrs[x]);
    }

    newWin = window.open(href, dict.target, attr_str);
  }

  if (newWin && newWin.focus) {
    newWin.focus();
  }
};
