// / The XMLHTTP object is supposed to cater to the need of AJAX across the organization.
// / The following properties / Methods would be available for the user to set
// / Properties
// / /
// /	-blnAllowDuplicateRequest : 
// /			Defines whether to apply duplicate request or not.
// /	-blnApplyRequestPooling : 
// /			Defines whether to apply request pooling or not.
// /	-nCustomPoolSize : 
// /			Defines the custom pool size.
// /	-blnIsXmlPost : 
// /			Posts the request as Xml String.
// /	-blnUseGetIfPostDoesNotWork : 
// /			Defined by user as true if he wants to use get method if post doesnot work well.
// /	
// / /Methods
// /	-SendRequest
// /		->Method to send the request. The function accepts the following parameters	
// /			strURL		: The URL path to which the request should be sent to
// /			strRequestParams		: The data to be sent across to the server
// /			strMethod	: 
// /						  Accepts: "POST" / "GET".
// /							 * If "POST" then the data would be available as a form variable on the server
// /	  						 * If "GET" then the data would be available as a query string variable on the server.
// /			strRequestId : It Contains the unique request id for pooling.
// /			strEventHandler : It Contains the Handler function that will be called when ReadyStateChange occurs.
// /			oConfig : This object contains the properties those can be changed on every request. 
// /
// /		->Return Values : The send request function will return following values
// /			oXmlHttp : This parameter will have reference to the Xml Http Object
// /			oError   : This parameter will have Error Description if error occured during processing
// /			strRequestId : This parameter will contain the Request Id,set at the time of sending the request.
// /			nResponseCode : This Parameter will contain the code of Response Status. it will contain following values
// /							User can make Response justification according to the response status code provided.
// /							1 : Successful Request
// /							  : If Request is completed within defined time and responded successfully.
// /							2 : Unsuccessful Request
// /							  : With any reason response fails. Or request doent responses within time.
// /							3 : Request Pool Full
// /							  : If No of requests are greater then the pool size,user has provided.
// /							4 : Duplicate Request
// /							  : If user has set the property "blnAllowDuplicateRequest" to false, and he is adding
// /								duplicate request to pool, this code will return with error "Duplicate Request"

function cXMLHttpConfig()
{
	///&& Async : Defines the asynchronous mode as true / false
	this.Async = true;
	///&& nSendTimeOuts : Stores the value user has provided for timeout
	this.nSendTimeOuts = 0;
	///&& strRH_CacheControl : To change the CacheControl property in Http Request Header
	this.strRH_CacheControl = null;
	///&& strRH_ContentLength :
	this.strRH_ContentLength = null;
	///&& strRH_ContentType : To change the ContentType property in Http Request Header
	this.strRH_ContentType = null;
	///&& strRH_AcceptRanges : To change the AcceptRanges property in Http Request Header
	this.strRH_AcceptRanges = null;
	///&& strRH_ETag  : To change the ETag property in Request Http Header
	this.strRH_ETag = null;
	///&& strRH_AcceptCharSet : To change the Accept-CharSet  property in Request Http Header
	this.strRH_AcceptCharSet = null;
	///&& strRH_AcceptLanguage : To change the Accept-Language  property in Request Http Header
	this.strRH_AcceptLanguage = null;
	///&& strRH_AcceptEncoding : To change the Accept-Encoding  property in Request Http Header
	this.strRH_AcceptEncoding = null;
	///&& strRH_Age : To change the Age property in Request Http Header
	this.strRH_Age = null;
	///&& strRH_Allow : To change the Allow property in Request Http Header
	this.strRH_Allow = null;
	///&& strRH_Authorization : To change the Authorixation property in Request Http Header
	this.strRH_Authorization = null;
	///&& strRH_Connection : To change the Connection property in Request Http Header
	this.strRH_Connection = null;
	///&& strRH_ContentEncoding : To change the Content-Encoding property in Request Http Header
	this.strRH_ContentEncoding = null;
	///&& strRH_ContentLanguage : To change the Content-Language property in Request Http Header
	this.strRH_ContentLanguage = null;
	///&& strRH_ContentLocation : To change the Content-Location property in Request Http Header
	this.strRH_ContentLocation = null;
	///&& strRH_ContentRange : To change the Content-Range property in Request Http Header
	this.strRH_ContentRange = null;
	///&& strRH_ContentMD5 : To change the Content-MD5 property in Request Http Header
	this.strRH_ContentMD5= null;
	///&& strRH_Date :  To change the Date property in Request Http Header
	this.strRH_Date = null;
	///&& strRH_Expect : To change the Expect property in Request Http Header
	this.strRH_Expect = null;
	///&& strRH_Expires : To change the Expires property in Request Http Header
	this.strRH_Expires = null;
	///&& strRH_From : To change the From property in Request Http Header
	this.strRH_From = null;
	///&& strRH_Host : To change the Host property in Request Http Header
	this.strRH_Host = null;
	///&& strRH_IfMatch : To change the If-Match property in Request Http Header
	this.strRH_IfMatch = null;
	///&& strRH_IfModifiedSince : To change the If-Modified-Since property in Request Http Header
	this.strRH_IfModifiedSince = null;
	///&& strRH_IfNoneMatch : To change the If-None-Match property in Request Http Header
	this.strRH_IfNoneMatch = null;
	///&& strRH_IfRange : To change the If-Range property in Request Http Header
	this.strRH_IfRange = null;
	///&& strRH_IfUnmodifiedSince : To change the If-Unmodified-Since property in Request Http Header
	this.strRH_IfUnmodifiedSince = null;
	///&& strRH_LastModified : To change the Last-Modified property in Request Http Header
	this.strRH_LastModified = null;
	///&& strRH_MaxForwards : To change the Max-Forwards property in Request Http Header
	this.strRH_MaxForwards = null;
	///&& strRH_Pragma : To change the Pragma property in Request Http Header
	this.strRH_Pragma = null;
	///&& strRH_ProxyAuthentication : To change the Proxy-Authentication  property in Request Http Header
	this.strRH_ProxyAuthentication = null;
	///&& strRH_Referer : To change the Referer property in Request Http Header
	this.strRH_Referer = null;
	///&& strRH_Range : To change the Range property in Request Http Header
	this.strRH_Range = null;
	///&& strRH_RetryAfter : To change the Retry-After property in Request Http Header
	this.strRH_RetryAfter = null;
	///&& strRH_Server : To change the Server property in Request Http Header
	this.strRH_Server = null;
	///&& strRH_TE : To change the TE property in Request Http Header
	this.strRH_TE = null;
	///&& strRH_Tailer : To change the Tailer property in Request Http Header
	this.strRH_Tailer = null;
	///&& strRH_TransferEncoding : To change the Transfer-Encoding property in Request Http Header
	this.strRH_TransferEncoding = null;
	///&& strRH_Upgrade : To change the Upgrade property in Request Http Header
	this.strRH_Upgrade = null;
	///&& strRH_UserAgent : To change the UserAgent property in Request Http Header
	this.strRH_UserAgent = null;
	///&& strRH_Vary : To change the Vary property in Request Http Header
	this.strRH_Vary = null;
	///&& strRH_Via : To change the Via property in Request Http Header
	this.strRH_Via = null;
	///&& strRH_Warning : To change the Warning property in Request Http Header
	this.strRH_Warning = null;
	///&& strRH_WWWAuthenticate : To change the WWWAuthenticate property in Request Http Header
	this.strRH_WWWAuthenticate = null;
	
}


