(function($) {
    $.extend({
        add2cart: function(source_id, target_id, callback) {
            var source = $('#' + source_id);
            var target = $('#' + target_id);
            var shadow = $('#' + source_id + '_shadow');
            if (!shadow.attr('id')) {
                $('body').prepend('<div id="' + source.attr('id') + '_shadow" style="display: none; background: white url(' + $("#" + source_id).attr('src') + ') no-repeat center center; border:solid 2px #F0F0F0; position: static; top: 0px; z-index: 100000;">&nbsp;</div>');
                var shadow = $('#' + source.attr('id') + '_shadow');
            }
            shadow.width(source.css('width')).height(source.css('height')).css('top', source.offset().top).css('left', source.offset().left).css('opacity', 0.6).show(300);
            shadow.css('position', 'absolute');
            shadow.animate({ width: target.innerWidth(), height: target.innerHeight(), top: target.offset().top, left: target.offset().left }, { duration: 1000 })
        .animate({ opacity: 0 }, { duration: 100, complete: function() { $('#' + source.attr('id') + '_shadow').css("display", "none"); } });
        }
    });
})(jQuery);
