(function($) {

	$.extend({
		add2cart: function(source_id, target_id, settings) {    
			settings = jQuery.extend({
			useclass: "animatediv",
			animationSpeed: 500, 
			hideAnimationSpeed: 500,
			opacity: 0.5,
			callback: ""
		}, settings);
	  
	  var source = $('#' + source_id );
      var target = $('#' + target_id );
      
      var shadow = $('#' + source_id + '_shadow');
      if( !shadow.attr('id') ) {         
		  $('body').prepend('<div class="'+ settings.useclass +'" id="'+source.attr('id')+'_shadow">&nbsp;</div>');
          var shadow = $('#'+source.attr('id')+'_shadow');
      }
      
      if( !shadow ) {
          alert('Cannot create the shadow div');
      }
     shadow.width(source.width()).height(source.height()).css('top', source.offset().top).css('left', source.offset().left).css('opacity', 0).show();
	
      //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.effect('transfer',{to: '#Cartdiv'},500,function(){ });
																  
																 
      
      shadow.animate({ opacity: settings.opacity }, { duration: settings.hideAnimationSpeed })
	    .animate( { width: target.innerWidth(), height: target.innerHeight(), top: target.offset().top, left: target.offset().left }, { duration: settings.animationSpeed } )
        .animate( { opacity: 0 }, { duration: settings.hideAnimationSpeed, complete: settings.callback } ).animate({width:0,height:0,top:0,left:0},{duration:10});
        
		}
	});
})(jQuery);

