This JavaScript function sets a systemuser lookup field to the currently logged in user.

function setLookupFieldToCurrentUser(executionContext) {
    var formContext = executionContext.getFormContext();
    var globalContext = Xrm.Utility.getGlobalContext();

    var currentUser = new Array();
    currentUser[0] = new Object();
    currentUser[0].entityType = "systemuser";
    currentUser[0].id = globalContext.userSettings.userId;
    currentUser[0].name = globalContext.userSettings.userName;


globalContext.userSettings.userId returns the GUID of the SystemUser.Id value for the current user. globalContext.userSettings.userName returns the name of the current user.