/// <class Name = "cACTLXmlHttp">
///<summary>
///		This class is used to define all the properties and variables required for XML/Http
///</summary>
///</class>
function cACTLXmlHttp()
{
	
	///-- userAgent : stores the information for the user agent ( browser being used )
	var userAgent = navigator.userAgent.toLowerCase();
	///-- __sBrowserType : Defines the browser type
	var __sBrowserType = "";
	///-- blnAsync : Defines XML Http Request Mode (true : Async, false : sync)
	var blnAsync = null;
	///-- strCallback : Defines the call back property
	var strCallback = "";
	///-- strDefaultCallback : Defines the default call back
	var strDefaultCallback = "fnACTLEvtHandler";
	///-- strCallbackTag : Defines the call back tag
	var strCallbackTag = "ACTLEvtHandler";
	///-- blnCallBackFound : Defines whether the call back function found or nor	
	var blnCallBackFound = false;
	///-- strReadyStateChange : Defines the state change
	var strReadyStateChange = "";
	///-- objRequestPool : Object of request pool
	var objRequestPool = null ;
	///-- nTimeOut : Variable to store the timout interval set by user
	var nTimeOut = null;
	///-- blnIsFormSubmitted : Defines whether the form is submitted or not
	var blnIsFormSubmitted = false;
	///-- oError : Error Object to catch exception and prompt an error message
	var oError = null;
	///-- nCounter : Defines a request counter
	var nCounter = -1;
	///-- oXmlHttp : Defines and XmlHttp Object reference 
	var oXmlHttp = null;
	///-- blnMethodChange : Sets the variable to true in case "POST" method does not work well
	var blnMethodChange = false;
	///-- blnIsPoolFull : Sets the value true when Request pool is full.
	var blnIsPoolFull=false;
	///-- blnIsDuplicateRequest : Sets the value true when duplicate request is made.
	var blnIsDuplicateRequest = false;
	///-- oParameter : Stores request wise parameters in key/value pairs.
	var oParameter = null;
	///-- objConfig : Config objec reference
	var objConfig = null;
	///-- strArrColNames : Sets name of the columns for oParameter Object
	 var strArrColNames = null;
	///-- enmFunctionType : Sets the enum type of Config object.	
	var enmFunctionType = {
							SuccessfulRequest   : 1,
							UnSuccessfulRequest : 2,
							RequestPoolFull		: 3,
							DuplicateRequest    : 4
						   }
		
	///&& blnAllowDuplicateRequest : Defines whether to apply duplicate request or not
	this.blnAllowDuplicateRequest = false ;
	///&& blnApplyRequestPooling : Defines whether to apply request pooling or not
	this.blnApplyRequestPooling = false ;
	///&& nCustomPoolSize : Defines the custom pool size
	this.nCustomPoolSize = 0 ;
	///&& blnIsXmlPost : Posts the request as Xml String
	this.blnIsXmlPost = false;
	///&& blnUseGetIfPostDoesNotWork : Defined by user as true if he wants to use get method if post doesnot work well
	this.blnUseGetIfPostDoesNotWork = false;
	///&& strObjectName : Name of reference to the object (this).
	this.strObjectName = "";
	
	
	
	this.fnInit_XmlHttp = cACTLXmlHttp_fnInit_XmlHttp;
	this.fnSendRequest = cACTLXmlHttp_fnSendRequest;
	this.fnInit_RequestPool = cACTLXmlHttp_fnInit_RequestPool ;
	this.fnPoolIn_Request = cACTLXmlHttp_fnPoolIn_Request ;
	this.fnPoolOut_Request = cACTLXmlHttp_fnPoolOut_Request ;
	this.fnTimeOut = cACTLXmlHttp_fnTimeOut; 
	this.fnOnConstruct = cACTLXmlHttp_fnOnConstruct;

	this.fnOnConstruct();
	/// Construct a refrence of current xml http object
	function cACTLXmlHttp_fnOnConstruct()
	{
		this.strObjectName = "XMLHttp_" + oJSFW.fnGetUnusedGlobalVariableName();
		eval(this.strObjectName + "=this;");
		
		oParameter = oJSFW.fnObjectInitializer('cParameterObject','',[]);
		strArrColNames= oJSFW.fnObjectInitializer('Array','',['XmlHttp','RequestId','SuccessfulRequest','TimeOut','EventHandler']);
		oParameter.oArrColumns = strArrColNames;
	}

	///<memberMethod name="fnThrowError">
	///<summary>
	/// This method is used to throw an Error	
	///</summary>
	///<param name="strMethodName">
	///		This parameter stores the method name where from the error is generated	
	///</param>
	///<param name="strMessage">
	///		This parameter stores the Message to be displayed as an error indication	
	///</param>
	///</memberMethod>
	function cACTLXmlHttp_fnThrowError(strMessage,strMethodName)
	{
		throw new cACTLException(strMessage, strMethodName);
		//var objError = oJSFW.fnObjectInitializer('cACTLException','',[strMessage,strMethodName]);
		//throw (objError) ;
	}

	///<memberMethod name="fnInit_RequestPool">
	///<summary>
	/// This method is used to initialise the request pool
	///</summary>
	///</memberMethod>
	function cACTLXmlHttp_fnInit_RequestPool()
	{
		/// Initialize RequestPool Instance if it is null.
		if ((objRequestPool == null) || (typeof(objRequestPool) != "object"))
		{
			objRequestPool = oJSFW.fnObjectInitializer('cACTLRequestPool','',[this.nCustomPoolSize]);
		}
	}

	///<memberMethod name="fnPoolIn_Request">
	///<summary>
	/// This method is used to send the request for adding a Pool	
	///</summary>
	///<param name="strRequestId">
	///		This parameter stores the request id
	///</param>
	///<param name="blnAllowDuplicateReq">
	///		This Parameter will notify whether to allow duplicate requests or not
	///</param>
	///</memberMethod>
	function cACTLXmlHttp_fnPoolIn_Request(strRequestId,blnAllowDuplicateReq,oXmlHttp)
	{
		return (objRequestPool.fnAddRequest(strRequestId,blnAllowDuplicateReq,oXmlHttp)) ;
	}

	///<memberMethod name="fnPoolOut_Request">
	///<summary>
	/// This method is used to send the request to remove a Pool
	///</summary>
	///<param name="strRequestId">
	///		This parameter stores the request id
	///</param>
	///</memberMethod>
	function cACTLXmlHttp_fnPoolOut_Request(strRequestId)
	{
		objRequestPool.fnRemoveRequest(strRequestId) ;
	}

	///<memberMethod name="fnInit_XmlHttp">
	///<summary>
	/// This method is used to initialize XML/Http
	///</summary>
	///</memberMethod>
	function cACTLXmlHttp_fnInit_XmlHttp() 
	{
 		var A;
		if(oJSFW.objBrowserInfo.IsIE)
		{
			try 
			{
				A = oJSFW.fnObjectInitializer('ActiveXObject','',['Msxml2.XMLHTTP']);
			}
			catch (e) 
			{
				try 
				{
					A = oJSFW.fnObjectInitializer('ActiveXObject','',['Microsoft.XMLHTTP']);
				}
				catch (oc)
				{
					A=null;
				}
			}
		}
		else if(oJSFW.objBrowserInfo.IsMozila)
		{
			if(A==null && typeof XMLHttpRequest != "undefined")
			{
				A = oJSFW.fnObjectInitializer('XMLHttpRequest','',[]);
			}
		}
		
		return A;
	}
	
	///<memberMethod name="fnSendRequest">
	///<summary>
	/// This method is used to send request
	///</summary>
	///<param name="strURL">
	///	This parameter stores the Full URL for the request to be submitted
	///</param>
	///<param name="strRequestParams">
	///	This parameter stores the query string to be submitted via GET or POST
	///</param>
	///<param name="strMethod">
	///	This parameter stores POST / GET based on whether you would like a Form submit or a Querystring posted to your page
	///</param>
	///<param name="strRequestId">
	///	This parameter stores the  Unique ID for the request. Every object on page using XmlHTTP should pass a unique ID.
	///</param>
	///<param name="strEventHandler">
	///	This parameter stores the function to be called when ready state changes.
	///</param>
	///<param name="oConfig">
	///	This parameter stores the config object reference.
	///</param>
	///</memberMethod>
	function cACTLXmlHttp_fnSendRequest(strURL,strRequestParams,strMethod,strRequestId,strEventHandler,oConfig)
	{
		var strMethodName = "ACTLXMLHTTP_fnSendRequest" ;
		var nNumOfArgs = 0 ,nExpArgs = 0;
		var blnContinueFlag = false,blnTFlag=true;
		var nRandomNo,nMiliSeconds,oDate,strFormData,strXmlContent;
		
			try
			{
				nNumOfArgs = arguments.length;
				nExpArgs   = cACTLXmlHttp_fnSendRequest.length;
				
				///-- 1. Throw an exception if argument length or argument types are mismatching
				if ((nExpArgs != nNumOfArgs) || (typeof(strURL) != "string") || (typeof(strRequestParams) != "string") || (typeof(strMethod) != "string") )
				{
					cACTLXmlHttp_fnThrowError("Invalid arguments to send XmlHttp request.",strMethodName) ;
				}
		
				///-- 2. Prompt an error if URL is not provided 
				if(strURL == null || strURL=='')
				{
					cACTLXmlHttp_fnThrowError("URL can not be null.",strMethodName) ;
				}
				
				///-- 3. Prompt an error if no Method is provided
				if(strMethod == null || strMethod=='')
				{
					cACTLXmlHttp_fnThrowError("Method can not be null.",strMethodName) ;
				}
				
				///-- 4. Prompt an error if no event handler is provided 
				if(strEventHandler == null || strEventHandler=='')
				{
					cACTLXmlHttp_fnThrowError("Event handler can not be null.",strMethodName) ;
				}
				else
				{
					strReadyStateChange = strEventHandler;
				}
		
				///--5. Create an instance of XML HTTP Object
				oXmlHttp = cACTLXmlHttp_fnInit_XmlHttp();
				///-- 6. Set Config object parameters to variables.
				objConfig = oConfig;
				blnAsync = oConfig.Async;
				nTimeOut = oConfig.nSendTimeOuts;
					
				///-- 7. Store Each instance of XmlHttp object and RequestId and Timer Id in array
					
				
				///-- 8. Initialize request pool if blnApplyRequestPooling is true and request pool is not created.
				if(this.blnApplyRequestPooling && objRequestPool==null)
				{
					this.fnInit_RequestPool();
				}
		
				///-- 9. Add request in pool if blnApplyRequestPooling is set to true
				if(this.blnApplyRequestPooling)
				{
					if(this.fnPoolIn_Request(strRequestId,this.blnAllowDuplicateRequest,this))
					{
						blnContinueFlag = true;
					}
					else
					{
						blnContinueFlag = false;
						if(this.blnIsPoolFull)
						{
							/// 10. Call an Event Handler with an Error if RequestPool is full
							eval(strEventHandler + '(this,"Request Pool is full",strRequestId,enmFunctionType.RequestPoolFull)');
						}
						else if(this.blnIsDuplicateRequest)
						{
							/// 11. Call an Event Handler with an Error if Duplicate Request Is found
							eval(strEventHandler + '(this,"Duplicate Request not allowed",strRequestId,enmFunctionType.DuplicateRequest)');
						}
					}
				}
				else
				{
					blnContinueFlag = true;					
				}
		
				///-- 12. Proceed if request is successfully added to the pool
				if(blnContinueFlag)
				{
					if (oXmlHttp) 
					{
						///-- 13. Check for Method and proceed accordingly
						switch (strMethod.toUpperCase())
						{
							///-- 14. Set FormSubmitted flag to true if method is POST
							case "POST":
							{
								strFormData = strRequestParams;		
								blnIsFormSubmitted = true;
								break;
							}
							///-- 15. Concate Query String with the url if method is GET
							case "GET":
							{
								strFormData = null;

								if( strURL.indexOf( "?" ) == -1 )
								{
									if(strRequestParams!="" && strRequestParams!=null)
										strURL = strURL + "?" + strRequestParams;
								}
								else
								{
									strURL = strURL + "&" + strRequestParams;
								}						
								break;
							}
						}
						
						

						if(oJSFW.objBrowserInfo.IsMozila)
						{
							
							///-- Mozilla Doesnt support Javascript to get content of a other web page for security reason. 
							///-- So we need to sign this javascript with mozilla's PrivilegeManager to send XML Http Request
							///-- with any type of url. i.e http://www.mysite.com/mypage.asp
							
							//netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
							//netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
							// netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
							// netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
							// netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
							// netscape.security.PrivilegeManager.enablePrivilege("CapabilityPreferencesAccess");
							// netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");
						}
					
						
						///-- 17. Open a link with provided Method, Url and mode blnAsync
						oXmlHttp.open(strMethod.toUpperCase(), strURL, blnAsync);
						
						
						///-- 18. Set Http Request Headers
						fnSetHTTPRequestHeaders();
						
						
						///-- 19. Set Different request headers for different browsers
						if (blnIsFormSubmitted)
						{
							if (this.blnIsXmlPost)
							{
								oXmlHttp.setRequestHeader("Content-Type", "text/xml");	
							}
							else
							{
								oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
							}
						}
						
						oDate =  oJSFW.fnObjectInitializer('Date','',[]);	
						nMiliSeconds = oDate.getMilliseconds();
						nRandomNo = Math.round(nMiliSeconds * Math.random() * 1000000000);
						
						///-- 20. Set Time out for a request
						if(nTimeOut != 0)
						{
							window.setTimeout(this.strObjectName + ".fnTimeOut(" +nRandomNo + ")"  ,nTimeOut);
						}
						
						var strArrColValues=oJSFW.fnObjectInitializer('Array','',[oXmlHttp,strRequestId,false,false,strEventHandler]);
						oParameter.fnAdd(nRandomNo,strArrColValues);
				
										
						///-- 21. Set Ready State Change event hadler
						var nRndNo = nRandomNo;
						//var oXH = oXmlHttp;	var strReqId =  strRequestId;
						if(blnAsync == true)
							oXmlHttp.onreadystatechange =  function () {fnReadyStateChange(nRndNo);} ; 
						
						oXmlHttp.send(strFormData);
						if(blnAsync == false)
						{
							fnReadyStateChange(nRndNo); 
						}
						
						///-- 23. Delete Xml http object
						delete oXmlHttp;
					} 
					else
					{
						cACTLXmlHttp_fnThrowError("Could not create connection object.",strMethodName);
					}
				}
			}
			catch(ex)
			{
				//alert(ex.message);	
				cACTLXmlHttp_fnThrowError(ex.message,strMethodName);
			}
		}
		
		///<memberMethod name="fnTimeOut">
		///<summary>
		/// This method is used to abort request or to remove request from pool
		///</summary>
		///<param name="nRandomNo">
		///	This parameter stores the unique id.
		///</param>
		///</memberMethod>nRandomNo
		function cACTLXmlHttp_fnTimeOut(nRandomNo)
		{
			var strMethodName = "cACTLXmlHttp_fnTimeOut";
			try
			{
				if(this.blnApplyRequestPooling)
				{
					this.fnPoolOut_Request(oParameter.fnGetValue(nRandomNo,"RequestId"));
				}
				oParameter.fnSetValue(nRandomNo,"TimeOut",true);
				oParameter.fnGetValue(nRandomNo,"XmlHttp").abort();
			}
			catch(ex)
			{
				//alert(ex.message);	
				cACTLXmlHttp_fnThrowError(ex.message,strMethodName);
			}
		}
		
		///<memberMethod name="fnSetHTTPRequestHeaders">
		///<summary>
		/// 
		///</summary>
		///</memberMethod>
		function fnSetHTTPRequestHeaders() 
		{
			var strMethodName = "fnSetHTTPRequestHeaders";
			
			try
			{
				if(objConfig.strRH_CacheControl!=null && objConfig.strRH_CacheControl!='')
					oXmlHttp.setRequestHeader("Cache-Control",String(objConfig.strRH_CacheControl));
				if(objConfig.strRH_ContentType!=null && objConfig.strRH_ContentType!='')
					oXmlHttp.setRequestHeader("Content-Type",String(objConfig.strRH_ContentType));
				if(objConfig.strRH_AcceptRanges != null && objConfig.strRH_AcceptRanges!='')
					oXmlHttp.setRequestHeader("Accept-Ranges",String(objConfig.strRH_AcceptRanges));	
				if(objConfig.strRH_ETag != null && objConfig.strRH_ETag!='')
					oXmlHttp.setRequestHeader("ETag",String(objConfig.strRH_ETag));	
				if(objConfig.strRH_ContentLength != null && objConfig.strRH_ContentLength!='')
					oXmlHttp.setRequestHeader("Content-Length",String(objConfig.strRH_ContentLength));	
				if(objConfig.strRH_AcceptCharSet != null && objConfig.strRH_AcceptCharSet!='')
					oXmlHttp.setRequestHeader("Accept-CharSet",String(objConfig.strRH_AcceptCharSet));	
				if(objConfig.strRH_AcceptLanguage != null && objConfig.strRH_AcceptLanguage!='')
					oXmlHttp.setRequestHeader("Accept-Language",String(objConfig.strRH_AcceptLanguage));	
				if(objConfig.strRH_AcceptEncoding != null && objConfig.strRH_AcceptEncoding!='')
					oXmlHttp.setRequestHeader("Accept-Encoding",String(objConfig.strRH_AcceptEncoding));	
				if(objConfig.strRH_Age != null && objConfig.strRH_Age!='')
					oXmlHttp.setRequestHeader("Age",String(objConfig.strRH_Age));	
				if(objConfig.strRH_Allow != null && objConfig.strRH_Allow!='')
					oXmlHttp.setRequestHeader("Allow",String(objConfig.strRH_Allow));	
				if(objConfig.strRH_Authorization != null && objConfig.strRH_Authorization!='')
					oXmlHttp.setRequestHeader("Authorization",String(objConfig.strRH_Authorization));	
				if(objConfig.strRH_Connection != null && objConfig.strRH_Connection!='')
					oXmlHttp.setRequestHeader("Connection",String(objConfig.strRH_Connection));	
				if(objConfig.strRH_ContentEncoding != null && objConfig.strRH_ContentEncoding!='')
					oXmlHttp.setRequestHeader("Content-Encoding",String(objConfig.strRH_ContentEncoding));	
				if(objConfig.strRH_ContentLanguage != null && objConfig.strRH_ContentLanguage!='')
					oXmlHttp.setRequestHeader("Content-Language",String(objConfig.strRH_ContentLanguage));	
				if(objConfig.strRH_ContentLocation != null && objConfig.strRH_ContentLocation!='')
					oXmlHttp.setRequestHeader("Content-Location",String(objConfig.strRH_ContentLocation));	
				if(objConfig.strRH_ContentRange != null && objConfig.strRH_ContentRange!='')
					oXmlHttp.setRequestHeader("Content-Range",String(objConfig.strRH_ContentRange));	
				if(objConfig.strRH_ContentMD5 != null && objConfig.strRH_ContentMD5!='')
					oXmlHttp.setRequestHeader("Content-MD5",String(objConfig.strRH_ContentMD5));	
				if(objConfig.strRH_Date != null && objConfig.strRH_Date!='')
					oXmlHttp.setRequestHeader("Date",String(objConfig.strRH_Date));	
				if(objConfig.strRH_Expect != null && objConfig.strRH_Expect!='')
					oXmlHttp.setRequestHeader("Expect",String(objConfig.strRH_Expect));	
				if(objConfig.strRH_Expires != null && objConfig.strRH_Expires!='')
					oXmlHttp.setRequestHeader("Expires",String(objConfig.strRH_Expires))
				if(objConfig.strRH_Host != null && objConfig.strRH_Host!='')
					oXmlHttp.setRequestHeader("Host",String(objConfig.strRH_Host));	
				if(objConfig.strRH_IfMatch != null && objConfig.strRH_IfMatch!='')
					oXmlHttp.setRequestHeader("If-Match",String(objConfig.strRH_IfMatch));	
				if(objConfig.strRH_IfModifiedSince != null && objConfig.strRH_IfModifiedSince!='')
					oXmlHttp.setRequestHeader("If-Modified-Since",String(objConfig.strRH_IfModifiedSince));	
				if(objConfig.strRH_IfNoneMatch != null && objConfig.strRH_IfNoneMatch!='')
					oXmlHttp.setRequestHeader("If-None-Match",String(objConfig.strRH_IfNoneMatch));	
				if(objConfig.strRH_IfRange != null && objConfig.strRH_IfRange!='')
					oXmlHttp.setRequestHeader("If-Range",String(objConfig.strRH_IfRange));	
				if(objConfig.strRH_IfUnmodifiedSince != null && objConfig.strRH_IfUnmodifiedSince!='')
					oXmlHttp.setRequestHeader("If-Unmodified-Since",String(objConfig.strRH_IfUnmodifiedSince));	
				if(objConfig.strRH_LastModified != null && objConfig.strRH_LastModified!='')
					oXmlHttp.setRequestHeader("Last-Modified",String(objConfig.strRH_LastModified));	
				if(objConfig.strRH_MaxForwards != null && objConfig.strRH_MaxForwards!='')
					oXmlHttp.setRequestHeader("Max-Forwards",String(objConfig.strRH_MaxForwards));	
				if(objConfig.strRH_Pragma != null && objConfig.strRH_Pragma!='')
					oXmlHttp.setRequestHeader("Pragma",String(objConfig.strRH_Pragma));	
				if(objConfig.strRH_ProxyAuthentication != null && objConfig.strRH_ProxyAuthentication!='')
					oXmlHttp.setRequestHeader("Proxy-Authentication",String(objConfig.strRH_ProxyAuthentication));	
				if(objConfig.strRH_Referer != null && objConfig.strRH_Referer!='')
					oXmlHttp.setRequestHeader("Referer",String(objConfig.strRH_Referer));	
				if(objConfig.strRH_Range != null && objConfig.strRH_Range!='')
					oXmlHttp.setRequestHeader("Range",String(objConfig.strRH_Range));	
				if(objConfig.strRH_RetryAfter != null && objConfig.strRH_RetryAfter!='')
					oXmlHttp.setRequestHeader("Retry-After",String(objConfig.strRH_RetryAfter));	
				if(objConfig.strRH_Server != null && objConfig.strRH_Server!='')
					oXmlHttp.setRequestHeader("Server",String(objConfig.strRH_Server));	
				if(objConfig.strRH_TE != null && objConfig.strRH_TE!='')
					oXmlHttp.setRequestHeader("TE",String(objConfig.strRH_TE));	
				if(objConfig.strRH_Tailer != null && objConfig.strRH_Tailer!='')
					oXmlHttp.setRequestHeader("Tailer",String(objConfig.strRH_Tailer));	
				if(objConfig.strRH_TransferEncoding != null && objConfig.strRH_TransferEncoding!='')
					oXmlHttp.setRequestHeader("Transfer-Encoding",String(objConfig.strRH_TransferEncoding));	
				if(objConfig.strRH_Upgrade != null && objConfig.strRH_Upgrade!='')
					oXmlHttp.setRequestHeader("Upgrade",String(objConfig.strRH_Upgrade));	
				if(objConfig.strRH_UserAgent != null && objConfig.strRH_UserAgent!='')
					oXmlHttp.setRequestHeader("User-Agent",String(objConfig.strRH_UserAgent));	
				if(objConfig.strRH_Vary != null && objConfig.strRH_Vary!='')
					oXmlHttp.setRequestHeader("Vary",String(objConfig.strRH_Vary));	
				if(objConfig.strRH_Via != null && objConfig.strRH_Via!='')
					oXmlHttp.setRequestHeader("Via",String(objConfig.strRH_Via));	
				if(objConfig.strRH_Warning != null && objConfig.strRH_Warning!='')
					oXmlHttp.setRequestHeader("Warning",String(objConfig.strRH_Warning));	
				if(objConfig.strRH_WWWAuthenticate != null && objConfig.strRH_WWWAuthenticate!='')
					oXmlHttp.setRequestHeader("WWW-Authenticate",String(objConfig.strRH_WWWAuthenticate));	
			}
			catch(ex)
			{
				cACTLXmlHttp_fnThrowError(ex.message,strMethodName);
			}
		}
		
		///<memberMethod name="fnReadyStateChange">
		///<summary>
		/// This method is used to get response and put it to the client
		///</summary>
		///</memberMethod>
		function fnReadyStateChange(nRandomNo) 
		{
			var nCtr,strEventHandler;
			var blnTimeFlag=false,blnNoError=true;
			
			var strMethodName = "fnReadyStateChange";
			var oXmlHttp=oParameter.fnGetValue(nRandomNo,"XmlHttp");
			var strRequestId=oParameter.fnGetValue(nRandomNo,"RequestId");
			this.strCallback = oParameter.fnGetValue(nRandomNo,"EventHandler");
			
			if(oParameter.fnGetValue(nRandomNo,"TimeOut") == true)
			{
				oError = "Request Timed Out";
				
				oParameter.fnRemove(nRandomNo);
				this.strCallback = this.strCallback + "(oXmlHttp, oError, strRequestId,enmFunctionType.UnSuccessfulRequest)";	
				eval(this.strCallback);
			}
			else if (oXmlHttp.readyState == 4 ) 
			{
				///-- Proceed If ReadyState is "4" & request is not timed out
				if (oXmlHttp.status == 200 ) 
				{
					/// "OK"
					try
					{
						///-- Get Browser Type and process accordingly
						if (oJSFW.objBrowserInfo.IsIE)
						{
							///-- Check for error code
							if(oXmlHttp.responseXML.parseError.errorCode != 0)
							{
								oError = oXmlHttp.responseXML.parseError.reason; 
								this.strCallback = this.strCallback + "(oXmlHttp, oError,strRequestId, enmFunctionType.UnSuccessfulRequest)";
								blnNoError= false;
							}
						}
							
						if(blnNoError || oJSFW.objBrowserInfo.IsMozila)
						{
							///-- Process if error code is valid
							if (oXmlHttp.responseXML != null)
							{
								var oCallBack = oJSFW.fnGetElementsByTagName(strCallbackTag,oXmlHttp.responseXML);
								
								oParameter.fnSetValue(nRandomNo,"SuccessfulRequest",true)
								
								if ((oCallBack != null) && oCallBack.length > 0)
								{	
									this.strCallback = oCallBack[0].text;
									blnCallBackFound = true;
								}
							}
							else
							{
								///-- It POST method does not work, then recall the function with GET method.
								if(this.blnUseGetIfPostDoesNotWork == true)
								{
									if(strMethod.toUpperCase()=="POST" && blnMethodChange==false)
									{
										blnMethodChange = true;
										this.fnSendRequest(strURL, strRequestParams, "Get", strRequestId);
									}
								}
							}
							
							/// Remove Key From Parameter Object
							//oParameter.fnRemove(nRandomNo);
							
							oError= null;
							this.strCallback = this.strCallback + "(oXmlHttp, oError,strRequestId, enmFunctionType.SuccessfulRequest)";	
							eval(this.strCallback);
						}
						
						
					}
					catch (ex)
					{
						cACTLXmlHttp_fnThrowError(ex.message,"strMethodName");
						//alert(oError);
					}
				} 
				else 
				{
					oError = "Problem retrieving Response Text";
					this.strCallback = this.strCallback + "(oXmlHttp, oError,strRequestId, enmFunctionType.UnSuccessfulRequest)";
					eval(this.strCallback);	
				}
			
				///-- Remove Request From Pool
				//if(oXmlHttp.blnApplyRequestPooling)
				//{
					cACTLXmlHttp_fnTimeOut(nRandomNo);
				//}
			}					
		}
}

	


