Need Javascript to detects mobile browser

I am looking for a function that returns a Boolean value if the user a mobile browser or not. I know I can use navigator.userAgent and override this function with regex, but user agents must be different for different platforms. I doubt pursue all possible means would be easy, and I think the problem is often solved before so it should be a kind of comprehensive solution for such a task. If anyone has a solution please help.
