//2006/11/01 sharkie@outlook.net
//use asynchronous XMLHttp request (AJAX) to save ad view:
//requirement: zxml library
function saveAd( adid ) {
//alert('will save '+adid);
  var oXmlHttp = zXmlHttp.createRequest();
  var timeStamp = new Date;
  var cacheBuster = timeStamp.getTime() + adid;
  oXmlHttp.open("get", "/ny1/navigation/support/nostore/recordAdView2.jsp?adid=" + adid + "&cacheBuster=" + cacheBuster, true);
  oXmlHttp.onreadystatechange = function () {
  if (oXmlHttp.readyState == 4) {
    if (oXmlHttp.status == 200) {
      //no response necessary:
      //alert('cacheBuster = ' + cacheBuster + '\nadid = ' + adid + '\n' + oXmlHttp.responseText);
    } else {
      //alert("An error occurred while saving ad " + adid + ":\n" + oXmlHttp.statusText); //statusText is not always accurate
    } //if status
  } //if readyState
  };
  oXmlHttp.send(null);
} //saveAd()

function saveAd2( adid ) {
  //saveAd(adid);
} //saveAd2()

function saveClick(adid) {
  var req = zXmlHttp.createRequest();
  req.open("get", "/ny1/navigation/support/nostore/recordAdClick.jsp?adid=" + adid, true);
  req.onreadystatechange = function () {
  if (req.readyState == 4) {
    var httpStatus; //FF loses "status" on unload
    try {
      if(req.status !== undefined && req.status != 0) httpStatus = req.status;
      else httpStatus = 13030;
    } //try
    catch(e) {
      httpStatus = 13030;
    } //catch
    if(httpStatus==200 || httpStatus==13030) {
      //no response necessary:
      //alert('saved adid = ' + adid + '\nhttpStatus = '+httpStatus+'\nresponse = '+req.responseText);
    } else {
      //alert("An error occurred while saving ad click: " + adid + ":\n" + req.statusText); //statusText is not always accurate
    } //if httpStatus
  } //if readyState
  };
  req.send(null);
} //saveClick()

