if (isJsEnabled()) {
  addLoadEvent(fillSubterms);
}

function fillSubterms() {
  var sdbs = [];
  var opts = document.getElementById('block-gunther-0').getElementsByTagName('input');
  var select = document.getElementById('block-gunther-0').getElementsByTagName('select')[0];
  for(var i=0; opt = opts[i]; i++) {
    if(opt && opt.name == 'Niveau') {
      uri = opt.getAttribute('ows:ac_uri');
      opt.ping = opt.getAttribute('ows:ping');
      opt.removeAttribute('ows:ac_uri');
      opt.removeAttribute('ows:ping');
      opt.options = '';
      opt.loaded = false;
      opt.onclick = function() {if(this.loaded) {fillSelect(select, this.options); HTTPGet(this.ping, function(){}, opt);} else {obj = this; window.setTimeout(function() {obj.onclick();}, 1000);}}
      HTTPGet(uri, getSubterms, opt);
    }
  }
}

function getSubterms(string, xmlhttp, opt) {
  if (xmlhttp.status == 200) {
    opt.options = parseJson(string);
    opt.loaded = true;
  }
}



function fillSelect(obj, options) {
  var a = obj.firstChild;
  while(a.nextSibling)
    obj.removeChild(a.nextSibling);
  obj.removeChild(a);
  var opt = document.createElement('option');
  for(i in options) {
    var my_opt = opt.cloneNode(false);
    my_opt.value = i;
    my_opt.appendChild(document.createTextNode(options[i]));
    obj.appendChild(my_opt);
  }
}
