function showLegend(query) {
  var layername = query.split('=')[1];
  if (!lsPop || !showPopup('xfl' + layername, layername)) {
    var qs = query + '&ini=' + mf.ini.value;
    var xhr = new xHttpRequest();
    if (!xhr.send('POST', lsUrl, qs, xhrTo, false, false, null, onLegendResponse)) gotoError();
    xhr = null;
  }
}

function onLegendResponse(req, status, obj) {
  if (status == 0) {
    var json = JSON.parse(req.responseText);
    if (json.ok) {
      if (lsPop) makeFenster('xfl' + json.layer, json.layer, null, json.legend, null, json.layertitle, lsLeft, lsTop, lsWidth, lsHeight);
      else {
        xInnerHtml(lsDiv, json.legend);
        showDiv(lsDiv, true);
      }
    } else alert(json.err);
  } else gotoError();
}
