var http = new ArdoCmsAjax();

function ArdoCmsAjax()
{
  this.url = 'func.php';
  this.params = {};
  /*this.handler = null;*/
  this.method = 'get';

  if(navigator.appName == 'Microsoft Internet Explorer')
  {
    this.obj = new ActiveXObject('Microsoft.XMLHTTP');
  }
  else
  {
    this.obj = new XMLHttpRequest();
  }
};

ArdoCmsAjax.prototype.param = function()
{
  var cnt = arguments.length;
  if (cnt==0 || cnt%2==1)
  {
    alert('incorrect arguments count');
    return;
  }
  this.params = {};
  for(i=0; i<arguments.length; i+=2) this.params[arguments[i]] = arguments[i + 1];
};

ArdoCmsAjax.prototype.send = function(f)
{
  var s='',l=0;
	for(k in this.params) s += k + '='+escape(this.params[k])+'&';
	l = s.length;
	s = s.substr(0, l - 1);

	if (this.method == 'get')
	{
    if (l) s = '?'+s;
    s = this.url+s;

    this.obj.open(this.method, s);
    if(typeof(f)=='function') this.obj.onreadystatechange = f;
    this.obj.send(null);
	}
  else
  {
    this.obj.open(this.method, this.url);
    this.obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    if(typeof(f)=='function') this.obj.onreadystatechange = f;
    this.obj.send(s);
  }

};
