// Ajax
function createXMLHttpRequest(cbFunc) {
  xmlHttpObject = null;
  if (window.XMLHttpRequest) {
    xmlHttpObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        return null;
      }
    }
  }
  else {
    return null ;
  }

  if (xmlHttpObject) {
    xmlHttpObject.onreadystatechange = cbFunc;
  }

  return xmlHttpObject;
}

var __onload_flag = window.onload;
window.onload = function() {
  if (__onload_flag) __onload_flag();
  loadXML();
}

function loadXML() {
  httpObj = createXMLHttpRequest(dispData);
  if (httpObj) {
    httpObj.open("GET","update.xml",true);
    httpObj.send(null);
  }
}

function dispData() {
  if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
    xmlData = httpObj.responseXML;
    titleList = xmlData.getElementsByTagName("title");
    urlList = xmlData.getElementsByTagName("link");
    itemNum = titleList.length;
    resultText = "";
    for (i=0; i<itemNum; i++) {
      title = titleList[i].childNodes[0].nodeValue;
      url = urlList[i].childNodes[0].nodeValue;
      resultText = resultText + "<a href=\"" + url + "\">" + title + "</a><br />";
    }
    document.getElementById("updatelist").innerHTML = resultText;
  }
}

function toggleText(textid, summaryid, showid, hideid){
  if(document.getElementById(textid).style.display == 'none'){
    document.getElementById(textid).style.display = 'block';
    document.getElementById(summaryid).style.display = 'none';
    document.getElementById(showid).style.display = 'none';
    document.getElementById(hideid).style.display = 'block';
  }else{
    document.getElementById(textid).style.display = 'none';
    document.getElementById(summaryid).style.display = 'block';
    document.getElementById(showid).style.display = 'block';
    document.getElementById(hideid).style.display = 'none';
  }
}

function toggleInput(showid, hideid){
  if(document.getElementById(showid).style.display == 'none'){
    document.getElementById(showid).style.display = 'block';
    document.getElementById(hideid).style.display = 'none';

    document.showform.author.value = document.hideform.author.value;
    document.showform.mailaddr.value = document.hideform.mailaddr.value;
    document.showform.hpurl.value = document.hideform.hpurl.value;
    document.showform.evaluate.checked = document.hideform.evaluate.checked;
    document.showform.text.value = document.hideform.text.value;
  }else{
    document.getElementById(showid).style.display = 'none';
    document.getElementById(hideid).style.display = 'block';

    document.hideform.author.value = document.showform.author.value;
    document.hideform.mailaddr.value = document.showform.mailaddr.value;
    document.hideform.hpurl.value = document.showform.hpurl.value;
    document.hideform.evaluate.checked = document.showform.evaluate.checked;
    document.hideform.text.value = document.showform.text.value;
  }
}

