addEvent(window, "load", setup, false);

function setup()
{
	var inserts = document.getElementsByTagName('a');
	for (i=0; i<inserts.length; i++) {
      if (/showList/.test(inserts[i].parentNode.className)) {
			inserts[i].onclick = function() {
				var showXML = processXMLHttpRequest(this.href, this.parentNode);
				return showXML;
			}
		}
	}
}

function processXMLHttpRequest(file, location)
{
   var xmlObj = null;
   if (window.XMLHttpRequest) {
      xmlObj = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
      xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      return true;
   }
   xmlObj.onreadystatechange = function() {
      if(xmlObj.readyState == 4) {
         processXML(xmlObj.responseXML, location);
      }
   }
   xmlObj.open ('GET', file, true);
   xmlObj.send ('');
   return false;
}
    
function processXML(obj, location)
{
   var rows = obj.getElementsByTagName('buch');
   var listBox = document.createElement('pre');
   var listText = "";
   for (var i=0, row; row=rows[i]; i++) {
   	var elems = row.childNodes;
   	for (var j=0, srow; srow=elems[j]; j++) {
   		if (srow.nodeType == 1) {
   			listText += srow.firstChild.data + "   ";
   		}
   	}
   	listText += "\n\r";
   }
   text = document.createTextNode(listText);
   listBox.appendChild(text);
   location.parentNode.replaceChild(listBox, location, listBox);
}

