Is this script place in the HEAD section of your page? If it is placed in the body section then the CSS won't effect the page until its reloaded if at all. My suggestion would be to use server side detection and build the page with the CSS include dynamically before the browser even sees it. You can do this in PERL, PHP and ASP.
One of the best products available for server-side detection is called BrowserHawk. It is available in both ActiveX Component and Java Server Page formats so it should be usable on almost any server.