/*
This method is used to make PNGs work in internet explorer on a PC. It does so by loading PNG graphics
through a directX mask transform.
*/

//this method determines if we need to run the png hack
function needHack(){
	var index;
	var version;
	
	//get the index of msie in the browser user agent
	index  = navigator.userAgent.indexOf("MSIE ");
	
	//check if this is IE
	if (index == -1) {
	    //this is not internet explorer, we can quit
	    return false;
	}else{
	    //get the version if IE
	    version = navigator.userAgent.substring(index + 5);
	    
	    //we will return true only if we are using IE 5.5 or 6 AND we are running on windows
	    return (((version.indexOf("5.5") == 0) || (version.indexOf("6") == 0)) && (navigator.platform == ("Win32")));
	}
}

function updatePNGGfx(){
	var src;
	var maskSrc;
	
	//determine if we need to run the PNG hack
	if(needHack()){
	    //loop through all images
		for(i = 0; i < document.images.length; i++){
		    //get a handle on the current image source
			src = document.images[i].src;

            //is this image a PNG graphic?	
			if(src.indexOf(".png") > -1){
			    //this is a PNG, get the gif mask
				maskSrc = src + ".gif";
				
				//set the image's souce to the mask image
				document.images[i].src = maskSrc;
				
				//apply the direct x filter
				document.images[i].runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
			}
		}
	}
}