var rpc={// v1.3
	q: [],

	send: function(u,c,d){
		var t, n = rpc.q.length, o = rpc.x.o(), a=d;

		rpc.q[n] = {request:d,conn:o,callback:c,response:{}};

		o.open(d?'POST':'GET',u,true);

		if(d)
		{
			try{o.setRequestHeader('Content-Type','application/x-www-form-urlencoded')}catch(e){};
			if(typeof(a)=='object')
			{
				a='';
				for(t in d)
				{
					a+=(a?'&':'')+t+'='+encodeURIComponent(d[t]);
				}
			}
			o.send(a);
		}else{
			o.send(null);
		}
		rpc.p(n);

		return n;
	},

	abort: function(id){
		try{rpc.q[id].conn.abort();rpc.q[id].conn=null}catch(e){}
		rpc.q[id]=null
	},

	x: {
		o: function()
		{
			var r=null
			try{
				r=new XMLHttpRequest()
			}catch(e){
				var i,s='.XMLHTTP',t='MSXML2'+s,m=[t+'.6.0',t+'.5.0',t+'.4.0',t+'.3.0',t,'Microsoft'+s];
				for(i in m)
				{
					try{
						r=new ActiveXObject(m[i]);if(r){break}
					}catch(e){}
				}
			}
			return r
		}
	},

	p: function(id){

		if(rpc.q[id]!=null)
		{
			if(rpc.q[id].conn.readyState==4)
			{
				rpc.q[id].response.text = rpc.q[id].conn.responseText;
				rpc.q[id].response.xml = rpc.q[id].conn.responseXML;

				var o={};
				try {
					eval('o='+rpc.q[id].response.text);
				}catch(e){
//					alert('RPC: '+(e.description?e.description:e));
				}
				rpc.q[id].response.js = o;


				if(rpc.q[id].callback)
				{
					rpc.q[id].callback(rpc.q[id].response);
				}

				rpc.q[id].conn=null;
				rpc.q[id]=null;
			}else{
				setTimeout('rpc.p('+id+')', 50);
			}
		}
	}
};
