What is the best way to detect all useragents which can handle JQuery Mobile?

What is the best way to detect all useragents which can handle JQuery Mobile?

Hello,

we developed to mobile versions of a website, the pretty one uses JQuery mobile, while where is a very basic fallback version with simple HTML/CSS for older mobile systems. Now my question is, how can I find out the useragents which can handle JQuery mobile?

I want to do this with PHP, something like this:

$user_agent = $_SERVER['HTTP_USER_AGENT'];
$browser = get_browser();

if(preg_match('/iphone/i',$user_agent) || preg_match('/android/i',$user_agent) || preg_match('/webos/i',$user_agent) || preg_match('/ios/i',$user_agent) || preg_match('/bada/i',$user_agent) || preg_match('/maemo/i',$user_agent) || preg_match('/meego/i',$user_agent) || preg_match('/fennec/i',$user_agent) || (preg_match('/symbian/i',$user_agent) && preg_match('/s60/i',$user_agent) && $browser['majorver'] >= 5) || (preg_match('/symbian/i',$user_agent) && preg_match('/platform/i',$user_agent) && $browser['majorver'] >= 3) || (preg_match('/blackberry/i',$user_agent) && $browser['majorver'] >= 5) || (preg_match('/opera mobile/i',$user_agent) && $browser['majorver'] >= 10) || (preg_match('/opera mini/i',$user_agent) && $browser['majorver'] >= 5)) {
      // use fancy JQuery Mobile template
} else {
      // use plain old template
}

But i just composed this now spontanously without testing, so does anybody have a better / simpler idea how to do this, or know how to make this function better?