/*
	Fix PNG for IE6 v1.0
	Requires MooTools 1.2, setup.1.js
	
	Author: Andrew Ferri <andrew@blacksheepcreative.co.nz>
	Date: 13 May 2010
	
	Instructions:
	<img>'s are fixed automatically.
	To fix elements with background PNG images:
		- Add a class of "fixPNG" to the element
		- OR run javascript function directly: $(element).fixPNG();
*/

spacerPNGimg = bsc.site.scripts + 'scripts.2/asset/fixpng.1/spacer.gif';

window.addEvent('load',function(){
	if (Browser.Engine.trident4) // IE6 only
	{
		$$('img[src$=png], img[src$=PNG], .fixPNG').each(function(el){
			el.fixPNG();
		});
	}
});

Element.implement({
	fixPNG: function()
	{
		if (Browser.Engine.trident4) // IE6 only
		{
			if ((this.get('tag') == 'img') || (this.get('tag') == 'input'))
			{
				// Fix PNG img
				var size = this.getSize();
				this.setStyles({
					'width': size.x,
					'height': size.y,
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='scale')"
				}).setProperty('src', spacerPNGimg);
			} else
			{
				// Fix PNG background
				var bg = this.getStyle('background-image');
				var src = bg.substring(5, bg.length-2);
				var mode = (this.getStyle('background-repeat') == 'no-repeat' ? 'crop': 'scale');
				this.setStyles({
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
					'background-image':	'url(' + spacerPNGimg + ')'
				});
			}
		}
	}
});
