/* vim: set expandtab tabstop=4 shiftwidth=4:
+----------------------------------------------------------------------+
| PHP version 4                                                        |
+----------------------------------------------------------------------+
| Copyright (c) 2006 Coldwell Banker Funkhouser Realtors               |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License (GPL) as        |
| published by the Free Software Foundation; either version 2 of the   |
| License, or (at your option) any later version.                      |
|                                                                      |
| 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.                             |
|                                                                      |
| To read the license, visit http://www.gnu.org/copyleft/gpl.html      |
+----------------------------------------------------------------------+
| Authors: Matthew Kirkpatrick <matt@cbfunkhouser.com>                 |
+----------------------------------------------------------------------+

 Created:      October 16, 2006
 Last Updated: October 16, 2006

 @version $Id: .png_correction.js,v 0.2 2006/10/16 10:49:00 EST $
 @copyright 2006

*/

// correctly handle PNG transparency in Win IE 5.5 & 6.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004
function correctPNG() {
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      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
         }
      }
   }    
}
window.attachEvent("onload", correctPNG);
