function loadPrimaryTable (url, query, elementId, callbackFunc) {

   var loading = 1;
   function ajaxBindCallback() {
      // progressive transitions are from 0 .. 4
      if (ajaxRequest.readyState == 4) {
         // 200 is the successful response code
         if (ajaxRequest.status == 200) {
            ajaxCallback ( ajaxRequest.responseText, elementId );
         } else {
            // error handling here
            alert("There was a problem retrieving this page: " + ajaxRequest.status  );
            alert(ajaxRequest.responseText);
         }
      }else{
         if( loading ) {
            loading = 0;
            document.getElementById(elementId).innerHTML = '<tr>Loading  <img src="/Burkholderia/images/loading.gif"></tr>';
         }
      }	
   }

   var ajaxRequest = null;
   var ajaxCallback = callbackFunc;


   // bind the call back, then do the request
   if (window.XMLHttpRequest) {
      // mozilla, firefox, etc will get here
      ajaxRequest = new XMLHttpRequest();
      ajaxRequest.onreadystatechange = ajaxBindCallback;
      ajaxRequest.open("POST", url , true);
      ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      ajaxRequest.setRequestHeader("Connection", "close");
      ajaxRequest.send(query);
   } else if (window.ActiveXObject) {
      // IE, of course, has its own way
      ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");

      if (ajaxRequest) {
         ajaxRequest.onreadystatechange = ajaxBindCallback;
         ajaxRequest.open("POST", url , true);
         ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
         ajaxRequest.setRequestHeader("Connection", "close");
         ajaxRequest.send( query );
      }
   }

}

function loadPrimaryTableCallback( responseText, elementId ) {
   var responseObj = eval('(' + responseText + ')' );
   document.getElementById(elementId).innerHTML = responseObj.rows;
   document.getElementById('search_page_controls').innerHTML = responseObj.page_controls;
}