///<class name = "cACTLRequestPool">
///<summary>
/// This class defines the ACTLRequest Pool
///</summary>
///</class>
function cACTLRequestPool(vNewPoolSize)
{
	///--nCustomPoolSize : Pool size defined by user of this cACTLRequestPool object.	
	var nCustomPoolSize = 0 ;
	///--nDefaultPoolSize: Default Pool size set for this cACTLRequestPool object.	
	var nDefaultPoolSize = 5 ;
	///-- nPoolSize : Actual Pool size used for this cACTLRequestPool object.This variable is used so that we don't have to check nCustomPoolSize & nDefaultPoolSize to decide which to use.
	var nPoolSize = 0 ;
	///-- arrRequestPool : Stores the xml http requests
	var arrRequestPool = null ;
	///-- arrEmptyPoolNumbers : Stores the pool numbers that are not occupied
	var arrEmptyPoolNumbers = null ;
	///-- IsPoolAvailable : True if pool is available
	var IsPoolAvailable = false ;
	
	this.fnAddRequest = cACTLRequestPool_fnAddRequest ;
	this.fnRemoveRequest = cACTLRequestPool_fnRemoveRequest ;
	this.fnCheckPoolAvailability = cACTLRequestPool_fnCheckPoolAvailability ;

	nCustomPoolSize = vNewPoolSize ;
	cACTLRequestPool_fnInit() ;


	///<memberMethod name="fnThrowError">
	///<summary>
	/// This method is used to throw an Error	
	///</summary>
	///<param name="strMethodName">
	///		This parameter stores the method name where from the error is generated	
	///</param>
	///<param name="strMessage">
	///		This parameter stores the Message to be displayed as an error indication	
	///</param>
	///</memberMethod>
	function cACTLRequestPool_fnThrowError(strMessage,strMethodName)
	{
		throw new cACTLException(strMessage,strMethodName);
		//var objError = oJSFW.fnObjectInitializer('cACTLException','',[strMessage,strMethodName]);
		//throw (objError) ;
	}


	///<memberMethod name="fnSetPoolSize">
	///<summary>
	/// This method is used to set the pool size
	///</summary>
	///</memberMethod>
	function cACTLRequestPool_fnSetPoolSize()
	{
		///-- 1. nNewPoolSize : convert the custom pool size to numeric value.
		var nNewPoolSize = Number(nCustomPoolSize) ;
	
		if (nNewPoolSize > 0)
		{
			nPoolSize = nNewPoolSize ; 
		}
		else
		{
			nPoolSize = nDefaultPoolSize ;
		}
	}

	
	///<memberMethod name="fnInit">
	///<summary>
	/// This method is used to init the request pool
	///</summary>
	///</memberMethod>
	function cACTLRequestPool_fnInit()
	{
		var strMethodName = "cACTLRequestPool.fnInit" ;
		try
		{	
			cACTLRequestPool_fnSetPoolSize() ;
			arrRequestPool = oJSFW.fnObjectInitializer('Array','',[]);
			arrEmptyPoolNumbers = oJSFW.fnObjectInitializer('Array','',[]);
		
			for (nCurrentIndex = 0 ; nCurrentIndex < nPoolSize ; nCurrentIndex++)
			{
				arrRequestPool.push("") ;
				arrEmptyPoolNumbers.push(nCurrentIndex) ;
			}
		
			cACTLRequestPool_fnSetPoolAvailability() ;
		}
		catch(ex)
		{
			//throw new cACTLException("Error occured while initializing the request pool : " + ex.message, "cACTLRequestPool.fnInit");
			cACTLRequestPool_fnThrowError("Error occured while initializing the request pool : " + ex.message , strMethodName) ;
		}
	}

	///<memberMethod name="fnSetPoolAvailability">
	///<summary>
	/// This method is used to set the pool availability
	///</summary>
	///</memberMethod>
	function cACTLRequestPool_fnSetPoolAvailability()
	{
		IsPoolAvailable = (arrEmptyPoolNumbers.length > 0) ;
	}
	
	///<memberMethod name="fnGetFromAvailablePool">
	///<summary>
	/// This method is used to get the pool number
	///</summary>
	///</memberMethod>
	function cACTLRequestPool_fnGetFromAvailablePool()
	{
		var nCurrentPoolNumber = -1 ;

		if (IsPoolAvailable)
		{
			nCurrentPoolNumber = arrEmptyPoolNumbers.pop() ;
			cACTLRequestPool_fnSetPoolAvailability() ;
		}

		return nCurrentPoolNumber ;
	}

	///<memberMethod name="fnSetToAvailablePool">
	///<summary>
	/// This method is used to set the pool number
	///</summary>
	///<param name="nCurrentPoolNumber">
	/// This parameter stores the current pool number
	///</param>
	///</memberMethod>
	function cACTLRequestPool_fnSetToAvailablePool(nCurrentPoolNumber)
	{
		arrEmptyPoolNumbers.push(nCurrentPoolNumber) ;
		cACTLRequestPool_fnSetPoolAvailability() ;
	}
	

	///<memberMethod name="fnGetIndexOfRequestInPool">
	///<summary>
	/// This method is used to get index of the requested pool
	///</summary>
	///<param name="strRequestId">
	/// This parameter stores the request id
	///</param>
	///</memberMethod>
	function cACTLRequestPool_fnGetIndexOfRequestInPool(strRequestId)
	{
		var nIndexOfRequestInPool = -1 ;

		for(iCurrentRequestPoolIndex = 0 ; iCurrentRequestPoolIndex < arrRequestPool.length ; iCurrentRequestPoolIndex++)
		{
			if (strRequestId.toLowerCase() == arrRequestPool[iCurrentRequestPoolIndex].toString().toLowerCase())
			{
				nIndexOfRequestInPool = iCurrentRequestPoolIndex ;
				break ;
			}
		}
		return nIndexOfRequestInPool ;
	}
	
	///<memberMethod name="fnCheckPoolAvailability">
	///<summary>
	/// This method is used to check the pool availability
	///</summary>
	///</memberMethod>
	function cACTLRequestPool_fnCheckPoolAvailability()
	{
		return (IsPoolAvailable) ;
	}


	///<memberMethod name="fnAddRequest">
	///<summary>
	/// This method is used to add a request
	///</summary>	
	///<param name="strRequestId">
	/// This parameter stores the request id 
	///</param>
	///</memberMethod>
	function cACTLRequestPool_fnAddRequest(strRequestId,blnAllowDuplicateReq,oXmlHttp)
	{
		var strMethodName = "cACTLRequestPool.fnAddRequest" ;
		var nIndexOfRequestInPool = -1 ;
		var retval = false ;
		if(!blnAllowDuplicateReq)
		{
			/// Check for the Request in pool if user has set blnAllowDuplicateRequest = false 
			if (cACTLRequestPool_fnGetIndexOfRequestInPool(strRequestId) >= 0)
			{
				retval=false;
				oXmlHttp.blnIsDuplicateRequest = true;
				return retval;
			}
		}
			
		/// Get any available index from pool.
		nIndexOfRequestInPool = cACTLRequestPool_fnGetFromAvailablePool() ;
		if (nIndexOfRequestInPool >= 0)
		{
			/// Add Request in pool with the RequestId, User has provided.
			arrRequestPool[nIndexOfRequestInPool] = strRequestId ;
			retval = true ;
			
			
			/// T** Temporary Code For Showing the request in pool in example
			/// to be removed from original js file
			eval(fnAddRequestInPool(strRequestId));
		}
		else
		{
			oXmlHttp.blnIsPoolFull = true;
			retval = false ;
			/// Throw an exception if Request pool is full.
			///throw new cACTLException("Request pool full. Please try later", "cACTLRequestPool.fnAddRequest");
		}
		return retval ;
	}

	
	///<memberMethod name="fnRemoveRequest">
	///<summary>
	/// This method is used to remove a request
	///</summary>
	///<param name="strRequestId">
	/// This parameter stores the request id 
	///</param>
	///</memberMethod>
	function cACTLRequestPool_fnRemoveRequest(strRequestId)
	{
		
		var strMethodName = "cACTLRequestPool.fnRemoveRequest" ;
		var nIndexOfRequestInPool = cACTLRequestPool_fnGetIndexOfRequestInPool(strRequestId) ;
		
		try
		{
			if (nIndexOfRequestInPool >= 0)
			{
				arrRequestPool[nIndexOfRequestInPool] = "" ;
				cACTLRequestPool_fnSetToAvailablePool(nIndexOfRequestInPool) ;
			}
		}
		catch(ex)
		{
			cACTLRequestPool_fnThrowError("Error occured while removing request from pool : " + ex.message,strMethodName) ;
		}
	}
}

	/*
		/// 6. Get HidValues and Concat it with the QueryString variable sQS
		if (String(s == 'undefined') 
		{   
			strHidClientValue	=  oJSFW.fnGetElementById('HidClient', true).value;
			strHidPageValue	= oJSFW.fnGetElementById('HidPage', true).value;
			if (oJSFW.fnGetElementById('HidSession',true) != null)
			{
				strHidSessionValue = oJSFW.fnGetElementById('HidSession',true).value;	
			}
		}
		else
		{
			strHidClientValue	= oJSFW.fnGetElementsByName('HidClient')[0].value;
			strHidPageValue	= oJSFW.fnGetElementsByName('HidPage')[0].value;
			if (oJSFW.fnGetElementsByName('HidSession') != null)
			{
				strHidSessionValue	= oJSFW.fnGetElementsByName('HidSession')[0].value ;
			}
		}
		strHidValues = "HidClient=" + strHidClientValue + "&"+
					   "HidSession=" + strHidSessionValue + "&" +
					   "HidPage=" + strHidPageValue ;

		strRequestParams += ((strRequestParams.length > 0) ? "&"  : "") + strHidValues ;
		
		oArrConfig[nCounter].strRequestParameters = strRequestParams;
		strFormData = strRequestParams;
		*/
		