﻿function requestFile() {
  var httpObj = createHttpRequest();
  httpObj.open("GET","../php/message_XML.php",false)
  httpObj.send(null);
  if ((httpObj.readyState == 4)) {
    document.getElementById('msgArea').innerHTML = httpObj.responseText;
  }else{
    document.getElementById('msgArea').innerHTML = "Loading...";
  }

  var xmlHttpReq = createHttpRequest()
  xmlHttpReq.open("GET","../php/activity_XML.php?new=5",false)
  xmlHttpReq.send(null);
  if (xmlHttpReq.readyState==4) {
    var xmlData = xmlHttpReq.responseXML;
    var data = xmlData.getElementsByTagName("data"); 
    var date = xmlData.getElementsByTagName("date");
    var link = xmlData.getElementsByTagName("link");
    var title = xmlData.getElementsByTagName("title");
    listData = "<dl>";
    for (var i = 0 ;i<data.length ;i++) {
      listData += "<dt>" + date[i].childNodes[0].nodeValue + "</dt>";
      listData += "<dd><a href='" + link[i].childNodes[0].nodeValue + "'>" + title[i].childNodes[0].nodeValue + "</a></dd>";
    }
    listData += "</dl>";
    document.getElementById('listArea').innerHTML = listData;
  }
}

function createHttpRequest() {
  var x = null;
  //IE7,Firefox, Safari
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
  }
  //IE6
  try {
    return new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
      // IE5
      try {
      return new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
      x = null;
    }
  }
  return x;
}
requestFile()
