// correctly handle PNG transparency in Win IE 5.5 or higher.
var PNG =
{
	fix: function(img)
	{
		//console.log(1);
		if(!img || !img.src || !$q.browser.msie)
		return;

		var imgName = img.src.toUpperCase();
		var type = imgName.substring(imgName.length-3, imgName.length);
		
		if (type != "PNG" && (!img.className || img.className != 'pngfix'))
		return;
		
		var imgID = (img.id ? "id='"+img.id+"' " : "");
		var imgClass = (img.className ? "class='"+img.className+"' " : "");
		var imgTitle = "title='"+(img.title ? img.title : img.alt)+"' ";
		var imgStyle = "display:inline-block;" + img.style.cssText;
		
		if (img.align == "left")
		imgStyle = "float:left;"+imgStyle;
		
		if (img.align == "right")
		imgStyle = "float:right;"+imgStyle;
		
		var href = '<img src="/@/fit/_0.gif" style="width:100%;height:100%;"/>';
		
		if (img.parentElement && img.parentElement.href)
		{
			imgStyle = "cursor:hand;"+imgStyle;
			href = '<a href="'+img.parentElement.href+'" style="display:block;position:relative;z-index:1000;">'+href+'</a>';
		}
		
		var strNewHTML = "<span "+imgID+imgClass+imgTitle+' style="heigth:'+img.height+';width:'+img.width+';'+imgStyle+";"+
		"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+
		"(src='" + img.src + "', sizingMethod='image');"+'">'+href+'</span>';
		
		var span=$e('span');
		span.innerHTML = strNewHTML;
		span = span.childNodes[0];
		
		var child = img.parentNode.childNodes;
		img.parentNode.insertBefore(span,img);
		img.parentNode.removeChild(img);
	},
	
	fixAll: function()
	{
		for(var i=document.images.length-1; i>=0; i--)
		PNG.fix(document.images[i]);
	}
};

PNG.fixAll.attach('load');
//window.attachEvent("onload", PNG.fixAll);