function UserWidget(userId)
{
	this.id = 'userWidget';
	this.updateUserUrl = 'http://'+getHost()+'/updateuser';
	this.userId = userId;
	
	UserWidget.prototype.updateProfile = function(oldDescription, newDescription) {
		newDescription = trim(newDescription);
		if (newDescription != trim(oldDescription)) {
			var self = this;
			var params = "userId="+this.userId+"&description="+encodeURIComponent(encodeURIComponent(newDescription));
			var updateProfileAjax = new Ajax.Request(
				this.updateUserUrl,
				{
					method: 'post', 
					asynchronous: true,
					postBody: params,
					onComplete: function(request, responseHeader){
							self.completeUpdateProfile(request, responseHeader, newDescription);
							},
					onException: function(request, responseHeader){
							self.reportException(request, responseHeader);
							},
					onFailure: function(request, responseHeader){
							self.reportError(request, responseHeader);
							}
			});
			$('profile_static_text').innerHTML = encodeHtml(newDescription);
			stopEdit(false);
		}
	}
	
	UserWidget.prototype.completeUpdateProfile = function(request, responseHeader, newDescription) {
		var result = request.responseText;		
		try { 
			if (result != OPERATION_SUCCESSFUL) 
				throw("");
		} catch (everything) {
			var message = "Sorry, an error occurred whilst updating your profile.";
			showErrorAlert(message);
			window.location.reload(); // clean up edit space
		}
	}	
	
}