var httpObject = null;

// Get the HTTP Object
function getHTTPObject() {
  if (window.XMLHttpRequest)
    httpObject = new XMLHttpRequest();
  else if (window.ActiveXObject)
    httpObject = new ActiveXObject("Microsoft.XMLHTTP");
  else {
    alert("Your browser does not support AJAX.");
    httpObject = null;
  }
}
// Change the value of the outputText field
function setOutput() {
  if (httpObject.readyState == 4) {
    if (httpObject.status == 200) {
      document.getElementById('example').innerHTML = httpObject.responseText;
    }
  }
}

function doWork(url) {
  getHTTPObject();
  if (httpObject != null) {
    if (url == "browse.php") {
      url = url + "?random=" + Math.random();
    } // CLOSES IF
    else {
	  url = url + "&random=" + Math.random();
    } // CLOSES ELSE
    httpObject.open("GET", url, true);
    httpObject.send(null); 
    httpObject.onreadystatechange = setOutput;
    //alert(url);
  }
}

function lookup(inputString) {
  if(inputString.length == 0) {
    $('#suggestions').hide();
  } // CLOSES IF
  else {
    var lang = $("input[name='l']:checked").val();

    $.post(jsBaseURL + "/includes/rpc.php", {queryString: ""+inputString+"", l: ""+lang+""}, function(data) {
      if(data.length > 0) {
        $('#suggestions').show();
        $('#autoSuggestionsList').html(data);
      }
    });
  } // CLOSES ELSE
} // CLOSES LOOKUP FUNCTION
	
function fill(thisValue) {
  $('#inputText').val(thisValue); 
  setTimeout("$('#suggestions').hide();", 350);
} // CLOSES FILL FUNCTION
