]> git.openstreetmap.org Git - rails.git/blob - public/javascripts/pngfix.js
Don't set the layers argument if the caller didn't specify it.
[rails.git] / public / javascripts / pngfix.js
1 function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
2 {
3   for(var i=0; i<document.images.length; i++)
4   {
5     var img = document.images[i]
6       var imgName = img.src.toUpperCase()
7       if (imgName.indexOf('.PNG') > 0 && !img.id.match(/^OpenLayers/))
8       {
9         var imgID = (img.id) ? "id='" + img.id + "' " : ""
10           var imgClass = (img.className) ? "class='" + img.className + "' " : ""
11           var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
12           var imgStyle = "display:inline-block;" + img.style.cssText 
13           if (img.align == "left") imgStyle = "float:left;" + imgStyle
14             if (img.align == "right") imgStyle = "float:right;" + imgStyle
15               if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle   
16                 var strNewHTML = "<span " + imgID + imgClass + imgTitle
17                   + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
18                   + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
19                   + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
20                   img.outerHTML = strNewHTML
21                   i = i-1
22       }
23   }
24 }
25 window.attachEvent("onload", correctPNG);