// JavaScript Document
/*
This is a function that loads the content of a XML file into a DOM variable.  It accounts for the differences in Brouzers  the form is as follows:
	xmlDoc=loadXMLDoc("filename");
*/
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
  {
  xhttp=new XMLHttpRequest();
  }
else
  {
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
} 
/*
The following four functions conpensate for the brouzer error if the XML file containes white space.

This function gets the first sibling and might be used like this:
	xmlDoc=loadXMLDoc("books.xml");

	x=get_firstChild(xmlDoc.getElementsByTagName("book")[0]);
	document.write(x.nodeName);

*/
function get_firstChild(n)
{
y=n.firstChild;
while (y.nodeType!=1)
  {
  y=y.nextSibling;
  }
return y;
}
/*
This function get the next sibling and might be used like this:
	xmlDoc=loadXMLDoc("books.xml");
	
	x=get_nextChild(xmlDoc.getElementsByTagName("book")[0]);
	document.write(x.nodeName);	

*/

function get_nextSibling(n)
{
y=n.nextSibling;
while (y.nodeType!=1)
  {
  y=y.nextSibling;
  }
return y;
} 

/*
This function gets the last child and is might be used like this:

	xmlDoc=loadXMLDoc("books.xml");
	
	x=get_lastChild(xmlDoc.getElementsByTagName("book")[0]);
	document.write(x.nodeName);
*/
function get_lastChild(n)
{
y=n.lastChild;
while (y.nodeType!=1)
  {
  y=y.previousSibling;
  }
return y;
}

/*
This function gets the previous sibling and it ight be used like this:

	xmlDoc=loadXMLDoc("books.xml");
	
	x=get_previousSibling(xmlDoc.getElementsByTagName("price")[0]);
	document.write(x.nodeName);
*/
function get_previousSibling(n)
{
y=n.previousSibling;
while (y.nodeType!=1)
  {
  y=y.previousSibling;
  }
return y;
}

