var supersleight = {	
	initialize: function(){
		this.root = false;
		this.applyPositioning = true;
		this.shim = '/images/supersleight/x.gif';
		this.shim_pattern = /x\.gif$/i;
		this.excludes = [];
		//this.fnLoadPngs();
	},
	
	fnLoadPngs: function() {
		if (this.root) {
			this.root = $(this.root);
		}else{
			this.root = document;
		}
		for (var i = this.root.all.length - 1, obj = null; (obj = this.root.all[i]); i--) {
			// background pngs
			if(obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
				this.bg_fnFixPng(obj);
			}
			// image elements
			if(obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
				this.el_fnFixPng(obj);
			}
			// apply position to 'active' elements
			if(this.applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT' || obj.tagName=='EMBED') && obj.style.position === ''){
				if(!this.excludes.include(obj)){
					obj.style.position = 'relative';
				}
			}
			// input elements type image
			if(obj.tagName=='INPUT' && obj.getAttribute('type')=='image' && obj.src.match(/\.png/i) !== null){
				this.el_fnFixPng(obj);
			}
		}
	},

	bg_fnFixPng: function(obj) {
		var mode = 'scale';
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
			mode = 'crop';
		}
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url('+this.shim+')';
	},

	el_fnFixPng: function(img) {
		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 = this.shim;
	},
	
	limitTo: function(el) {
		this.root = el;
	},
	
	exclude: function(el){
		this.excludes.push(el);
	},
		
	run: function() {
		fnLoadPngs();
	}
};

//document.observe('dom:loaded', supersleight.initialize.bind(supersleight));