if(typeof(badBrowser) == 'undefined' || !badBrowser) addStyleSheet("/include/css/noscript.css");

// Add a stylesheet to the document
function addStyleSheet(styleSheetURL,insertBefore,resultFunction) {
    var initialStyleSheets = document.styleSheets.length;
    if(document.createStyleSheet) document.createStyleSheet(styleSheetURL,0);
    else {
        // Create new stylesheet link
        var newCSS = document.createElement('link');
        newCSS.setAttribute('rel','stylesheet');
        newCSS.setAttribute('type','text/css');
        newCSS.href= styleSheetURL;
        //newCSS.href='data:text/css,'+escape("@import url(' " + styleSheetURL + " ');");
        var theHead = document.getElementsByTagName('head')[0];
        if(insertBefore == true) {
            // If specified, add new stylesheet link to beginning of <head>
            if(theHead.hasChildNodes()) theHead.insertBefore(newCSS,theHead.childNodes[0]);
            else theHead.appendChild(newCSS);
        } else {
            // Otherwise add it to the end
            theHead.appendChild(newCSS);
        }
    }
    if(typeof(resultFunction) == 'function') {
        // If we have a result function, get waiting for the style sheet to load
        var styleSheetFail = window.setTimeout(
            function() {
                if(typeof(styleSheetResults) == 'function') styleSheetResults(false);
                window.clearInterval(waitingForStyleSheet);
            },5000
        );
        var waitingForStyleSheet = window.setInterval(
            function() {
                if(document.styleSheets.length == initialStyleSheets + 1) {
                    window.clearTimeout(styleSheetFail);
                    window.clearInterval(waitingForStyleSheet);
                    if(typeof(resultFunction) == 'function') resultFunction(true,document.styleSheets[document.styleSheets.length - 1]);
                }
            },30
        );
    }
    return true;
}
