
// Add various classes to the document body before the <body> tag exists in the DOM
(function () {
    var isCompatible = true;
    var ua = navigator.userAgent.toLowerCase();
    var version = (ua.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1];
    var browser = {
        ie: /msie/.test(ua) && !/opera/.test(ua),
        mozilla: /mozilla/.test(ua) && !/(compatible|webkit)/.test(ua),
        safari: /webkit/.test(ua),
        opera: /opera/.test(ua),
        konqueror: /KDE/.test(navigator.vendor)
    };
    
    // For easy CSS browser detection
    // Ex. for IE6, adds following classes: ie ie6 ie55-up ie6-up ie6-down ie7-down
    if (browser.ie) {
        var v = parseFloat(version);
        var n = [5.5, 6, 7];
        var c = ' ie ie'+v;
        
        // Add the ieN-down and ieN-up classes
        for (var i = n.length; i--;) {
            if (n[i] >= v) {
                c += ' ie'+n[i]+'-down';
            }
            if (n[i] <= v) {
                c += ' ie'+n[i]+'-up';
            }
        }
        isCompatible = (v >= 6);
        document.documentElement.className += c.replace(/\./g, '');
    } else {
        for (var b in browser) {
            if (browser[b]) {
                document.documentElement.className += ' '+b;
            }
        }
    }
    

    
    // Tell the CSS that the JavaScript is initialized
    if (isCompatible) {
        document.documentElement.className += ' js';
    }
    
    
    
})();
