function mondoXmlClientClass()
{
	var Kommunikator;
	this.Kommunikator = Kommunikator;
	var OutFunction;
	this.OutFunction = OutFunction;
	var AttributeArray;
	this.AttributeArray = AttributeArray;
	var xmlType = 'ezobject';
	this.xmlType = xmlType;

    function processXmlResponse(xml)
    {
        var doc;
        if (window.ActiveXObject)
        {
			doc = new ActiveXObject("Microsoft.XMLDOM");
            doc.async = 'false';
            doc.loadXML(xml);
        }
        else
        {
            var parser=new DOMParser();
            doc = parser.parseFromString(xml,"text/xml");
        }

        if( doc.hasChildNodes() )
        {
            var tabResult = Array();
            var allobjects = doc.getElementsByTagName('object');
            for(var o = 0; o < allobjects.length; o++)
            {
                tabResult[o] = Array();
                
                var title = allobjects[o].getElementsByTagName('title');
                tabResult[o]['title'] = title[0].firstChild.nodeValue;
                
                var url = allobjects[o].getElementsByTagName('url');
                tabResult[o]['url'] = url[0].firstChild.nodeValue;
                
                var section_id = allobjects[o].getElementsByTagName('section_id');
                tabResult[o]['section_id'] = section_id[0].firstChild.nodeValue;
    
                var node_id = allobjects[o].getElementsByTagName('node_id');
                tabResult[o]['node_id'] = node_id[0].firstChild.nodeValue;
    
                var parent_node_id = allobjects[o].getElementsByTagName('parent_node_id');
                tabResult[o]['parent_node_id'] = parent_node_id[0].firstChild.nodeValue;

                var short_date = allobjects[o].getElementsByTagName('shortdate');
                tabResult[o]['shortdate'] = short_date[0].firstChild.nodeValue;

                var year = allobjects[o].getElementsByTagName('year');
                tabResult[o]['year'] = year[0].firstChild.nodeValue;

				var attributes = allobjects[o].getElementsByTagName('attribute');
				tabResult[o]['attributes'] = Array();

				for(var at=0; at < attributes.length; at++)
				{
					if( exists( attributes[at].getElementsByTagName('value')[0] ) )
					{
						var key_temp = attributes[at].getElementsByTagName('name')[0].firstChild.nodeValue;
						var valuetemp = attributes[at].getElementsByTagName('value')[0].firstChild;
						if(valuetemp)
						{
							tabResult[o]['attributes'][key_temp] = Array();
							tabResult[o]['attributes'][key_temp]['type'] = attributes[at].getElementsByTagName('type')[0].firstChild.nodeValue;
							tabResult[o]['attributes'][key_temp]['value'] = valuetemp.nodeValue;
						}
					}
				}
            }
			this.OutFunction(tabResult);
        }
        else
        {
        }
		return false;
    }
	this.processXmlResponse = processXmlResponse;

	function processXmlKeyword(xml)
    {
        var doc;
        if (window.ActiveXObject)
        {
			doc = new ActiveXObject("Microsoft.XMLDOM");
            doc.async = 'false';
            doc.loadXML(xml);
        }
        else
        {
            var parser=new DOMParser();
            doc = parser.parseFromString(xml,"text/xml");
        }
		
        if( doc.hasChildNodes() )
        {
            var tabResult = Array();
            var allobjects = doc.getElementsByTagName('object');
            for(var o = 0; o < allobjects.length; o++)
            {
                tabResult[o] = Array();
                
                var objtitle = allobjects[o].getElementsByTagName('name');
                tabResult[o]['name'] = objtitle[0].firstChild.nodeValue;
                
                var objclass = allobjects[o].getElementsByTagName('class');
                tabResult[o]['class'] = objclass[0].firstChild.nodeValue;
                
                var objurl = allobjects[o].getElementsByTagName('url');
                tabResult[o]['url'] = objurl[0].firstChild.nodeValue;
                
                var objsection_name = allobjects[o].getElementsByTagName('section_name');
                tabResult[o]['section_name'] = objsection_name[0].firstChild.nodeValue;
            }
			this.OutFunction(tabResult);
        }
        else
        {
        }
		return false;
    }
	this.processXmlKeyword = processXmlKeyword;

	function LoadResult( req, nextfunc, attributeArray )
	{
		this.Kommunikator = null;
		this.Kommunikator = getXMLHTTP();
		
		this.Kommunikator.onreadystatechange = function()
		{
			if( mondoXmlClient.Kommunikator.readyState == 4 )
			{
				if( mondoXmlClient.Kommunikator.status == 200 )
				{
					if( mondoXmlClient.xmlType == 'ezobject' )
					{
						mondoXmlClient.processXmlResponse( mondoXmlClient.Kommunikator.responseText );
					}
					else if( mondoXmlClient.xmlType == 'ezkeyword' )
					{						
						mondoXmlClient.processXmlKeyword( mondoXmlClient.Kommunikator.responseText );
					}
					else
					{
						this.OutFunction(tabResult);
					}
				}
				else 
				{
				}
			} 
		}; 
		if(typeof (attributeArray) != "undefined" && attributeArray != null )
		{
			this.AttributeArray	= attributeArray;
		}
		else
		{
			this.AttributeArray = new Array();	
		}
		this.OutFunction = nextfunc;
		this.Kommunikator.open("POST", req , true);
		this.Kommunikator.send(null);
	}
	this.LoadResult = LoadResult;
	
    function getXMLHTTP()
    {
		var xhr=null;
		if(window.XMLHttpRequest)
		{
			xhr = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
			try
			{
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e1)
				{
					xhr = null; 
					alert('Error creating xmlhttp');
				}
			}
		}
		else
		{
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		}
		return xhr;
	}
	this.getXMLHTTP = getXMLHTTP;
}
var mondoXmlClient = new mondoXmlClientClass();

