function getFacets(url, fields, names, id, limit, seed) {
   if (typeof limit == 'undefined' ) limit = "5";
   if (typeof seed == 'undefined' ) seed = "500"
   var html = "";
   if (url == '' || typeof url == 'undefined') {
     url = '?dummy=0';
   }
   myurl = "/cdm4/get_facets.php" + url + "&real_name=" + names + "&nick_fields=" + fields + "&seed=" + seed + "&facet_limit=" + limit;
   getUrl(myurl, id);
}

function getFacetsEx(url, fields, names, id, seed, limit) {
  var html = "";
  myurl =  "/cdm4/get_facets.php" + url + "&real_name=" + names + "&nick_fields=" + fields + "&facet_limit=" + limit + "&seed=" + seed;
  getUrl(myurl, id);
}

function getXHR() {
    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
            try {
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
                    xmlhttp=false;
            }
    }
    if (!xmlhttp && window.createRequest) {
            try {
                    xmlhttp = window.createRequest();
            } catch (e) {
                    xmlhttp=false;
            }
    }
    return xmlhttp;
}

function getUrl(url, id) {
    var xmlhttp = getXHR();
    xmlhttp.open("GET", url, true);     // true mean asynchronous
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200) {
               id.innerHTML = xmlhttp.responseText;
            }
        }
    }
    xmlhttp.send(null);
}

