// JavaScript Document
function ajaxHelper(functionName) {
  var xmlHttp;
  // Firefox, Opera 8.0+, Safari, SeaMonkey
  try {
    xmlHttp = new XMLHttpRequest();
  }
  catch (e) {
    // Internet Explorer
    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {
        alert("Sorry, your browser does not support AJAX.");
        return false;
      }
    }
  }

  xmlHttp.onreadystatechange = function() {
    // The request is complete == state 4
    var img_id = functionName + "Loader";

    document.getElementById(img_id).innerHTML = "";
    if (xmlHttp.readyState == 4) {

      var response = xmlHttp.responseText;
      var open_escape = "('";
      var close_escape = "')"

      // Send reponse to _ajax hook of passed function name
      eval(functionName + "_ajax" + open_escape + encodeURIComponent(response) + close_escape);
    } else {
      document.getElementById(img_id).innerHTML= "<img src='img/loading.gif' />";
    }
  }

  // Get request string from _init hook of passed function name
  var requestString = eval(functionName + "_init" + '()');
  if (requestString) {
    xmlHttp.open("POST", requestString, true);
    xmlHttp.setRequestHeader('Content-type', 'text/html;charset=utf-8;');
    xmlHttp.send(null);
  }
}