Doing it at the script (PHP, etc...) level is easy, however you probably want the webserver to handle that instead...assuming you use Apache, the key directive you will need is for the randomness: RewriteMap
Example:
let's say you create /my/dir/de_map.txt and it contains this line:
dynamic url1|url2 (as many as you like)
Here could be your Germany for example redirect section:
RewriteMap servers rnd:/my/dir/de_map.txt
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^DE$
RewriteRule ^(.*)$ http://${servers:dynamic}/$1 [P,L]
Of course, you should have your conditions to check whether it's mobile or not as well before that stuff, and make sure MaxMind mod_geoip is installed.
Note: Since its 5am here and Im just tossing this out quick from memory, you may wish to double-check the syntax
