// Checks the browser and adds classes to the body to reflect it.
/*

$(document).ready(function(){
    
    var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
    // Is this a version of IE?
    if($.browser.msie){
        $('body').addClass('browserIE');
        
        // Add the version number
        $('body').addClass('browserIE' + $.browser.version.substring(0,1));
    }
    
    
    // Is this a version of Chrome?
    if($.browser.chrome){
    
        $('body').addClass('browserChrome');
        
        //Add the version number
        userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
        userAgent = userAgent.substring(0,1);
        $('body').addClass('browserChrome' + userAgent);
        
        // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
        $.browser.safari = false;
    }
    
    // Is this a version of Safari?
    if($.browser.safari){
        $('body').addClass('browserSafari');
        
        // Add the version number
        userAgent = userAgent.substring(userAgent.indexOf('version/') +8);
        userAgent = userAgent.substring(0,1);
        $('body').addClass('browserSafari' + userAgent);
    }
    
    // Is this a version of Mozilla?
    if($.browser.mozilla){
        
        //Is it Firefox?
        if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1){
            $('body').addClass('browserFirefox');
            
            // Add the version number
            userAgent = userAgent.substring(userAgent.indexOf('firefox/') +8);
            userAgent = userAgent.substring(0,1);
            $('body').addClass('browserFirefox' + userAgent);
        }
        // If not then it must be another Mozilla
        else{
            $('body').addClass('browserMozilla');
        }
    }
    
    // Is this a version of Opera?
    if($.browser.opera){
        $('body').addClass('browserOpera');
    }
    
    
});
*/

var AC = {};
AC.Detector = {
    getAgent: function () {
        return navigator.userAgent.toLowerCase();
    },
    isMac: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/mac/i);
    },
    isWin: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/win/i);
    },
    isWin2k: function (M) {
        var U = M || this.getAgent();
        return this.isWin(U) && (U.match(/nt\s*5/i));
    },
    isWinVista: function (M) {
        var U = M || this.getAgent();
        return this.isWin(U) && (U.match(/nt\s*6/i));
    },
    isWebKit: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/AppleWebKit/i);
    },
    isChrom: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/chrom/i);
    },
    isSafari: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/safari/i);
    },
    isOpera: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/opera/i);
    },
    isIE: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/msie/i);
    },
    isIEStrict: function (M) {
        var U = M || this.getAgent();
        return U.match(/msie/i) && !this.isOpera(U);
    },
    isFlock: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/flock/i);
    },
    isFirefox: function (M) {
        var U = M || this.getAgent();
        return !!U.match(/firefox/i);
    },
    isiPhone: function (M) {
        var U = M || this.getAgent();
        return this.isMobile(U);
    },
    isMobile: function (M) {
        var U = M || this.getAgent();
        return this.isWebKit(U) && U.match(/Mobile/i);
    },
    isiTunesOK: function (M) {
        var U = M || this.getAgent();
        return this.isMac(U) || this.isWin2k(U);
    },
    isQTInstalled: function () {
        var U = false;
        if (navigator.plugins && navigator.plugins.length) {
            for (var M = 0; M < navigator.plugins.length; M++) {
                var g = navigator.plugins[M];
                if (g.name.indexOf("QuickTime") > -1) {
                    U = true;
                }
            }
        } else {
            qtObj = false;
            execScript("on error resume next: qtObj = IsObject(CreateObject(\"QuickTimeCheckObject.QuickTimeCheck.1\"))", "VBScript");
            U = qtObj;
        }
        return U;
    },
    getQTVersion: function () {
        var U = "0";
        if (navigator.plugins && navigator.plugins.length) {
            for (var g = 0; g < navigator.plugins.length; g++) {
                var S = navigator.plugins[g];
                var M = S.name.match(/quicktime\D*([\.\d]*)/i);
                if (M && M[1]) {
                    U = M[1];
                }
            }
        } else {
            ieQTVersion = null;
            execScript("on error resume next: ieQTVersion = CreateObject(\"QuickTimeCheckObject.QuickTimeCheck.1\").QuickTimeVersion", "VBScript");
            if (ieQTVersion) {
                U = (ieQTVersion >> 24).toString(16);
            }
        }
        return U;
    },
    isQTCompatible: function (g, j) {
        function M(w, R) {
            var i = parseInt(w[0], 10);
            if (isNaN(i)) {
                i = 0;
            }
            var V = parseInt(R[0], 10);
            if (isNaN(V)) {
                V = 0;
            }
            if (i === V) {
                if (w.length > 1) {
                    return M(w.slice(1), R.slice(1));
                } else {
                    return true;
                }
            } else {
                if (i < V) {
                    return true;
                } else {
                    return false;
                }
            }
        }
        var S = g.split(/\./);
        var U = j ? j.split(/\./) : this.getQTVersion().split(/\./);
        return M(S, U);
    },
    isValidQTAvailable: function (U) {
        return this.isQTInstalled() && this.isQTCompatible(U);
    }
};
