// ************************************************************
// General XML / XMLHttpRequest Methods
// ************************************************************
function CreateXmlHttpRequest() 
{
	var xmlhttp;

	// IE6
	try 
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) 
	{
        xmlhttp = null;
	}
	
	// IE5
	if (xmlhttp==null)
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (e) 
		{
			xmlhttp = null;
		}
	}

	// Netscape
	if (xmlhttp==null)
	{
		try 
		{
			xmlhttp = new XMLHttpRequest();
		} 
		catch (e) 
		{
			xmlhttp = null;
		}
	}

  return (xmlhttp);
}

//Gets the first node from a xml
function GetFirstNode(node, path)
{
	var nodeList = node.getElementsByTagName(path);
	
	if(nodeList.length > 0)
	{
		return(nodeList[0]);
	}
	
	return(null);
}

//Gets the value of the xml node
function GetNodeValue(node)
{
	if(node != null)
	{
		if(node.firstChild != null)
		{
			return(node.firstChild.nodeValue);
		}
	}
	return('');
}

// Gets a list of nodes with the required tag name direcly below the current node
function SelectNodes(node, tagname)
{
	var ret = new Array();
	if(node!=null)
	{
		if(node.childNodes!=null)
		{
			for(var i=0;i<node.childNodes.length;i++)
			{
				if(node.childNodes[i].tagName==tagname) ret[ret.length] = node.childNodes[i];
			}
		}
	}
	return(ret);
}

// Gets the first nodewith the required tag name direcly below the current node
function SelectSingleNode(node, tagname)
{
	if(node!=null)
	{
		if(node.childNodes!=null)
		{
			for(var i=0;i<node.childNodes.length;i++)
			{
				if(node.childNodes[i].tagName==tagname) return(node.childNodes[i]);
			}
		}
	}
	return(null);
}
