/**
 * Utility for fixing PNG's in IE6
 */
org_24ways_supersleight = new es_lang.Package(true,
	/*Title*/   '',
	/*Docs */   '-- none --',
	/*Package*/ function() {
		
		var IE6PngFixer = function(dotImg, root, noPositioning) {
			_applyPositioning = !(noPositioning == true);
			
			var fixPngBackgrounds = 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(' + dotImg + ')';
			};

			var fixPngImages = 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 = dotImg;
			};
			
			// Public
			this.run = function(ignoreBackgrounds) { 
				if (root) {
					root = document.getElementById(root);
				} else {
					root = document;
				}
				for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
					if (!ignoreBackgrounds) {
						if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
							fixPngBackgrounds(obj);
						}
					}
					if (obj.tagName == 'IMG' && obj.src.match(/\.png$/i) !== null){
						fixPngImages(obj);
					}
					if (_applyPositioning && (obj.tagName == 'A' || obj.tagName == 'INPUT') && obj.style.position === ''){
						obj.style.position = 'relative';
					}
				}
			};
		};

		// === PACKAGE PUBLIC ===
		this.IE6PngFixer = IE6PngFixer;
		// === PACKAGE PUBLIC ===
	}
);






