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

	$('.ajax_add_to_cart').click(function () {
		var self = $(this);
		if($(this).is('.option')) {
			var option = self.attr('id').split('|');
			self.parents('form:first').append('<input type="hidden" name="'+option[0]+'" value="'+option[1]+'" />');
		}
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: self.parents('form:first').find(':input'),
			success: function (html) {
				$('#module_cart .middle').html(html);
			},	
			complete: function () {
				var cart  = $('#module_cart').offset();
				var image = self.attr('image') ? $('#'+self.attr('image')) : $('#image');
				var imagepos = image.offset();
				$('body').append('<img src="' + image.attr('src') + '" id="temp" style="position: absolute; top: ' + image.offset().top + 'px; left: ' +image.offset().left + 'px;" />');
				params = {
					top : cart.top + 'px',
					left : cart.left + 'px',
					opacity : 0.0,
					width : $('#module_cart').width(),  
					heigth : $('#module_cart').height()
				};
				$('#temp').animate(params, 'slow', false, function () {
					$('#temp').remove();
				});		
			}			
		});
		return false;
	});			
});
