I am attempting to write a wysiwyg text editor to use in back-end site administration forms. It's working pretty well, aside from one error: when I hilight a large block of text and change the font, the change only applies to portions of the text selected (which appears to be random portions). Here is the javascript I'm using:

function applyFont() {
 document.execCommand("fontname", false,  document.all.fontNameSelector.value);
Where am I going wrong?