Html page that tests browser/player and turns wmode on or off

I’d like to make an html or php page that tests whether the browser is firefox or internet explorer and what version player it is running and does the following:

flash 9 on IE or Firefox

display movie in WMODE=transparent windowless

flash 8 on IE

display movie in WMODE=transparent windowless

flash 8 on FF

display movie in WMODE=window

I want to do this all on one page without redirects. Also, is there a way I can create a variable within the flash movie by putting some script on this html page that will always work? I do not want to have the flash movie call php scripts from within the movie.

Also, when I pop a flash movie into dreamweaver or publish, it seems that there ends up being a lot of useless crap code around the flash file. What do I need and what do I not need?

thanks
Jason