// Gère la transparence des png sous ie 6 //
function correctPNG()
   {
   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=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
       + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
       img.outerHTML = strNewHTML
       i = i-1
        }
      }
   }


function correctPNGProto()
{

     // this will iterate with each element with the class 'ie-fix-opacity' and add an IE filter
     // replacing the background-image for the filter of that image
      var version = parseFloat(navigator.appVersion.split('MSIE')[1]);
      if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
      {
		  document.getElementsByClassName('ie-fix-opacity').each(function(poElement){
		  // if IE5.5+ on win32, then display PNGs with AlphaImageLoader
		  var cBGImg = poElement.currentStyle.backgroundImage;
		  var cImage = cBGImg.substring(cBGImg.indexOf('"') + 1, cBGImg.lastIndexOf('"'));
		  poElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + cImage + "', sizingMethod='scale')";
		  poElement.style.backgroundImage = "none";
      });
      }
}

var clear="/images/clear.gif" //path to clear.gif

function pngfix  ()
{
	var els=document.getElementsByTagName('*');
	var i_p=/\.png/i;
	var i=els.length;
	while (i-- >0)
	{
		var el=els[i];
		var es=el.style;
		if(el.src&&el.src.match(i_p)&&es.filter=='')
		{
			el.height = el.height;
			el.width = el.width;
			es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
			el.src = clear;
		}
		else
		{ 
			var elb=el.currentStyle.backgroundImage;
			if(elb.match(i_p))
			{
				var path=elb.split('"');
				var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';
				es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
				//es.height=el.clientHeight+'px';
				es.backgroundImage="none";
			}
		}
		//if (el.currentStyle.position!='absolute' && !es.filter && !el.tagName.match(/(body|html|script)/gi)) es.position="relative";
		//if (es.filter&&el.currentStyle.position=="relative") es.position="static";
	}
}

if (window.attachEvent) {
      window.attachEvent("onload", pngfix);
}
