// PNGHandler: Object-Oriented Javascript-based PNG wrapper // -------------------------------------------------------- // original code by Scott Schiller - www.schillmania.com // modified for own purpose by Pascal COURTOIS courtois@linuxfr.org // -------------------------------------------------------- // Description: // Provides gracefully-degrading PNG functionality where // PNG is supported natively or via filters (Damn you, IE!) // Should work with PNGs as images and DIV background images. function PNGHandler() { var self = this; this.na = navigator.appName.toLowerCase(); this.nv = navigator.appVersion.toLowerCase(); this.isIE = this.na.indexOf('internet explorer')+1?1:0; this.isWin = this.nv.indexOf('windows')+1?1:0; this.ver = this.isIE?parseFloat(this.nv.split('msie ')[1]):parseFloat(this.nv); this.isMac = this.nv.indexOf('mac')+1?1:0; this.transform = null; this.filterMethod = function(oOld) { // IE 5.5+ proprietary filter garbage (boo!) // Create new element based on old one. Doesn't seem to render properly otherwise (due to filter?) // use proprietary "currentStyle" object, so rules inherited via CSS are picked up. var o = document.createElement('div'); // oOld.nodeName var filterID = 'DXImageTransform.Microsoft.AlphaImageLoader'; o.style.width = oOld.currentStyle.width; o.style.height = oOld.currentStyle.height; if (oOld.nodeName == 'IMG'|| oOld.nodeName == 'INPUT') { var h=oOld.getAttribute('height'); var w=oOld.getAttribute('width'); var newSrc = oOld.getAttribute('src'); // apply filter oOld.src = '..//template/auth/icons/none.gif'; // get rid of image oOld.style.filter = "progid:"+filterID+"(src='"+newSrc+"',sizingMethod='scale')"; oOld.width=w; oOld.height=h; oOld.style.writingMode = 'lr-tb'; // Has to be applied so filter "has layout" and is displayed. Seriously. Refer to http://msdn.microsoft.com/workshop/author/filter/reference/filters/alphaimageloader.asp?frame=true } } this.supportTest = function() { // Determine method to use. // IE 5.5+/win32: filter if (this.isIE && this.isWin && this.ver >= 5.5) { // Support for PNG - milelage may vary // window.status = 'IE 5.5+ filter method.'; self.transform = self.filterMethod; return true; } return false; } this.init = function() { if (this.supportTest()) { this.elements = getElementsByClassName('png'); for (var i=0; i