function writeDebug(){}
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;this.extensions=['.gif','.png'];this.filterID='DXImageTransform.Microsoft.AlphaImageLoader';this.PNGsupport=true;this.transform=self.doNothing;this.filterMethod=function(o){if(o.nodeName.toLowerCase()!='img'){var b=o.currentStyle.backgroundImage.toString();o.style.backgroundImage='none';var i1=b.indexOf('url("')+5;var newSrc=b.substr(i1,b.length-i1-2).replace(self.extensions[0],self.extensions[1]);o.style.writingMode='lr-tb';o.style.filter="progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod='"+(o.className.indexOf('scale')+1?'scale':'crop')+"')";}else if(o.nodeName.toLowerCase()=='img'){var newSrc=o.getAttribute('src').replace(self.extensions[0],self.extensions[1]);o.src='image/none.gif';o.style.filter="progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod="+(o.className.indexOf('scale')+1?'scale':'crop')+"')";o.style.writingMode='lr-tb';}}
this.pngMethod=function(o){bgImage=this.getBackgroundImage(o);if(bgImage){o.style.backgroundImage=bgImage.replace(self.extensions[0],self.extensions[1]);writeDebug('PNGHandler.pngMethod(): bgImage='+o.style.backgroundImage);}else if(o.nodeName.toLowerCase()=='img'){o.src=o.src.replace(self.extensions[0],self.extensions[1]);}else if(!bgImage){writeDebug('PNGHandler.pngMethod('+o.nodeName+'): no bgImage');}}
this.getBackgroundImage=function(o){var b,i1;var bgUrl=null;if(o.nodeName.toLowerCase()!='img'&&!(this.isIE&&this.isMac)){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{return false;}}else{var bg=(o.currentStyle?o.currentStyle:o.style).backgroundImage.toString();if(bg){return bg;}else{writeDebug('PNGHandler.getBackgroundImage(): Could not find BG');return false;}}}
return bgUrl;}
this.refresh=function(o,src){var newSrc=(o.currentStyle?o.currentStyle:o.style).backgroundImage.toString();if(src)newSrc=src;newSrc=(newSrc?newSrc:(src?src:o.src)).replace(self.extensions[0],self.extensions[1]);writeDebug('PNGHandler.refresh('+o+','+src+')');writeDebug('PNGHandler.refresh(): newSrc='+newSrc);if(self.PNGsupport){writeDebug('PNGHandler.refresh(): using filter string '+"progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod='crop')");o.style.filter="progid:"+self.filterID+"(src='"+newSrc+"',sizingMethod='crop')";o.style.writingMode='lr-tb';}else{writeDebug('PNGHandler.refresh(): not using filter');}}
this.doNothing=function(){}
this.supportTest=function(){if(this.isIE&&this.isWin&&this.ver>=5.5){writeDebug('PNGHandler.supportTest(): IE/win32, v5+ - supported');self.transform=self.filterMethod;}else if(!this.isIE&&this.ver<5){writeDebug('PNGHandler.supportTest(): No PNG support assumed (!ie, ver<5)');self.PNGsupport=false;self.extensions=['.png','.gif'];self.transform=self.pngMethod;}else if(!this.isIE&&this.ver>=5||(this.isIE&&this.isMac&&this.ver>=5)){writeDebug('PNGHandler.supportTest(): ie:mac 5+ or other v5+ - supported');self.transform=self.pngMethod;}else{writeDebug('PNGHandler.supportTest(): No PNG support assumed');self.PNGsupport=false;self.extensions=['.png','.gif'];self.transform=self.pngMethod;}
return true;}
this.init=function(){this.supportTest()
if(this.transform){this.elements=$$('div.png');writeDebug('PNGHandler.init() - start ('+this.elements.length+' elements)');for(var i=0;i<this.elements.length;i++){this.transform(this.elements[i]);}}
writeDebug('PNGHandler.init() - finish');}}
