

function AjaxConnection(uri) {
   this.setOptions=setOptions;
   this.getOptions=getOptions;
   this.init_object=init_object;
   this.connect=connect;
   this.uri=uri;
} 

function setOptions(opt){
   this.options = '';
   for(i=0;i<opt.length;i++)  
   {
      if (i!= 0) this.options +='&';
	  this.options += opt[i];
   }
}

function getOptions(){
   return this.options;
}

//var connection = new AjaxConnection(); 
//connection.getOptions();
//connection.setOptions(new Array("action=getList","user=me")); 
//Now, call setOptions with an array, because you want to sort through any options and create the correct POST list for later. 
//The next two lines declaring the connect() function and the URI that it will use: 
//To create the connect() function, type the following lines at the end of your class: 

function connect(return_func){
			var that = this;
            this.init_object();
            this.x.open("POST", this.uri,true);
            this.x.onreadystatechange = function() {
                if (that.x.readyState != 4)
                        return;
                        //eval(return_func + '(x.responseText)');
						return_func(that.x.responseText);
                        //delete x;
                }
            this.x.setRequestHeader('Content-Type',
                    'application/x-www-form-urlencoded');
            this.x.send(this.options);
        
}
		
function init_object() {
        //var x;
        try {
                this.x=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                        this.x=new ActiveXObject("Microsoft.XMLHTTP");
                } catch (oc) {
                        this.x=null;
                }
        }
        if(!this.x && typeof XMLHttpRequest != "undefined")
                this.x = new XMLHttpRequest();
        //if (x)
          //      return x;
}

