
function HTTPSocket(URL){
	this.url = URL;
	this.postValues = Array();
	this.postKeys = Array();
	this.post = Array();
	this.i = 0;
	this.theDiv;
	var el = this;

	if(window.XMLHttpRequest){
		this.xmlhttp = new XMLHttpRequest();
	} else {
		this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

  	this.xmlhttp.onreadystatechange = function(){
		el.readyStatus = this.readyState;
		if(el.readyStatus == 4){
			el.httpStatus = this.status;
			el.httpStatusText = this.statusText;
			if(el.theDiv){
				el.theDiv.innerHTML = this.responseText;
			}
		}


		if(el.readyStatus == 4){
	        	el.onLoad();
		}

        }


	this.setVar = function(key, value){
		this.postKeys[this.i] =  key;
		this.postValues[this.i] =  value;
		this.post[this.i] = ""+key+"="+escape(value)+"";
		this.i++;
	}

	this.send = function(){

		post = this.post.join("&");


	 	if(post){



			this.xmlhttp.open("POST", this.url, true);


	    		this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
			this.xmlhttp.setRequestHeader("Content-length", post.length);
			this.xmlhttp.setRequestHeader("Connection","close");
			this.xmlhttp.send(post);
  
  		} else {
			this.xmlhttp.open("GET", this.url, true);
    			this.xmlhttp.send(null);
  		}

	}



	this.getBody = function(){
		return this.xmlhttp.responseText;
	}

	this.getVariables = function(){
		b = Array();
		vars = this.xmlhttp.responseText.split("&");
		for(i=0; i < vars.length; i++){
			values = vars[i].split("=");

			b[values[0]] = values[1];
		}
		return b;


	}
	this.getXML = function(){
		return this.xmlhttp.responseXML.documentElement;
	}

}



