var mobileDetect = {
    init: function() {
        this.userAgent = navigator.userAgent.toLowerCase();
    },
    isIphone: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["iphone"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    isIpod: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["ipod"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    isBlackberry: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["blackberry"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    isAndroid: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["android"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    isIemobile: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["iemobile"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    isPalmPre: function() {
        this.isBrowser = (this.userAgent.indexOf(this.mobileAgent["palm pre"].productFamily) == -1) ? false : true;
        return this.isBrowser;
    },
    getMobileAgent: function() {
        var strMobile;
        for (property in this.mobileAgent) {
            if (this.userAgent.indexOf(this.mobileAgent[property].productFamily) != -1) {
                strMobile = property;
                if (this.mobileAgent[property].model) {
                    var tempProp = property;
                    for (property in this.mobileAgent[tempProp].model) {
                        for (i = 0; i < this.mobileAgent[tempProp].model[property].length; i++) {
                            if (this.userAgent.indexOf(this.mobileAgent[tempProp].model[property][i]) != -1) {
                                strMobile += ", " + property;
                            }
                        }
                    }
                }
                return strMobile;
            }
        }
        return null;
    },
    mobileAgent: {
        "iphone": {
            "productFamily": "iphone"
        },
        "ipod": {
            "productFamily": "ipod"
        },
        "blackberry": {
            "productFamily": "blackberry",
            "model": {
                "tour": ["blackberry9630"],
                "storm": ["blackberry9500", "blackberry9530"],
                "bold": ["blackberry9000", "blackberry9100"],
                "88XX": ["blackberry8800", "blackberry8820", "blackberry8830"],
                "electron": ["blackberry8700", "blackberry8700c", "blackberry8700f", "blackberry8700g", "blackberry8700r", "blackberry8700v", "blackberry8703", "blackberry8703e", "blackberry8705g", "blackberry8707", "blackberry8707v"],
                "curve": ["blackberry8300", "blackberry8310", "blackberry8320", "blackberry8330", "blackberry8350i", "blackberry8900"],
                "pearl flip": ["blackberry8220", "blackberry8230"],
                "pearl": ["blackberry8100", "blackberry8110", "blackberry8120", "blackberry8130"]
            }
        },
        "palm pre": {
            "productFamily": "pre/1.0"
        },
        "android": {
            "productFamily": "android"
        },
        "iemobile": {
            "productFamily": "iemobile"
        }
    }
};
mobileDetect.init();