/*************************************************************************************/
/*  Title: PNG Fix
/*  Fix poor support for PNG alpha transparency in IE 5.5 & 6.
/*  Replaces all images with .png extension with a transparent spacer.gif with the
/*  same dimensions (CSS) and applies alpha transparent PNG as background (which
/*  is supported in IE 5.5 & 6).
/*************************************************************************************/
function correctPNG(){
	if(navigator.userAgent.indexOf('MSIE 5.5') != -1 || navigator.userAgent.indexOf('MSIE 6.0') != -1){
		for(var i = 0; i < document.images.length; i++){
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if(imgName.indexOf(".PNG") != -1 && img.width > 0 && img.height > 0){				
				img.src = img.src.substring(0, (imgName.indexOf(".PNG") + 4));
				var imgAlt = img.alt;
				var imgID = (img.id) ? 'id="' + img.id + '" ' : "";
				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;
				var imgWidth = img.width;
				var imgHeight = img.height;
				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 = "<img src=\"/mahome/images/spacer.gif\" " + imgID + imgClass + imgTitle + " style=\"width:" + imgWidth + "px; height:" + imgHeight + "px;" + imgStyle + " float:left; visibility:visible; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale');\" alt=\"" + imgAlt + "\" />";
				//var strNewHTML = "<img src=\"" + img.src + "\" alt="" />";
				img.outerHTML = strNewHTML;
				//alert(strNewHTML);
				i = i - 1;
			}
		}
	}
}
if(window.attachEvent){
	window.attachEvent("onload", correctPNG);
}
function correctSinglePNG(id){
	if(navigator.userAgent.indexOf('MSIE 5.5') != -1 || navigator.userAgent.indexOf('MSIE 6.0') != -1){
		img = document.getElementById(id);
		var imgName = img.src.toUpperCase();
	   // alert("Handling " + id + ", " + imgName);
		if(imgName.indexOf(".PNG") != -1){	
			img.src = img.src.substring(0, (imgName.indexOf(".PNG") + 4));
			var imgAlt = img.alt;
			var imgID = (img.id) ? 'id="' + img.id + '" ' : "";
			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;
			var imgWidth = img.width;
			var imgHeight = img.height;
			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 = "<img src=\"/mahome/images/spacer.gif\" " + imgID + imgClass + imgTitle + " style=\"width:" + imgWidth + "px; height:" + imgHeight + "px;" + imgStyle + " float:left; visibility:visible; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale');\" alt=\"" + imgAlt + "\" />";
			//var strNewHTML = "<img src=\"" + img.src + "\" alt="" />";
			img.outerHTML = strNewHTML;
			//alert(strNewHTML);
			//alert(img.outerHTML + "\n" + strNewHTML);
		}
	}
}