function clsAjax(p_strRequestUrl)
{
	
	clsAjax.prototype.m_strRequestUrl = p_strRequestUrl;
	
	// This method creates and returns the XmlHttpRequest object 
	clsAjax.prototype.getXmlHttpObject = function()
	{
		var oXMLHTTP;
		if (window.XMLHttpRequest)
		{
			var oXMLHTTP = new XMLHttpRequest()
			if (oXMLHTTP.overrideMimeType)
			{
				oXMLHTTP.overrideMimeType('text/xml');
			}
		}
		//   IE
		else if (window.ActiveXObject)
		{
			try
			{
				oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch(e)
			{
				try	{
				oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{}
			}
		}
//		try
//		{
//			// Firefox, Opera 8.0+, Safari
//			
//			oXMLHTTP = new XMLHttpRequest();
//			if (oXMLHTTP.overrideMimeType)
//			{
//				oXMLHTTP.overrideMimeType('text/xml');
//			}
//			
//		}
//		catch (e)
//		{
//			// Internet Explorer
//			try
//			{
//				oXMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");
//			}
//			catch (e)
//			{
//				oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
//			}
//		}
		return oXMLHTTP;
	}
	/*------------------------------------------------------------------
	 This method takes three arguments:
	 Argument 1st: This is a combo box object which have to fill
	 Argument 2nd: This is a field name which is used to fill the value of the combo box
	 Argument 3rd: This is a field name which is used to fill the text of the combo box
	------------------------------------------------------------------*/
	clsAjax.prototype.fillComboBox = function(p_objComboCtrl, p_strOptValue, p_strOptText)
	{
		var oXMLHTTP = this.getXmlHttpObject();
		if(oXMLHTTP)
		{
			//Setting the event handler for the response
			oXMLHTTP.onreadystatechange = function()
			{
				if(oXMLHTTP.readyState == 4)
				{
					//Valid Response is received
					if(oXMLHTTP.status == 200)
					{
						var objClientNode = oXMLHTTP.responseXML.documentElement;
						var v_strOptText, v_strOptValue;
						p_objComboCtrl.options.length = 0;
						for(i=0; i<objClientNode.childNodes.length; i++)
						{
							v_strOptText = getInnerText(objClientNode.getElementsByTagName(p_strOptText)[i]);
							v_strOptValue = getInnerText(objClientNode.getElementsByTagName(p_strOptValue)[i]);
							p_objComboCtrl.options[i] = new Option(v_strOptText, v_strOptValue)
						}
					}
					else //something is wrong 
					{
						alert("Could not retreive data from the server" );
					}
				}
			}
			/*------------------------------------------------------------------
			Initializes the request object with GET (METHOD of posting), 
			Request URL and sets the request as asynchronous.
			------------------------------------------------------------------*/
			oXMLHTTP.open("GET", this.m_strRequestUrl,  true);

			//Sends the request to server
			oXMLHTTP.send(null);
		}
	}
	
	/*------------------------------------------------------------------
	Send request to server and return response string.
	------------------------------------------------------------------*/
	clsAjax.prototype.getXMLData = function()
	{
		try
		{
		    var oXMLHTTPTemp = this.getXmlHttpObject();
		    oXMLHTTPTemp.open("GET", this.m_strRequestUrl, false);
		    oXMLHTTPTemp.send(null);
		    return oXMLHTTPTemp.responseText;
		
//			var oXMLHTTP = this.getXmlHttpObject();
//			oXMLHTTP.open("GET", this.m_strRequestUrl, false);
//			oXMLHTTP.send(null);
//			return oXMLHTTP.responseText;
		}
		catch(e)
		{
			alert("Error: Data could not be retrieved.");
		}
		
	}
	
	/*------------------------------------------------------------------
	This  function load the XML string received from xmlhttp request and returns a XML DOM document object.
	------------------------------------------------------------------*/
	clsAjax.prototype.loadXMLstring = function(strXML)
	{	
		var xmlDoc ;
		try
		{
			//IE
			xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
			xmlDoc.async = "false"
			xmlDoc.loadXML(strXML);
			return xmlDoc;
		}			
		catch(e)
		{
			try //Firefox, Mozilla, Opera, etc.
			{
				//FireFox
				parser = new DOMParser();
                xmlDoc = parser.parseFromString(strXML,"text/xml");
                return xmlDoc;
			}
			catch(e)
			{
			    alert("XML Document is not created Properly. Error: " + e.message)
			}
		}
		
		return (null);
	}

}

function getInnerText (node)
{
	return (node.textContent || node.innerText || node.text);
}
