// Copyright 2006 Michael Chaney Consulting Corporation
//
// Fixes png files with alpha transparency to show properly in IE 5/6.
//
// This is hideous.  This searches for all images or
// <input type="image".../> elements on the page.  If the src ends
// with "png", it does these three things:
// 1. sets up the style.filter to use the alpha loader filter, using
//    the src from the original element.
// 2. sets the width and height in the style to the current
//    width/height of the element.
// 3. sets the src of the image/input to clear.gif

if (ie_version>0 && ie_version<7) {
	function set_ie_pngs() {
		function style_ie_png(el) {
			el.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + el.src + "', sizingMethod='crop')";
			el.style.width="" + el.width + "px";
			el.style.height="" + el.height + "px";
			el.src='/images/clear.gif';
		}

		// find all images that have a src ending with png
		for (var i=0 ; i<document.images.length; i++) {
			if (document.images[i].src.match(/\.png$/)) {
				style_ie_png(document.images[i]);
			}
		}
		// look for image submits on each form that are png's
		var inputs = document.getElementsByTagName('input');
		for (var i=0 ; i<inputs.length; i++) {
			if (inputs[i].type=='image' && inputs[i].src.match(/\.png$/)) {
				style_ie_png(inputs[i]);
			}
		}
	}

	add_body_onload(set_ie_pngs);
}
