

jQuery.fn.iepngfix = function() {
    var blankImg = '/img/spacer.gif';
    
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var procede = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7.0);
    if( !procede ) return this;

    return this.each( function() {
        if( this.runtimeStyle.filter ) return;
        var bg = this.currentStyle.backgroundImage;
        if( !bg && !this.src ) return false;
        if( bg && bg != 'none' ) {
            var img = bg.substring(5,bg.length-2);
            var offset = this.style["background-position"];
            this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='scale')";
            this.style.backgroundImage = "url('"+blankImg+"')";
            this.style["background-position"] = offset; // reapply
        } 
        else if( this.src) {
            var src = this.src.replace(/%A0/g,'%20').replace(/%26/g,'/'); // filter can't handle & or nbsp;
            this.style.width = this.width + "px";
            this.style.height = this.height + "px";
            this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='crop')";
            this.src = blankImg;
        }
    });
};

$(window).load( function() {
    $('.transpng:visible').iepngfix();
});



function enableAlpha(obj){
    var bg = obj.currentStyle.backgroundImage;
    var img = obj;
    
    if(obj.style.filter) return;

    if (bg && bg.match(/\.[php|png]/i) != null) {
        var img = bg.substring(5,bg.length-2);
        var offset = obj.style["background-position"];
        obj.style.filter =
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+img+"', sizingMethod='scale')";
        obj.style.backgroundImage = "url('"+blankImg+"')";
        obj.style["background-position"] = offset; // reapply
    } else if (img && img.src.match(/\.[php|png]/i) != null) {
        var src = img.src.replace(/%A0/g,'%20').replace(/%26/g,'/'); // filter can't handle & or nbsp;
        img.style.width = img.width + "px";
        img.style.height = img.height + "px";
        img.style.filter =
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='crop')";
        img.src = blankImg;
    }
}


