//Delete via AJAX
function delete_pm(pmid, pmtitle, redir)
{
	if(confirm("Are you sure you want to delete the message titled " + pmtitle))
	{
		var opt = {
		method:'post', 
		postBody:'m=delpm&password=<?php echo $user['password']; ?>&id=' + pmid + '&uid=<?php echo $user['username']; ?>',
		onSuccess: function(t) { handle_delete_pm(t, pmid, redir); }
		}
		new Ajax.Request('ajax.php', opt);
	}
}

//Toggle reply form with a fancy effect
function reply()
{
	if(!Element.visible('reply'))
	{
		Effect.SlideDown('reply');
	}
	else
	{
		 Effect.SlideUp('reply');
	}
}

//Either redirect to the inbox, or remove the table row of that PM
function handle_delete_pm(t, pmid, redir)
{
	if(t.responseText == "0")
	{
		alert("The PM could not be deleted!  This may be a systems error, so please try again.");
	}
	else
	{
		if(redir)
		{
			window.location = 'pm.php';
		}
		else
		{
			new Effect.Fade('pm_' + pmid);
		}
	}
}
