function setFader(obj) {
    var fader = {

        obj: null,
        speed: 100,
        currentOpacity: 100,
        _fadeAction: null,
        _watchers: new Array(),

        fadeIn: function() {
            //increase opacity
            if(this.speed <= 0) this.speed = 1;
            if(this.speed > 100) this.speed = 100;
            this.currentOpacity += 5;

            //correct values over 100%
            if(this.currentOpacity > 100) this.currentOpacity = 100;

            //If IE
            if(this.obj.filters) {

                //If the filter was not previously set, we initialize it
                if(!this.obj.filters.alpha) { this.obj.style['filter'] = 'alpha(opacity=' + this.currentOpacity + ');'; }

                //Set new opacity
                this.obj.filters.alpha.opacity =  this.currentOpacity;
            }

            //Set opacity in CSS3
            this.obj.style.opacity = (this.currentOpacity / 100);

            //Set opacity in Mozilla
            this.obj.style.MozOpacity = (this.currentOpacity / 100);

            //Set opacity in Konkerer
            this.obj.style.KhtmlOpacity = (this.currentOpacity / 100);

            //If necesary, set the recurring action
            if(this.currentOpacity < 100) {
                clearTimeout(this._fadeAction);
                var timeOut = ( 101 - this.speed );

                this._fadeAction = setTimeout("document.getElementById('" + this.obj.id + "').fader.fadeIn()",timeOut);
            } else {
                clearTimeout(this._fadeAction);
                this._fadeAction = null;
                for(var i in this._watchers){
                    try {
                        this._watchers[i].notify(this);
                    } catch(e) {
                        alert("Wrong watcher interface\n"+e+"\n I'm " + this.obj.id);
                    }
                }
            }

        },

        fadeOut: function () {
            //reduce opacity
            if(this.speed <= 0) this.speed = 1;
            if(this.speed > 100) this.speed = 100;
            this.currentOpacity -= 5;

            //correct negative values
            if(this.currentOpacity < 0) this.currentOpacity = 0;

            //If IE
            if(this.obj.filters) {

                //If the filter was not previously set, we initialize it
                if(!this.obj.filters.alpha) { this.obj.style['filter'] = 'alpha(opacity=' + this.currentOpacity + ');'; }

                //Set new opacity
                this.obj.filters.alpha.opacity =  this.currentOpacity;
            }

            //Set opacity in CSS3
            this.obj.style.opacity = (this.currentOpacity / 100);

            //Set opacity in Mozilla
            this.obj.style.MozOpacity = (this.currentOpacity / 100);

            //Set opacity in Konkerer
            this.obj.style.KhtmlOpacity = (this.currentOpacity / 100);

            //If necesary, set the recurring action
            if(this.currentOpacity)
            {
                clearTimeout(this._fadeAction);
                var timeOut = ( 101 - this.speed );
                this._fadeAction = setTimeout("document.getElementById('" + this.obj.id + "').fader.fadeOut()",timeOut);
            } else {
                clearTimeout(this._fadeAction);
                this._fadeAction = null;
                for(var i in this._watchers){
                    try {
                        this._watchers[i].notify(this);
                    } catch(e) {
                        alert("Wrong watcher interface\n I'm " + this.obj.id);
                    }
                }
            }

        },

        _setObj: function (obj) {

            /*
             *  Try to detect opacity set by CSS
             */

            //Check If IE
            if(obj.filters) {

                //check If alpha is set by CSS
                if(obj.filters.alpha) { this.currentOpacity = obj.filters.alpha.opacity; }
                else { this.currentOpacity = 100; }

            }

            //Check for FF
            else if (window.getComputedStyle)
            {

                //Get Mozilla opacity set in css (if any)
                var MozOpacity = document.defaultView.getComputedStyle(obj,null).getPropertyValue("-moz-opacity");
                if(MozOpacity.toString().length) { this.currentOpacity = parseInt(MozOpacity) * 100; }
                else {
                    var CSS3Opacity = document.defaultView.getComputedStyle(obj,null).getPropertyValue("opacity");
                    if(CSS3Opacity.toString().length) { this.currentOpacity = parseInt(CSS3Opacity) * 100; }
                    else { this.currentOpacity = 0; }
                }

            } else {
                alert('Not compatible browser');
            }

            this.obj = obj;
        },

        addWatcher: function (objWatcher) {
            this._watchers.push(objWatcher);
        }
    };

    fader._setObj(obj);
    obj.fader = fader;
    return fader;
}
