
var PNGMagic = {
	replaceAll: function() {
		if (/MSIE (5\.5)|[6]/.test(navigator.userAgent) && navigator.platform == "Win32" && document.all) {
			if (!PNGMagic.site_url) {
			  $A(document.getElementsByTagName("script")).findAll( function(s) {
			    return (s.src && s.src.match(/pngmagic\.js/))
			  }).each( function(s) {
			  	PNGMagic.site_url = s.src.replace(/(javascript\/.*)$/, '');
			  });
			}

			$A(document.getElementsByClassName('PNGMagic')).each(function(node) {
				if (node.tagName.toLowerCase() == 'img') {
					// Replace the image with a blank one and set the msfilter
					node.setStyle({
						width: node.offsetWidth + 'px',
						height: node.offsetHeight + 'px',
						filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+node.src+"', sizingMethod='crop')"
						});
					node.src = PNGMagic.site_url+'admin/images/spacer.gif';
				}
				else if (node.style.backgroundImage.match(/url\(.*\.png\)$/)) {
					node.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+node.style.backgroundImage.match(/\((.*)\)/)[1]+"', sizingMethod='crop')";
					node.style.backgroundImage = 'none';
				}
				node.removeClassName('PNGMagic');
			});
		}
	}
}

if (/MSIE (5\.5)|[6]/.test(navigator.userAgent) && navigator.platform == "Win32" && document.all) {
	Event.observe(window, 'load', PNGMagic.replaceAll);
}
