
/*
   remoteURL: url of the request sent to the server
   requestType: Type of request (GET or POST)
   callbackFunction: callback function
   isAsynchronous: true if the transaction is asynchronous (script doesn't wait for the response)
*/

function dnn_CAJAX(){
	this.req = false;
	this.CallBack=null;
	this.name = "CAJAX";
}

dnn_CAJAX.prototype = 
{
	ajaxManager: function(remoteURL, requestType, callbackFunction, isAsynchronous, parameters)
	{
			
		if(window.XMLHttpRequest) 
		{
			try 
			{
				this.req = new XMLHttpRequest();
			} 
			catch(e) 
			{
				this.req = false;
			}
		// branch for IE/Windows ActiveX version
		} 
		else if(window.ActiveXObject) 
		{
			try 
			{
			   this.req = new ActiveXObject("Msxml2.XMLHTTP");
			} 
			catch(e) 
			{
			   try 
			   {
				this.req = new ActiveXObject("Microsoft.XMLHTTP");
			   } 
			   catch(e) 
			   {
				this.req = false;
			   }
			}
		}
		
		if(this.req) 
		{
			//
			this.CallBack = callbackFunction
				//alert(this.name)
			this.req.onreadystatechange = this.ResponseMGR.bind(this)
			this.req.open(requestType, remoteURL, isAsynchronous);
			this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			this.req.send(parameters);
		}
				
	},
	ResponseMGR: function()
	{	
		if ((this.req.readyState != null && this.req.readyState == 4))
		{
			this.CallBack();
		}
	}
}

Function.prototype.bind = function(obj) { 
  var method = this, 
   temp = function() { 
    return method.apply(obj, arguments); 
   }; 
  
  return temp; 
 } 
