/*
 * PNG Patch 1.0 javascript library
 *
 * Copyright © 2003 - 2007 Davide Bia
 * http://www.flyonthenet.com/
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2
 *  as published by the Free Software Foundation;
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  http://www.gnu.org/licenses/gpl-2.0.txt
 *
 */ 
function PNG_Replace(PNG_Image)
{
  var PNG_Patched = false;
  if(!PNG_Image)
    PNG_Image = event.srcElement;
  if(PNG_Image.src.search(/\.png$/i) > -1 && PNG_Image.className.search(/(?=^|\b)noalpha(?=\b|$)/i) == -1)
  {
    var PNG_Span = document.createElement("span");
    PNG_Span.setAttribute("title", PNG_Image.title || PNG_Image.alt);
    if(PNG_Image.className)
      PNG_Span.className = PNG_Image.className;
    if(PNG_Image.border)
      PNG_Span.style.borderWidth = PNG_Image.border + "px";
    PNG_Span.style.display = "inline-block";
    PNG_Span.style.height = PNG_Image.offsetHeight + "px";
    PNG_Span.style.width = PNG_Image.offsetWidth + "px";
    PNG_Span.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + PNG_Image.src + "')";
    PNG_Image.replaceNode(PNG_Span);
    PNG_Patched = true;
  }
  return PNG_Patched;
}
function PNG_Patch( )
{
  if(typeof document.images != "undefined" && typeof document.body.style.filter != "undefined")
    for(var i=0; i<document.images.length; i++)
      if(PNG_Replace(document.images[i]))
        i--;
}
if(navigator.userAgent.indexOf("MSIE 6.0") > -1)
{
  if(document.readyState != "complete")
    document.attachEvent("onreadystatechange", PNG_Patch);
  else PNG_Patch("logoMEDAS");
}
