registerClickListener = function() {

  var tempPopups = $tm.path.tempPopups;
  window.addEventListener('click', function(evt) {

    var popupStates = utils.getTiddlersByPrefix(tempPopups);

    for (var i = popupStates.length; i--;) {
      if (utils.getText(popupStates[i])) break;
    }

    if (i === -1) return;

    if (!$tw.utils.hasClass(evt.target, 'tc-drop-down')
       && !utils.getAncestorWithClass(evt.target, 'tc-drop-down')) {
    // = clicked on an element that isn't a dropdown or inside one
      for (var i = popupStates.length; i--;) {
        utils.setText(popupStates[i], '');
      }
    }

  }, false);
}
@TODO: suggest this to Jeremy for TW popup handling