$(document).ready(function()
{	


$('#response').hide();


function reply( comment_id )
{
	if( comment_id == '' )
	{
		$('#response').hide();
		$('#response_comment').html('');
	}
	else
	{
		var html = $('#comment_' + comment_id).html();
		$('#response').show();
		$('#response_comment').html(html);
	}
	
	$('input#parent_comment').val(comment_id);
	
}

 // address book functions
 $(".show_address_book").click(
 	function()
	{
		$("#address_book").slideDown();
	}
 );
 
 $(".hide_address_book").click(
 	function()
	{
		$("#address_book").slideUp();
	}
 );
 });
 
 
 function add_user(id)
{
	var user_title = $('.link_'+id).html();
	
	if ($('#user_link_' + id).length == 0 ) {
		var html = '<div class="link left" id="user_link_' + id + '"><p><a class="left close" href="#" onclick="return remove_user(\'' + id + '\');"></a>'+ user_title +'</p></div>';
		var field = '<input name="recipient[]" type="hidden" value="'+id+'" id="user_link_field_'+id+'" />';
		$('div#linked_user_items').append(html);
		$('div#linked_user_fields').append(field);
		
	}
	else
	{
		warn('"' + user_title + '" has already been linked');
	}
	
	return false;
}

function remove_user(id)
{
	$('#user_link_'+id).remove();
	$('#user_link_field_'+id).remove();
	return false;
}