$(document).ready(function () {
	$.fn.click_fun = function (product_id) {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: $('#product'+product_id+' :input'),
			success: function (html) {
				//$('#module_cart .middle').html(html);
				window.location="./shoppingcart"; 
				
			},	
			complete: function () {
				var image = $('#image'+product_id).offset();
				var link = $('#link'+product_id).offset();
				var cart  = $('#module_cart').offset();
	
				$('#link'+product_id).before('<img src="' + $('#image'+product_id).attr('src') + '" id="temp" style="position: absolute; top: ' + link.top + 'px; left: ' + link.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();
				});		
			}			
		});			
	}

	$.fn.delete_product_wishlist = function (product_id, reload) {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/wishlist/deleteProduct',
			dataType: 'html',
			data: $('#wishlist'+product_id+' :input'),
			success: function (html) {
				if (reload == undefined )
					$('#wishlist .middle').html(html);
				else
					location.reload(); 
			},	
			complete: function () {
			}			
		});			
	}

	$.fn.checkout_wishlist = function () {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/wishlist/checkoutWishlist',
			dataType: 'html',
			data: $('#wishlistcheckout :input'),
			success: function (html) {
				$(location).attr('href',html);
			},	
			complete: function () {
			}			
		});			
	}

	$.fn.add_product_wishlist = function (product_id) {
		$.ajax({
			type: 'post',
			url: 'index.php?route=module/wishlist/addProduct',
			dataType: 'html',
			data: $('#product'+product_id+' :input'),
			success: function (html) {
				$('#wishlist .middle').html(html);
			},	
			complete: function () {
				var image = $('#image'+product_id).offset();
				var link = $('#link'+product_id).offset();
				var cart  = $('#wishlist').offset();
	
				$('#link'+product_id).before('<img src="' + $('#image'+product_id).attr('src') + '" id="temp" style="position: absolute; top: ' + link.top + 'px; left: ' + link.left + 'px;" />');
	
				params = {
					top : cart.top + 'px', 
					left : cart.left + 'px',
					opacity : 0.0,
					width : $('#wishlist').width(),  
					heigth : $('#wishlist').height()
				};		
	
				$('#temp').animate(params, 'slow', false, function () {
					$('#temp').remove();
				});		
			}
		});			
	}

});


