﻿/* Adds support for 24 bit .png images in IE */
if(navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent)
{
	window.attachEvent("onload", alphaBackgrounds);
}

function alphaBackgrounds()
{  	
	if(navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent)
	{	
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7);
		
		for(i = 0; i < document.all.length; i++)
		{
			var bg = document.all[i].currentStyle.backgroundImage;
			
			if(itsAllGood && bg)
			{	    
				if(bg.match(/\.png/i) != null)
				{
					var mypng = bg.substring(5, bg.length - 2);
										
					/*if(mypng.indexOf("Small-Paper-Area.png") != -1 || mypng.indexOf("Small-Paper-Area2.png") != -1)
					{
						fixPNG(mypng);
						continue;
					}*/
										
					if(mypng.indexOf("CheckBox") == -1)
					{
						document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + mypng + "', sizingMethod='Scale')";
						document.all[i].style.background = "url('/Media/Image/blank.gif')";
					}
				}
			}
		}
	}
}

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

//<img src="xyz.png" alt="foo" width="10" height="20" onload="fixPNG(this)">

function fixPNG(myImage) 
{
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
	{
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
                       + " style=\"" + "width:" + myImage.width 
                       + "px; height:" + myImage.height 
                       + "px;" + imgStyle + ";"
                       + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                       + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
		alert(strNewHTML);
		myImage.outerHTML = strNewHTML	  
	}
}
