/**
 * Changes all png images to backgrounds with a filter applied
 * to eliminate the grey transparency problems in IE 5.5 and 6
 */
function transformPNG()
{
	// Check if the browser is IE
	if ( !Prototype.Browser.IE )
	{
		return;
	}
	
	// Determine if the user is using IE 5.5 or IE 6 
	var agent_details = navigator.userAgent.split('MSIE'); 
	var version = parseFloat(agent_details[1]);
	
	if ( version < 5.5 || version >= 7 )
	{
		return;
	}
	
	// Get all images
	var images = $$('img');
	
	// Loop through the images and check if each is a png, do transformation if they are
	for ( var i = 0, length = images.length; i < length; i++ )
	{
		var image = images[i];
		var filename = image.readAttribute('src');
		if ( filename.toLowerCase().endsWith('png') )
		{
			image.setStyle({
				filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + filename + '", sizingMethod="scale")'
			});
			image.writeAttribute({
				src: 'assets/template_images/spacer.gif'
			});
		}
	} 
}

// Attach events
Event.observe(window, 'load', transformPNG);