// JavaScript Document


function Xml()
{
	
		var xml;
	
		if (window.ActiveXObject)
		{
			xml=new ActiveXObject("Microsoft.XMLDOM");
		}
		// code for Mozilla, Firefox, Opera, etc.
		else if (document.implementation && document.implementation.createDocument)
		{
			xml=document.implementation.createDocument("","",null);
		}
		else
		{
			alert('Your browser cannot handle this script');
		}
		
		xml.async=false;
//		xml = xml.documentElement;
		root=xml.createElement('root');
		xml.appendChild(root);

	
	this.AddNode = function(id, name,rootName, value) 
	{
		

		var RootNode
		if(rootName ==''){RootNode = xml.getElementsByTagName('root')[0];}
		else
		{
			RootNode = xml.getElementsByTagName(rootName)[0];
		}
//		alert (RootNode);
		
		node=xml.createElement(name);
		if (value !='' || value != undefined)
		{
			nodeText=xml.createTextNode(value);
			node.appendChild(nodeText);
		}
		RootNode.appendChild(node);
	}
	
//	this.Text = xml.responseText;
	this.Xml = xml;
	this.SetXml = function(Txml) {xml = Txml; }
	
	this.NodeValue = function(nodeName){ 
		try
		{
		if (xml.getElementsByTagName(nodeName)[0].childNodes[0] != undefined)
			NodeValue = xml.getElementsByTagName(nodeName)[0].childNodes[0].data; 
		else
			NodeValue = null;
		}
		catch(e)
		{
			NodeValue = null;	
		}/**/

		return NodeValue;
	}
	this.RemoveNode = function(nodeName)
	{
		
		try
		{
			if (xml.getElementsByTagName(nodeName)[0].childNodes[0] != undefined)
			{
		//		NodeValue = xml.getElementsByTagName(nodeName)[0].childNodes[0].data; 
				
				xml.getElementsByTagName(nodeName)[0].parentNode.removeChild(xml.getElementsByTagName(nodeName)[0]);
				

				
			}

		}
		catch(e)
		{
			alert(e)
		}/**/	
		
	}
	
	this.FilterElementsByTagName = function(tagName)
	{
		
	//	xml.xml = xml.getElementsByTagName(tagName); 
		//alert(xml.childNodes[0].nodeName);

		return xml.getElementsByTagName(tagName); 
	 	//	alert(tagName)
	}
	

	
	
	this.Length = xml.childNodes[0].nodeName;

}

function LoadXml(text)
{
	// code for IE
	if (window.ActiveXObject)
	  {
	  var doc=new ActiveXObject("Microsoft.XMLDOM");
	  doc.async="false";
	  doc.loadXML(text);
	  }
	// code for Mozilla, Firefox, Opera, etc.
	else
	  {
	  var parser=new DOMParser();
	  var doc=parser.parseFromString(text,"text/xml");
	  }	
	  
	return doc;
}

function CreateXml()
{
	
		if (window.ActiveXObject)
		{
			xml=new ActiveXObject("Microsoft.XMLDOM");
		}
		// code for Mozilla, Firefox, Opera, etc.
		else if (document.implementation && document.implementation.createDocument)
		{
			xml=document.implementation.createDocument("","",null);
		}
		else
		{
			alert('Your browser cannot handle this script');
		}
		
		xml.async=false;
		return xml.documentElement;
}



