(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-color: #060; border: solid 1px #FFF; position: static; top: 0px; z-index: 100000;">&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.6).show();
			  shadow.css('position', 'absolute');
			  
			  shadow.animate( { width: target.width(), height: target.height(), top: target.offset().top, left: target.offset().left }, { duration: 600 } )
				.animate( { opacity: 0.2 }, { duration: 100, complete:  function(e) {
             															$(shadow).remove();
																	}

						 					} );

		}
		
		
		
		
	});
	
	
	$.extend({
		add3cart: function(source_id, target_id, callback) {
    	
			  var source = $('#' + source_id );
			  var target = $('#' + target_id );
			  
			  var shadow = $('#' + source_id + '_shadow');
			  
			  if( !shadow.attr('class') ) {
				  $('body').prepend('<div class="'+source.attr('class')+'_shadow" style="display: none; background-color: #060; border: solid 1px #FFF; position: static; top: 0px; z-index: 100000;">&nbsp;</div>');
				  var shadow = $('.'+source.attr('class')+'_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.6).show();
			  shadow.css('position', 'absolute');
			  
			  shadow.animate( { width: target.width(), height: target.height(), top: target.offset().top, left: target.offset().left }, { duration: 600 } )
				.animate( { opacity: 0.2 }, { duration: 100, complete:  function(e) {
             															$(shadow).remove();
																	}

						 					} );

		}
		
		
		
		
	});
		
})(jQuery);
