function HttpRequest(url, payload, callback, data) {
  var hr;  
  if (window.XMLHttpRequest){
    // If IE7, Mozilla, Safari, etc: Use native object
    hr = new XMLHttpRequest();
  }
  else {
    if (window.ActiveXObject){
      // ...otherwise, use the ActiveX control for IE5.x and IE6
      hr = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  
  // Send the request
  if (hr) {
    hr.open((payload) ? "POST" : "GET", url, true);
    hr.onreadystatechange = function () {
      if (hr.readyState == 4) {
        callback(hr, data);
      }
    }
    
    hr.send(payload);
  }
}

function lookupAlert(id) {
  var urlStr = "/dtc.ejs?command=PublicDTCRiderAlertsLookup&id="+id;
  HttpRequest(urlStr, null, lookupAlertCallback, null);
}

function lookupAlertCallback(request, data) {
  if (request.status == 200) {
    var xmlDoc = request.responseXML;
    var alertico = document.getElementById('alertic-o');
    var alerttext = document.getElementById('alerttext');
    var alertList = xmlDoc.getElementsByTagName("alert");
    if (alertList) {
      var numOfAlerts = alertList.length;
      if (numOfAlerts > 0) {
        var content = "";
        for (var alert = 0; alert < numOfAlerts; alert++) {
          var thisAlert = alertList.item(alert);
          var desc = thisAlert.getElementsByTagName("desc").item(0).firstChild.data;
          if (content != "") content = content + '<br/><br/>';
          content = content + desc + '<br/>';
        }
        alerttext.innerHTML = content;
      }
    }
  }
  else
  {
    alert("There was a problem retrieving rider alert information.\n" + request.statusText);
  }
}


function showElement(id) {
  if (document.all) { //IS IE 4 or 5 (or 6 beta)
    eval("document.all." + id + ".style.visibility = 'visible'");
  }
  if (document.layers) { //IS NETSCAPE 4 or below
    document.layers[id].visibility = 'visible';
  }
  if (document.getElementById && !document.all) {
    var divname = document.getElementById(id);
    divname.style.visibility = 'visible';
  }
}

function hideElement(id) {
  if (document.all) { //IS IE 4 or 5 (or 6 beta)
    eval("document.all." + id + ".style.visibility = 'hidden'");
  }
  if (document.layers) { //IS NETSCAPE 4 or below
    document.layers[id].visibility = 'hidden';
  }
  if (document.getElementById && !document.all) {
    divname = document.getElementById(id);
    divname.style.visibility = 'hidden';
  }
}
  
