//////////////////////////////////////////////
// Italcom Spa
// Browser: IE 6.0, Netscape 7.0, Mozilla 1.4
// Library: CDomDocumentNode
// Version 1.0
// Require: CXmlDeserializer
// 			CHttpRequest
// 			CSoapRequest
// Objects: CDomDocumentNode_IE_prototypes
// 			CDomDocumentNode_IE_prototypes
//////////////////////////////////////////////

// CDomDocumentNode_IE_prototypes: this object implements the methods for extract
// body content in the response message. Only IE supported.  
function CDomDocumentNode_IE_prototypes()
{
	CDomDocumentNode.prototype.loadXML = function (xmlDoc) { this.domparser.loadXML(xmlDoc); this.document = this.domparser; }
	CDomDocumentNode.prototype.getElementsByTagName = function (tagname, ns)
	{ 
		if (ns != null)
		{
			this.document.setProperty("SelectionNamespaces", "xmlns:_namespaceuri = '" + ns + "'");
			return this.document.documentElement.selectNodes("//_namespaceuri:" + tagname);
		}
		else
		{
			return this.document.getElementsByTagName(tagname);
		}
	}
	
	CDomDocumentNode.prototype.firstChild = function ()
	{
	
		if (this.document.documentElement.firstChild == null)
			return null;
		
		var node = this.document.documentElement.firstChild;
		var doc = new CDomDocumentNode();
		doc.loadXML(CDomDocumentNode.xml(node));
		return doc;
		
	}
	
	
	CDomDocumentNode.prototype.nodeValue = function()
	{
		return this.document.documentElement.nodeValue;
	}


	CDomDocumentNode.prototype.nodeName = function()
	{
		return this.document.documentElement.nodeName;
	}


	CDomDocumentNode.xml = function (node) { return node.xml; }
	CDomDocumentNode.getChildOfNode = function (node, deph)
	{

		var doc = node;
		for (; deph>0;deph--)
			doc = doc.firstChild;
		
		var result = new CDomDocumentNode();
		result.loadXML(CDomDocumentNode.xml(doc));
		return result;
	}


}

// CDomDocumentNode_Mozilla_prototypes: this object implements the methods for extract
// body content in the response message. Olny Mozilla supported.  
function CDomDocumentNode_Mozilla_prototypes()
{
	CDomDocumentNode.prototype.loadXML = function (xmlDoc) { this.document = this.domparser.parseFromString(xmlDoc, 'text/xml'); }
	CDomDocumentNode.prototype.getElementsByTagName = function (tagname, ns)
	{ 
		if (ns != null)
		{
			return this.document.getElementsByTagNameNS(ns, tagname);
		}
		else
		{
			return this.document.getElementsByTagName(tagname);
		}
	}
	
	CDomDocumentNode.prototype.firstChild = function ()
	{

		if (this.document.documentElement.firstChild == null)
			return null;

		var node = this.document.documentElement.firstChild;
		var doc = new CDomDocumentNode();
		doc.loadXML(CDomDocumentNode.xml(node));
		return doc;
	}

	
	CDomDocumentNode.prototype.nodeValue = function()
	{
		return this.document.documentElement.nodeValue;
	}


	CDomDocumentNode.prototype.nodeName = function()
	{
		return this.document.documentElement.nodeName;
	}
	
	CDomDocumentNode.xml = function (node) { return (new XMLSerializer()).serializeToString(node);}
	CDomDocumentNode.getChildOfNode = function (node, deph)
	{
		var doc = node;
		for (; deph>0;deph--)
			doc = doc.firstChild;
		var result = new CDomDocumentNode();
		result.loadXML(CDomDocumentNode.xml(doc));
		return result;
	}
	


}

// Costructor
function CDomDocumentNode ()
{
 	this.DOMParserAvailable = true;
 	
 	try
 	{
 		this.domparser = new ActiveXObject("Microsoft.XMLDOM");
 		CDomDocumentNode_IE_prototypes();
 	}
 	catch (e)
 	{
 		try
 		{
 			this.domparser = new DOMParser();
			CDomDocumentNode_Mozilla_prototypes();
		}
 		catch(e)
 		{
 			this.DOMParserAvailable = false;
 		}
 	}
}




// Common methods: coommon methods (IE, Mozilla) for extract
// body content in the response message.
CDomDocumentNode.prototype.xml = function()
{
	return CDomDocumentNode.xml(this.document.documentElement);
}

CDomDocumentNode.prototype.node = function()
{
	return this.document.documentElement;
}

CDomDocumentNode.prototype.getAttribute = function(attrname)
{
	return this.document.documentElement.attributes.getNamedItem(attrname).nodeValue;
}

