$(document).ready(function () {
	$('#add_to_cart').removeAttr('onclick');

	$('#add_to_cart').click(function () {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: $('#product :input'),
			success: function (html) {
				$('#module_cart').html(html);
			},	
			complete: function () {
				var image = $('#image').offset();
				var cart  = $('#module_cart').offset();
	
				$('#image').before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');
	
				params = {
					top : cart.top + 'px',
					left : cart.left + 'px',
					opacity : 0.0,
					width : $('#module_cart').width(),  
					height : $('#module_cart').height()
				};		
	
				$('#temp').animate(params, 'slow', false, function () {
					$('#temp').remove();
				});		
			}			
		});			
	});
});

function add_to_cart(product_id, imgId)
{
	imgId = '#' + imgId;
	
	$.ajax({
		type: 'post',
		url: 'index.php?route=module/cart/callback',
		dataType: 'html',
		data: {product_id:product_id, quantity:1},
		success: function (html) {
			$('#module_cart').html(html);
		},	
		complete: function () {
			var image = $(imgId).offset();
			var cart  = $('#module_cart').offset();

			$(imgId).before('<img src="' + $(imgId).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;" />');

			params = {
				top : cart.top + 'px',
				left : cart.left + 'px',
				opacity : 0.0,
				width : $('#module_cart').width(),  
				height : $('#module_cart').height()
			};		

			$('#temp').animate(params, 'slow', false, function () {
				$('#temp').remove();
			});		
		}			
	});	
}
