/*
*
* jQuery.fader 1.0
* jQuery JavaScript Library v1.3.2
* http://jquery.com/
*
* Example
* $('.box').fader({
*    time: 300
* });
*
*/


(function($){
    $.fn.fader = function(options) {
        var
        defaults = {
            mode:1,
            // mode 1 = fade only
            // mode 2 = change color only
            // mode 3 = fade and change
            time: 300,
            beginopacity: 0,
            begincolor: $(this).css("color"),
            tofade : "a"
        },
        settings = $.extend({}, defaults, options);

        this.each(function() {
            var $this = $(this);

            if((settings.mode==1)||(settings.mode==3)){
                // Set the begining opacity to 0
                $this.find(settings.tofade).animate({
                    opacity: settings.beginopacity
                }, 0 );
            }
            if((settings.mode==2)||(settings.mode==3)){
                // Set the begining opacity to 0
                $this.find(settings.tochange).animate({
                    opacity: settings.begincolor
                }, 0 );
            }
            $this.hover(function(){
                if((settings.mode==1)||(settings.mode==3)){
                    $this.find(settings.tofade).stop().animate({
                        opacity: 1
                    }, settings.time );
                }
                if((settings.mode==2)||(settings.mode==3)){
                    $this.find(settings.tochange).stop().animate({
                        color:settings.changecolor
                    }, settings.time );
                }
            }, function() {
                if((settings.mode==1)||(settings.mode==3)){
                    $this.find(settings.tofade).stop().animate({
                        opacity: settings.beginopacity
                    }, settings.time );
                }
                if((settings.mode==2)||(settings.mode==3)){
                    $this.find(settings.tochange).stop().animate({
                        color:settings.begincolor
                    }, settings.time );
                }
            });

        });
        // returns the jQuery object to allow for chainability.
        return this;
    }
})(jQuery);

