(function($) {

	$.extend({
		add2cart: function(source_id, target_id, img, callback, classOrId) {
			
		if(classOrId == 'class') {
			var source = $('.' + source_id );
		} else {
			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-image:url('+img+');background-color:#fff;background-repeat:no-repeat;background-position:center; border: solid 1px darkgray; position: static; top: 0px; z-index: 10;">&nbsp;</div>');
          var shadow = $('#'+source.attr('id')+'_shadow');
      }
      
      if( !shadow ) {
          alert('Cannot create the shadow div');
      }
      
      shadow.width(source.css('width')).height(source.css('height')).css('top', source.offset().top).css('left', source.offset().left).css('opacity', 0.5).show();
      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: 1000, complete: shadow.fadeOut("slow") } );
        
		}
		

		
	});


})(jQuery);

