// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function odlcorrectPNG() 
{
	for(var i=0; i<document.images.length; i++)
	{
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		{
			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 
			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 = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + (img.width) ?"width:" + img.width + "px;":""+
			(img.height) ?"height:" + img.height + "px;":"" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
function getElementsByQuasi(tag, quasivalue,attribute)
{
//window.alert(attribute);
     var elem = document.getElementsByTagName(tag);
     var arr = new Array();
     for(i = 0,iarr = 0; i < elem.length; i++) {
          att = elem[i].getAttribute(attribute);
		  if(att)
		  {
	          if(att.replace(quasivalue,'')!=att) {
	               arr[iarr] = elem[i];
	               iarr++;
	          }
          }
     }
	 if(arr.length==0){arr=false;}
     return arr;
}
/*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/

function correctPNG() 
{
	var tagName = "span"
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	for(var i=0; i<document.images.length; i++)
	{
			
		var img = document.images[i]
		if ((version >= 5.5) && (document.body.filters)) 
		{
		  var imgName = img.src.toUpperCase()
		  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		  {
			 var imgID = (img.src) ? img.src : ""
			 for(var e=0;getElementsBy(tagName, imgID+e,"id")>0;e++){}
				imgID+=e;
			 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			 var imgStyle = "display:inline-block;visibility:visible;" + img.style.cssText 
			 var js = "" 
			 if (img.align == "left") imgStyle += "float:left;"
			 if (img.align == "right") imgStyle += "float:right;"
			 if (img.parentElement.href) imgStyle += "cursor:hand;"
			 if (img.width) imgStyle += "width:" + img.width + "px;"
			 if (img.height) imgStyle += " height:" + img.height + "px;"
			 if (img.src)
			 { 
				var src=img.src;
				src=src.replace("(",escape("("));
				src=src.replace(")",escape(")"));
				src=src.replace(" ",escape(" "));
			 imgStyle += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + src + "\', sizingMethod='scale');"
			 }
			 var strNewHTML = "<"+tagName+" " + "id='" + imgID + "' name='" + imgID + "' " + imgClass + imgTitle
			 + " style=\"" +imgStyle+"\""
			 +js
			 +" src='"+src+"'"
			 + ">"
			 strNewHTML += "</"+tagName+">" 
			 img.outerHTML = strNewHTML
			 if (img.parentElement)alert(img.parentElement);
			var imgfixed=getElementsBy(tagName, imgID,"id")[0];
			if (img.parentElement)if (img.parentElement.href)imgfixed.onmouseover=function(){this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + surligneimagesrc(this.src) + "\', sizingMethod='scale')";};
			if (img.parentElement)if (img.parentElement.href)imgfixed.onmouseout=function(){this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader"
			 + "(src=\'" + this.src + "\', sizingMethod='scale')";};
			 i = i-1
		  }
	   }
	}
}

window.onload=function(){correctPNG();};
