// ajax processor file
function ajaxFunction(m, url, arg)       // m=method, url=url retrieve, arg=url argument
{

  if(arg == '--')
  {
    alert('You must choose a Start Date');
    return;
  }

  //set wait message
  document.getElementById("cbtext").innerHTML += '...retrieving data. Please wait...';

  //start use random arg so caching won't occur
  var nocache = "&nocache=" + Math.random() * 1000000;
  request = new ajaxRequest();

  //send the request
  request.open(m, url + arg + nocache, true);

  // check state to see if a return can be processed
  request.onreadystatechange = function()
  {
    if (this.readyState == 4)
    {
        if (this.status == 200)
        {
            if (this.responseText != null)
            {
              // reset wait message
              document.getElementById("cbtext").innerHTML = 'Update selected week';
              // all is good process returned response info from the global request object
              // each form that uses ajax will have it's own inline javascript code with this
              // function in it
              ProcessResponse();
            }
            else
            {
              alert('Ajax error: No data received');
            }
        }
        else
        {
          alert( 'Ajax error: ' + this.statusText);
        }
    }
  }

 //end the request
  request.send(null);
}

// get and return the request
function ajaxRequest()
{
    try
    {
        var request = new XMLHttpRequest();
    }
    catch(e1)
    {
        try
        {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch(e2)
        {
            try
            {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch(e3)
            {
                request = false;
            }
        }
    }
    return request;
}