
Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5)) == 6;
Prototype.FixPNG = { Pixel: '/static/images/pixel.gif' };

Element.addMethods({
fixpng: (Prototype.Browser.IE && Prototype.Browser.IE6) ? function(element)
	{
		function fixPosition(element) { if (element.style.position != 'absolute') element.style.position == 'relative'; }
		function filter(src, method) { return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod='" + method + "',src='" + src + "')"; }
		var elementName = element.nodeName.toLowerCase();
		if (elementName == 'img' || elementName == 'input')
		{
			if (element.src && element.src.match(/.*\.png([?].*)?$/i))
			{
				element.setStyle(
        {
        	filter: filter(element.src, element.hasClassName('pngfix_resize')?'resize':'crop'),
        	width: element.getWidth(),
        	height: element.getHeight()
        });
				element.src = Prototype.FixPNG.Pixel;
				fixPosition(element);
			}
		}
		{
			var image = element.currentStyle.backgroundImage;
			if (image.indexOf(".png") != -1)
			{
				element.setStyle({
				filter: filter(image.split('url("')[1].split('")')[0], 'crop'),
					backgroundImage: "none"
				});
				element.childElements().each(fixPosition);
			}
		}
	} : function(element) {return false; }
});  

