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.isIEMac = (this.isIE&&!this.isWin); this.isIEWin = (this.isIE&&this.isWin); this.ver = this.isIE?parseFloat(this.nv.split('msie ')[1]):parseFloat(this.nv); this.isMac = this.nv.indexOf('mac')+1?1:0; this.isOpera = (navigator.userAgent.toLowerCase().indexOf('opera ')+1 || navigator.userAgent.toLowerCase().indexOf('opera/')+1); if (this.isOpera) this.isIE = false; // Opera filter catch (which is sneaky, pretending to be IE by default) this.filterID = 'DXImageTransform.Microsoft.AlphaImageLoader'; this.supported = false; this.transform = self.doNothing; this.filterMethod = function(o) { // 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 DOM "currentStyle" method, so rules inherited via CSS are picked up. if (o.nodeName != 'IMG') { var b = o.currentStyle.backgroundImage.toString(); // parse out background image URL o.style.backgroundImage = 'none'; // Parse out background image URL from currentStyle. var i1 = b.indexOf('url("')+5; var newSrc = b.substr(i1,b.length-i1-2).replace('.gif','.png'); // find first instance of ") after (", chop from string o.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 o.style.filter = "progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod='"+(o.className.indexOf('scale')+1?'scale':'crop')+"')"; } else if (o.nodeName == 'IMG') { var newSrc = o.getAttribute('src').replace('.gif','.png'); // apply filter o.src = 'image/none.gif'; // get rid of image o.style.filter = "progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod="+(o.className.indexOf('scale')+1?'scale':'crop')+"')"; o.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.pngMethod = function(o) { // Native transparency support. Easy to implement. (woo!) bgImage = this.getBackgroundImage(o); if (bgImage) { // set background image, replacing .gif o.style.backgroundImage = 'url('+bgImage.replace('.gif','.png')+')'; } else if (o.nodeName == 'IMG') { o.src = o.src.replace('.gif','.png'); } else if (!bgImage) { // no background image } } this.getBackgroundImage = function(o) { var b, i1; // background-related variables var bgUrl = null; if (o.nodeName != 'IMG' && !(this.isIE && this.isMac)) { // ie:mac PNG support broken for DIVs with PNG backgrounds if (document.defaultView) { if (document.defaultView.getComputedStyle) { b = document.defaultView.getComputedStyle(o,'').getPropertyValue('background-image'); i1 = b.indexOf('url(')+4; bgUrl = b.substr(i1,b.length-i1-1); } else { // no computed style return false; } } else { // no default view return false; } } return bgUrl; } this.doNothing = function() {} this.supportTest = function() { // ¿ Es un IE 7 ? if (this.isIE && this.isWin && this.ver >= 7) { self.transform = self.filterMethod; return true; } // ¿Es un firefox antiguo? if (!this.isIE && this.ver < 5) { self.transform = null; return false; } // ¿Es un firefox moderno o un IE de mac 5+? if (!this.isIE && this.ver >= 5 || (this.isIE && this.isMac && this.ver >= 5)) { self.transform = self.pngMethod; return true; } // ¿Es algo desconocido? Entonces es mejor no usar PNG por si acaso self.transform = null; return false; } this.init = function() { this.supported = this.supportTest(); } } var pngHandler = new PNGHandler(); pngHandler.init(); if (pngHandler.supported) { document.cookie='pngsupport=1; path=/; domain=groony.com;'; } else { document.cookie='pngsupport=0; path=/; domain=groony.com;'; }