//Get every new value, taken from our unique IDs assigned earlier.
function edit_user(uid)
{
	var opt = {
		method:'post', 
		postBody:'m=edituser&id=' + uid + '&username=' + $F('username_' + uid) + '&email=' + $F('email_' + uid) + '&name=' + $F('name_' + uid) + '&auth=' + $F('auth_' + uid) +'&password=<?php echo $user['password']; ?>',
		onSuccess: function(t) { handle_edit(t, uid); }
		}
		new Ajax.Request('./ajax.php', opt);
}

function handle_edit(t, uid)
{
	if(t.responseText == "1")
	{
		//Give a pretty notice to say that it was saved
		new Effect.Highlight('user_' + uid);
	}
	else
	{
		alert("The user's data was not updated, please try again.");
	}
}

function delete_user(uid, username)
{
	//Confirm the delete
	if(confirm("Are you sure you want to delete " + username + "?"))
	{
		var opt = {
		method:'post', 
		postBody:'m=deluser&id=' + uid + '&password=<?php echo $user['password']; ?>',
		onSuccess: function(t) { handle_delete_user(t, uid); }
		}
		new Ajax.Request('./ajax.php', opt);
	}
}

function handle_delete_user(t, uid)
{
	if(t.responseText == "1")
	{
		//Remove the user from the table very nicely :)
		new Effect.Fade('user_' + uid);
	}
	else
	{
		//Agh!
		alert("The user was not deleted, please try again.");
	}
}
