function sack(file) {
	this.xmlhttp = null;

	this.reset = function() {
		this.method = "POST";
		this.argumentSeparator = "+";
		this.URLString = "";
		this.encodeURIString = true;
		this.scriptPhp = file;
		this.vars = new Object();
		this.onLoading = function() { };
  	this.onCompletion = function() { };
  	};
  	
  this.ajaxTimeout = function() {
		this.xmlhttp.abort();
		
  	};

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				this.xmlhttp = null;
			}
		}
		if (! this.xmlhttp) {
			if (typeof XMLHttpRequest != "undefined") {
				this.xmlhttp = new XMLHttpRequest();
			}
		}
	};

	this.setVar = function(name, value){
		this.vars[name] = Array(value, false);
	};

	this.encVar = function(name, value, returnvars) {
		if (true == returnvars) {
			return Array(encodeURIComponent(name), encodeURIComponent(value));
		} else {
			this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
		}
	};

	this.processURLString = function(string, encode) {
		encoded = encodeURIComponent(this.argumentSeparator);
		regexp = new RegExp(this.argumentSeparator + "|" + encoded);
		varArray = string.split(regexp);
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split("=");
			if (true == encode){
				this.encVar(urlVars[0], urlVars[1]);
			} else {
				this.setVar(urlVars[0], urlVars[1]);
			}
		}
	};

	this.createURLString = function(urlstring) {
		if (this.encodeURIString && this.URLString.length) {
			this.processURLString(this.URLString, true);
		}

		if (urlstring) {
			if (this.URLString.length) {
				this.URLString += this.argumentSeparator + urlstring;
			} else {
				this.URLString = urlstring;
			}
		}

		// prevents caching of URLString
		this.setVar("rndval", new Date().getTime());

		urlstringtemp = new Array();
		for (key in this.vars) {
			if (false == this.vars[key][1] && true == this.encodeURIString) {
				encoded = this.encVar(key, this.vars[key][0], true);
				delete this.vars[key];
				this.vars[encoded[0]] = Array(encoded[1], true);
				key = encoded[0];
			}

			urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
		}
		if (urlstring){
			this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
		} else {
			this.URLString += urlstringtemp.join(this.argumentSeparator);
		}
	};

	this.runAJAX = function(urlstring) 
	{
		this.createURLString(urlstring);
		if (this.xmlhttp) 
		{
			var self = this;
			this.xmlhttp.open(this.method, this.scriptPhp, true);
			try 
			{
				this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			} 
			catch (e) { }
			this.xmlhttp.onreadystatechange = function() {
			if(self.xmlhttp.readyState==4)
			{
				self.response = self.xmlhttp.responseText;
				self.responseXML = self.xmlhttp.responseXML;
				if (self.xmlhttp.status == "200") self.onCompletion();
				self.URLString = "";
			}
			else self.onLoading();
		};
		this.xmlhttp.send(this.URLString);
		}
	};

	this.reset();
	this.createAJAX();
}

