Have you tried using something like Modernizr? In general you shouldn't detect browsers because there are so many of them and you just cannot know every feature of every version of every browser on every platform, not to even mention that you can't even be sure that the user agent header is right. You should detect features instead.
There are many more browsers and more incompatibilities on the mobile platforms than on the desktop. After trying to build portable websites for mobile browsers you'll actually start to love IE6 for it's compliance with standards. That's why I recommend using something like the jQuery Mobile to do the hard work of figuring out the differences and inconsistencies between platforms and giving you a nice and consistent API. Otherwise here's a list of platforms that you have to consider supporting: http://jquerymobile.com/gbs/