subject_id = '';

function handleHttpResponse() {
  if (http.readyState == 4) {
    if (subject_id != '') {
      document.getElementById(subject_id).innerHTML = http.responseText;
    }
  }
}

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object


// nahradi vnitrek sekce 'div_id' obsahem vracenym z volaneho skriptu
function list_ajax(div_id, searchtext){
  var items;

// sirka staci podle dokumentu - vypis je ze stran obalen dalsim obsahem, ktery ma pevne danou minimalni sirku
  myWidth = document.body.clientWidth;
// vyska se urci podle skutecne viditelne casti okna
// misto umistenu udaje o vysce se lisi podle prohlizece
  if (typeof(window.innerHeight) == 'number') {
    //Non-IE
    myHeight = window.innerHeight;
  } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  items = 12;
  if (myWidth > 1250)
    items = 16;
  if (myWidth > 1435)
    items = 20;
  if (myWidth > 1612)
    items = 24;
  if (myWidth > 1795)
    items = 28;
  if (myHeight < 1000)
    items = (items/4)*3;

  http.open("GET", "list_ajax.php?items_per_page="+items+"&searchtext="+searchtext, true);

  http.onreadystatechange = function() {
    if (http.readyState == 4) {
      document.getElementById(div_id).innerHTML = http.responseText;
    }
  };

  http.send(null);
}

