This is a pretty complex thing you're trying to pull off if you're planning on using all custom code. What I would do is create the OS and then use 3rd party (and open-source) code to include the features. The reason is just that building your own features (such as the e-mail client) from the ground up may serve to be a bit complicated, especially in addition to the work you'll need to do to make the OS.
So, make it easy on yourself. Make the OS, and then integrate the features (more like a regular OS anyway). My suggestions for the 3rd-party features:
-Text Editor: TinyMCE
-Media Player: JW Player
-Email Client: JMailbox, Roundcube, or SquirrelMail
-Game: Just embed the SWFs for some existing flash games
-Paint: PaintWeb (this also has the ability to integrate into TinyMCE)
(Just google these, and they should give you some ideas). I have used most of these- they're not too difficult to integrate into a site.