here's the fucntion :
personnaly i put it in the first template call
at the end you must call _spBodyOnLoadFunctionNames.push() function brought by SharePoint to execute you needed function on page load :
_spBodyOnLoadFunctionNames.push("get_CurrentUser");
Now after you did all that, save the file and execute.
i hope i helped you even if a little bit, if there's a question about that or anything else, mail me or comment on the post, i'll be here.