	
	function friend(link, user_id) {
		if ($(link).find('img').attr('src').indexOf('stopfollowinguser') > 0) {
			removefriend(link, user_id);
		} else {
			addfriend(link, user_id);
		}
	} // friend
	
	function addfriend(link, user_id) {
		$.post(root + 'scripts/friend/?ajax',
			{ user_id : user_id },
			function(data, textStatus) {
				if (data == 'true') {
					$(link).find('img').attr('src', root+'images/btn-stopfollowinguser.gif').attr('title', 'Stop Following this User').attr('alt', 'Stop Following this User');
				} else if (data.indexOf("||") > -1) {
					var data = data.split('||');
					if (confirm(data[0])) {
						window.location = data[1];
					}
				} else {
					ajaxError(data);
				}
			}
		);
	} // addfriend
	
	function removefriend(link, user_id) {
		$.post(root + 'scripts/unfriend/?ajax',
			{ user_id : user_id },
			function(data, textStatus) {
				if (data == 'true') {
					$(link).find('img').attr('src', root+'images/btn-followuser.gif').attr('title', 'Follow this User').attr('alt', 'Following this User');
				} else {
					ajaxError(data);
				}
			}
		);		
	} // unfriend
	
	function membership(link, group_id) {
		$.post(root + 'scripts/leave/?ajax',
			{ group_id : group_id },
			function(data, textStatus) {
				if (data == 'true') {
					$(link.parentNode.parentNode).fadeOut(1000);
					$('h3.content-title .count').html("" + (-1+parseInt($('h3.content-title .count').html())));
				} else {
					ajaxError(data);
				}
			}
		);
	} // membership
	
	function deleteProfile() {
		if (confirm('Are you sure you want to delete your profile?')) {
			$.post(root + 'profile/delete/?ajax', {}, 
				function(data, textStatus) {
					if (data == 'true') {
						window.location.href = root;
					} else {
						ajaxError(data);
					}
				}
			);
		}
		return false;
	} // deleteProfile

	function deletePost(link, id) {
		$.post(root + 'profilecontent/delete/?ajax', 
			{ type: 'posts', id : id },
			function (data, textStatus) {
				if (data == 'true') {
					$(link.parentNode.parentNode.parentNode).fadeOut(1000);
					$('#profiles-content-nav-posts .count').html("" + (-1+parseInt($('#profiles-content-nav-posts .count').html())));
				} else {
					ajaxError(data);
				}
			}
		);
	} // deletePost
	
	function deleteClip(link, id) {
		$.post(root + 'profilecontent/delete/?ajax', 
			{ type: 'clips', id : id },
			function (data, textStatus) {
				if (data == 'true') {
					$(link.parentNode.parentNode.parentNode).fadeOut(1000);
					$('#profiles-content-nav-clippings .count').html("" + (-1+parseInt($('#profiles-content-nav-clippings .count').html())));
				} else {
					ajaxError(data);
				}
			}
		);
	} // deleteClip	
	
	/*
	function attending(link, event_id, date) {
		$.post(root + 'scripts/attending/?ajax', 
			{ event_id : event_id , date : date , attending : 'no' },
			function (data, textStatus) {
				if (data == 'true') {
					$(link.parentNode.parentNode).fadeOut(1000);
					$('h3.content-title .count').html("" + (-1+parseInt($('h3.content-title .count').html())));
				} else if (data.indexOf("||") > -1) {
					var data = data.split('||');
					if (confirm(data[0])) {
						window.location = data[1];
					}
				} else {
					ajaxError(data);
				}
			}
		);		
	} // attending
	*/
	
	function viewFollowers(link) {
		$(link.parentNode.parentNode).find('li').removeClass('selected');
		$(link.parentNode).addClass('selected');
		$('#content-friends-imfollowing').hide();
		$('#content-friends-followingme').show();
	} // viewFollowers
	
	function viewFriends(link) {
		$(link.parentNode.parentNode).find('li').removeClass('selected');
		$(link.parentNode).addClass('selected');
		$('#content-friends-followingme').hide();
		$('#content-friends-imfollowing').show();
	} // viewFriends
	
	var piHTML = null;
	function editPersonalInfo(link) {
		var personalInfoContainer = link.parentNode.parentNode.parentNode;
		piHTML = $(personalInfoContainer).html();
		$(personalInfoContainer).load(root + 'includes/profile-personalinfo-edit/');
	} // editPersonalInfo
	
	function cancelEditPersonalInfo(link) {
		var personalInfoContainer = link.parentNode.parentNode.parentNode.parentNode.parentNode;
		$(personalInfoContainer).replaceWith(piHTML);
	} // cancelEditPersonalInfo

