var supersleight = function() {

  var root = false;
  var applyPositioning = true;

  // Path to a transparent GIF image
  var shim = 'Images/x.gif';

  // RegExp to match above GIF image name
  var shim_pattern = /x\.gif$/i;

  var fnLoadPngs2 = function(targetElement) {

    root = targetElement

    if (root) {

      adjustElement(root)

      for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
        adjustElement(obj)
      }
    }

  };

  var adjustElement = function(obj) {

    // background pngs
    if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
      bg_fnFixPng(obj);
    }
    // image elements
    if (obj.tagName == 'IMG' && obj.src.match(/\.png$/i) !== null) {
      el_fnFixPng(obj);
    }
    // apply position to 'active' elements
    if (applyPositioning && (obj.tagName == 'A' || obj.tagName == 'INPUT') && obj.style.position === '') {
      obj.style.position = 'relative';
    }

  }

  var bg_fnFixPng = function(obj) {

    if (obj == null) { return false }

    var mode = 'scale';
    var bg = obj.currentStyle.backgroundImage;
    var src = bg.substring(5, bg.length - 2);
    if (src.indexOf('SponsorshipBar_10') == -1) {
      if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
        mode = 'crop';
      }
      obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
      obj.style.backgroundImage = 'url(' + shim + ')';
    }
    
  };

  var el_fnFixPng = function(img) {

    if (img == null) { return false }
      
    var src = img.src;
    img.style.width = img.width + "px";
    img.style.height = img.height + "px";
    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
    img.src = shim;
  
  };

  var addLoadEvent = function(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
      window.onload = func;
    } else {
      window.onload = function() {
        if (oldonload) {
          oldonload();
        }
        func();
      };
    }
  };

  return {

    init: function() {
      addLoadEvent(fnLoadPngs);
    },

    limitTo: function(el) {
      root = el;
    },

    run: function() {
      fnLoadPngs();
    },

    BLC: function() {
      el_fnFixPng(document.getElementById('imgSiteLogo'));
      el_fnFixPng(document.getElementById('imgBLCSummary'));
      bg_fnFixPng(document.getElementById('ctl00_PageBody_divPledge'));
      bg_fnFixPng(document.getElementById('divTwitter'));
      el_fnFixPng(document.getElementById('imgTwitterIcon'));
      bg_fnFixPng(document.getElementById('divCountDown'));
      bg_fnFixPng(document.getElementById('pastPosts'));
      bg_fnFixPng(document.getElementById('divBlog'));
      bg_fnFixPng(document.getElementById('divTheCharity'));
      bg_fnFixPng(document.getElementById('Orphanages'));
      bg_fnFixPng(document.getElementById('100PC'));
      bg_fnFixPng(document.getElementById('100k'));
      bg_fnFixPng(document.getElementById('SeekingSponsors'));
      el_fnFixPng(document.getElementById('pdfIcon'));
      el_fnFixPng(document.getElementById('imgBlogger'));
      bg_fnFixPng(document.getElementById('footer'));
      bg_fnFixPng(document.getElementById('WhereWhen'));
      bg_fnFixPng(document.getElementById('nominate'));      
    },

    runSetElem: function(targetElement) {
      fnLoadPngs2(targetElement);
    }

  };
} ();