function addToFriends(user) {
	$.post("/members/addToFriends?async=true", { user: user, type: "data" }, 
		function(data){
			alert(data);
			switch(data){
				case '0':	$('#friends-ok').show();
						 	break;
				case '1': 	var $friendsError = $('#friends-error');
							$friendsError.html( "Friend request pending" + $friendsError.html() );
							$friendsError.show();
						  	break;
			  	case '2': 	var $friendsError = $('#friends-error');
							$friendsError.html( "Already a friend" + $friendsError.html() );
							$friendsError.show();
			  				break;
				case 'A1':	showModalOrRedirect( offsite );
							break;
				case 'A2':	showModalOrRedirect( offsite );
							break;
			}
			$('#add-to-friends').hide();
		}
	);			
	var $addToFriends = $('#add-to-friends-error');
	
	$addToFriends.html( "hi" + $addToFriends.html() );
}

function addUserComment( uId, type ){
	$commentObj = $('#' + type );
	$commentSizeObj = $('#user-comments-size');
	$addButtonObj = $('#user-comment-button');
	$addingCommentObj = $('#user-comment-adding');
	var comment = $commentObj.val();
	if ($.trim(comment) == "" || $('#recent_comment').val() == comment){
		return false;
	}
	$addButtonObj.hide();
	$addingCommentObj.show();
	foaUsageLog(window.location, "Add User Comment");

	$.post("/members/users/addUserComment?async=true", { userId: uId, comment:comment, type: "data" }, 
		function(data){
			switch(data){
				case 'A1':	registerOrLogin("Add User Comment");
							break;
				case 'A2':	registerOrLogin("Add User Comment");
							break;
				default:	$('#no-user-comments').hide();
							$('#user-comments').prepend( data );
							$commentObj.val("");
							var currCount = parseInt($('#user-comments-size').text());
							var newCount = eval("currCount+1");
							$commentSizeObj.text(newCount+"");
							$('#recent_comment').val(comment);
						 	break;
			}
			$addButtonObj.show();
			$addingCommentObj.hide();
		}
	);			
}

function deleteUserComment( cId, uId, coId ){
	$commentSizeObj = $('#user-comments-size');
	$.post("/members/users/deleteUserComment?async=true", { commentId: cId, userId: uId, commentsOwnerId: coId, type: "data" }, 
		function(data){
			switch(data){
				case 'A1':	//error
							break;
				default:	$('#user-comment-' + cId).remove();
							var currCount = parseInt($('#user-comments-size').text());
							var newCount = eval("currCount-1");
							$commentSizeObj.text(newCount+"");
						 	break;
			}
		}
	);
}