function GetXmlHttpObject(){
  var xmlHttp=null;
  try{
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch(e){
      // Internet Explorer
    try{
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  return xmlHttp;
}

  /*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
  window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
  @end @*/
  
var client;
var ad;
var id = 0;

function handler() {
  if(client.readyState == 4 && client.status == 200) {
    if(client.responseText != null){
      response = client.responseText;
      responseSplit = response.split("::");
      id = responseSplit[0];
      ad = responseSplit[1];
      document.getElementById('shippingMessage'+id).innerHTML = ad;
    }
    else{
      //comm error
    }
  }
  else if(client.readyState == 4 && client.status != 200){
    //captcha network error
  }
}

function getAd(warehouse, ad_type, id){
  if(typeof(ad_type) == 'undefined'){
    ad_type = "default";
  }
  
  client = new XMLHttpRequest();
  client.onreadystatechange = handler;
  client.open("POST", "/scripts/shippingMessage.php?warehouse="+warehouse+"&type="+ad_type+"&id="+id);
  client.send("");
}
  
function printAd(warehouse, ad_type){
  document.write("<div id=\"shippingMessage"+id+"\"></div>");
  getAd(warehouse, ad_type, id);
  id++;
}