$(document).ready(function () {
	$('#add_to_cart').removeAttr('onclick');

	$('#add_to_cart').click(function () {
			
		if($('.des_prod_quan_pri_txtbox').val()!=""){
			$(this).after('<div id="attention"><img src="image/loading_1.gif" alt="" /></div>');
			var cartid=$(this);
			
			/*$.ajax({
			type: 'post',
			url: 'index.php?route=product/product/stock_check',
			data: $('#product :input'),
			success: function(data){
		if(data==1){*/
			$.ajax({
			type: 'post',
			url: 'index.php?route=module/cart/callback',
			dataType: 'html',
			data: $('#product :input'),
			beforeSend:function(){
					cartid.hide();
			},
			complete: function () {
				$("#attention").remove();
				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();
				});		
			},
			success: function (html) {
				//$('#module_cart .middle').html(html);
				$('#module_cart').html('('+html+')');
				cartid.show();
			}			
		});
		
		/*}else{
				$("#attention").remove();
				alert(data);
				
				
		}
	}
});*/
			
}else{
			alert('Enter number of quantity');
			
   }			
			
	});			
});
