/*

Copyright 2003-2005 Conclusive Systems, LLC
All code herein may not be reproduced in full or in part under penalty of law.

*/

/* works well in the body tag, for a one-time sweep of all pngs */
function convert_pngs(node)
{
  var node = document.body;
  var imgs = node.getElementsByTagName('img');
  for (var i = 0; i < imgs.length; i++) convert_png(imgs[i]);
}

/* works well in the onload event of an img, so it happens whenever the src gets swapped */
function convert_png(img)
{
  if (!img.runtimeStyle) return;//not IE
  if (img.src.toLowerCase().lastIndexOf('.png') == -1) return;//not png
  img.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + img.src + '\',sizingMethod=\'scale\')';
  img.src = 'images/blank.gif';
}

/* call after the object has been loaded */
function convert_png_bg(obj)
{
  if (!obj.currentStyle) return;//not IE
  var sizing = 'scale';
  var png = obj.currentStyle.backgroundImage;
  png = obj.currentStyle.backgroundImage.substr(5, png.length - 7);//remove url() wrapper
  obj.runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + png + '\', sizingMethod=\'' + sizing + '\')';
  obj.style.backgroundImage = 'url(\'images/blank.gif\')';
}