/**
 * Broswer Detect
 */

(function () {
    var idSeed = 0,
        toString = Object.prototype.toString,
        ua = navigator.userAgent.toLowerCase(),
        check = function (r) {
            return r.test(ua);
        },
        that = this,
        DOC = document;
        
        
        this.isStrict = DOC.compatMode == "CSS1Compat",
        this.isOpera = check(/opera/),
        this.isChrome = check(/chrome/),
        this.isWebKit = check(/webkit/),
        this.isSafari = !isChrome && check(/safari/),
        this.isSafari2 = isSafari && check(/applewebkit\/4/),
        // unique to Safari 2
        this.isSafari3 = isSafari && check(/version\/3/),
        this.isSafari4 = isSafari && check(/version\/4/),
        this.isIE = !isOpera && check(/msie/),
        this.isIE7 = isIE && check(/msie 7/),
        this.isIE8 = isIE && check(/msie 8/),
		this.isIE9 = isIE && check(/msie 9/),
        this.isIE6 = isIE && !isIE7 && !isIE8 && !isIE9,
        this.isGecko = !isWebKit && check(/gecko/),
        this.isGecko2 = isGecko && check(/rv:1\.8/),
        this.isGecko3 = isGecko && check(/rv:1\.9/),
        this.isGecko35 = isGecko && check(/rv:1\.9\.1/),
        this.isBorderBox = isIE && !isStrict,
        this.isWindows = check(/windows|win32/),
        this.isMac = check(/macintosh|mac os x/),
        this.isAir = check(/adobeair/),
        this.isLinux = check(/linux/),
        this.isSecure = /^https/i.test(window.location.protocol);
        
    function getBrowser() {
        if (that.isIE6) {
            return 'ie6';
        } else if (that.isIE7) {
            return 'ie7';
        } else if (that.isIE8) {
            return 'ie8';
        } else if (that.isIE9) {
            return 'ie9';
        } else if (that.isGecko) {
            return 'gecko';
        } else if (that.isGecko2) {
            return 'gecko2';
        } else if (that.isGecko3) {
            return 'gecko3';
        } else if (that.isChrome) {
            return 'chrome';
        } else if (that.isSafari) {
            return 'safari';
        } else if (that.isOpera) {
            return 'opera';
        }
        return null;
    }
    
    var body = document.getElementsByTagName('body')[0];

    if (!body.className) {
        body.className = getBrowser();
    } else {
        body.className = body.className + ' ' + getBrowser();
    }
})();

   
