Refactored all code and converted to external library. detectmobilebrowser is a jquery based function from the open source website mentioned.