From http://stackoverflow.com/questions/11381673/javascript-solution-to-detect-mobile-browser/11381730#11381730