$(document).ready(function() { 
	/*place jQuery actions here*/ 
	var link = "/index.php/";
	
	
	$("ul.products form").submit(function() {
		// Get the product ID and the quantity 
		var id = $(this).find('input[name=product_id]').val();
		var qty = $(this).find('input[name=quantity]').val();
		var siz = $(this).find('select[name=size]').val();
		
		 $.post(link + "comanda/add_cart_item", { product_id: id, quantity: qty, size: siz, ajax: '1' },
  			function(data){
  			if(data == 'true'){
    			$.get(link + "comanda/show_cart", function(cart){
  					$("#cart_content").html(cart);
				});
    		}else{
    			alert("Product does not exist!");
    		}		
 		 }); 
		return false;
	});
	
	$(".empty").live("click", function(){
    	$.get(link + "comanda/empty_cart", function(){
    		$.get(link + "comanda/show_cart", function(cart){
  				$("#cart_content").html(cart);
			});
		});
		
		return false;
    });	
});
