var http = null;

if (window.ActiveXObject) {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
  http = new XMLHttpRequest();
}

function give_sitesID(rubric) {
  var tmp = "config/_ajax_functions.php?f=give_sitesID&rubric="+rubric;
  if (http != null) {
    var selectfield = document.getElementById("selectfield");
    var children = selectfield.childNodes;
    if(children.length > 0) {
      while(children.length > 0) {
        selectfield.removeChild(selectfield.lastChild);
      }
    }
    
    http.open("GET", tmp, true);
    http.onreadystatechange = resultID;
    http.send(null);
  }
}
function resultID() {
  if(http.readyState == 4) {
    var daten = http.responseText;
    daten = eval("(" + daten + ")");
    var selectfield = document.getElementById("selectfield");
    for (var i = 0; i < daten.length; i++) {
      var array = daten[i];
      var optionfield = document.createElement("option");
      var textfield = document.createTextNode(array.title);
      optionfield.value = array.resultvalue;
      optionfield.appendChild(textfield);
      selectfield.appendChild(optionfield);
    }
  }
}


function give_sites(rubric,exeption) {
  var tmp = "config/_ajax_functions.php?f=give_sites&rubric="+rubric+"&expeption="+exeption;
  if (http != null) {
    var selectfield = document.getElementById("sortID");
    var children = selectfield.childNodes;
    if(children.length > 0) {
      while(children.length > 1) {
        selectfield.removeChild(selectfield.lastChild);
      }
    }
    
    http.open("GET", tmp, true);
    http.onreadystatechange = result;
    http.send(null);
  }
}

function result() {
  if(http.readyState == 4) {
    var daten = http.responseText;
    daten = eval("(" + daten + ")");
    var selectfield = document.getElementById("sortID");
    for (var i = 0; i < daten.length; i++) {
      var array = daten[i];
      var optionfield = document.createElement("option");
      var textfield = document.createTextNode(array.title);
      optionfield.value = array.resultvalue;
      optionfield.appendChild(textfield);
      selectfield.appendChild(optionfield);
    }
  }
}

function clipper(divID,triggerField) {
  var divblock = document.getElementById(divID);
  var status = divblock.style.display;
  if(triggerField == 1) divblock.style.display="inline"; else divblock.style.display="none";
}



