function PngFix(urlImagens)
{
	this.PngFix(urlImagens);
}

PngFix.prototype = {
	urlImagens:'',
	ImagensAlteradas:'',
	
	applyCssHack:function()
	{
		var supported = /MSIE (5\.5)|[6]/.test(navigator.userAgent) && navigator.platform == "Win32";
		
		if (supported) {
			for (i = 0; i < document.all.length; i++) {
				if (document.all[i].currentStyle) {					
					var bg = document.all[i].currentStyle.backgroundImage;
					if (bg) {
						if (bg.match(/\.png/i) != null) {
							var mypng = bg.substring(5,bg.length-2);
							document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='scale')";
							document.all[i].style.backgroundImage = "URL('" + this.urlImagens + "transparent.gif')";
							this.ImagensAlteradas.push(mypng);
						}
					}
				}				
			}
			
			this.applyCSSHack2();
		}
	},
	
	seachInImagens:function(query)
	{
		for (var k = 0; k < this.ImagensAlteradas.length; k++) {
			if (query == this.ImagensAlteradas[k])
				return true;
		}
		
		return false;
	},
	
	applyCSSHack2:function()
	{
		for(var i=0; i < document.all.length; i++) {
			var img = document.all[i];
			if (img.src) {
				var imgName = img.src.toUpperCase();
				if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
					if (!this.seachInImagens(img.src)) {
						var Teste = new Image();
						Teste.src = img.src;						
						var imgID = (img.id) ? "id='" + img.id + "' " : "";
						var imgClick = (img.onclick) ? 'onClick="' + this.trataFunction(img.onclick.toString()) + '" ' : "";
						var imgClass = (img.className) ? "class='" + img.className + "' " : "";
						var imgTitle = (img.title) ? "title='" + img.title + "' " : "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;
						if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
						var strNewHTML = 
						"<div " + imgID + imgClass + imgTitle + imgClick
						+ " style=\"" + "width:" + Teste.width + " px; "
						+ "height:" + Teste.height + "px;" + imgStyle + ";"
						+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
						+ "(src=\'" + img.src + "\', sizingMethod='scale'); background-image:url('" + this.urlImagens + "transparent.gif');\"></div>";
						img.outerHTML = strNewHTML;
						i = i--;
					}
				}
			}
		}
	},
	
	trataFunction:function(funcao)
	{
		var texto = funcao.replace(/function anonymous()/g, '');
		texto = texto.replace(/{/g, '');
		texto = texto.replace(/}/g, '');
		texto = texto.replace(/\r/g, '');
		texto = texto.replace(/\n/g, '');
		
		return texto.substr(2);
	},
	
	PngFix:function(url)
	{
		this.urlImagens = url;
		this.ImagensAlteradas = new Array();
		this.applyCssHack();
	}
}
