Switch to Drupal Mobile Theme Programatically
The best option out there is to use module themekey that has all the tweaks to detect the user browser and serve the right theme. The performance hit is un-noticeable and it has already done all the hard work for you already.

Check a nice tutorial here: http://mustardseedmedia.com/podcast/episode52