Changing FCKeditor's background colour on focus

I've been working on a form which requires each element's background colour to change when it receives focus. This is fairly straightforward and just needs a simple JavaScript function to be called using the onfocus and onblur attributes on the form's elements to achieve the desired effect.

One of the textareas however, needed to have rich text capabilities so I decided to replace it with FCKeditor

Once I'd done this, I had to work out how to get FCKeditor to behave the same as the other form inputs.

Since the onfocus and onblur attributes can only be applied to the a, area, button, input, label, select and textarea elements I didn't appear to have anywhere to attach the attributes to.

I'd almost given up when I discovered that FCKeditor has a JavaScript API, making interaction with it possible once the editor is loaded and running.

It was then a simple matter of adding a few more lines of JavaScript to the head of the document to get FCKeditor to change it's background colour on focus in the same way as the other form elements.

The JavaScript:

<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance){
  editorInstance.Events.AttachEvent('OnFocus', FCKeditor_OnFocus);
  editorInstance.Events.AttachEvent('OnBlur', FCKeditor_OnBlur);
  }
function FCKeditor_OnFocus(editorInstance){
  editorInstance.EditorDocument.body.style.cssText += 'background-color:#ffd;';
  }
function FCKeditor_OnBlur(editorInstance){
  editorInstance.EditorDocument.body.style.cssText += 'background-color:#fff;';
  }
</script>