function TeraWurflAjax(webservice){
	// Properties
	this.webservice = webservice;
	this.capabilities = new Array();
	this.errors = new Array();
	this.xmlHttpReq = false;
	this.onUpdate=function(r){};
	var self = this;

	// Methods
	this.getHelpIndex = function(action){
		this.action = action;
		this.fullURL = this.webservice + '?action=' + this.action;
		
		if(window.XMLHttpRequest) {
			self.xmlHttpReq = new XMLHttpRequest();
		}else if (window.ActiveXObject) {
			try{
				self.xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(e){}
			}
		}
		self.xmlHttpReq.open('GET', this.fullURL, true);
		self.xmlHttpReq.onreadystatechange = this.handleResponse;
		self.xmlHttpReq.send(null);
	}

	this.handleResponse = function(){
		if(self.xmlHttpReq.readyState != 4) return;
		if(self.xmlHttpReq.status == 12029 || self.xmlHttpReq.status == 12007){
			alert("Error: Could not connect to TeraWurflHelp webservice");
			return;
		}
		var responseData = self.xmlHttpReq.responseText;
		self.onUpdate(JSON.parse(responseData));
	}
	this.urlencode = function(str){
		str = (str+'').toString();
		return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
	}
}
