Waiting for LT editor to finish loading. (focus, end of content, etc.)

Hi,

I want to focus the editor, move the cursor to end of content, maybe restore the cursor
position, and possibly other things, that require the editor to finish the “Check Text”
operation before they will work. How can I make the script wait for that to happen or
use a dynamic setTimeout etc with TinyMCE or LT. I am using the basic web page
code supplied by LT.
This is what I am using now. I would prefer a way that is self-contained in my mydoit()
function.

function mydoit() {
var langCode = document.checkform.lang.value;
tinyMCE.activeEditor.execCommand(“mceWritingImprovementTool”, langCode);

//run commands only after the editor is finished loading.
//2000 (2 seconds) is arbitrary and usually works.
setTimeout(function() { tinyMCE.get(“checktext”).focus(); }, 2000);

//this focuses and moves cursor to end of content using a goToTheEnd() function.
//setTimeout(function() { tinyMCE.get(“checktext”).focus(); goToTheEnd(); }, 2000);
}

Thanks