//©2006 Bad Math Inc. (http://www.badmath.com/)  Free to use, so long as this credit line is included.

//convert any <img> tags with '.png' in the filename to use MS's AlphaImageLoader on IE/Win, to support PNG alpha transparency
//'x.gif' (single-pixel transparent gif) is required

//USAGE: include this script at the *bottom* of your page:
//e.g.: <script type="text/javascript" language="JavaScript" src="badMath-ieWinPNGAlpha.js"></script>


function ieMakeTransparentPNGs() {

	if ( 
		((navigator.userAgent.toLowerCase()).indexOf('msie') + 1) && 		//'+1' because indexOf returns -1 if string is not found
		((navigator.userAgent.toLowerCase()).indexOf('windows') + 1)  && 
		!((navigator.userAgent.toLowerCase()).indexOf('opera') + 1) 		//Opera reports itself as MSIE/Windows, but also adds an 'Opera' string
		) { 	

		for (i=0;i<document.images.length;i++) {
			if (document.images[i].src.toLowerCase().indexOf('.png') + 1) {

				var pngImage = document.images[i];
				pngImage.style.width = pngImage.offsetWidth;
				pngImage.style.height = pngImage.offsetHeight;
				pngImage.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+pngImage.src+"',sizingMethod='scale');";
				pngImage.src = 'x.gif';

			}
		}
	}
	
}

ieMakeTransparentPNGs();