;(function($) {
	$.fn.fixPNG = function() {
		var IE6 = $.browser.msie && $.browser.version.substr(0,1) == 6 && !window.XMLHttpRequest, oldIE = IE6 || ($.browser.msie && $.browser.version.substr(0,1) == 7);
		if(IE6){
			return this.each(function () {
				if($(this).is('img')) {
					var src = $(this).attr('src');
					
					if (src.match(/^.+\.png$/)) {
						var className = $(this).attr('class') ? "class='"+$(this).attr('class')+"' " : "";
						var title = $(this).attr('title') ? "title='"+$(this).attr('title')+"' " : "";
						var ratio = $(this).attr('ratio') ? "ratio='"+$(this).attr('ratio')+"' " : "";
						var rw = $(this).attr('rw') ? "rw='"+$(this).attr('rw')+"' " : "";
						var rh = $(this).attr('rh') ? "rh='"+$(this).attr('rh')+"' " : "";
						var id =    $(this).attr('id') ? "id='"+$(this).attr('id')+"' " : "";
						var style = $(this).attr('style') ? $(this).attr('style') : "";
						var align = $(this).attr('align') ? $(this).attr('align') : "";
						var ahref = $(this).parent().is('a');
						
						var w = "width: "+$(this).css('width')+";";
						var h = "height: "+$(this).css('height')+";";
						
						var filter = ";filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + src + "\', sizingMethod='scale');";
						
						if(align == "left")  style += "float: left; ";
						if(align == "right") style += "float: right; ";
						if(ahref) style += "cursor: hand;";
						style = "style=\"display: inline-block;"+w+h+style+filter+"\" ";

						var conteiner = "<span "+className+id+style+title+ratio+rw+rh+"></span>";
						//alert(conteiner);
						$(this).replaceWith(conteiner);
					}
				} else {
					var image = $(this).css('backgroundImage');
					
					if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
						image = RegExp.$1;
						$(this).css({
							'backgroundImage': 'none',
							'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + ($(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
						}).each(function () {
							var position = $(this).css('position');
							if (position != 'absolute' && position != 'relative')
								$(this).css('position', 'relative');
						});
					}
				}
			});
		}
	};
})(jQuery);
