var HTTP_XML_Shell = function()
{
	this.requestObject = null;
	
		if ( window.XMLHttpRequest ) {		
			this.requestObject =  new XMLHttpRequest() ;// Gecko
		} else if ( window.ActiveXObject ) {	
			this.requestObject =  new ActiveXObject("MsXml2.XmlHttp") ;// IE
		}
}


HTTP_XML_Shell.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer,method,strParam)
{
	var pHTTP_XML_Shell = this ;
	var pXmlHttp = this.requestObject;

	var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
    if (method == null) {
		method = 'GET';	
	}
	
	pXmlHttp.open( method, urlToCall, bAsync ) ;
	
	if (method == 'POST') {
		pXmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	} else {
		strParam = null;	
	}
	
	
	if ( bAsync )
	{	
		pXmlHttp.onreadystatechange = function() 
		{		
			if ( pXmlHttp.readyState == 4 )
			{
				if (pXmlHttp.responseText.length > 0) {
	
					pHTTP_XML_Shell.DOMDocument = pXmlHttp.responseXML ;
					if (pXmlHttp.status == 200 || pXmlHttp.status == 304 ) {
						asyncFunctionPointer( pHTTP_XML_Shell ) ;
					} else {
						alert('xml_request_err' + ': ' + pXmlHttp.statusText + ' (' + pXmlHttp.status + ')' ) ;
					}
				}

			}
		}
	}
	
	
 	 if(pXmlHttp.readyState > 0) {     
          pXmlHttp.send(strParam) ;
     }
	
	if ( ! bAsync )
	{
		if ( pXmlHttp.status == 200 || pXmlHttp.status == 304 )
			this.DOMDocument = pXmlHttp.responseXML ;
		else
		{
			alert( 'xml_request_err' + ': ' + pXmlHttp.statusText + ' (' + pXmlHttp.status + ')' ) ;
		}
	}
}

HTTP_XML_Shell.prototype.CheckError = function( responseXml )
{
	var iErrorNumber = 0
	var oErrorNode = responseXml.SelectSingleNode( 'container/Error' ) ;
	
	if ( oErrorNode )
	{
		iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value ) ;
		if (iErrorNumber == 0) {
			return 0;
		} else {
			alert(oErrorNode.attributes.getNamedItem('text').value ) ;
		}
	}
	return iErrorNumber ;
}



HTTP_XML_Shell.prototype.SelectNodes = function( xpath )
{
	if ( document.all )	{	
		return this.DOMDocument.selectNodes( xpath ) ;// IE
	} else {
		var aNodeArray = new Array(); // Gecko

		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, 
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
		if ( xPathResult ) 
		{
			var oNode = xPathResult.iterateNext() ;
 			while( oNode )
 			{
 				aNodeArray[aNodeArray.length] = oNode ;
 				oNode = xPathResult.iterateNext();
 			}
		} 
		return aNodeArray ;
	}
}

HTTP_XML_Shell.prototype.SelectSingleNode = function( xpath ) 
{
	if ( document.all )	{	
		return this.DOMDocument.selectSingleNode( xpath ) ;// IE
	} else {
		var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
				this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); // Gecko

		if ( xPathResult && xPathResult.singleNodeValue )
			return xPathResult.singleNodeValue ;
		else	
			return null ;
	}
}

HTTP_XML_Shell.prototype.destruct = function()
{
	this.DOMDocument   = null;
	this.requestObject = null;
}