function XMLTransferHelper() {

	this.createDocument = function() {
		if (document.implementation && document.implementation.createDocument) { 
			return document.implementation.createDocument("", "", null); 
		} else if (window.ActiveXObject) { 
			return new ActiveXObject("Microsoft.XMLDOM"); 
		}
		throw "Unsupported Browser";
	}
	
	this.sendDocument = function(url, doc, callback, method) {
		if(!method) method = "POST";
		me.callback = callback;
		if (window.XMLHttpRequest) { // Mozilla etc. 
			xmlhttp=new XMLHttpRequest(); 
		} else if (window.ActiveXObject) { // IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		}
		if (!xmlhttp) throw "unsupported browser";
		xmlhttp.onreadystatechange=me.updated; 
		xmlhttp.open(method,url,true); 
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		xmlhttp.send(doc); 
	}
	
	this.updated = function() {
		if(xmlhttp.readyState < 4) {
			return;
		}
		try {
			if(xmlhttp.status != 200) return;
		} catch (e) {
			window.status = e;
			return;
		}
		try {
			var doc = xmlhttp.responseXML;
			if((!doc || !doc.documentElement) && window.ActiveXObject) {
					doc = new ActiveXObject("Microsoft.XMLDOM");
					doc.async=false;
					doc.loadXML(xmlhttp.responseText);
					if(!doc.firstChild) { //ie try again stripping extended chars.
						var txt = xmlhttp.responseText;
						doc.loadXML(cleanText(txt));
					}
			}
			if(!doc || !doc.documentElement) {
				me.callback(null, me);
			} else {
				me.callback(doc, me);
			}
		} catch (ex) {
		}
	}
	
	this.lastResponse = function() {
		return xmlhttp.responseText;
	}
	
	this.lastXMLHTTP = null;
	this.callback = null;
	var xmlhttp = null;
	var me = this;
};
