$.fn.extend({
	fixPNG: function()
	{
		if ($.browser.msie && $.browser.version == 6)
		{
			this.each(function() {
				if (this.nodeName.toLowerCase() != 'img') return;
				if (this.width == 0 || this.height == 0) return;
				if (this.wrapped) {
					this.parentNode.parentNode.replaceChild(this, this.parentNode);
					this.runtimeStyle.display = '';
					this.wrapped = false;
				}
				if (/.png$/.test(this.src)) {
					$(this).wrap("<span class='"+this.className+"' style='background: url(images/blank.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=scale,src=\""+this.src+"\");height:"+this.offsetHeight+"px;width:"+this.offsetWidth+"px;display:block;position:relative;background:url(images/blank.gif);'></span>");
					this.runtimeStyle.display = 'none';
					this.wrapped = true;
					if (!this.wasWrapped) {
						this.wasWrapped = true;
						this.attachEvent('onpropertychange', function() {
							if (event.propertyName == 'wrapped') return;
							
							if (this.wrapped) {
								if (event.propertyName == 'style.filter') return;
								if (event.propertyName == 'src') {
									this.parentNode.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+this.src+'")';
								}
								else if (/^style\./.test(event.propertyName)) {
									var stn = event.propertyName.split('.').pop();
									this.parentNode.style[stn] = this.style[stn];
									if (stn == 'display') this.style.display == 'none';
								}
								else this.parentNode[event.propertyName] = this[event.propertyName];
							}
						});
					}
				}
			});
		}
	}
});

if ($.browser.msie && $.browser.version == 6)
{
	$(function() {
		$("img:not(.noPNGfix)").each(function() {
			$(this).fixPNG();
		});
	});
	
	window._initIE6FixedPosition = function(element)
	{
		element.style.right = '';
		element.style.bottom = '';
		$(window).scroll(function() {
			$(element).css({
				position: 'absolute',
				top		: document.documentElement.scrollTop + 'px',
				left	: document.documentElement.scrollLeft + 'px',
				width   : (document.documentElement.offsetWidth - 21) + 'px',
				height  : document.documentElement.offsetHeight + 'px'
			});
		});
	}
}
