/* Courtesy of http://www.switchonthecode.com/tutorials/simple-ajax-php-and-javascript
*/

function  getXMLHttp()
{
  var xmlHttp

  try
  {
    //Firefox, Opera 8.0+, Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    //Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      try
      {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
        alert("Your browser does not support AJAX!")
        return false;
      }
    }
  }
  return xmlHttp;
}

function MakeRequest(ajaxPage, ajaxResponseLocation, getPost, params)
{
	document.getElementById(ajaxResponseLocation).innerHTML = "<img id=\"loading\" src=\"images/loading.gif\" style=\"display:show;\" />";
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText, ajaxResponseLocation);
    }
  }
  xmlHttp.open(getPost, ajaxPage, true); //(GET/POST, LOCATION, USE AJAX CALL)
  if(getPost == "GET"){
	xmlHttp.send(null);
  } else {//POST REQUEST
  //params will be in this form "key=value?key2=value?..."
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connectioin", "close");
	xmlHttp.send(params);
  }
}
function  HandleResponse(response, ajaxResponseLocation)
{
  document.getElementById(ajaxResponseLocation).innerHTML = response;
}

//added to support afl website
function AjaxGetSellerInfo(ajaxPage, ajaxResponseLocation, getPost, params)
{
	document.getElementById(ajaxResponseLocation).innerHTML = "<img id=\"loading\" src=\"images/loading.gif\" style=\"display:show;\" />";
  var xmlHttp = getXMLHttp();
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      ReturnSellerInfo(xmlHttp.responseText, ajaxResponseLocation);
    }
  }
  xmlHttp.open(getPost, ajaxPage, true); //(GET/POST, LOCATION, USE AJAX CALL)
  if(getPost == "GET"){
	xmlHttp.send(null);
  } else {//POST REQUEST
  //params will be in this form "key=value?key2=value?..."
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connectioin", "close");
	xmlHttp.send(params);
  }
}
