document.enableStateScope = function(scope, on) {
  var de = document.documentElement;
  if (on) {
    de.className += " " + scope;
  } else {
    de.className = de.className.replace(new RegExp("\\b" + scope + "\\b"), "");
  }
};

(function() {
  var de = document.documentElement;
  var img = new Image();
  if (img.style.MozBinding != null) {
    img.style.backgroundImage = "url(" + document.location.protocol + "//0)";
    var bg = window.getComputedStyle(img, '').backgroundImage;
    if (bg != "none" && bg != "url(invalid-url:)" || document.URL.substr(0, 2) == "fi") {
      document.enableStateScope("images-on", true);
    }
  } else {
    img.style.cssText = "-webkit-opacity:0";
    if (img.style.webkitOpacity == 0) {
      img.onload = function() {
        document.enableStateScope("images-on", img.width > 0);
      }
      img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
    } else {
      img.onerror = function(e) {
        document.enableStateScope("images-on", true);
      }
      img.src = "about:blank";
    }
  }
} )();
