var last='';

function insert(what)
{
  form.comment.value=form.comment.value+what;
  form.comment.focus();
}

function prepareRecords() {

  if (httpRequest.readyState == 4) {
    document.getElementById("loading").style.display = 'none';
    if (httpRequest.status == 200) {
      textResponse = httpRequest.responseText;
      document.getElementById("records").innerHTML = textResponse;
    }
  }
}

function getRecords()
{
  if (last==document.getElementById("mapname").value) return;
  last = document.getElementById("mapname").value;

  if (window.ActiveXObject)
  {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else
  {
    httpRequest = new XMLHttpRequest();
  }
  httpRequest.open("POST", "/records.php", true);
  httpRequest.onreadystatechange= function () {prepareRecords(); } ;
  document.getElementById("loading").style.display = 'block'; // SHOW LOADING IMAGE
  httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  httpRequest.send("map="+encodeURIComponent(document.getElementById("mapname").value)+"&type="+encodeURIComponent(document.getElementById("type").value)+"&send=yes");
}
