  function XML_RPC_Client(url,saveLocation,enableAutologin)
  {
  	this.url=url;
    
  	this.saveLocation=((typeof(saveLocation)=='undefined')?0:saveLocation); // '1' - save location; '0' - don't save location; '-1' - path throw, if already logged in;
  	this.enableAutologin=((typeof(enableAutologin)=='undefined')?0:enableAutologin); // '0' - don't use autologin, '1' - try autologin
    
  	this.http_request=false;
  	
  	this.request="";
  	this.value=null;
  	this.failedCode=null;
  	
  	this.failed=false;

  	this.data=null;
  	this.callbackFunction;
/*    
    var rpcLog=document.createElement('textarea');
    rpcLog.rows=25;
    rpcLog.cols=80;
    rpcLog.id='rpcLog';
    document.body.appendChild(rpcLog);
/**/    
    this.httpRequests=[];
    
  	
		this.createXmlHttpRequestObject=function()
		{
  		var xmlHttp=null;
  		try
  		{
    		xmlHttp = new XMLHttpRequest();
  		}
  		catch(e)
  		{
    		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    		"MSXML2.XMLHTTP.5.0",
                                    		"MSXML2.XMLHTTP.4.0",
                                    		"MSXML2.XMLHTTP.3.0",
                                    		"MSXML2.XMLHTTP",
                                    		"Microsoft.XMLHTTP");
    		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    		{
      		try 
      		{ 
        		xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      		} 
      		catch (e) {}
    		}
  		}
    	return xmlHttp;
		}		
    
    this.setData=function(data,callback)
    {
      this.data=data;
      this.data.location=window.location.toString();
      this.data.saveLocation=this.saveLocation;
      this.data.enableAutologin=this.enableAutologin;
      this.callbackFunction=callback;
    }

  	this.call=function(method,id)
  	{
  		this.failedCode=null;
  		this.failed=false;
  	
			this.httpRequests[id]=this.createXmlHttpRequestObject();
		
			if (!this.httpRequests[id])
			{
				throw "XMLHttpRequest not supported.";
				return false;
			}
			
			var JSON_call_object={"method":method,"params":this.data,"id":id};

      var callbackFunction=this.callbackFunction;
      
      var httpRequestLocal=this.httpRequests[id];
      this.httpRequests[id].onreadystatechange=function()
      {
        switch (httpRequestLocal.readyState)
        {
          case 1: 
//            document.getElementById("rpcLog").value+="Request: /n"+JSON_call_object.toJSONString()+"/n/n";
            try{
                httpRequestLocal.send(JSON_call_object.toJSONString());
            }
            catch(e){}        
          break;
          case 4:
  	if ( httpRequestLocal.status == 200 ) {
        	try {
//		document.getElementById("rpcLog").value+="Response: /n"+httpRequestLocal.responseText+"/n/n";
	            var serverResponse = httpRequestLocal.responseText.parseJSON();
							}catch (e){
		          	serverResponse = {'result':null,'error':e,'id':id};
		          }
		          if (serverResponse.result!==null && serverResponse.result.redirect)
		          {
		           	window.location=serverResponse.result.redirect;
		          }
							callbackFunction(serverResponse);
            }
          break;
        }
      };
      
      //window.location;
			this.httpRequests[id].open('POST',url,true);

    }  
    
    this.killRequest=function(id)
    {
//      delete this.httpRequests[id];
      this.httpRequests[id].onreadystatechange=function(){};
    }
  }/**/