function friendFeedTasks(id) {
	var $j = jQuery;	

	var fft = this;
	this.id = id;

	this.toggleComments = "#ff_togglecommentslink_" + id;
	this.discussions = '#friendfeeddiscussions_' + id;
	this.newComment = '#ff_newcomment_' + id;
	this.loadingImg = '#ff_loadingimage_' + id;
	this.userName = '#ff_username_' + id;
	this.apiKey = '#ff_apikey_' + id;
	this.authSaved = '#ff_authsaved_' + id;
	this.authEntry = '#ff_authentry_' + id;
	this.commentsForm = '#ff_commentsform_' + id;
	this.likeButton = '#ff_likeentry_' + this.id;
	this.logoutButton = '#ff_forgetauth_' + this.id;
	this.commentsList = '#friendfeedcommentslist_' + this.id;
	this.likesList = '#friendfeedlikeslist_' + this.id;
	this.remember = '#ff_remember_' + this.id;
	this.usernameDisplay = '#ff_usernamedisplay_' + this.id;
		
	this.addLike = function(e) {
		fft.ajaxRequest('like');
		return false;
	}
		
	this.addComment = function(e) {
		if ($j(fft.newComment).val()) {
			fft.ajaxRequest('comment');
		}
		return false;
	}
		
	this.logout = function(e) {
		fft.ajaxRequest('logout');
		return false;
	}
	
	this.ajaxRequest = function(action) {
		var id = fft.id;
	
		if (action != 'logout' && ((!$j(fft.userName).val() || !$j(fft.apiKey).val()) && !$j(fft.authSaved).is(':visible'))) {
			alert('Please enter your FriendFeed username (nickname) and API Key.');
			$j(fft.userName).focus();
		} else {		
			var body = $j(fft.commentsForm).serialize();
			body += "&ac=" + action;
			
			$j(fft.loadingImg).show(); 
			$j(fft.commentsForm + " *").attr("disabled", "disabled");
			
			$j.ajax({
				url: friendFeedServicePath + "friendfeed_ajax.php",
				type: "GET",
				data: body,
				success: function(msg) {
						if (action == 'logout') {
							$j(fft.userName).val('');
							$j(fft.apiKey).val('');
							$j(fft.authEntry).show();
							$j(fft.authSaved).hide();
							$j(fft.likeButton).removeAttr('disabled');
						} else {
							if (action == 'like') {
								$j(fft.likesList).html(msg);
							} else {
								$j(fft.commentsList).html(msg);
							}
							 
							if ($j(fft.remember).is(':checked') && $j(fft.authEntry).is(':visible')) {
								$j(fft.usernameDisplay).text($j(fft.userName).val());
								$j(fft.authEntry).hide();
								$j(fft.authSaved).show();							
							}
							$j(fft.newComment).val('');
						}
				 
					},
				error: function(request, err, ex) { 
						alert("Sorry, an error occured");
					},
				complete: function (request, msg) { 
					$j(fft.loadingImg).hide(); 
					$j(fft.commentsForm + " *").removeAttr("disabled");
				}
			});
		}	
	}
	

	//Show / Hide the discussions
	this.toggleDiscussions = function (e) { 
		$j(fft.discussions).toggle(); 
		$j(fft.toggleComments).text((!$j(fft.discussions).is(':visible') ? 'show' : 'hide'));
		return false;  
	}			
	
	this.observeForm = function() {
		$j(fft.commentsForm).bind('submit', fft.addComment);
		$j(fft.likeButton).bind('click', fft.addLike);
		$j(fft.logoutButton).bind('click', fft.logout);		
	}
	
	this.observeShowHide = function() {
		$j(fft.toggleComments).bind('click', fft.toggleDiscussions);
	}
	
}