The message i get is getElemenbtby(...) is null or somthing like that. I thougt this should work. Not the easist question to answer whats wrong but a few tips would be greatly appreciated.
I did a test myself and got the following to work without problem. The div with id foo turns up red as expected. The js error message indicates you have not used the correct id when trying to find the element (the element can't be found and hence is null)...
(Editreason: remove junk code... )