// NOTE: Requires Prototype!

// change all images with .png to divs with the correct filter style for IE < 7
// please note that style properties for the image are lost in this version


var fix_png = function () {
	if ( Prototype.Browser.IE && parseInt(navigator.appVersion) < 7 )
	{
		// change all images with .png
		$$('img[src$=".png"]').each(function(oImg) {
			oImg.replace( new Element('div', {'class': oImg.className, 'style': oImg.readAttribute('style')}).setStyle({
				'width': 				oImg.width+"px",
				'height': 			oImg.height+"px",
				'text-indent': 	'-1000em',
				'background': 	'none',
				'display': 			'inline-block',
				'filter': 			"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+oImg.src+"'),sizingMethod='scale')"
			}) );
		});
		
		// change all png backgrounds
		$$('div').each(fix_png_bg);
		$$('td').each(fix_png_bg);
	}
};

function fix_png_bg (elem) {
	var regs = elem.getStyle('backgroundImage').match(/url\(["']*(.*?)["']*\)/i);
	if (regs)
	{
		var file = regs[1];
		if (file.indexOf(".png") > -1)
		{
			elem.setStyle({
				'backgroundImage': 'none',
				'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+file+"'),sizingMethod='scale');"
			});
		}
	}
}

Event.observe(window, "load", fix_png);