function social_edit_shout(object)
{
	var previous_img = $(object).find('img').attr('src');
	$(object).find('img').attr('src', './images/loading2.gif');
	data = {};
	data['mode'] = 'edit_shout_retrieve_post';
	data['shout_id'] = $(object).parent().parent().parent().attr('id').substr(13);
	$.ajax({
			url: 'ajax_social.php',
			type: "POST",
			data: data,
			dataType: "json",
			success: function(data)
			{
				if(data.status == 'success')
				{
					if(data.title)
					{
						$shout_title_object = $(object).parent().parent().find('.shout_title');
						temp = '<span id="social_edit_shout_title_div"><input type="text" id="social_edit_shout_title" value="' + data.title + '" /></span>';
						if($('#social_edit_shout_title_div').length > 0)
						{
							$('#social_edit_shout_title_div').html(temp);
						}
						else
						{
							$shout_title_object.after(temp);
						}
						$shout_title_object.hide();
					}
					if(data.message)
					{
						$shout_message_object = $(object).parent().parent().find('.shout_message');
						temp = '<div id="social_edit_shout_message_div">';
						temp += '<form name="social_shout_guide_news_form">';
						temp += '<textarea id="social_shout_guide_news_textarea" name="social_shout_guide_news_textarea" class="shout_edit_textarea">'+data.message+'</textarea>';
						temp += $('#social_bbcode').html();
						temp += '<div>';
						temp += '<input onclick="social_edit_shout_submit(this, '+$(object).parents('.shout_parent').attr('id').substr(13)+')" type="button" value="Save" />';
						temp += '<input onclick="social_edit_shout_submit_cancel()" type="button" value="Cancel" />';
						temp += '</div>';
						temp += '</form>';
						temp += '</div>';
						if($('#social_edit_shout_message_div').length > 0)
						{
							$('#social_edit_shout_message_div').html(temp);
						}
						else
						{
							$shout_message_object.after(temp);
						}
						$shout_message_object.hide()
						$('#shout_edit_textarea').autogrow();
					}
					$(object).find('img').attr('src', previous_img);
				}
				else
				{
					$.top_floating_div('Error, please refresh browser.', 'alert_error');
				}
			},
			error: function()
			{
				$.top_floating_div('Error, please refresh browser.', 'alert_error');
			}
	});
}
function social_edit_shout_submit(dom_object, shout_id)
{
	$('#social_shout_guide_news_textarea').attr('disabled', 'disabled');
	$(dom_object).parent().html('<img src="./images/loading.gif" alt="" />');
	data = {};
	data['mode'] = 'social_edit_shout_submit';
	data['shout_id'] = shout_id;
	if($('#social_shout_guide_news_textarea').length > 0)
	{
		data['edit_shout_message'] = $('#social_shout_guide_news_textarea').val();
	}
	if($('#social_edit_shout_title').length > 0)
	{
		data['edit_shout_title'] = $('#social_edit_shout_title').val();
	}
	if(typeof data['edit_shout_message'] != 'undefined' || typeof data['edit_shout_message'] != 'undefined')
	{
		$.ajax({
				url: 'ajax_social.php',
				type: "POST",
				data: data,
				dataType: "json",
				success: function(data)
				{
					if(data.status == 'success')
					{
						if(data.title)
						{
							$shout_title_object = $('#social_shout_'+shout_id).find('.shout_title');
							$shout_title_object.show();
							$shout_title_object.html(data.title);
						}
						if(data.message)
						{
							$shout_message_object = $('#social_shout_'+shout_id).find('.shout_message');
							$shout_message_object.show();
							$shout_message_object.html(data.message);
						}
						social_edit_shout_submit_cancel();
					}
					else
					{
						$.top_floating_div('Error, please refresh browser.', 'alert_error');
					}
				},
				error: function()
				{
					$.top_floating_div('Error, please refresh browser.', 'alert_error');
				}
		});
	}
}
function social_edit_shout_submit_cancel()
{
	if($('#social_edit_shout_message_div').length > 0)
	{
		$('#social_edit_shout_message_div').prev().show();
		$('#social_edit_shout_message_div').remove();
	}
	if($('#social_edit_shout_title_div').length > 0)
	{
		$('#social_edit_shout_title_div').prev().show();
		$('#social_edit_shout_title_div').remove();
	}	
}
/*
function social_handle_ajax(type, id, name)
{
	$.ajax({
		type: "POST",
		url: 'ucp.php',
		dataType: 'json',
		data: 'i=zebra&add='+name+'&mode=friends&submit=Yes',
		success: function(msg){
			if(msg.status == 'success')
			{
				$.top_floating_div(msg.username+' has received your friend request.', 'alert_success');
				$('#social_add_friend_link').wrap('<strike>').attr('title',friend_waiting_confirmation);
				$('#social_add_friend_link').unbind('click');
			}
			else
			{
				$.top_floating_div('Data send fail, please refresh your browser','alert_error');
			}
		},
		error: function(){
			$.top_floating_div('Data send fail, please refresh your browser','alert_error');
		}
	});
}
function social_add_friend(user_id, username)//
{
	social_handle_ajax('add_friend', user_id, username);
/*	$("#dialog").html('Please wait while you are redirecting to <b>'+$(this).find('img').attr('class')+'</b>')
	.dialog('option','title','Redirecting')
	.bind('dialogopen', function(event,ui){
		$('.ui-dialog-titlebar-close').remove();
	}).dialog('open');
}*/