function AjaxProxy(url, methodName, requestMode)
{
	if( url != null )
	{	
		if( url.length > 0 )
			this.url = url;
	}
				
	if( methodName != null )
	{	
		if( methodName.length > 0 )
			this.methodName = methodName;
	}
	
	this.requestMode = requestMode;
	if( this.requestMode == null )
		this.requestMode = "GET";
	
	this.crossSiteMode = false;
	this.format = "text";
	this.parameters = new NameValueCollection();
}
						
AjaxProxy.prototype.createRequestObject = function()
{
	var returnRequestObject;

	if( window.XMLHttpRequest )
	{
		returnRequestObject = new XMLHttpRequest();	
		if( returnRequestObject.overrideMimeType )
			returnRequestObject.overrideMimeType("text/xml");
		//this.requestMode = "GET";
	}
					
	if( window.ActiveXObject )
	{
		try {
			returnRequestObject = new ActiveXObject("Msxml2.XMLHTTP");
			//this.requestMode = "POST";
        } catch (e) {
			try {
				returnRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
				//this.requestMode = "POST";
			} catch (e) {}
		}
	}
		
	return returnRequestObject;
}
		
AjaxProxy.prototype.execute = function()
{
	if( this.url != null )
	{
		this.requestObject = this.createRequestObject();
		if( this.requestObject != null )
		{
			var Params = "";
			var ProxyReference = this;
			
			this.parameters.set("method", this.methodName);
		
			if( this.crossSiteMode == true )
			{
				try {
					netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
				} catch (e) {
					alert("Permission UniversalBrowserRead denied.");
				}
			}
						
			var requestUrl = this.url;
			if( this.requestMode.toUpperCase() == "GET" )
				requestUrl += "?" + this.parameters.toString();
			
			this.requestObject.onreadystatechange = function(){ProxyReference.responseHandler()};
			this.requestObject.open(this.requestMode, requestUrl, true);
			
			//if( this.requestMode.toUpperCase() == "POST" )
			//{
				//Params = this.parameters.toString();
				
				var body = '';
				var boundaryString = 'ajax';
				var boundary = '--' + boundaryString;

		        for (var key in this.parameters.items) {
					body += "--" + boundary + "\nContent-Disposition: form-data;name=\"" + key + "\"\n";
					body += "\n";
					body += this.parameters.get(key) + "\n";
		        }
		        body += "--" + boundary + "--";
				this.requestObject.setRequestHeader("Content-type", "multipart/form-data; boundary=\"" + boundary + "\"");

				//this.requestObject.setRequestHeader("Content-type", "multipart/form-data; boundary=" + boundary);
				//this.requestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				this.requestObject.setRequestHeader("Content-length", body.length);
				this.requestObject.setRequestHeader("Connection", "close");
			//}

			this.requestObject.send(body);
		}
	}
}
			
AjaxProxy.prototype.responseHandler = function()
{
	if( this.requestObject != null )
	{
		if( (this.requestObject.readyState == 4) && (this.requestObject.status == 200) )
		{
			if( this.format.toUpperCase() == "XML" )
				this.callback(this.requestObject.responseXML);
			else
				this.callback(this.requestObject.responseText);
		}
	}
}			
