function addToCart(id){
	$('#wait').show();
//	var color = $('#item_color').val();
//	var size = $('#item_size').val();
	var color = $("input[@name=color]:checked").val();
	var size = $("input[@name=size]:checked").val();
	//alert(color);
	$.post('/ru/ajax', {
		act: "cart_add_item",
		item_id: id,
		item_color: color,
		item_size: size
	},function(data){
		if(data == 'ok'){
			refreshCart();
		} else {
			alert(data);	
		}
		$('#wait').hide();
	});
	return false;
}

function refreshCart(){
	$.post('/ru/ajax', {
		act: "cart_get_count"
	},function(data){
		$('#cart_items').html(data);
	});
	
}
function refreshBigCart(){
	$.post('/ru/ajax', {
		act: "cart_get_big"
	},function(data){
		$('#big_cart').html(data);
	});
	
}

function deleteSelected(){
	$('#wait').show();
	var to_del = '';
	$('.to_delete').each(function(){
								  if(this.checked){
									  to_del = to_del+' '+$(this).val();
								  }
								  });
	if(to_del!=''){
			$.post('/ru/ajax', {
				act: "cart_delete_items",
				items_del: to_del
			},function(data){
				refreshBigCart();
				refreshCart();
				$('#wait').hide();
			});	
	} else {
		$('#wait').hide();	
	}
//	alert('delete');
}

function checkAll(chk){
	var checked_status = chk.checked;
	$(".to_delete").each(function(){this.checked = checked_status;});	
}

function editCount(id, new_count){
	$.post('/ru/ajax', {
		act: "cart_edit_count",
		item_id: id,
		count: new_count
	},function(data){
		refreshBigCart();
		refreshCart();
		$('#wait').hide();
	});
}