addLoadEvent(function Window_onLoad(){
	LoadFriendList();
	AssignEvents();
});

var remove_id=0;

function AssignEvents(){
	$('.delete_link_friend').click(function(){ConfirmRemoveFriend(this.rel, this.rev);});
}

function LoadFriendList(){
	$('#num_of_friends').html(friend_cnt);
}

function ConfirmRemoveFriend(friend_id,friend_name){
	if (confirm('Are you sure you want to remove '+friend_name+' from your friends list?')){
		RemoveFriend(friend_id);
	}
}


function RemoveFriend(friend_id){
	remove_id=friend_id;
	url=js_dir+'ajax_funcs/remove.friend.php';
	params='user_id='+profile_user_id+'&friend_id='+friend_id;
	type='post';
	callback_func='RemoveFriend_Response()';
	doAjax(url,params,type,callback_func);
}

function RemoveFriend_Response(){
	if (ajax_return==1){
		$('#friend_'+remove_id).remove();
		friend_cnt--;
		$('#num_of_friends').html(friend_cnt);
		if (friend_cnt==0){
			ShowNoFriends();
		}
	}else{
		showAjaxReturn();
	}
}

function ShowNoFriends(){
	$('#friend_list').parent().remove();
	$('#num_of_friends').html('0');
}
