/* Based on:
 * http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.
 *************************************************************
 * Will only fix .png images that have width & height attributes & are in class 'transparency'
*/

function fix_png_transparency() {
    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" && img.width && img.height && img.className.indexOf('transparency')>=0) {
            //alert('fixing '+img+' (name='+imgName+', w='+img.width+' h='+img.height+')');
            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 + "\');\"></span>";
        //alert(strNewHTML);
            img.outerHTML = strNewHTML;
            i = i-1;
        }
    }
}


if(navigator.appName=='Microsoft Internet Explorer') {
    var ieVersion=0+parseFloat((navigator.appVersion.split("MSIE"))[1]);
    if((ieVersion >= 5.5) && (ieVersion < 7)) {
        register_onload_handler(fix_png_transparency);
    }
}
