(function ($) {
        $.fn.cross = function (options) {
            return this.each(function (i) { 
                // cache 
                var $$ = $(this);
                
                // get the target from the backgroundImage + regexp
                var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');

                // nice long chain: wrap img element in span
                $$.wrap('<span style="position: relative;"></span>')
                    // change selector to parent - i.e. newly created span
                    .parent()
                    // prepend a new image inside the span
                    .prepend('<img>')
                    // change the selector to the newly created image
                    .find(':first-child')
                    // set the image to the target
                    .attr('src', target);

                // css styling for different browsers
                if ($.browser.mozilla) {
                    $$.css({
                        'position' : 'absolute', 
                        'left' : 0,
                        'background' : '',
                        'top' : this.offsetTop
                    });
                } else if ($.browser.opera && $.browser.version < 9.5) {
                    // fix for opera                   
                    $$.css({
                        'position' : 'absolute', 
                        'left' : 0,
                        'background' : '',
                        'top' : "0"
                    });
                } else if ($.browser.msie && $.browser.version < 7.0) {
                    // fix for ie                    
                    $$.css({
                         'position' : 'absolute', 
                        'left' : 0,
                        'background' : '',
                        'top' : "0"
                    });
                } else { // Safari
                    $$.css({
                        'position' : 'absolute', 
                        'left' : 0,
                        'background' : ''
                    });
                }

                // animate
                $$.hover(function () {
                    $$.stop().animate({
                        opacity: 0
                    }, 950);
                }, function () {
                    $$.stop().animate({
                        opacity: 1
                    }, 1550);
                });
            });
        };
        
    })(jQuery);
    
    // bind
    $(window).bind('load', function () {
        $('img.fade').cross();
    });